Autor Beitrag
AceTheFace
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: So 17.11.02 15:52 
Hallo,

ich erstelle für mein Programm folgendermassen ein TrayIcon:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
with TrayIconData do
  begin
    cbSize := SizeOf(TrayIconData);
    Wnd := Handle;
    uID := 0;
    uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
    uCallbackMessage := WM_ICONTRAY;
    hIcon := Application.Icon.Handle;
    StrPCopy(szTip, Application.Title);
  end;

  Shell_NotifyIcon(NIM_ADD, @TrayIconData);


Mit form1.hide lasse ich dann beim onMinimize-Event das Programm verschwinden.

Wie schaffe ich es jetzt, über ein PopUpMenu oder einen LinksKLick auf das TrayIcon das Programm wieder sichtbar zu machen?

Im Moment mache ich das über form1.show. Habs auch schon mit form1.setfocus probiert, aber das Programm erscheint bloss minimiert in der Taskleiste. Wie schaffe ich, dass es auch gleich maximiert wird? Application.restore hilft auch nicht :(

Gruss und danke,

Ace
DeCodeGuru
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1333
Erhaltene Danke: 1

Arch Linux
Eclipse
BeitragVerfasst: So 17.11.02 15:58 
ich verwende immer folgenden Code:

ausblenden Quelltext
1:
2:
const  //nach der Uses-Klausel
  PM_TRAY = WM_APP + 201;


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
private
    { Private-Deklarationen }
    procedure PMTray(var sMsg: TMessage); message PM_TRAY;
  public
    { Public-Deklarationen }
  end;


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.PMTray(var sMsg : TMessage);
var
  Mauspos: TPoint;
begin
  inherited;
  GetCursorPos(Mauspos);
  case sMsg.LParam of
    WM_LButtonDown:
    begin
      PopupMenu1.PopupComponent := MainForm;
      SetForegroundWindow(Handle);
      PopupMenu1.Popup(Mauspos.X, Mauspos.Y);
    end;
    WM_RButtonDown:
    begin
      PopupMenu1.PopupComponent := MainForm;
      SetForegroundWindow(Handle);
      PopupMenu1.Popup(Mauspos.X, Mauspos.Y);
    end;
  end;
end;


Der Code müsste so funktionieren.

_________________
Viele Grüße
Jakob