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: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellApi, AppEvnts; type TWMHotkey = RECORD Msg: Cardinal; idHotKey: Word; Modifiers: Integer; VirtKey: Integer; end;
const IC_CLICK = WM_APP + 201; ID = $FF; type TForm1 = class(TForm) ButtonSystray: TButton; ButtonHotkeysSetzen: TButton; procedure ButtonSystrayClick(Sender: TObject); procedure ButtonHotkeysSetzenClick(Sender: TObject); private procedure Systray(var sMsg: TMessage); message IC_CLICK; procedure WMHotKey(var Msg: TWMHotKey); Message WM_HOTKEY; public end;
var Form1: TForm1; NIM : TNotifyIconData; implementation
{$R *.dfm}
procedure TForm1.Systray(var sMsg: TMessage); begin inherited; if (sMsg.LParam = WM_LBUTTONDOWN) then begin Show; Shell_NotifyIcon(NIM_DELETE, @NIM); Application.Restore; Form1.FormStyle:=fsNormal; end; end;
procedure TForm1.ButtonSystrayClick(Sender: TObject); begin Form1.FormStyle:=fsStayOnTop; 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 := 'flx tools'; end; Shell_NotifyIcon(NIM_ADD, @NIM); end;
procedure TForm1.WMHotKey(Var Msg: TWMHotkey); begin case Msg.IdHotKey of ID: Caption := 'alles klar'; end; inherited; end;
procedure TForm1.ButtonHotkeysSetzenClick(Sender: TObject); begin if NOT RegisterHotKey(Form1.Handle, ID, MOD_CONTROL + MOD_Alt, Ord('F')) then ShowMessage('Hotkey konnte nicht registriert werden'); end;
end. |