About KeyDown Even&Windows Message(200分)

  • 主题发起人 主题发起人 roc
  • 开始时间 开始时间
R

roc

Unregistered / Unconfirmed
GUEST, unregistred user!
In Form,How to catch the ArrowKey &amp; TabKey Down Even,My program use<br>KeyDown Even,but can't catch ArrowKey&amp;TabKey Down,because the<br>ArrowKey&amp;Tabkey only use to move focus.Thank You!<br>
 
用ApplicationEvents。<br>procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;<br>&nbsp; var Handled: Boolean);<br>begin<br>&nbsp; &nbsp;case msg.message of<br>&nbsp; &nbsp;WM_Keydown: begin<br>&nbsp; &nbsp; &nbsp; ...<br>&nbsp; &nbsp;end;<br>&nbsp; &nbsp;end;<br>end;<br>绝对可以捕捉到ArrowKey&amp;Tabkey
 
像这样做就可以了。<br>type TMyEdit= class(TEdit)<br>private<br>&nbsp; // 截获 WM_GETDLGCODE 消息<br>&nbsp; procedure WMGETDLGCODEDLG(var Message: TMessage); message WM_GETDLGCODE;<br>end;<br>procedure TMyEdit.WMGETDLGCODEDLG(var Message: TMessage);<br>begin<br>&nbsp; Message.Result := DLGC_WANTTAB;<br>end;<br><br>I've successfully tested it, Ok ?<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; From: BaKuBaKu
 
不要用KEYDWON事件,<br>用KEYPRESS事件就可以捕获回车、TAB、SHIFT等了
 
keypress捕捉不到arrow key
 
多人接受答案了。
 
后退
顶部