Einzelnen Beitrag anzeigen

ManfredG

Registriert seit: 12. Feb 2007
Ort: Berlin
34 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#9

Re: CallbackMessage TNotifyIconData

  Alt 26. Dez 2007, 13:06
nein, mehr in der form:

Delphi-Quellcode:
const WM_TASKBARICON = WM_USER+nnn;

type
TTaskBarIcon = class(TWinControl)
   private
      procedure WMTaskbarEvent(var Msg: TMessage); message WM_TASKBARICON;
  ...

constructor TaskBarIcon.Create(AOwner: TComponent);
var tnid : TNOTIFYICONDATA;
begin
  inherited Create(AOwner);
  Visible := FALSE;
  tnid.cbSize := sizeof(TNOTIFYICONDATA);
  tnid.Wnd := Self.Handle;
  tnid.uID := 1;
  tnid.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
  tnid.uCallbackMessage := WM_TASKBARICON;
  tnid.hIcon :=Application.MainForm.IconImg.picture.icon.handle;
  strcopy(tnid.szTip,'ProgName');
  Shell_NotifyIcon(NIM_ADD, @tnid);
...
end;

procedure TaskBarIcon.WMTASKBAREVENT(var message: TMessage);
var point : TPoint;
begin
 case message.LParamLo of
  WM_LBUTTONDOWN : begin
                    Application.MainForm.Show; // so ungefähr
                   end;
  WM_RBUTTONDOWN : begin
                    GetCursorPos(point);
                    PM_Task.PopUp(point.x,point.y); // z.B. ein PopUp-Menü
                   end;
 end;
end;
Manfred Götze
  Mit Zitat antworten Zitat