设置全局快捷键 <br>CoDelphi.com<br><br>摘 要:我需要的系统范围内的快捷键,如何才能做到呢?<br>关键字:快捷键<br>类 别:系统控制<br> <br> <br>CoDelphi.com版权所有,未经允许,不得进行任何形式转载<br><br><br>type <br>TForm1 = class(TForm) <br>procedure FormCreate(Sender: TObject); <br>procedure FormDestroy(Sender: TObject); <br>protected <br>procedure hotykey(var msg:TMessage); message WM_HOTKEY; <br>end; <br><br>var <br>Form1: TForm1; <br>id,id2:Integer; <br><br>implementation <br><br>{$R *.DFM} <br><br><br>procedure TForm1.hotykey(var msg:TMessage); <br>begin <br>if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=81) then <br>begin <br>ShowMessage('Ctrl + Q '); <br>end; <br><br>if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=82) then <br>begin <br>ShowMessage('Ctrl + R '); <br>end; <br>end; <br><br><br>procedure TForm1.FormCreate(Sender: TObject); <br>begin <br>id:=GlobalAddAtom('hotkey'); <br>RegisterHotKey(handle,id,mod_control,81); <br><br>id2:=GlobalAddAtom('hotkey2'); <br>RegisterHotKey(handle,id2,mod_control,82); <br>end; <br><br>procedure TForm1.FormDestroy(Sender: TObject); <br>begin <br>UnRegisterHotKey(handle,id); <br>UnRegisterHotKey(handle,id2); <br>end;<br>