找回密码
 加入
搜索
查看: 2039|回复: 5

树形列表函数_GUICtrlTreeView_Add使用问题

[复制链接]
发表于 2008-9-23 11:11:10 | 显示全部楼层 |阅读模式
本帖最后由 qq342252004 于 2009-12-20 09:37 编辑

_GUICtrlTreeView_Add 这个树形列表函数如何执行选中项目

[ 本帖最后由 qq342252004 于 2008-9-23 13:47 编辑 ]
发表于 2008-9-23 12:16:30 | 显示全部楼层
你指的是什么意思
 楼主| 发表于 2008-9-25 07:52:43 | 显示全部楼层
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

$Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()

    Local $hItem, $hImage, $iImage, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
   
    GUICreate("TreeView Add", 400, 300)

    $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState()

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 165)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 168)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 137)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 146)
    _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 1 To Random(2, 10, 1)
        $iImage = Random(0, 5, 1)
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x), $iImage, $iImage)
        For $y = 1 To Random(2, 10, 1)
            $iImage = Random(0, 5, 1)
            _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y), $iImage, $iImage)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($hTreeView)

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

请问如何执行选中项目的任务.
发表于 2009-7-19 18:21:35 | 显示全部楼层
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <TreeViewConstants.au3>

    Global $hItem, $hImage, $iImage, $hTreeView,$nMsg
    Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
    GUICreate("TreeView Add", 400, 300)
    $hTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
        $Button1 = GUICtrlCreateButton("Button1", 170, 270, 81, 25, $WS_GROUP)
    GUISetState()

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, "shell32.dll", 131)
    _GUICtrlTreeView_SetNormalImageList($hTreeView, $hImage)
    _GUICtrlTreeView_BeginUpdate($hTreeView)
        $hItem = _GUICtrlTreeView_Add($hTreeView, 0, "中国", 1, 1)
                $Child=_GUICtrlTreeView_AddChild($hTreeView, $hItem,"广东", 1, 1)
    _GUICtrlTreeView_EndUpdate($hTreeView)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        If _GUICtrlTreeView_GetChecked($hTreeView, $Child) Then 
                        MsgBox(0,0,'你选择了广东')
                        EndIf
                        If _GUICtrlTreeView_GetChecked($hTreeView, $hItem) Then 
                        MsgBox(0,0,'你选择了中国')
                        EndIf
        EndSwitch
WEnd
不建议从例子去学习
还是先搞清相关函数的定义吧
发表于 2010-3-5 03:29:05 | 显示全部楼层
学习学习。
发表于 2010-3-15 14:10:41 | 显示全部楼层
不错,学习了.
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-7-5 12:15 , Processed in 0.076228 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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