Jump to content

Treeview wildcard/catchall


Recommended Posts

Hi Guys,

I'm working on an onevent script with a treeview control which is populated from an .ini

The problem I'm having is because the treeview gets populated manually and I'm using onevent mode, I would need to create a function for each item in the treeview which is a bit of a nuisance. So, I was going to get the selected item once treeview is clicked but the GUICtrlSetOnEvent(-1, "TreeView1Click") doesn't seem to work.

Is there a catchall event for treeviews to do this or will I have to use Assign for each item in the tree and create an event for each one?

Example code:

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 179, 389, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$TreeView1 = GUICtrlCreateTreeView(8, 16, 145, 353)
GUICtrlSetOnEvent(-1, "TreeView1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$treeitems = IniReadSection("testtree.ini","Types")
$treesubitems = IniReadSection("testtree.ini","SiteTypes")
For $i = 1 To $treeitems[0][0]
    $tretype = GUICtrlCreateTreeViewItem($treeitems[$i][0],$TreeView1)
    for $i2 = 1 to $treesubitems[0][0]
        if $treeitems[$i][1] = $treesubitems[$i2][1] or $treeitems[$i][1] = "All" Then
            $siteid = GUICtrlCreateTreeViewItem($treesubitems[$i2][0],$tretype)
        EndIf
    Next
Next


While 1
    Sleep(100)
WEnd

Func Form1Close()
    Exit
EndFunc
Func Form1Maximize()

EndFunc
Func Form1Minimize()

EndFunc
Func Form1Restore()

EndFunc
Func TreeView1Click()
    MsgBox(0,"","Do something")
EndFunc

Example .ini:

[Types]
All=All
Unktype=Type1
Unktype2=Type2
Unktype3=Type3

[Sitetypes]
Site1=Type1
Site2=Type2
Site3=Site3
Site4=Type1
Site5=Type2
Site6=Site3
Site7=Type1
Site8=Type3
Site9=Site1
Site10=Type1
Site11=Type2
Site12=Site3
Site13=Type1
Site14=Type2
Site15=Site3
Site16=Type1
Site17=Type1
Site18=Site3
Site19=Type1
Site20=Type2
Site21=Site3
Site22=Type1
Site23=Type2
Site24=Site3
Site25=Type1
Site26=Type3
Site27=Site3
Site28=Type1
Site29=Type1
Site30=Site3
Site31=Type3
Site32=Type2
Site33=Site3
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...