問題描述:
如何在DW中按下左右光標時切換到相鄰單元格?
解決方案:
首先聲明外部函數:
Subroutine keybd_event(int bVk,int bScan,ulong dwFlags,ulong dwExtraInfo) LIBRARY "user32.dll"
一、如果不想在DW的單元格內利用左右鍵編輯內容,只要一按下左右鍵就切換到其他單元格的話可以:
新建ue_key 對應 pbm_dwnkey ,代碼如下:
if key=keyleftarrow! then
keybd_event(16,0,0,0) //按下SHIFT鍵
keybd_event(9 ,0,0,0) //按下下TAB
keybd_event(9 ,0,2,0) //放開TAB鍵
keybd_event(16,0,2,0) //放開SHIFT鍵
return 1
elseif key=keyrightarrow! then
keybd_event(9 ,0,0,0) //按下下TAB
keybd_event(9 ,0,2,0) //放開TAB鍵
return 1
end if
二、如果還想在DW的單元格內利用左右鍵編輯內容,只在空或者全選時按下左右鍵才切換到其他單元格的話可以:
新建ue_key 對應 pbm_dwnkey ,代碼如下:
integer li_len,li_len_selected
li_len=len(this.gettext())
li_len_selected=len(this.SelectedText())
if not (isnull(this.gettext()) or this.gettext()="" or li_len=li_len_selected) then return
if key=keyleftarrow! then
keybd_event(16,0,0,0) //按下SHIFT鍵
keybd_event(9 ,0,0,0) //按下下TAB
keybd_event(9 ,0,2,0) //放開TAB鍵
keybd_event(16,0,2,0) //放開SHIFT鍵
return 1
elseif key=keyrightarrow! then
keybd_event(9 ,0,0,0) //按下下TAB
keybd_event(9 ,0,2,0) //放開TAB鍵
return 1
end if