|
楼主 |
发表于 2010-5-12 10:26:58
|
显示全部楼层
那么,这里的3为什么不替换为 Edit 的 Control ID 呢?#include <GUIEdit.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("", 400 ,300)
$Edit = GUICtrlCreateEdit("", 5, 5, 390, 260, BitOR($ES_WANTRETURN, $WS_VSCROLL))
$hEdit = GUICtrlGetHandle(-1)
GUICtrlCreateButton("Ok", 220, 270, 80, 20)
GUICtrlCreateButton("Cancel", 310, 270, 80, 20)
$hEC = DllCallBackRegister("_EditProc", "int", "hWnd;uint;wparam;lparam")
$hOEC = _WinAPI_SetWindowLong($hEdit, -4, DllCallBackGetPtr($hEC))
GUISetState()
While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)
DllCallbackFree($hEC)
Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam)
If ($iMsg = $WM_KEYDOWN) And ($iwParam = 9) Then
Return GUICtrlSetData($Edit, GUICtrlRead($Edit) & @Tab)
EndIf
Return _WinAPI_CallWindowProc($hOEC, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc ;==>_EditProc
另外,如果有两个以上 Edit,又应该怎么处理这个_EditProc 呢?#include <GUIEdit.au3>
#include <WindowsConstants.au3>
$hGUI = GUICreate("", 400 ,300)
GUICtrlCreateEdit("", 5, 5, 390, 120, BitOR($ES_WANTRETURN, $WS_VSCROLL))
$hEdit1 = GUICtrlGetHandle(-1)
GUICtrlCreateEdit("", 5, 135, 390, 120, BitOR($ES_WANTRETURN, $WS_VSCROLL))
$hEdit2 = GUICtrlGetHandle(-1)
GUICtrlCreateButton("Ok", 220, 270, 80, 20)
GUICtrlCreateButton("Cancel", 310, 270, 80, 20)
$hEC = DllCallBackRegister("_EditProc", "int", "hWnd;uint;wparam;lparam")
$hOEC1 = _WinAPI_SetWindowLong($hEdit1, -4, DllCallBackGetPtr($hEC))
GUISetState()
While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)
DllCallbackFree($hEC)
Func _EditProc($hWnd, $iMsg, $iwParam, $ilParam)
If ($iMsg = $WM_KEYDOWN) And ($iwParam = 9) Then
Return GUICtrlSetData(3, GUICtrlRead(3) & @Tab)
EndIf
Return _WinAPI_CallWindowProc($hOEC1, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc ;==>_EditProc
|
|