加一过程procedure WMhotkeyhandle(var msg:TMessage); message wm_hotkey;
procedure TForm1.WMHotkeyhandle(var msg:TMessage);
begin
if (msg.LParamHi=$41) and (msg.LParamLo=NOD_CONTROL or mod_Alt) then
begin
msg.Result :=1;
Application.BringToFront;
end;
end;
//注册热键
procedure TForm1.FormCreate(Sender:TObject);
begin
hotkeyid :=GlobalAddAtom(pchar('UserDefineHotkey'))-$C000;
registerhotkey(handle,hotkeyid,MOD_CONTROL or mod_Alt,$41);
end;
//释放热键
procedure TForm1.FormClose(Sender:TObject;var Action:TCloseAction);
begin
unregisterhotkey(handle,hotkeyid);
DeleteAtom(HotKeyID);
end;
本例程设置热键Ctrl+Alt+A,当按下此热键后,将窗体置于最前,关闭窗体时释放热键