如果模拟键盘Shift+TAB ?? 是按住shift的情况下,按一下Tab. (30分)

  • 主题发起人 主题发起人 zscar
  • 开始时间 开始时间
Z

zscar

Unregistered / Unconfirmed
GUEST, unregistred user!
有人知吗?
 
不好意思,我还是不大清楚你的意思。^_^<br>我试了一下,在编辑状态tab是跑到dbgrid下一个field:如果field是最后一个,则跑到<br>下一条纪录的第一个field.shift+tab则相反。<br>因此改成这样。不知道你是不是这个意思?<br>procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word;<br>&nbsp; Shift: TShiftState);<br>begin<br>&nbsp; &nbsp;if key = vk_right then begin &nbsp;//按下右箭头;<br>&nbsp; &nbsp; &nbsp; DBGrid1.Perform(Wm_KeyDown, Vk_Tab, 0);//模拟tab;<br>&nbsp; &nbsp; &nbsp; key:=0;//屏蔽vk_right<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp;else if key=vk_left then begin //按下左箭头;<br>&nbsp; &nbsp; &nbsp; //以下事件模拟按下shift,按下tab,松开tab,松开shift键盘事件。<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Shift, MapVirtualKey( VK_Shift, 0 ), 0 , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Tab, MapVirtualKey( VK_Tab, 0 ), 0 , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Tab, MapVirtualKey( VK_Tab, 0 ), KEYEVENTF_KEYUP , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Shift, MapVirtualKey( VK_Shift, 0 ), KEYEVENTF_KEYUP , 0 ); &nbsp;// Alt key up<br>&nbsp; &nbsp; &nbsp; key:=0;//屏蔽left arrow<br>&nbsp; &nbsp;end<br>end;
 
if key=vk_left then begin //按下左箭头;<br>&nbsp; &nbsp; &nbsp; //以下事件模拟按下shift,按下tab,松开tab,松开shift键盘事件。<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Shift, MapVirtualKey( VK_Shift, 0 ), 0 , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Tab, MapVirtualKey( VK_Tab, 0 ), 0 , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Tab, MapVirtualKey( VK_Tab, 0 ), KEYEVENTF_KEYUP , 0 );<br>&nbsp; &nbsp; &nbsp; keybd_event( VK_Shift, MapVirtualKey( VK_Shift, 0 ), KEYEVENTF_KEYUP , 0 ); &nbsp;// Alt key up<br>&nbsp; &nbsp; &nbsp; key:=0;//屏蔽left arrow<br>我就要这几句,不好意思就这30分给你加上我衷心的同你说声谢谢:).<br>
 
后退
顶部