rabbitsz 发表于 2013-5-5 11:57:25

Autoit 3 如何实现树形复选框

本帖最后由 rabbitsz 于 2013-5-5 11:58 编辑

下面仅仅是树形,那如何实现树形复选框,前辈们指导一下哇 !

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>

_Main()

Func _Main()
        Local $maintree, $aboutitem, $generalitem, $toolsitem, $effectitem, $styleitem
        Local $cmditem, $miscitem, $descgroup, $effectsgroup, $effectstree
        Local $effect1, $effect2, $effect3, $effect4, $effect5
        Local $stylesgroup, $stylestree, $style1, $style2, $style3, $style4, $style5
        Local $aboutlabel, $cancelbutton, $msg

       

        #forceref $cmditem, $miscitem, $effect2, $effect4, $effect5, $style1, $style2, $style3

        GUICreate("GUI with more treeviews", 340, 200, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX,

$WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))
      
       

        $maintree = GUICtrlCreateTreeView(10, 10, 120, 150)
        $aboutitem = GUICtrlCreateTreeViewItem("About", $maintree)
        $generalitem = GUICtrlCreateTreeViewItem("General", $maintree)
        $toolsitem = GUICtrlCreateTreeViewItem("Tools", $maintree)
        $effectitem = GUICtrlCreateTreeViewItem("Effects", $generalitem)
        $styleitem = GUICtrlCreateTreeViewItem("Styles", $generalitem)
        $cmditem = GUICtrlCreateTreeViewItem("Commandline", $toolsitem)
        $miscitem = GUICtrlCreateTreeViewItem("Misc", $toolsitem)

        $descgroup = GUICtrlCreateGroup("Description", 140, 105, 180, 55)
        GUICtrlSetState(-1, $GUI_HIDE)

        $effectsgroup = GUICtrlCreateGroup("Effects", 140, 5, 180, 95)
        GUICtrlSetState(-1, $GUI_HIDE)
        $effectstree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES,

$TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
        GUICtrlSetState(-1, $GUI_HIDE)
        $effect1 = GUICtrlCreateTreeViewItem("Effect 1", $effectstree)
        $effect2 = GUICtrlCreateTreeViewItem("Effect 2", $effectstree)
        $effect3 = GUICtrlCreateTreeViewItem("Effect 3", $effectstree)
        $effect4 = GUICtrlCreateTreeViewItem("Effect 4", $effectstree)
        $effect5 = GUICtrlCreateTreeViewItem("Effect 5", $effectstree)

        $stylesgroup = GUICtrlCreateGroup("Styles", 140, 5, 180, 95)
        GUICtrlSetState(-1, $GUI_HIDE)
        $stylestree = GUICtrlCreateTreeView(150, 20, 160, 70, BitOR($TVS_CHECKBOXES,

$TVS_DISABLEDRAGDROP), $WS_EX_CLIENTEDGE)
        GUICtrlSetState(-1, $GUI_HIDE)
        $style1 = GUICtrlCreateTreeViewItem("Style 1", $stylestree)
        $style2 = GUICtrlCreateTreeViewItem("Style 2", $stylestree)
        $style3 = GUICtrlCreateTreeViewItem("Style 3", $stylestree)
        $style4 = GUICtrlCreateTreeViewItem("Style 4", $stylestree)
        $style5 = GUICtrlCreateTreeViewItem("Style 5", $stylestree)

        $aboutlabel = GUICtrlCreateLabel("This is only a treeview demo.", 160, 80, 160, 20)

        $cancelbutton = GUICtrlCreateButton("Cancel", 130, 170, 70, 20)
        GUISetState()

        GUICtrlSetState($effect1, $GUI_CHECKED)
        GUICtrlSetState($effect3, $GUI_CHECKED)
        GUICtrlSetState($style4, $GUI_CHECKED)
        GUICtrlSetState($style5, $GUI_CHECKED)

        While 1
                $msg = GUIGetMsg()
                Select
                        Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton
                                ExitLoop
                        Case $msg = $aboutitem
                                GUICtrlSetState($descgroup, $GUI_HIDE)
                                GUICtrlSetState($effectstree, $GUI_HIDE)
                                GUICtrlSetState($effectsgroup, $GUI_HIDE)
                                GUICtrlSetState($stylestree, $GUI_HIDE)
                                GUICtrlSetState($stylesgroup, $GUI_HIDE)
                                GUICtrlSetState($aboutlabel, $GUI_SHOW)

                        Case $msg = $effectitem
                                GUICtrlSetState($stylestree, $GUI_HIDE)
                                GUICtrlSetState($stylesgroup, $GUI_HIDE)
                                GUICtrlSetState($aboutlabel, $GUI_HIDE)
                                GUICtrlSetState($effectsgroup, $GUI_SHOW)
                                GUICtrlSetState($descgroup, $GUI_SHOW)
                                GUICtrlSetState($effectstree, $GUI_SHOW)
                                GUICtrlSetBkColor($effectstree, 0xD0F0F0)
                                ;GUIctrlSetState...($effectstree,$GUI_SHOW)

                        Case $msg = $styleitem
                                GUICtrlSetState($effectstree, $GUI_HIDE)
                                GUICtrlSetState($effectsgroup, $GUI_HIDE)
                                GUICtrlSetState($aboutlabel, $GUI_HIDE)
                                GUICtrlSetState($stylesgroup, $GUI_SHOW)
                                GUICtrlSetState($descgroup, $GUI_SHOW)
                                ;GUIctrlSetState.($stylestree,$GUI_SHOW)
                                GUICtrlSetState($stylestree, $GUI_SHOW)
                                GUICtrlSetColor($stylestree, 0xD00000)
                                GUICtrlSetBkColor($stylestree, 0xD0FFD0)

                EndSelect
        WEnd

        GUIDelete()
        Exit
EndFunc   ;==>_Main

rabbitsz 发表于 2013-5-5 17:08:18

已搞定 !
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=stc2.kxf
$Form1 = GUICreate("STC Conformance Automation", 326, 406, 222, 124)
$MenuItem1 = GUICtrlCreateMenu("File")
$MenuItem2 = GUICtrlCreateMenu("Action")
$MenuItem3 = GUICtrlCreateMenu("About")
$Group1 = GUICtrlCreateGroup("Action", 16, 8, 297, 377)
$Button1 = GUICtrlCreateButton("ConfigureIUT", 112, 32, 81, 25)
$Button2 = GUICtrlCreateButton("Setup", 24, 32, 73, 25)
$Button3 = GUICtrlCreateButton("StartTest", 216, 32, 73, 25)
$Group2 = GUICtrlCreateGroup("Select Feature(s)", 24, 64, 273, 313)
$TreeView1 = GUICtrlCreateTreeView(40, 88, 241, 289, BitOR($GUI_SS_DEFAULT_TREEVIEW,$TVS_CHECKBOXES))
GUICtrlSetBkColor(-1, 0xFFFFFF)
$TreeView1_0 = GUICtrlCreateTreeViewItem("IP Multicast", $TreeView1)
$TreeView1_1 = GUICtrlCreateTreeViewItem("IGMPV2", $TreeView1_0)
$TreeView1_2 = GUICtrlCreateTreeViewItem("IGMPV3", $TreeView1_0)
$TreeView1_3 = GUICtrlCreateTreeViewItem("IGMPSNOOPING", $TreeView1_0)
$TreeView1_4 = GUICtrlCreateTreeViewItem("MLDSNOOPING", $TreeView1_0)
$TreeView1_5 = GUICtrlCreateTreeViewItem("MLDV2", $TreeView1_0)
$TreeView1_6 = GUICtrlCreateTreeViewItem("MLDV1", $TreeView1_0)
$TreeView1_7 = GUICtrlCreateTreeViewItem("MSDP", $TreeView1_0)
$TreeView1_8 = GUICtrlCreateTreeViewItem("PIM", $TreeView1_0)
$TreeView1_9 = GUICtrlCreateTreeViewItem("Broadband Access", $TreeView1)
$TreeView1_10 = GUICtrlCreateTreeViewItem("IPv4 and IPv6 Routing", $TreeView1)
$TreeView1_11 = GUICtrlCreateTreeViewItem("Bridging", $TreeView1)
$TreeView1_12 = GUICtrlCreateTreeViewItem("Data Center", $TreeView1)
$TreeView1_13 = GUICtrlCreateTreeViewItem("Metro and Copper Ethernet", $TreeView1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

smooth 发表于 2013-5-5 21:07:55

楼主有才,谢谢分享。

PPTBS 发表于 2013-5-5 21:30:40

谢谢分享 ing

ppp092 发表于 2013-8-14 11:53:50

很不错哟~~

kc098829 发表于 2014-1-29 17:01:29

這個好阿{:face (356):}

newsmile 发表于 2014-2-1 08:18:53

看起来真的好漂亮,谢谢分享

kkahk 发表于 2014-2-12 01:51:54

不错的,谢谢分享了

dabaiyun 发表于 2014-2-21 20:35:44

这个看起来确实很漂亮

hnfeng 发表于 2014-2-21 21:27:26

不错,谢谢分享了

netegg 发表于 2014-2-22 04:28:39

是这个吗.........

joyran 发表于 2014-2-22 08:46:15

谢谢分享了。

ak47gglllk 发表于 2014-2-23 09:08:17

感谢分享,感谢大神

xz00311 发表于 2014-2-24 11:59:34

还是蛋蛋发出来那个图的才是完美的

chenking84 发表于 2014-2-24 15:16:01

看起来真的好漂亮,谢谢分享
页: [1] 2
查看完整版本: Autoit 3 如何实现树形复选框