May
18
Как свернуть форму при нажатии на кнопку Х в заголовке
17:34unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
gEndSession:boolean;
procedure WMQueryEndSession(var message: TWMQueryEndSession); message WM_QUERYENDSESSION;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.WMQueryEndSession(var message: TWMQueryEndSession);
begin
message.Result := 1;
gEndSession := True;
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if not gEndSession then begin
CanClose := false;
Application.Minimize;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
gEndSession := True;
close;
end;
end.
http://www.delphimaster.ru/cgi-bin/forum.pl?id=1147957288&n=18