Thema: Delphi hotkeys

Einzelnen Beitrag anzeigen

Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#10

Re: hotkeys

  Alt 17. Apr 2004, 16:59
Delphi-Quellcode:
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
      HotKeyID: Integer;
    procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WMHotKey(var Msg: TWMHotKey);
begin
  if Msg.HotKey = HotKeyID then
    ShowMessage('Ctrl + Alt + P wurde gedrückt !');
end;

procedure TForm1.FormCreate(Sender: TObject);
const
  VK_P = $50;
begin
  HotKeyID := GlobalAddAtom(PChar(Application.Exename + '_Hotkey1'));
  RegisterHotKey(Handle, HotKeyID, MOD_CONTROL + MOD_ALT, VK_P);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  UnRegisterHotKey(Handle, HotKeyID);
  GlobalDeleteAtom(HotKeyID);
end;
Thomas
  Mit Zitat antworten Zitat