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 ApplicationEvent Minimize nur 1x (https://www.delphipraxis.net/79501-applicationevent-minimize-nur-1x.html)

Piro 23. Okt 2006 23:13


ApplicationEvent Minimize nur 1x
 
Guten Abend,

habe gerade mit TurboDelphi und den beiden Komponenten ApplicationEvent und TrayIcon herum gespielt. Beim Aufruf des Minimieren soll die Application verschwinden und das TrayIcon erscheinen. Ich benutze folgenden Code:
Code:
...
procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
 TrayIcon1.Visible := True;
 form1.FormStyle := fsStayOnTop;
 Application.MainForm.Hide;
end;

procedure TForm1.TrayIcon1DblClick(Sender: TObject);
begin
 TrayIcon1.Visible := False;
 Application.Restore;
end;
...
Dies funktioniert beim aller ersten Mal auch einwandfrei. Nach Wiederherstellung der Application und dem Erneuten Minimieren, erscheint das TrayIcon aber die Application verschwindet nicht mehr aus der Taskleiste. Weiß einer warum?

Sunlight7 23. Okt 2006 23:20

Re: ApplicationEvent Minimize nur 1x
 
Versuche statt Application.Restore;
Application.MainForm.Show;

Piro 23. Okt 2006 23:38

Re: ApplicationEvent Minimize nur 1x
 
Leider geht dann bei 2.Minimieren dann gar nichts mehr. Soll heißen, dass die Mainform sich nicht mehr minimiert.

Man woran kann das denn liegen?

Sunlight7 23. Okt 2006 23:45

Re: ApplicationEvent Minimize nur 1x
 
Wahrscheinlich weil Delphi glaubt, das sie noch minimiert ist.

Das hab ich vorher übersehen, beides verwenden:
Application.MainForm.Show;
Application.Restore;

Oder auch anders rum...
Hab grad keine Delphi zum testen zur Hand...

Piro 23. Okt 2006 23:53

Re: ApplicationEvent Minimize nur 1x
 
Danke, es hat geklappt. Ist schon komisch, dass es von der Reihenfolge abhängig ist. Hier die Lösung:

Delphi-Quellcode:

procedure TForm1.ApplicationEvents1Minimize(Sender: TObject);
begin
 Form1.FormStyle := fsStayOnTop;
 TrayIcon1.Visible := True;
 Form1.Hide;
end;

procedure TForm1.TrayIcon1DblClick(Sender: TObject);
begin
 Application.MainForm.Show;
 Application.Restore;
 TrayIcon1.Visible := False;
end;
Danke und guten Nacht.

Luckie 24. Okt 2006 00:03

Re: ApplicationEvent Minimize nur 1x
 
Warum setzt du den FormStyle auf fsStayOnTop, wenn du es doch versteckst? Abgesehen mal davon, dass man den FormStyle zur Laufzeit nicht ändern sollte.

Sunlight7 24. Okt 2006 00:28

fsStayOnTop
 
Stimmt, ist mir gar nicht aufgefallen...

Aber warum sollte man die nicht zur Laufzeit ändern :gruebel:
Weil sich das Fensterhandle ändert?


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:38 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