1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI;
type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private fIconData: TNOTIFYICONDATA; procedure TaskTrayWndProc (var Msg: TMessage); message cWM_MYTRAYICONCALLBACK; public end;
var Form1: TForm1;
const cWM_MYTRAYICONCALLBACK = WM_USER + 1000;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject); begin with fIconData do begin cbSize := SizeOf (TNOTIFYICONDATA); Wnd := Handle; uID := 1; uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP; hIcon := LoadIcon (0, IDI_INFORMATION); szTip := 'Tooltip'; uCallBackMessage := cWM_MYTRAYICONCALLBACK; end;
If not Shell_NotifyIcon (NIM_ADD, @fIconData) then ; end;
procedure TForm1.TaskTrayWndProc (var Msg: TMessage); begin case Msg.LParam of WM_LBUTTONDOWN: MessageDlg ('Linke Maustaste gedrückt!', mtInformation, [mbOK], 0); WM_RBUTTONDOWN: MessageDlg ('Rechte Maustaste gedrückt!', mtInformation, [mbOK], 0); end; end;
end. |