#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
找到一个代码,试了一下,双击列表就可以停止倒计时,单击就没反应,有更好的解决方法吗? |