设置窗体热键

作者在 2010-02-26 13:17:43 发布以下内容
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
protected
procedure hotykey(var msg:TMessage); message WM_HOTKEY;
end;

var
Form1: TForm1;
HotKey:Integer;

implementation

{$R *.DFM} 


procedure TForm1.hotykey(var msg:TMessage); 
begin 
if (msg.LParamLo=MOD_CONTROL) and (msg.LParamHi=13) then
begin
ShowMessage('fuck');               //实现过程
end; 
end;

procedure TForm1.FormCreate(Sender: TObject);
begin 
HotKey:=GlobalAddAtom('HotKey');
RegisterHotKey(handle,HotKey,mod_control,13);   //给窗体注册enter和Ctrl热键
end; 

procedure TForm1.FormDestroy(Sender: TObject); 
begin 
UnRegisterHotKey(handle,HotKey);    //删除
end;

-------------------------------------------
这是个简单的例子
if (ssCtrl in Shift) and (chr(Key) in [’A’, ’a’])
 then
ShowMessage(’Ctrl-A’);

编程点滴 | 阅读 224153 次
文章评论,共0条
游客请输入验证码
浏览2354321次