我编的热键为什么不起作用?原代码如下::(50分)

  • 主题发起人 主题发起人 hitskys
  • 开始时间 开始时间
H

hitskys

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;

type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
hotkeyid :integer;
procedure WMhotkeyhandle(var msg:Tmessage);
message wm_hotkey;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
hotkeyid:=GlobalAddAtom(pchar
('UserDefineHotKey'))-$C000;
registerhotkey(handle,hotkeyid,
MOD_CONTROL or mod_Alt,$41);
end;

procedure TForm1.Wmhotkeyhandle
(var msg:Tmessage);
begin
if (msg.LParamHi=$41) and
(msg.lparamLo=MOD_CONTROL or mod_Alt) then
begin
msg.Result:=1; //该消息已经处理
application.BringToFront;
//把窗口最前面显示
end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unregisterhotkey(handle,hotkeyid);
DeleteAtom(HotKeyID);
end;

end.
我设的热键是ctrl+alt+a,可是为什么不管用??请多多赐教!!
 
procedure TForm1.Wmhotkeyhandle
(var msg:Tmessage);
begin
if (msg.LParamHi=$41) and
(msg.lparamLo=MOD_CONTROL or mod_Alt) then
begin
msg.Result:=1; //该消息已经处理
application.BringToFront;
//把窗口最前面显示
end;
end;
你这个函数有问题,你没有对你定义的hotkeyid做处理,如果你下面的方法保证可用的。
begin
case Msg.HotKey of
hotkeyid:
dosomething;
end;
end;
 
后退
顶部