[已解决]麻烦大神看下guictrlsetdata这个问题
本帖最后由 synaspe 于 2015-10-25 10:29 编辑#include<ButtonConstants.au3>
#include<GUIConstantsEx.au3>
#include<StaticConstants.au3>
#include<WindowsConstants.au3>
#include <GUIConstants.au3>
Local $time = 3, $d = 1
Opt("GUIOnEventMode", 1)
GUICreate("froml",200,200)
GUISetOnEvent($GUI_EVENT_CLOSE,"_Co")
$Button = GUICtrlCreateButton("暂停",20,20,50,30)
GUICtrlSetOnEvent($Button, "_Go")
$La = GUICtrlCreateLabel("123",100,100)
$Lable1 = GUICtrlCreateLabel("123",60,60)
GUISetState(@SW_SHOW)
AdlibRegister("_Timer",1000)
While 1
WEnd
Func _timer()
If $time = 0 Then _Ao()
Switch $d
case 0
AdlibUnRegister("_Timer")
case 1
$time -=1
EndSwitch
GUICtrlSetData($La,$time)
EndFunc
Func _Go()
Switch $d
Case 1
$d = 0
GUICtrlSetData($Button,"继续")
Case 0
$d = 1
GUICtrlSetData($Button,"暂停")
AdlibRegister("_Timer",1000)
EndSwitch
EndFunc
Func _Ao()
AdlibUnRegister("_Timer")
GUICtrlSetData ($La,"进行中")
EndFunc
Func _Co()
MsgBox(0,"123",1)
Exit
EndFunc
GUICtrlSetData ($La,"进行中")这条没反应,我运行的时候也没报错,不知是什么原因,谢谢! AdlibUnRegister("_timer")
GUICtrlCreateLabel("正在安装",100,100)
GUICtrlDelete($La)
自己尝试了几次改成这样也能达到我要的效果,结贴。 Opt("GUIOnEventMode", 1)
Global $time = 10, $d = 1, $Button, $La
GUICreate("froml", 200, 200)
GUISetOnEvent(-3, "_Co")
$Button = GUICtrlCreateButton("暂停", 20, 20, 80, 30)
GUICtrlSetOnEvent($Button, "_Go")
$La = GUICtrlCreateLabel("123", 100, 100, 100)
GUICtrlCreateLabel("xxx", 60, 60)
GUISetState(@SW_SHOW)
AdlibRegister("_Timer", 1000)
While 1
Sleep(1000)
WEnd
Func _timer()
If $time = 0 Then Return _Ao()
Switch $d
Case 0
AdlibUnRegister("_Timer")
Case 1
$time -= 1
EndSwitch
GUICtrlSetData($La, $time)
EndFunc ;==>_timer
Func _Go()
Switch $d
Case 1
$d = 0
GUICtrlSetData($Button, "继续")
Case 0
$d = 1
GUICtrlSetData($Button, "暂停")
AdlibRegister("_Timer", 1000)
EndSwitch
EndFunc ;==>_Go
Func _Ao()
AdlibUnRegister("_Timer")
GUICtrlSetData($La, "进行中")
GUICtrlSetData($Button, "重新开始")
Dim $time = 10, $d = 0
EndFunc ;==>_Ao
Func _Co()
MsgBox(0, "123", 1)
Exit
EndFunc ;==>_Co
回复 3# afan
原来加了个Return _Ao(),GUICtrlSetData ($La,"进行中")这条才有反应,谢谢前辈!
页:
[1]