Jump to content
Sign in to follow this  
Pottery

TreeView linking

Recommended Posts

Pottery

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?

Share this post


Link to post
Share on other sites
JRowe

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!

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  

×