--> How to Minimize Form When In Close on Delphi | Delphi Tips Trick

For Newbie

Tuesday 15 November 2011

How to Minimize Form When In Close on Delphi

| Tuesday 15 November 2011


Tricks to minimize the time from Close Button on the form is clicked, typically used in applications that use the trayicon.

Usually the applications that use the Tray Icon, at its interface does not provide the minimize button, only the close button (the button that I mean: no sign of any cross-box, located at the top right corner of form).


Edit Form onCloseQuery event.
TForm1.FormCloseQuery procedure (Sender: TObject; var CanClose: Boolean);
begin
   / / Commands that can not be on the Close Form
   CanClose: = False;
   / / Minimize
   Application.Minimize;
end;

The code above is just a short example only, for more details:
var
   cClose: Boolean;

TForm1.FormCreate procedure (Sender: TObject);
begin
   cClose: = False;
end;

TForm1.FormCloseQuery procedure (Sender: TObject; var CanClose: Boolean);
begin
   CanClose: = cClose;
   if not then Application.Minimize cClose;
end;

/ / If Button1 is clicked then the form will be closed.
procedure TForm1.Button1Click (Sender: TObject);
begin
   cClose: = True;
   Close;
end;

Related Posts

No comments: