Jump to content

Help with utilizing control notification messages

Go to solution Solved by spudw2k,

Recommended Posts

I'm struggling to find any examples for this.  I am looking to utilize control notification messages as defined in their respective constants include. 

For example: in the TreeViewConstants.au3 include I see notifications for selection chang(e/ing), expand(ed/ing), etc.

I was thinking it would tie into the usage of WM_NOTIFY, but I don't know I would populate the dllstruct for $tagNMTREEVIEW.  I am also assuming that "Action" would be the portion of the struct where I would identify the notification message?  Can anyone shed some light on this for me?


Link to post
Share on other sites
  • Solution

I don't know what I was doing wrong before, but I was able to piece together some working code from examples. 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>
$item1=GUICtrlCreateTreeViewItem("Root Item 1",$TreeView1)
$item2=GUICtrlCreateTreeViewItem("Root Item 2",$TreeView1)
for $i=1 to 10
    GUICtrlCreateTreeViewItem("Child Item "&$i,$item1 )
    GUICtrlCreateTreeViewItem("Child Item "&$i,$item2 )

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case  $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $IdFrom, $iCode
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $IdFrom = DllStructGetData($tNMHDR, "IdFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $IdFrom
        Case $TreeView1
            Switch $iCode
                Case $TVN_SELCHANGEDW
                    Local $tInfo = DllStructCreate($tagTVITEMEX , $lParam)
                    Local $iState = DllStructGetData($tInfo, "State")
                            $idx = _GUICtrlTreeView_GetSelection($TreeView1)
                            $sTree = _GUICtrlTreeView_GetTree($TreeView1, $idx)
       If $sTree Then ConsoleWrite($sTree & @CRLF)
                    Return 0
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...