Jump to content

question about GUICtrlCreateTreeView


Bert
 Share

Recommended Posts

  • Moderators

Is there a example of using GUICtrlCreateTreeView and adding a item by right click with the mouse and a menu pops up asking if I want to add a item? 've looked around, but I'm not quite finding what I need.

Are you talking about Gary's CSnippet.au3?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I looked at that, but it is 2200 lines of code, and is very complex. It would take me too long to figure out how he did what I need.

I'm hoping I can get a more simple and smaller example.

Take the following script:

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3
Dim $n_btn_insert

$h_GUI = GUICreate("TreeView UDF Sample", 220, 250)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewInsertItem($treeview, "SubItem1", $h_root1)
_GUICtrlTreeViewInsertItem($treeview, "SubItem2", $h_root1)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")
_GUICtrlTreeViewInsertItem($treeview, "SubItem3", $h_root3)
_GUICtrlTreeViewInsertItem($treeview, "SubItem4", $h_root3)

$n_btn_insert   = GUICtrlCreateButton("Insert Items", 10, 220, 200, 20)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        
        Case $n_btn_insert
            GUICtrlSetCursor($treeview, 1)
            For $i = 3 To 500
                _GUICtrlTreeViewInsertItem($treeview, "RootItem" & $i)
                ToolTip((500 - $i) & " items are created...")
            Next
            ToolTip("")
            GUICtrlSetCursor($treeview, 2)
    EndSwitch
WEnd

Exit

This script is from the help file. The way this one works is you click on the button, and items are added to the tree menu.

My question is this: Instead of the button, you -

  • Right click in the tree menu.
  • a menu appears giving you choices such as "add item", "delete item", and so forth.
  • If a item was highlighted when you right clicked, the add or delete will only affect the item in question
  • You select what you want, and the action is performed.
Can someone give me a snippit of code that does this? I've been searching and have been scratching my head trying to figure this out.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...