unit ScreenCatch;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons;type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    HotKeyID: integer;
    procedure WMhotkey(var msg: TWMhotkey); message WM_hotkey;
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
  HotKeyID := GlobalAddAtom(pchar('MyHotKey'));
  if RegisterHotKey(Handle, HotKeyID, 0, $83) then
    form1.Caption := 'ok';
end;procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  unregisterhotkey(handle, HotKeyID);
  DeleteAtom(HotKeyID);
end;
procedure TForm1.WMhotkey(var msg: TWMhotkey);
begin
  if (msg.WParamHi=$83) then
  begin
    msg.Result:=1;
    form1.Caption:='hotkey';
    application.BringToFront;
  end; 
end;end.为什么程序始终响应不了TForm1.WMhotkey事件呢
帮帮忙吧

解决方案 »

  1.   

    不是不响应你写错了,
    procedure TForm1.WMhotkey(var msg: TWMhotkey);
    begin
      if (msg.WParamHi=HotKeyID) then
      begin
        msg.Result:=1;
        form1.Caption:='hotkey';
        application.BringToFront;
      end; 
    end;
      

  2.   

    $83是什么键。我有个例子可以用.
      RegisterHotKey(Handle,100,0,VK_F2);        // F2键 if Message.WParam =100 then
     begin
        caption:='ok'; 
     
     end;
      

  3.   


    if (msg.WParamHi=$83) then-->
    if (msg.LparamHi=$83) then