找回密码
 加入
搜索
查看: 2372|回复: 1

[AU3基础] ListView复选框选中计算不准确,就是选中后再取消计算不准确,谢谢!(已解决)

[复制链接]
发表于 2013-4-15 19:21:04 | 显示全部楼层 |阅读模式
本帖最后由 cfs43210 于 2013-4-15 20:27 编辑

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("窗体", 405, 294, 302, 218)
$ListView1 = GUICtrlCreateListView("编号|名称", 16, 16, 369, 201)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 235)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Write()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
Func Write()
        For $i = 1 To 10
                GUICtrlCreateListViewItem($i & '|KB' & $i, $ListView1)
        Next
EndFunc   ;==>Write


Func WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam) ;ListView,$TreeView单双击右键产生的事件
        Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
        Local $tagNMHDR = DllStructCreate("int;int;int", $lParam)
        If @error Then Return $GUI_RUNDEFMSG
        $IDFrom = DllStructGetData($tagNMHDR, 2)
        $Event = DllStructGetData($tagNMHDR, 3)
        $tagNMHDR = 0
        Switch $IDFrom;选择产生事件的控件
        Case $ListView1
                        Switch $Event; 选择产生的事件
                                Case $NM_CLICK ; 左击
                                        $nx = _GUICtrlListView_GetItemCount($ListView1)
                                        $s = 1
                                        For $i = 0 To $nx
                                                If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then
                                                $s += 1
                                                EndIf
                                        Next
                                        WinSetTitle($Form1, "", "已选择:" & $s)
                        EndSwitch
        EndSwitch
EndFunc   ;==>WM_NOTIFY
 楼主| 发表于 2013-4-15 19:56:19 | 显示全部楼层
看似这么简单,没办法解决吗?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-2 05:19 , Processed in 0.079481 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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