Jump to content

TreeView linking


 Share

Recommended Posts

I used the search bar but didn't really find anything, how do I link text in treeview to functions?

For example, the treeview:

Sample 1
  Sample 2
  Sample 3
Sample 4
  Sample 5

And I want sample 3 to be linked to _ExampleFunction, how would I go about doing that?

Link to comment
Share on other sites

Linked how? You want it to launch _ExampleFunction() when it's clicked?

#Include <GuiTreeView.au3>

$clickedItem = _GUICtrlTreeView_HitTestItem($hWnd, $iX, $iY)

$hWnd is the handle to your treeview, $iX is the X position of the mouse cursor, $iY is the y position. You'll need to watch for clicks, for example,

GUIRegisterMsg($WM_LBUTTONDOWN, "SomethingWasClicked")

Then register a function that checks to see what was clicked, then if it was item 3, launch _ExampleFunction().

Func SomethingWasClicked()
$clickedItem = _GUICtrlTreeView_HitTestItem($hWnd, $iX, $iY)
If $clickedItem = $treeItem3 Then
_ExampleFunction()
EndIf
EndFunc

You'll need to work this into your program and fill in the blanks, but that's one way of linking items. There are probably easier methods on the forum. Search for "_GUICtrlTreeView_HitTestItem"in the Examples and GUI help forums. Good luck!

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...