Sign in to follow this  
Followers 0
MikelSevrel

How to run a function on click in TreeView?

9 posts in this topic

Is it possible to be able to return the text of a TreeView Item by clicking on it? And if so, how? Hopefully that summed it up. :o


Coming soon....

Share this post


Link to post
Share on other sites



Is it possible to be able to return the text of a TreeView Item by clicking on it? And if so, how? Hopefully that summed it up. :o

In your GUI Message loop, you could throw in:

If GUICtrlRead($treeview) == $myTreeViewID Then
    myTVFunc()
EndIf
...

Hopefully that'll get you started.


[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

No. I need to get the text from the treeview item when I click on it. The TreeView text is variable, and I need to get that variable.

So say this is how the treeview looks:

Main
    ->Option
    ->Option2
          ->SubOption1
          ->SubOption2
              ->SubSubOption1
    ->Option3
I need to get the text "SubSubOption1" when I click on it.

I've seen this functionality in AutoIt Explorer, but I can't make heads or tails of the code.

btw: Thanks for trying.

Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

No. I need to get the text from the treeview item when I click on it. The TreeView text is variable, and I need to get that variable.

So say this is how the treeview looks:

Main
    ->Option
    ->Option2
          ->SubOption1
          ->SubOption2
              ->SubSubOption1
    ->Option3
I need to get the text "SubSubOption1" when I click on it.

I've seen this functionality in AutoIt Explorer, but I can't make heads or tails of the code.

btw: Thanks for trying.

So to be clear, this is not an AutoIt GUI, but rather some other program's GUI?

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
Share on other sites

No, it's AutoIt. But the problem is I cannot define the individual treeitems because they are created from files, and and are not constants.


Coming soon....

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i think I'm on the right track, but I'm unsure of the syntax. Coudl anyone take a look at this:

Case $msg = $GUI_EVENT_PRIMARYDOWN
            $a = GUIGetCursorInfo()
                $rect   = DllStructCreate("long;int;int;int")
                $ctrl_hwnd =                        DLLCall("user32.dll","hwnd","GetDlgItemText","hwnd",GUICtrlGetHandle($TreeView1),"int",$a[4],"str",DllStructGetPtr($rect))
                $l = DllStructGetData($rect,1)
                MsgBox(0,$TreeView1,$l)
Edited by MikelSevrel

Coming soon....

Share this post


Link to post
Share on other sites

Anyone even know if a DLLCall is the right way to go?


Coming soon....

Share this post


Link to post
Share on other sites

You can get rid of this, though it would certainly be a nice function to have.


Coming soon....

Share this post


Link to post
Share on other sites

Well, if you're reading in the information, then you can store the pointers in an array, like so:

Dim $items[$MAX_ITEMS][2]
For $i = 0 To $MAX_ITEMS
    $items[$i][0] = FileReadLine($file);Reading what's put in the treeview
    $items[$i][1] = GUICtrlCreateTreeViewItem($items[$i][0], $parentTree)
Next

While 1
    If GUIGetMsg() == $GUI_EVENT_CLOSE Then
        ExitLoop
    EndIf
    If GUICtrlRead($treeview) <> 0 Then
        For $c = 0 To $MAX_ITEMS
            If GUICtrlRead($treeview) == $items[$c][1] Then
                MsgBox(0, "", "You clicked on " & $items[$c][0])
            EndIf
        Next
    EndIf
WEnd

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

Share this post


Link to post
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
Sign in to follow this  
Followers 0