瞎捣鼓用WM_COMMAND好像可以实现了,现在的问题是程序运行时点关闭按钮无效,怎么处理?#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\form11.kxf
Global $StopCode
$Form1 = GUICreate("Form1", 500, 200)
$Input1 = GUICtrlCreateInput("Input1", 56, 32, 225, 21)
$Button1 = GUICtrlCreateButton("Button1", 312, 24, 65, 33)
$Button2 = GUICtrlCreateButton("Button2", 400, 24, 73, 33)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$StopCode = 0
GUICtrlSetData($Button1, '开始')
GUICtrlSetData($Button1, '正在运行')
GUICtrlSetState($Button1, $GUI_DISABLE)
GUICtrlSetState($Input1, $GUI_DISABLE)
For $n = 1 To 10
If $StopCode = 1 Then ExitLoop
$ts = TimerInit()
Do
GUICtrlSetData($Input1, $n)
Until TimerDiff($ts) > 500
Next
GUICtrlSetData($Button1, '开始')
GUICtrlSetState($Button1, $GUI_ENABLE)
GUICtrlSetState($Input1, $GUI_ENABLE)
EndSwitch
WEnd
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
Local $hWndFrom, $iIDFrom, $iCode, $iIDFrom1
Switch BitAND(0xffff, $wParam)
Case $Button2
$StopCode = 1
EndSwitch
EndFunc ;==>WM_COMMAND
|