这是别人的一段程序,我还没调过
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;
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;
声明:
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;
Shift: TShiftState);
begin
if key=VK_LEFT then
showmessage('ok');
end;
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;