找回密码
 加入
搜索
查看: 1411|回复: 5

如何停止倒计时?

[复制链接]
发表于 2009-4-20 20:31:46 | 显示全部楼层 |阅读模式
下面的代码哪里出错了?不管我点安装还是取消都没反应,只有倒计时在动,不管点什么都没反应。
哪位老大知道的指点一下,我想做到的是点任意一个按钮,或者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 编辑 ]
发表于 2009-4-20 20:59:55 | 显示全部楼层
#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 编辑 ]

评分

参与人数 1金钱 +3 收起 理由
sowind + 3 谢谢,问题解决一半,点列表时,倒计时不会 ...

查看全部评分

 楼主| 发表于 2009-4-20 21:34:59 | 显示全部楼层
谢谢楼上的兄弟,点列表时,倒计时还是不会停止。
 楼主| 发表于 2009-4-20 21:46:24 | 显示全部楼层
#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

找到一个代码,试了一下,双击列表就可以停止倒计时,单击就没反应,有更好的解决方法吗?
发表于 2009-4-20 22:01:28 | 显示全部楼层
#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金钱 +5 收起 理由
sowind + 5 评分补上,谢谢!

查看全部评分

 楼主| 发表于 2009-4-20 22:40:32 | 显示全部楼层
谢谢,楼上的兄弟,今天没办法评分,明天补上!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-28 16:11 , Processed in 0.076085 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表