Autor Beitrag
schlumsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

alles Win :)
Delphi 2005 Prof, Delphi 2007
BeitragVerfasst: Mo 30.11.09 21:42 
Hallo in die Runde,

eine Frage zum Thema Tray und Application.restore.
Ich minimiere mein Programm in die Tray. Wenn der User auf das Icon klickt wird das Programm wieder angezeigt. Soweit alles ok, nun möchte ich aber beim klicken auf das Trayicon zuerst eine Funktion ausführen und in Abhängigkeit von deren Ergebnis das Programm anzeigen, oder eben auch nicht.

Mein Code zum minimieren sieht so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
   procedure TFormSilentAlert.ApplicationEvents1Minimize(Sender: TObject);
begin
   FormSilentAlert.Hide;
  with NIM do begin
    cbSize := SizeOf (nIM);
    Wnd := Handle;
    uID := 0;
    uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
    uCallbackMessage := IC_CLICK;
    hIcon := Application.Icon.Handle;
    szTip := 'wpcstf';
  end;
  Shell_NotifyIcon(NIM_ADD, @NIM);
end;


Kann mir da jemand helfen?

thx & lg

_________________
icq 102779206
"God is real, unless declared integer..."
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mo 30.11.09 23:23 
Das war der Quellcode für das Minimize Event, richtig. Bringt uns hier nun leider nicht weiter.
Dein Quellcode macht: Programm wird minimiert -> Tray Icon hinzufügen.

Zeig mal bitte den Quellcode, wie du das Programm wieder "öffnest", also aus dem Tray wieder anzeigst.

_________________
PROGRAMMER: A device for converting coffee into software.
schlumsch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

alles Win :)
Delphi 2005 Prof, Delphi 2007
BeitragVerfasst: Di 01.12.09 21:51 
Ja nee ich bin auch brasslich...
Habe meine Procedur ganz übersehen, nu funktioniert alles wie gewollt :)

dDie Lösung sieht nun so aus

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
 procedure TFormSilentAlert.Systray(var sMsg: TMessage);
var
  Pnt: TPoint;
begin
  // Vorgang: Klick auf das Icon neben der Uhr und Anzeige der Anwendung
  inherited;
  if (sMsg.LParam = WM_LBUTTONDOWN) then begin
   if (FormSilentAlert.checkPriviledges() = true) then begin  // <--Pruefen
      Show;
      Shell_NotifyIcon(NIM_DELETE, @NIM);
      Application.Restore; //zeigt die Anwendung wieder an
      Application.BringToFront;
   end;
  end;
    if (sMsg.LParam = WM_RBUTTONDOWN) then begin
     SetForegroundWindow(FormSilentAlert.Handle);
        GetCursorPos(Pnt);
        PopupMenu_tray.Popup(Pnt.x, Pnt.y);
  end;
end;


...gut das wir das diskutiert haben *g*
Sorry & lg

_________________
icq 102779206
"God is real, unless declared integer..."
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: Di 01.12.09 22:28 
user profile iconschlumsch hat folgendes geschrieben Zum zitierten Posting springen:

ausblenden Delphi-Quelltext
1:
   if (FormSilentAlert.checkPriviledges() = true) then begin  // <--Pruefen					


So weit, so gut. Der Vergleich auf = TRUE kann beizeiten aber in die Hose gehen. Da Deine Funktion eh ein Boolean zurückgibt reicht ein
ausblenden Delphi-Quelltext
1:
   if FormSilentAlert.checkPriviledges() then begin  // <--Pruefen					

Gewöhn Dir das an.
Die Antwort auf die potentielle Frage, weshalb man ein Boolean-Wert nie auf TRUE prüfen sollte, findet man ganz sicher zigfach erklärt hier im Forum.

_________________
Ich streite einsam mich mit dieser Oberflächenwelt
Gutes sei ein löblich Brot von dem ich zehre - bis zum Tod [Das Ich - Im Ich]
schlumsch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

alles Win :)
Delphi 2005 Prof, Delphi 2007
BeitragVerfasst: Mi 02.12.09 11:16 
okay, dann nehm ich den Tip mal auf und danke

_________________
icq 102779206
"God is real, unless declared integer..."