这是别人的一段程序,我还没调过
type
TMyComponent = class (TgriphControl)
...
protected
procedure CMWantSpecialKey(var Message: TCMWantSpecialKey); message
CM_WANTSPECIALKEY;
end;
procedure TMyComponent.CMWantSpecialKey(var Message: TCMWantSpecialKey);
begin
inherited;
if Message.CharCode = VK_LEFT then
Message.Result := 1;
end;

解决方案 »

  1.   

    我也没DELPHI,只能帮你想想,你如果想全局监控VK——LEFT,那么你得用钩子了!
      

  2.   

    你可以截获WM_KEYDOWN消息
    声明:
      procedure WMKeyDown(var Msg:TMessage);WM_KeyDown;实现:
      procedure TMyComponent.WMKeyDown(var Msg:Tmessage);
      begin 
       inherited;
       if Msg.Param=Vk_Left then
       beign
         ;//capture the vk_left pressing down message
       end;
      end;end;
      

  3.   

    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
     if key=VK_LEFT then
     showmessage('ok');
    end;
      

  4.   

    使用消息的
    type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        procedure test(var msg:Tmessage);message WM_KeyDown;//这里定义
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    procedure Tform1.test(var msg:Tmessage);
    begin
     if msg.WParam=Vk_Left then//这里触发
      showmessage('OK');
    end;