找回密码
 加入
搜索
查看: 1596|回复: 3

[AU3基础] [已决解]TreeView怪问题

[复制链接]
发表于 2010-12-20 11:11:29 | 显示全部楼层 |阅读模式
本帖最后由 m904337 于 2010-12-20 12:07 编辑

预设是选择ALL,功能都正常,但如果不要选择ALL,要选A和B时选择步骤不一样结果也跟着不一样,我的步骤如下
第一种结果:先取消ALL,,在选择A和B,只显示read1讯息
第二种结果:先选择A和B,在取消ALL,会显示read1和read2讯息
最后都是选择A和B,只是选的先后顺序不一样,结果也跟着不一样,不知道问题出在哪?请高手帮帮忙~
如下原码
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
Dim $tmp[4]
$Form1 = GUICreate("Form1", 187, 266, 356, 206)
$Button1 = GUICtrlCreateButton("OK", 40, 200, 105, 41)
$TreeView1 = GUICtrlCreateTreeView(32, 24, 121, 145, $TVS_CHECKBOXES)
$ALL = GuiCtrlCreateTreeViewItem("ALL", $TreeView1)
GuiCtrlSetState(-1, $GUI_CHECKED)
$tmp[1] = GuiCtrlCreateTreeViewItem("A", $TreeView1)
$tmp[2] = GuiCtrlCreateTreeViewItem("B", $TreeView1)
$tmp[3] = GuiCtrlCreateTreeViewItem("C", $TreeView1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        If GUICtrlRead($ALL)=$GUI_CHECKED Then
                                MsgBox(4096, "A", "Hi..A")
                                MsgBox(4096, "B", "Hi..B")
                                MsgBox(4096, "C", "Hi..C")
                        Else
                                For $i = 1 To 3 Step 1
                                        If GUICtrlRead($tmp[$i])=$GUI_CHECKED Then
                                                MsgBox(4096, "", "read"&$i)

                                        EndIf
                                Next
                        EndIf
                        Exit
        EndSwitch
WEnd
发表于 2010-12-20 11:52:10 | 显示全部楼层
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>

Global $tmp[3]
GUICreate("Form1", 180, 260)
$Button1 = GUICtrlCreateButton("OK", 40, 200, 100, 41)
$TreeView1 = GUICtrlCreateTreeView(5, 5, 150, 150, $TVS_CHECKBOXES)
$ALL = GUICtrlCreateTreeViewItem("ALL", $TreeView1)
GUICtrlSetState(-1, 1)
$tmp[0] = GUICtrlCreateTreeViewItem("A", $TreeView1)
$tmp[1] = GUICtrlCreateTreeViewItem("B", $TreeView1)
$tmp[2] = GUICtrlCreateTreeViewItem("C", $TreeView1)
GUISetState()

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case - 3
                        Exit
                Case $Button1
                        If BitAND(GUICtrlRead($ALL), 1) Then
                                MsgBox(4096, "A", "Hi..A")
                                MsgBox(4096, "B", "Hi..B")
                                MsgBox(4096, "C", "Hi..C")
                        Else
                                For $i = $tmp[0] To $tmp[UBound($tmp) - 1]
                                        If BitAND(GUICtrlRead($i), 1) Then MsgBox(4096, "", "read" & $i - $tmp[0])
                                Next
                        EndIf
        EndSwitch
WEnd
 楼主| 发表于 2010-12-20 12:05:57 | 显示全部楼层
谢谢超版大大,这么短时间就解决我2天的烦恼~~还需要加强自己学习~
发表于 2010-12-20 12:06:59 | 显示全部楼层
路过学习....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-6 09:21 , Processed in 0.078486 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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