Sign in to follow this  
Followers 0
capricorn33

Problem with GUITreeView UDF

5 posts in this topic

Hi

Can anybody help me with a little problem?

I'm trying to get the GUITreeView management UDF running, I'm building this little treevieweditor...

but I can't get the UDF commands to work properly. In the attached example

_GUICtrlTreeViewGetTree doesn't return any pathstring...

It just doesn't work...

(I'm quite convinced is something reaaally simple and stupid mistake I have made - But I just don't seem to be able to solve it on my own....) :whistle:

Running autoit beta 1.1.131 on win 98 SE, with UDF:s in correct include-folder...

Grateful for any help

#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>

dim $inputview 

      $mainwindow = GUICreate("treeview editor",600,300)
      $inputview = GUICtrlCreateInput ( "text", 200, 6 , 380 , 200 , BitOr($ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL))
      $mess = "hi, this is the notes window"
      GUICtrlSetData ( $inputview, StringAddCR($mess))
      
      ;labels, buttons...
      $closebutton = GUICtrlCreateButton ("Close",100,210,70,20)
      
      ;create TREEVIEW-GUI
      $tw = Assign("r0",GUICtrlCreateTreeView ( 6,6,190,200 , _
       BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE))
      $r1 = GUICtrlCreateTreeViewitem ("node1",$r0)
      $r2 = GUICtrlCreateTreeViewitem ("node2",$r0)
      $r3 = GUICtrlCreateTreeViewitem ("node3",$r2)
      $r4 = GUICtrlCreateTreeViewitem ("node4",$r2)
      $r5 = GUICtrlCreateTreeViewitem ("node5",$r3)

      GUISetState () 

; WAITING LOOP

      dim $s, $i, $msg
      
      While 1              
         $msg = GUIGetMsg(1)   ; events in GUI?
         $s = $msg[0] - $r1+1  
         
          Select
               Case $msg[0] = $closebutton Or $msg = $GUI_EVENT_CLOSE
                  ExitLoop    ;terminate
                  
               Case $s >= 0     ;finds activated treviewitem
                  if $msg[0] = eval("r" & $s) then
                     $d = GUICtrlSetData ( $inputview,  "OK, found the right treviewitem; " & $s)    
                     
                     ;THIS IS THE TESTED UDF-command, then.... =======================================
                        $path = _GUICtrlTreeViewGetTree($tw, "/")                        
                        msgbox(0,"testing UDF _GUICtrlTreeViewGetTree","path from " & $tw & " " & $path)
                     ;================================================================================
                  endif

          EndSelect
      WEnd
              
exit

Share this post


Link to post
Share on other sites



1st as of 131 GUIGetMsg in advanced mode doesn't return an array any more

2nd it was buggy for treeview

Suggest getting the latest beta to begin with, as of this minute it is 3.1.1.133


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Suggest getting the latest beta to begin with, as of this minute it is 3.1.1.133

Thanks for replying, gafrost. I just installed the newest beta, but it didn't help.... :whistle:

Any more ideas...?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

My bad, it was the GuiCtrlRead that changed, but try this

#include <GUIConstants.au3>
#include <GuiTreeView.au3>
#include <TreeViewConstants.au3>

Dim $inputview

$mainwindow = GUICreate("treeview editor", 600, 300)
$inputview = GUICtrlCreateInput("text", 200, 6, 380, 200, BitOR($ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL))
$mess = "hi, this is the notes window"
GUICtrlSetData($inputview, StringAddCR($mess))

;labels, buttons...
$closebutton = GUICtrlCreateButton("Close", 100, 210, 70, 20)
Local $r[6]
$r[0] = 5
;create TREEVIEW-GUI
$tw = GUICtrlCreateTreeView(6, 6, 190, 200, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$r[1] = GUICtrlCreateTreeViewItem("node1", $tw)
$r[2] = GUICtrlCreateTreeViewItem("node2", $tw)
$r[3] = GUICtrlCreateTreeViewItem("node3", $r[2])
$r[4] = GUICtrlCreateTreeViewItem("node4", $r[2])
$r[5] = GUICtrlCreateTreeViewItem("node5", $r[3])

GUISetState()

; WAITING LOOP

Dim $s, $i, $msg

While 1
    $msg = GUIGetMsg(1)   ; events in GUI?
    
    Select
        Case $msg[0] = $closebutton Or $msg[0] = $GUI_EVENT_CLOSE
            ExitLoop    ;terminate
        Case Else
            For $x = 1 To $r[0]
                If $msg[0] = $r[$x] Then
                    $d = GUICtrlSetData($inputview, "OK, found the right treviewitem; " & $r[$x])
                    
                    ;THIS IS THE TESTED UDF-command, then.... =======================================
                    $path = _GUICtrlTreeViewGetTree($tw, "/")
                    MsgBox(0, "testing UDF _GUICtrlTreeViewGetTree", "path from " & $tw & " " & $path)
                    ;================================================================================
                EndIf
            Next
            
    EndSelect
WEnd

Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Yeees! Now it's working! Thanks a lot, gafrost.

I must confess that I don't understand WHY it's working better now - but it is!

:whistle::):)

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