Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Minimize on close? (https://www.delphipraxis.net/97126-minimize-close.html)

Razor 5. Aug 2007 13:23


Minimize on close?
 
How can i minimize on close?


procedure TMainFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if rzcheckbox10.Checked=true then
canclose:=false;

if mainfrm.CloseQuery=true then
TextTrayIcon1.HideMainForm;



end;

This wont work

DeddyH 5. Aug 2007 13:43

Re: Minimize on close?
 
Do you want to minimize or to hide your form? Here' s an example for hiding:
Delphi-Quellcode:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if CheckBox1.Checked then
    begin
      Action := caNone;
      self.Hide;
    end;
end;
But beware that your form is not visible anymore so that the user cannot close it anytime. For this be sure to give him the possibility to reach your application (e.g. by a hotkey or an icon in the TNA).

r2c2 5. Aug 2007 14:14

Re: Minimize on close?
 
Just a hint(it has nothing to do with your problem, but can cause problems either):
Delphi-Quellcode:
if rzcheckbox10.Checked=true then
This =true thing can be problematic as described here: http://r2c2.weingut-rehn.de/content5..._Variablen.htm

I don't know, if you can spek German, so here in short:
- An bool variable is a bool expession itself. So it's not necessary to put ae =true there
- because of the different binary representations of bool vars, it can cause problems, when you use WinAPI functions or interact with other apps

//Edit:
Using delphi-tags makes it easier to read code... So just use those funny buttons in the posting-editor... thx

regards

Christian

Razor 5. Aug 2007 14:30

Re: Minimize on close?
 
I figured it out already thanks! :-D

Delphi-Quellcode:
procedure TMainFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin

if rzcheckbox10.Checked=true then begin
canclose:=false;
TextTrayIcon1.hideMainForm;

    exit;



                   
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:48 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz