如何停止倒计时?
下面的代码哪里出错了?不管我点安装还是取消都没反应,只有倒计时在动,不管点什么都没反应。哪位老大知道的指点一下,我想做到的是点任意一个按钮,或者listview选项,倒计时会自动停下。谢谢!
#include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$started = 1
$hGUI = GUICreate("Program", 400, 300)
$iStyle = BitOR($LVS_SINGLESEL, $LVS_REPORT)
$iExStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, _
$LVS_EX_GRIDLINES, 0x200)
$Install = GUICtrlCreateButton("安装(&I)", 40, 250, 80, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetState(-1, $GUI_FOCUS)
$Cancel = GUICtrlCreateButton("取消(&C)", 140, 250, 80, 25)
GUISetState()
$iListView = GUICtrlCreateListView("Name|Program", 5, 5, 350, 240, $iStyle, $iExStyle)
;_GUICtrlListView_SetColumnWidth($iListView, 0, 150)
$sItem = "TEST|TEST1"
GUICtrlCreateListViewItem($sItem, $iListView)
AdlibEnable("Times")
GUISetState()
Func Times()
For $time = 10 To 1 Step -1
GUICtrlSetData($Install, "安装(" & $time & ")")
Sleep(1000)
Next
If $started Then
Exit
EndIf
EndFunc ;==>Times
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Install
AdlibDisable()
MsgBox(0, "提示", "安装", 100)
Case $msg = $Cancel
AdlibDisable()
MsgBox(0, "提示", "退出", 100)
Exit
EndSelect
WEnd
[ 本帖最后由 sowind 于 2009-4-20 22:25 编辑 ] #include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$started = 1
$cc=10
$hGUI = GUICreate("Program", 400, 300)
$iStyle = BitOR($LVS_SINGLESEL, $LVS_REPORT)
$iExStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, _
$LVS_EX_GRIDLINES, 0x200)
$Install = GUICtrlCreateButton("安装(&I)", 40, 250, 80, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetState(-1, $GUI_FOCUS)
$Cancel = GUICtrlCreateButton("取消(&C)", 140, 250, 80, 25)
GUISetState()
$iListView = GUICtrlCreateListView("Name|Program", 5, 5, 350, 240, $iStyle, $iExStyle)
;_GUICtrlListView_SetColumnWidth($iListView, 0, 150)
$sItem = "TEST|TEST1"
GUICtrlCreateListViewItem($sItem, $iListView)
AdlibEnable("Times",1000)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Install
AdlibDisable()
MsgBox(0, "提示", "安装", 100)
Case $msg = $Cancel
AdlibDisable()
MsgBox(0, "提示", "退出", 100)
Exit
EndSelect
WEnd
Func Times()
$cc -=1
GUICtrlSetData($Install, "安装(" & $cc & ")")
if $cc=0 then exit
EndFunc ;==>Times
[ 本帖最后由 ddx13 于 2009-4-20 21:02 编辑 ] 谢谢楼上的兄弟,点列表时,倒计时还是不会停止。 #include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$cc=10
$hGUI = GUICreate("Program", 400, 300)
$iStyle = BitOR($LVS_SINGLESEL, $LVS_REPORT)
$iExStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, _
$LVS_EX_GRIDLINES, 0x200)
$Install = GUICtrlCreateButton("安装(&I)", 40, 250, 80, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetState(-1, $GUI_FOCUS)
$Cancel = GUICtrlCreateButton("取消(&C)", 140, 250, 80, 25)
GUISetState()
$iListView = GUICtrlCreateListView("Name|Program", 5, 5, 350, 240, $iStyle, $iExStyle)
;_GUICtrlListView_SetColumnWidth($iListView, 0, 150)
$sItem = "TEST|TEST1"
GUICtrlCreateListViewItem($sItem, $iListView)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
AdlibEnable("Times",1000)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Install
AdlibDisable()
MsgBox(0, "提示", "安装", 100)
Case $msg = $Cancel
AdlibDisable()
MsgBox(0, "提示", "退出", 100)
Exit
EndSelect
WEnd
Func Times()
$cc -=1
GUICtrlSetData($Install, "安装(" & $cc & ")")
if $cc=0 then exit
EndFunc ;==>Times
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
;~ Local $tBuffer
$hWndListView = $iListView
If Not IsHWnd($iListView) Then $hWndListView = GUICtrlGetHandle($iListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
;Case $LVN_ITEMCHANGED ; An item has changed
Case $LVN_COLUMNCLICK ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
ConsoleWrite("A column was clicked" & @LF)
AdlibDisable()
Case $LVN_ITEMACTIVATE ; Sent by a list-view control when the user activates an item
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
AdlibDisable()
Return 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
找到一个代码,试了一下,双击列表就可以停止倒计时,单击就没反应,有更好的解决方法吗? #include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
$started = 1
$cc = 10
$hGUI = GUICreate("Program", 400, 300)
$iStyle = BitOR($LVS_SINGLESEL, $LVS_REPORT)
$iExStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, _
$LVS_EX_GRIDLINES, 0x200)
$Install = GUICtrlCreateButton("安装(&I)", 40, 250, 80, 25, $BS_DEFPUSHBUTTON)
GUICtrlSetState(-1, $GUI_FOCUS)
$Cancel = GUICtrlCreateButton("取消(&C)", 140, 250, 80, 25)
GUISetState()
$iListView = GUICtrlCreateListView("Name|Program", 5, 5, 350, 240, $iStyle, $iExStyle)
;_GUICtrlListView_SetColumnWidth($iListView, 0, 150)
$sItem = "TEST|TEST1"
GUICtrlCreateListViewItem($sItem, $iListView)
AdlibEnable("Times", 1000)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Install
AdlibDisable()
MsgBox(0, "提示", "安装", 100)
Case $msg = $Cancel
AdlibDisable()
MsgBox(0, "提示", "退出", 100)
Exit
EndSelect
WEnd
Func Times()
$cc -= 1
if GUICtrlRead ($iListView)=0 then
GUICtrlSetData($Install, "安装(" & $cc & ")")
if $cc = 0 then exit
else
GUICtrlSetData($Install, "安装(&I)")
endif
EndFunc ;==>Times 谢谢,楼上的兄弟,今天没办法评分,明天补上!
页:
[1]