unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DoFormCloseButtonEnable(AHandle: HWND; AEnable: Boolean);
var
lMenue: Integer;
begin
lMenue := Windows.GetSystemMenu(AHandle, LongBool(False));
if (lMenue <> 0)
then
begin
if (AEnable)
then
begin
Windows.EnableMenuItem(lMenue, SC_CLOSE, MF_BYCOMMAND
or MF_SYSMENU);
end
else
begin
Windows.EnableMenuItem(lMenue, SC_CLOSE, MF_BYCOMMAND
or MF_GRAYED);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoFormCloseButtonEnable(
Handle,false);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DoFormCloseButtonEnable(
Handle,true);
end;
end.