Sign in to follow this  
Followers 0
paullab

Treeview Events with Opt("GUIOnEventMode", 1)

4 posts in this topic

#1 ·  Posted (edited)

I am tearing my hair out, I can't believe I am stuck with this!!!. I have trawled the forums and example code but can not find any GUIOnEventMode help.

I am using Opt("GUIOnEventMode", 1) but can not seem to detect events on the treeview

In the example events are detected on the tab but not on the treeview or any of it's nodes.

I have tried WM_Notify, Click, DBLCLICK and a host of others to no avail

If anyone has any ideas before I redo it all with Opt("GUIOnEventMode", 0) I would really appreciate it.

Thanks in advance

#NoTrayIcon
#include <GUIConstants.au3>
#Include <GuiTreeView.au3>

Global Const $DebugIt = 1

Opt("GUIOnEventMode", 1)

Global Const $WM_LBUTTONDBLCLK = 0x0203;
#Region Globals
Global Const $s_Title   = 'Treeviewtest'
Global Const $s_Version = '0.1'

Global $ItemMatrix [1][1]

; GUI
$h_Gui = GuiCreate($s_Title & " " & $s_Version, 704, 488, 290,160 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))


$tab=GUICtrlCreateTab (2,2, 700,460)
$tab_schema=GUICtrlCreateTabitem ("Tab1")
$tree_schema    = GUICtrlCreateTreeView(20,30,550,230)
$tab_query=GUICtrlCreateTabitem ("Tab2")
GUICtrlSetState($tab_query,$GUI_DISABLE)
GUICtrlCreateTabitem (""); end of Tab control

buildtree()

GUIRegisterMsg($WM_LBUTTONDBLCLK, "MY_WM_NOTIFY")
GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")
GUISetState (@SW_SHOW,$h_Gui)   

While 1
    sleep(100)
WEnd

Func xxx()
MsgBox(0,"Error!","You should never get here")
EndFunc

Func buildtree()            
    $treeVal = "Root Node"
    ReDim $ItemMatrix [3][5]
    $ItemMatrix [0][0] = GUICtrlCreateTreeViewItem($treeVal,$tree_schema); root
    $ItemMatrix [0][1] = GUICtrlCreateTreeViewItem("Item 1" , $ItemMatrix [0][0])
    $ItemMatrix [0][2] = GUICtrlCreateTreeViewItem("Item 1-1" , $ItemMatrix [0][1])
    $ItemMatrix [0][3] = GUICtrlCreateTreeViewItem("Item 1-2" , $ItemMatrix [0][1])
    $ItemMatrix [1][1] = GUICtrlCreateTreeViewItem("Item 2" , $ItemMatrix [0][0])
    $ItemMatrix [1][2] = GUICtrlCreateTreeViewItem("Item 2-1" , $ItemMatrix [1][1])
    $ItemMatrix [1][3] = GUICtrlCreateTreeViewItem("Item 2-2" , $ItemMatrix [1][1])
    $ItemMatrix [1][4] = GUICtrlCreateTreeViewItem("Item 2-3" , $ItemMatrix [1][1])         
    $ItemMatrix [2][1] = GUICtrlCreateTreeViewItem("Item 3" , $ItemMatrix [0][0])
    $ItemMatrix [2][2] = GUICtrlCreateTreeViewItem("Item 3-1" , $ItemMatrix [2][1])
    $ItemMatrix [2][3] = GUICtrlCreateTreeViewItem("Item 3-2" , $ItemMatrix [2][1])

EndFunc

Func OnExit ()
    GUIDelete()
    Exit
EndFunc

Func MY_WM_NOTIFY($hWnd, $msg, $wParam, $lParam)
    $nNotifyCode    = BitShift($wParam, 16)
    $nID            = BitAnd($wParam, 0x0000FFFF)
    Local $hCtrl = $lParam
;~  If $nNotifyCode <> 0 Then
        If $DebugIt Then 
            ConsoleWrite("-->$Code ID Ctrl " &$nNotifyCode & "-" & $nID & "-" & $hCtrl & @LF) 
        EndIf
;~  EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Edited by paullab

Wallpaper Rotatorwith overlay, Loop through a folder of wallpaper & another of overlay, then create a combined image and set it as the wallpaperE-Mail passthru, Send any file, even executables via e-mail as plain text. The recipient can then later re-construct them.Slideshow widget, A slideshow widget similar to the Vista onePredictive typing using the Numpad, Predictive typing using the numpad of a keyboar similar to that on a mobile phone (the key is the .t16 file).PSTools Front End, For Remote Admin. Just makes life a lot easier (Demonstrates executing external programs and passing parameters, tabbed form Handling STDIN/STDERR)FTP Helper application Up and Download files from an FTP server demonstrates this and Tooltray TipsShow a Map of your Post-codes/Zip Codes, Uses the Clipboard, Hotkeys, the system tray (incl. menus)Disc/CD/DVD Catalogue, Ideal for all those Covermount Discs (Demonstrates Array handling, executing DOS programs, handling STDIN/STDOUT recursive directory reads, file searching.)YAST , Yet another Stopwatch/Timer (Uses a hotkey, Copies to clipboard, handles multiple events and stays on top)Keyboard Status Indicator , Indicates status of NumLock, Caps Lock and Scroll Lock Keys, demonstrates API calling & System tray Icon Toggling

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I've not used the treeview control before.. but I gave it a shot.

Sorry I sorta changed the way you build the tree..

#NoTrayIcon
#include <GUIConstants.au3>
#Include <GuiTreeView.au3>

Opt("GUIOnEventMode", 1)

#Region Globals
Global Const $s_Title   = 'Treeviewtest'
Global Const $s_Version = '0.1'
Global $ItemMatrix[12], $spn

; GUI
$h_Gui = GuiCreate($s_Title & " " & $s_Version, 704, 488, 290,160 ,BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$tab=GUICtrlCreateTab (2,2, 700,460)
$tab_schema=GUICtrlCreateTabitem ("Tab1")
$ItemMatrix[0] = GUICtrlCreateTreeView(20,30,550,230)
$tab_query=GUICtrlCreateTabitem ("Tab2")
GUICtrlSetState($tab_query,$GUI_DISABLE)
GUICtrlCreateTabitem (""); end of Tab control

buildtree()

GUISetOnEvent($GUI_EVENT_CLOSE,"OnExit")
GUISetState (@SW_SHOW,$h_Gui)

While 1
    sleep(100)
WEnd

Func buildtree()
    $spn = StringSplit('Root Node|Item 1|Item 1-1|Item 1-2|Item 2|Item 2-1|Item 2-2|Item 2-3|Item 3|Item 3-1|Item 3-2', '|')
    Local $a = 0
    For $i = 1 To 11
        $ItemMatrix[$i] = GUICtrlCreateTreeViewItem($spn[$i], $ItemMatrix[$a])
        GUICtrlSetOnEvent(-1, "WhatFunction")
        If $i = 1 Or $i = 4 Or $i = 8 Then $a = 1
        If $i = 2 Or $i = 5 Or $i = 9 Then $a = $i
    Next
EndFunc

Func WhatFunction()
    For $s = 1 To 11
        If @GUI_CtrlId = $ItemMatrix[$s] Then MsgBox(0,'', 'Ctrl Text = ' & $spn[$s] & @LF & 'Ctrl ID = ' & $ItemMatrix[$s])
    Next
EndFunc

Func OnExit ()
    Exit
EndFunc

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

It's Official, I'm Blonde!

I forgot that each treeview item is a control in it's own right.

Thanks for your time both of you


Wallpaper Rotatorwith overlay, Loop through a folder of wallpaper & another of overlay, then create a combined image and set it as the wallpaperE-Mail passthru, Send any file, even executables via e-mail as plain text. The recipient can then later re-construct them.Slideshow widget, A slideshow widget similar to the Vista onePredictive typing using the Numpad, Predictive typing using the numpad of a keyboar similar to that on a mobile phone (the key is the .t16 file).PSTools Front End, For Remote Admin. Just makes life a lot easier (Demonstrates executing external programs and passing parameters, tabbed form Handling STDIN/STDERR)FTP Helper application Up and Download files from an FTP server demonstrates this and Tooltray TipsShow a Map of your Post-codes/Zip Codes, Uses the Clipboard, Hotkeys, the system tray (incl. menus)Disc/CD/DVD Catalogue, Ideal for all those Covermount Discs (Demonstrates Array handling, executing DOS programs, handling STDIN/STDOUT recursive directory reads, file searching.)YAST , Yet another Stopwatch/Timer (Uses a hotkey, Copies to clipboard, handles multiple events and stays on top)Keyboard Status Indicator , Indicates status of NumLock, Caps Lock and Scroll Lock Keys, demonstrates API calling & System tray Icon Toggling

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