关于用ApplicationEvent截获并转换键盘按键出现的怪现象---请高手指点,急!(10分)

  • 主题发起人 主题发起人 terrace
  • 开始时间 开始时间
T

terrace

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把pg dn和pg up键模拟成TAB和SHIFT+TAB键的功能。运行的结果是:按一下pg dn键<br>后光标不断的执行TAB键功能闪烁转移。好象进入死循环。不知道问题出在哪里呢?<br>procedure TMain.ApplicationEvents1Message(var Msg:tagMSG;var Handled:Boolean);<br>begin<br>&nbsp; if Msg.message = WM_KEYDOWN then<br>&nbsp; begin<br>&nbsp; &nbsp; if msg.wParam = VK_PRIOR then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; msg.wParam :=0;<br>&nbsp; &nbsp; &nbsp; Handled:=true;<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_SHIFT,0, 0, 0); &nbsp;<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_TAB,0, 0, 0);<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_TAB,0, KEYEVENTF_KEYUP, 0);<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_SHIFT,0, KEYEVENTF_KEYUP, 0);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; if msg.wParam =VK_NEXT &nbsp;then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; msg.wParam :=0;<br>&nbsp; &nbsp; &nbsp; Handled:=true;<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_TAB,0, 0, 0);<br>&nbsp; &nbsp; &nbsp; Keybd_event(VK_TAB,0, KEYEVENTF_KEYUP, 0); <br>&nbsp; &nbsp; end;<br>&nbsp; end; &nbsp;
 
楼上那位兄台,在我的win2000 s+D5上执行你的代码没有问题的。可能是你的运行环境的原因吧。
 
我用xp+d7也没问题.
 
没问题,你再测试程序。
 
后退
顶部