Jump to content
Sign in to follow this  
Jon

Treeview control

Recommended Posts

At first sight it works.

However, remark.

Helpful treeview is small file system with it's special operations (like MkDir, RemoveDir, CreateDir and so on). Every item has path, name and maybe icon, which have to change by name and by view on screen.

The last behaviour is addition to fs operation.

Currently there are simple tasks with treeview:

1. How can you test whether some item exists in tree?

ie #1/#10/#20

It can be done by "Select" operation with result returned.

$State = ControlTreeView ( "Some Tree", "", "SysTreeView321", "Select", "#1/#10/#20")

if $State = 1 - item exists, otherwise - 0

But "Select" doesn't support numeric indexing

2. How can you move selected item to user in view?

I see that "Select" can't open and move tree. Maybe it doesn't work at all.

3. How can you set item content/path?

Thanx


The point of world view

Share this post


Link to post
Share on other sites

Beta released.

I did first tests and here are my notes/propositions:

Modify commands:

Expand,Collapse: new optional param: recurse (default=0)

New commands:

GetItemCount - parameter: item, default = #0 - recursive child count

GetLevel - parameter: item

GetIndex - parameter: item - return #2 for third item in its last level

GetNext - parameter: item (sets @error if not found)

GetNextChild - parameter: item (sets @error if not found)

GetPrev - parameter: item (sets @error if not found)

GetPrevChild - parameter: item (sets @error if not found)

GetParent - parameter: item (sets @error if not found)

HasChildren - parameter: item

IsExpanded - parameter: item

IsVisible - parameter: item

IsBold - parameter: item

GetImageIndex - parameter: item

Find - the same as Select but only return item and not select it (sets @error if not found)

- to be able check existence without selecting

FindEx - Find based on substring (sets @error if not found)

New commands (less priority):

SetText - parameter: item

SetBold - parameter: item

SetImageIndex - parameter: item

Here are my examples for testing:

example 1 - here I discovered ControlTreeView should return @error or @extended in case "item is not found" in commands like GetSelected or Select

#include <GUIConstants.au3>

$gui = GUICreate("ControlTreeview test", 212, 212)
$treeview = GUICtrlCreateTreeView (6,6,200,160,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_CHECKBOXES),$WS_EX_CLIENTEDGE)
$h_tree = ControlGetHandle("", "", $treeview)

$root = GUICtrlCreateTreeViewitem ("Root",$treeview)
$item1 = GUICtrlCreateTreeViewitem ("Item 1",$root)
$item2 = GUICtrlCreateTreeViewitem ("Item 2",$root)
$item3 = GUICtrlCreateTreeViewitem ("Item 3",$root)
$item4 = GUICtrlCreateTreeViewitem ("Item 4",$root)
$item41 = GUICtrlCreateTreeViewitem ("Item 41",$item4)
$item42 = GUICtrlCreateTreeViewitem ("Item 42",$item4)
$item5 = GUICtrlCreateTreeViewitem ("Item 5",$root)

;~ ControlTreeView ( $gui, "", $h_tree, "Select", "Root" )
ControlTreeView ( $gui, "", $h_tree, "Expand", "Root" )
ControlTreeView ( $gui, "", $h_tree, "Check", "Root|Item 2")
ControlTreeView ( $gui, "", $h_tree, "Check", "Root|Item 5" )

$show = GUICtrlCreateButton("Show", 70, 180, 70, 20)

GUISetState ()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $show
            Show()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
Exit

Func Show()
;~     ControlTreeView ( $gui, "", $h_tree, "Expand", "Root|Item 4" )
    $result =  ""
    $item = ControlTreeView ( $gui, "", $h_tree, "GetSelected") ;,1)
;~     $result &=  "@error: " & @TAB & @error & @CRLF
    $result &=  "Selected: " & @TAB & $item & @CRLF
    $item = ControlTreeView ( $gui, "", $h_tree, "GetSelected",1)
    $result &=  "Selected(1): " & @TAB &  $item & @CRLF
    $tmp = ControlTreeView ( $gui, "", $h_tree, "GetText", $item )
    $result &=  "@error: " & @TAB & @error & @CRLF
    $result &=  "GetText: " & @TAB & @TAB & $tmp & @CRLF
    $tmp = ControlTreeView ( $gui, "", $h_tree, "IsChecked", $item )
    $result &=  "IsChecked: " & @TAB &  $tmp
    MsgBox(0,'Result', $result)
EndFuncoÝ÷ ÙìZ^Ú«z+)®h±çpk+ha® häëyåb{"¶ÞÀg­5ìmüg­5ìm
¥uÊ&©Ý±«­¢+Ø¥¹±Õ±ÐíU%
½¹ÍѹÑ̹ÔÌÐì((ÀÌØíÕ¤ôU%
ÉÑ ÅÕ½Ðí
½¹Ñɽ±QÉÙ¥ÜÑÍÐÅÕ½Ðì°ÈÄÈ°ÈÄȤ(ÀÌØíÑÉÙ¥ÜôU%
Ñɱ
ÉÑQÉY¥Ü ذذÈÀÀ°ÄØÀ°   ¥Ñ=H ÀÌØíQYM}!M   UQQ=9L°ÀÌØíQYM}!M1%9L°ÀÌØíQYM}1%9MQI==P°ÀÌØíQYM}
!
-   =aL¤°ÀÌØí]M}a}
1%9Q¤(ÀÌØí¡}ÑÉô
½¹Ñɽ±Ñ!¹± ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÀÌØíÑÉ٥ܤ((ÀÌØíɽ½ÐôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½ÐíI½½ÐÅÕ½Ðì°ÀÌØíÑÉ٥ܤ(ÀÌØí¥Ñ´ÄôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÄÅÕ½Ðì°ÀÌØíɽ½Ð¤(ÀÌØí¥Ñ´ÈôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÈÅÕ½Ðì°ÀÌØíɽ½Ð¤(ÀÌØí¥Ñ´ÌôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÌÅÕ½Ðì°ÀÌØíɽ½Ð¤(ÀÌØí¥Ñ´ÐôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÐÅÕ½Ðì°ÀÌØíɽ½Ð¤(ÀÌØí¥Ñ´ÐÄôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÐÄÅÕ½Ðì°ÀÌØí¥Ñ´Ð¤(ÀÌØí¥Ñ´ÐÈôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÐÈÅÕ½Ðì°ÀÌØí¥Ñ´Ð¤(ÀÌØí¥Ñ´ÔôU%
Ñɱ
ÉÑQÉY¥Ý%Ñ´ ÅÕ½Ðí%Ñ´ÔÅÕ½Ðì°ÀÌØíɽ½Ð¤((íø
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½ÐíM±ÐÅÕ½Ðì°ÅÕ½ÐíI½½ÐÅÕ½Ðì¤(
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½ÐíáÁ¹ÅÕ½Ðì°ÅÕ½ÐíI½½ÐÅÕ½Ðì¤(
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½Ðí
¡¬ÅÕ½Ðì°ÅÕ½ÐíI½½Ññ%Ñ´ÈÅÕ½Ðì¤(
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½Ðí
¡¬ÅÕ½Ðì°ÅÕ½ÐíI½½Ññ%Ñ´ÔÅÕ½Ðì¤((ÀÌØíÍ¡½ÜôU%
Ñɱ
ÉÑ    ÕÑѽ¸ ÅÕ½ÐíM¡½ÜÅÕ½Ðì°ÜÀ°ÄàÀ°ÜÀ°ÈÀ¤((U%MÑMÑÑ ¤(]¡¥±Ä(ÀÌØíµÍôU%Ñ5Í ¤(M±Ð(
ÍÀÌØíµÍôÀÌØíÍ¡½Ü(M¡½Ü ¤(
ÍÀÌØíµÍôÀÌØíU%}Y9Q}
1=M(á¥Ñ1½½À(¹M±Ð(]¹(á¥Ð((Õ¹M¡½Ü ¤(ÀÌØí¥Ñ´ôÅÕ½ÐìÀÅÕ½Ðììɽ½Ð(Ñ%ѵ%¹¼ ÀÌØí¥Ñ´¤((ÀÌØí¥Ñ´ô
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½ÐíÑ9áÑ
¡¥±ÅÕ½Ðì°ÀÌØí¥Ñ´¤(%ÉɽÈQ¡¸IÑÕɸ((]¡¥±Ä(Ñ%ѵ%¹¼ ÀÌØí¥Ñ´¤(ÀÌØí¥Ñ´ô
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½ÐíÑ9áÐÅÕ½Ðì°ÀÌØí¥Ñ´¤(%ÉɽÈQ¡¸á¥Ñ1½½À(]¹(¹Õ¹ìôôÐíM¡½Ü((Õ¹Ñ%ѵ%¹¼ ÀÌØí¥Ñ´¤(ÀÌØí¥Ñµ}ÑáÐô
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½ÐíÑQáÐÅÕ½Ðì°ÀÌØí¥Ñ´¤(ÀÌØí¡­ô
½¹Ñɽ±QÉY¥Ü ÀÌØíÕ¤°ÅÕ½ÐìÅÕ½Ðì°ÀÌØí¡}ÑÉ°ÅÕ½Ðí%Í
¡­ÅÕ½Ðì°ÀÌØí¥Ñ´¤((%ÀÌØí¡­ôÄQ¡¸(ÀÌØí¡­ôÅÕ½Ðí¡­ÅÕ½Ðì(±Í(ÀÌØí¡­ôÅÕ½ÐíÕ¹¡­ÅÕ½Ðì(¹%((
½¹Í½±]É¥Ñ ÀÌØí¥Ñµ}ÑáеÀìQµÀìÀÌØí¡­µÀì
I1¤(¹Õ¹ìôôÐíÑ%ѵ%¹
Edited by Zedna

Share this post


Link to post
Share on other sites

Internally within a C function, yes. Exposed via the variant type so you can do things in AutoIt with it, no.

No. You are using an integer. On 32 bit machines integers and pointers (HTREENODE) are the same. On 64bit machines they are not. Any code that assumes you can store pointers in a integer is broken - simple as that :) This is why none of the DllCall and DllStruct code works in the x64 version of AutoIt - because it is all based on the concept that you can mess around with handles and ints.

Is-it plan to implement a function that's allow to control an ownerdraw listbox ?

Share this post


Link to post
Share on other sites

Correct. <_<

The only true pointer type that can be used at the moment is a window handle (hWnd). These are stored properly on both the 32 and 64bit versions. I may try and change the window handle type into a generic pointer type which may help many of these problems, but that's a project in itself.

I've currently got a limited version of DllCall working on x64 and I've implemented a generic pointer type. Tonight I'm going try and find all the places in DllCall/DllStruct where a 32bit integer was used to hold a pointer (broken on x64) and make it use a native pointer instead. I'm not sure how much stuff I can avoid breaking while I do it. At the very least any scripts/includes that assumed a pointer was 32bits will need fixing - I'll implement some sort of sizeof(ptr) so a script can tell how big pointers are.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...