[已决解]TreeView怪问题
本帖最后由 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
$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 = GuiCtrlCreateTreeViewItem("A", $TreeView1)
$tmp = GuiCtrlCreateTreeViewItem("B", $TreeView1)
$tmp = 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
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
Global $tmp
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 = GUICtrlCreateTreeViewItem("A", $TreeView1)
$tmp = GUICtrlCreateTreeViewItem("B", $TreeView1)
$tmp = 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 To $tmp
If BitAND(GUICtrlRead($i), 1) Then MsgBox(4096, "", "read" & $i - $tmp)
Next
EndIf
EndSwitch
WEnd 谢谢超版大大,这么短时间就解决我2天的烦恼~~还需要加强自己学习~ 路过学习....
页:
[1]