(Gast)
n/a Beiträge
|
Re: Systray-Icon in eigener Klasse
7. Jun 2005, 15:02
Delphi-Quellcode:
uses
Menus;
type
TSystrayIcon = class
...
private
FHandle: cardinal;
FPopupMenu: TPopupMenu;
WM_TASKBAREVENT: cardinal;
WM_TASKBARCREATED: cardinal;
procedure MessageHandler(var Msg: TMessage);
...
end;
implementation
constructor TSystrayIcon.Create;
begin
inherited;
FHandle := AllocateHWnd(MessageHandler);
WM_TASKBAREVENT := RegisterWindowMessage(ClassName);
WM_TASKBARCREATED := RegisterWindowMessage('TaskbarCreated'); // wenn der explorer abscheißt, das das icon von deinem progrämmchen wiederhergestellt wird
...
end;
destructor TSystrayIcon.Destroy;
begin
DeallocateHWnd(FHandle);
...
inherited;
end;
procedure TSystrayIcon.MessageHandler(var Msg: TMessage);
begin
if Msg.Msg = WM_TASKBAREVENT then begin
... hier dein GetCursorPos(ptCursor); ... if Assigned(FPopupMenu) then FPopupMenu.Popup(ptCursor.X, ptCursor.Y); ...
end
else if Msg.Msg = WM_TASKBARCREATED then
AddIconToSysTray('blah');
end;
|
|
Zitat
|