Sign in to follow this  
Followers 0
spudw2k

Help with utilizing control notification messages

3 posts in this topic

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?

 

Share this post


Link to post
Share on other sites

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>
GUICreate('treeview',200,400)
$TreeView1=GUICtrlCreateTreeView(0,0,200,400)
$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 )
Next
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case  $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

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
        EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

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