如何用postmessage(or perform)向windows发送Tab键被按下的消息?(100分)(100分)

  • 主题发起人 主题发起人 HongKong2
  • 开始时间 开始时间
perform(cm_dialogkey,vk_tab,0)
 
为什么该函数在TDbCtrlGrid中的控件中用enter代替tab不管用?(即用该函数不能等同与按下<br><br>下Tab键???)请高手指教
 
是否还有其他的办法或perform中的参数是否还有别的?
 
使一使:<br>&nbsp; &nbsp;PostMessage(Handle,WM_IME_CHAR,9,0);<br>
 
这个方法不行。有没有别的?<br>怎样完全(完全)模拟当按下Enter键时用Tab键代替?perform(cm_dialogkey,vk_tab,0)一旦<br>遇上button控件就停在Button上不移动了,请问,这到底为啥????<br>
 
1 SelectNext(ActiveControl,False,True); <br>2 setfocus方法! <br><br>&nbsp;
 
SelectNext(ActiveControl, &nbsp; &nbsp; &nbsp;true, &nbsp; &nbsp; True);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;↑ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ↑ &nbsp; &nbsp; &nbsp; &nbsp; ↑<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CurrentControl, GoForward, CheckTabStop<br>还可以发送消息:<br>&nbsp; &nbsp; &nbsp; PoseMessage(Handle,WM_NextDLGCTL,0,0)<br>焦点在Button上的时候对Button是没有用的,<br>可以用AppcationEvents,在OnMessage里面抢先处理按键就行了。
 
PoseMessage(Handle,WM_Keydown,Vk_tab,0)
 
我做了一个控件Xkey,用Enter键实现Tab的功能,非常简单,<br>但是没有处理在Button上的情况,如果你愿意将它改一改,<br>我可以发给你,需要的话请发邮件到 yang_gq@163.net
 
PoseMessage(Handle,WM_Keydown,Vk_tab,0)<br>不能通过编译
 
PostMessage(ActiveControl.Handle, WM_KEYDOWN, VK_TAB, 0);<br>
 
&nbsp; &nbsp;在OnKeyDowm事件中加入一下代码,如在From上实现请将KeyPreview设为True.<br>&nbsp; &nbsp; if Key = VK_Return then<br>&nbsp; &nbsp; begin PERFORM(WM_NEXTDLGCTL,0,0) end;<br>&nbsp; &nbsp; 对DBGrid中或Button中的处理,请在相应事件中编写代码。<br>
 
PERFORM(WM_NEXTDLGCTL,0,0) 和PoseMessage(Handle,WM_Keydown,Vk_tab,0)<br>不能用在DBCtrlGrid中。<br>以下<br>来自:Pipi. 时间:00-3-3 0:07:56 ID:194093 &nbsp;<br>我是这样的:<br>form.KeyPrew 设置为 true<br>在form的 OnShortCut 事件里面<br>if(msg.CharCode=VK_RETURN)then<br>&nbsp; msg.CharCode:=VK_TAB;<br><br>&nbsp;<br>&nbsp;<br>
 
是 PosTMessage(Handle,WM_Keydown,Vk_tab,0)<br>不是PoseMessage(Handle,WM_Keydown,Vk_tab,0)
 
//为什么该函数在TDbCtrlGrid中的控件中用enter代替tab不管用?<br>在DBGrid1KeyPress中<br>if Key = #13 then<br>&nbsp; &nbsp; if not (ActiveControl is TDBGrid) then<br>&nbsp; &nbsp; &nbsp; begin <br>&nbsp; &nbsp; &nbsp; Key := #0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; Perform(WM_NEXTDLGCTL, 0, 0); <br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; if (ActiveControl is TDBGrid) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;with TDBGrid(ActiveControl) do<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if selectedindex &lt; (fieldcount -1) then <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;selectedindex := selectedindex +1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;selectedindex := 0;
 
又来晚了,<br>真不走运。
 
多人接受答案了。
 
后退
顶部