你在窗体上放一个ApplicationEventsprocedure TformMain.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin if Msg.wParam= VK_Tab then Begin 'do something you want; Handled:=True; end; end;
可是为什么会处理两遍呢? procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a'; end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean); begin if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a'; handled:=true; end;同样还是处理了两遍,而且在有多个空间的窗体上移动老鼠,还处理这个事件!
改成这样就可以了 if (msg.wParam=vk_tab) and (msg.message=256) then
下面两种都可以 if (msg.wParam=vk_tab) and (msg.message=WM_KeyDown) then if (msg.wParam=9) and (msg.message=256) then
//灵活一点兄弟, 这样改 procedure TForm1.apevt1Message(var Msg: tagMSG; var Handled: Boolean); begin //msg.lParam:=983041 或 (Msg.lParam and (1 shl 30)<>0 ) if (msg.wParam=vk_tab) and (Msg.lParam and (1 shl 30)<>0 ) then begin Form1.Caption:=Form1.Caption+'a'; handled:=true; end; end;
var Handled: Boolean);
begin
if Msg.wParam= VK_Tab then Begin
'do something you want;
Handled:=True;
end;
end;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a';
end;
var Handled: Boolean);
begin
if msg.wParam=vk_tab then Form1.Caption:=Form1.Caption+'a';
handled:=true;
end;同样还是处理了两遍,而且在有多个空间的窗体上移动老鼠,还处理这个事件!
if (msg.wParam=vk_tab) and (msg.message=256) then
if (msg.wParam=vk_tab) and (msg.message=WM_KeyDown) then
if (msg.wParam=9) and (msg.message=256) then
procedure TForm1.apevt1Message(var Msg: tagMSG; var Handled: Boolean);
begin
//msg.lParam:=983041 或 (Msg.lParam and (1 shl 30)<>0 )
if (msg.wParam=vk_tab) and (Msg.lParam and (1 shl 30)<>0 ) then begin
Form1.Caption:=Form1.Caption+'a';
handled:=true;
end;
end;