|
发表于 2013-8-9 22:40:24
|
显示全部楼层
本帖最后由 fangbaiyu 于 2013-8-9 22:50 编辑
鄙人语文很差 看了LZ的问题 很凌乱
乱写了一通 LZ看看 是不是你想要的效果
例一:#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global $gu_hMainForm = GUICreate("", 200, 300)
Global $gu_nEdit = GUICtrlCreateEdit("", 10, 10, 180, 220)
Global $gu_nButton1 = GUICtrlCreateButton("Button1", 30, 250, 50, 30)
Global $gu_nButton2 = GUICtrlCreateButton("Button2", 110, 250, 50, 30)
Global $gu_hEdit = GUICtrlGetHandle($gu_nEdit)
GUICtrlSetOnEvent($gu_nButton1, "_MY_EVENT")
GUICtrlSetOnEvent($gu_nEdit, "_MY_EVENT")
GUISetOnEvent($GUI_EVENT_CLOSE, "_MY_EVENT")
GUICtrlSetState($gu_nButton2, $GUI_DISABLE)
GUISetState(@SW_SHOW)
While 1
Sleep(10)
WEnd
GUIDelete()
Exit
Func _MY_EVENT()
Local $t_bVar
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $gu_nButton1
$t_bVar = GUICtrlSetData($gu_nEdit, "Test", 1)
If $t_bVar Then _SendMessage($gu_hMainForm, $WM_COMMAND, $EN_CHANGE, 0)
Case $gu_nEdit
GUICtrlSetState($gu_nButton2, $GUI_ENABLE)
EndSwitch
EndFunc
例二:#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Global $gu_hMainForm = GUICreate("", 200, 300)
Global $gu_nEdit = GUICtrlCreateEdit("", 10, 10, 180, 220)
Global $gu_nButton1 = GUICtrlCreateButton("Button1", 30, 250, 50, 30)
Global $gu_nButton2 = GUICtrlCreateButton("Button2", 110, 250, 50, 30)
Global $gu_hEdit = GUICtrlGetHandle($gu_nEdit)
GUICtrlSetOnEvent($gu_nButton1, "_MY_EVENT")
GUICtrlSetOnEvent($gu_nEdit, "_MY_EVENT")
GUISetOnEvent($GUI_EVENT_CLOSE, "_MY_EVENT")
GUICtrlSetState($gu_nButton2, $GUI_DISABLE)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")
While 1
Sleep(10)
WEnd
GUIDelete()
Exit
Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
Local $wNotifyCode = BitShift($wParam, 16)
Local $wID = BitAND($wParam, 0x0000FFFF)
Local $hWndCtrl = $lParam
Switch $hWndCtrl
Case $gu_hEdit
Switch $wNotifyCode
Case $EN_UPDATE
GUICtrlSetState($gu_nButton2, $GUI_ENABLE)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _MY_EVENT()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $gu_nButton1
GUICtrlSetData($gu_nEdit, "Test", 1)
EndSwitch
EndFunc
|
|