#include <GUIConstants.au3>
$Form1 = GUICreate('test', 247, 158)
$Label1 = GUICtrlCreateLabel('用户名:', 16, 16, 43, 17)
$User = GUICtrlCreateCombo('', 72, 16, 169, 21)
GUICtrlSetData(-1, "a|bb|ccc")
;GUICtrlSetState($User, $GUI_FOCUS)
$Label2 = GUICtrlCreateLabel('密码:', 24, 56, 31, 17)
$Password = GUICtrlCreateCombo('b', 72, 54, 169, 21)
$Button1 = GUICtrlCreateButton('确定', 80, 112, 89, 33)
GUISetState(@SW_SHOW)
GUIRegisterMsg(0x111, '_WM_COMMAND')
Do
Local $msg = GUIGetMsg()
Until $msg = -3 Or $msg = $Button1
Func _WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
If Not $ilParam Then
Local $hc, $aRt, $id
If BitAND($iwParam, 0xFFFF) <> 1 Then
$id = BitAND($iwParam, 0xFFFF)
If $id = $User Then GUICtrlSetState($Password, $GUI_FOCUS)
If $id = $Password Then GUICtrlSetState($Button1, $GUI_FOCUS)
Else
$aRt = DllCall('user32.dll', 'hwnd', 'GetFocus')
If Not @error Then $hc = $aRt[0]
If $hc = GUICtrlGetHandle($User) Then GUICtrlSetState($Password, $GUI_FOCUS)
If $hc = GUICtrlGetHandle($Password) Then GUICtrlSetState($Button1, $GUI_FOCUS)
EndIf
EndIf
EndFunc ;==>_WM_COMMAND
在这个代码里鼠标点击不自动切换。 |