模拟Tab按键怎么实现?(20分)

  • 主题发起人 主题发起人 book523
  • 开始时间 开始时间
B

book523

Unregistered / Unconfirmed
GUEST, unregistred user!
我用postmessage(WM_KEYDOWN,VK_TAB,0)怎么实现不了阿?
 
VOID keybd_event(<br><br>&nbsp; &nbsp; BYTE bVk, // virtual-key code<br>&nbsp; &nbsp; BYTE bScan, // hardware scan code<br>&nbsp; &nbsp; DWORD dwFlags, // flags specifying various function options<br>&nbsp; &nbsp; DWORD dwExtraInfo // additional data associated with keystroke<br>&nbsp; &nbsp;); <br>&nbsp;<br><br>Parameters<br><br>bVk<br><br>Specifies a virtual-key code. The code must be a value in the range 1 to 254. <br><br>bScan<br><br>Specifies a hardware scan code for the key. <br><br>dwFlags<br><br>A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags: <br><br>Value Meaning<br>KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).<br>KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.<br>&nbsp;<br><br>dwExtraInfo<br><br>Specifies an additional 32-bit value associated with the key stroke.
 
sendmessage(xxx.handle,WM_KEYDOWN,VK_TAB,0)<br>send直接发给xxx<br>post发到消息区,xxx到消息区查找才能接收(也就是有一段时间间隔)
 
您是否是要在控件上按下某個鍵后讓其就好似按下Tab鍵呢?<br>那麼您應該在該控件的OnKeypress事件中如下寫道<br>if key=#13 then //回車<br>&nbsp; begin<br>&nbsp; &nbsp; key=#0;<br>&nbsp; &nbsp; Perform(WM_NEXTDLGCTL,0,0);<br>&nbsp; end;<br>end;
 
TO sydan:<br>是啊!你这样实现很简单阿!<br>但是为什么不能模拟按TAB键来达到这个目的呢?
 
if key=#13 then //回車<br>&nbsp; begin<br>&nbsp; &nbsp; key=#0;<br>&nbsp; &nbsp; Perform(WM_NEXTDLGCTL,0,0);<br>&nbsp; end;<br>可以实现了!!<br>你那里不能?
 
您按照我的方法不行嗎?<br>如果您是想整個表單都能按下回車鍵個跳到下一控件的話,那你就如下操作吧!<br>1-將表單的KeyPreview設為True<br>2-在表單的OnKeypress事件中如下寫道<br>if key=#13 then //回車<br>&nbsp; begin<br>&nbsp; &nbsp; key=#0;<br>&nbsp; &nbsp; Perform(WM_NEXTDLGCTL,0,0);<br>&nbsp; end;<br>end;<br><br>這樣,當您在此表單中按下回車后光標將自動跳動到下一控件上了,<br>設置Tab次序,則是在表單中按下右鍵,再先Set Tab進行設置吧!
 
终于可以了,但是在dbgrid中的回车键怎么处理呢?
 
dbgrid中也要回車退出嗎?這個沒必要吧!<br>不過也很簡單,,,,就用我剛才說的方法就行了,我的是Delphi6.0+Win2K成功實現
 
接受答案了.
 
后退
顶部