找回密码
 加入
搜索
查看: 11868|回复: 18

[交流] Autoit 3 如何实现树形复选框

 火.. [复制链接]
发表于 2013-5-5 11:57:25 | 显示全部楼层 |阅读模式
本帖最后由 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
 楼主| 发表于 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2013-5-5 21:07:55 | 显示全部楼层
楼主有才,谢谢分享。
发表于 2013-5-5 21:30:40 | 显示全部楼层
谢谢分享 ing
发表于 2013-8-14 11:53:50 | 显示全部楼层
很不错哟~~
发表于 2014-1-29 17:01:29 | 显示全部楼层
這個好阿
发表于 2014-2-1 08:18:53 | 显示全部楼层
看起来真的好漂亮,谢谢分享
发表于 2014-2-12 01:51:54 | 显示全部楼层
不错的,谢谢分享了
发表于 2014-2-21 20:35:44 | 显示全部楼层
这个看起来确实很漂亮
发表于 2014-2-21 21:27:26 | 显示全部楼层
不错,谢谢分享了
发表于 2014-2-22 04:28:39 | 显示全部楼层
是这个吗.........

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-2-22 08:46:15 | 显示全部楼层
谢谢分享了。
发表于 2014-2-23 09:08:17 | 显示全部楼层
感谢分享,感谢大神
发表于 2014-2-24 11:59:34 | 显示全部楼层
还是蛋蛋发出来那个图的才是完美的
发表于 2014-2-24 15:16:01 | 显示全部楼层
看起来真的好漂亮,谢谢分享
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-13 14:33 , Processed in 0.109886 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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