Sign in to follow this  
Followers 0
Wooltown

Corrected TreeView behaviour by Holger

7 posts in this topic

It works fine to checkmark/uncheckmark checkboxes with Spacebar, thank you, but is the intention that the checkboxes should be checkmarked/uncheckmarked by just going up and down using the arrows ? - If so how can I detect in what way the checkbox is being checkmarked/uncheckmarked ? - If made by just using the arrows/spacebar/mouseclick ?

Hopefully you undestand how I mean.

Regards

Sven

Share this post


Link to post
Share on other sites



It works fine to checkmark/uncheckmark checkboxes with Spacebar, thank you, but is the intention that the checkboxes should be checkmarked/uncheckmarked by just going up and down using the arrows ? - If so how can I detect in what way the checkbox is being checkmarked/uncheckmarked ? - If made by just using the arrows/spacebar/mouseclick ?

Hopefully you undestand how I mean.

Regards

Sven

<{POST_SNAPBACK}>

That's does not look to good. I hope Holger will comment.

Share this post


Link to post
Share on other sites

@Wooltown:

Sorry, I couldn't completely understand what you mean. :(

Why is the kind of the checkboxes are checked/unchecked important?

Normally the item will checked/unchecked only if you press space or click on it.

If the check/uncheck with using the arrows then you may have a bug in your script cause I checked the behaviour under Win95/98/NT4/2000 and XP :)

We have only one possibility for returning an event: GuiGetMsg() Or with using GuiCtrlSetOnEvent().

But I see no problem at the moment... :(

So long...

Holger

P.S.: maybe I didn't understand you the right way, if so then please send me your script or the standalone _working_ part of your script which makes the problem :

Share this post


Link to post
Share on other sites

A small misstake when I answeded you, the Code you sent me, I just added a MessageBox, the checkmar/uncheckmark works fine, but when I go up and down using the arrows, it will trigger the Event, and I'm using the event to build an array of what tests to run during the night, so I dont't what AutoIt to react with an event when ust going up and down using the arrow keys.'

Regards

Sven

#include <GUIConstants.au3>

Opt("GUIOnEventMode",1)

GUICreate("test")

$treeview = GUICtrlCreateTreeView (6,6,300,434,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_CHECKBOXES,$TVS_TRACKSELECT ),$WS_EX_CLIENTEDGE )

$item1 = GUICtrlCreateTreeViewItem("Item1",$treeview)

GUICtrlSetOnEvent(-1,"ItemSelection")

$item2 = GUICtrlCreateTreeViewItem("Item2",$treeview)

GUICtrlSetOnEvent(-1,"ItemSelection")

$item3 = GUICtrlCreateTreeViewItem("Item3",$treeview)

GUICtrlSetOnEvent(-1,"ItemSelection")

$item4 = GUICtrlCreateTreeViewItem("Item4",$treeview)

GUICtrlSetOnEvent(-1,"ItemSelection")

$subitem1 = GUICtrlCreateTreeViewItem("SubItem1",$item1)

GUICtrlSetOnEvent(-1,"ItemSelection")

$subitem2 = GUICtrlCreateTreeViewItem("SubItem2",$item1)

GUICtrlSetOnEvent(-1,"ItemSelection")

$status = GUICtrlCreateLabel("0",350,10,50,20)

GUISetOnEvent($GUI_EVENT_CLOSE,"ExitGUI")

GUISetState()

While 1

    Sleep(10)

WEnd

Exit

Func ItemSelection()

    GUICtrlSetData($status,@GUI_CtrlId)

    Msgbox(0,"Event",@GUI_CtrlId,1)

EndFunc

Func ExitGUI()

    Exit

EndFunc

Share this post


Link to post
Share on other sites

Is the above suggestion about when to trigger an Event OK to implement ?

Regards

Sven

Share this post


Link to post
Share on other sites

I don't understand it completely.

But what about just checking the state of the item and then add it i.e. to an array and then later check out this array.

Or maybe something like:

#include <GUIConstants.au3>
Opt("GUIOnEventMode",1)

GUICreate("test")
$treeview = GUICtrlCreateTreeView (6,6,300,434,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_CHECKBOXES,$TVS_TRACKSELECT ),$WS_EX_CLIENTEDGE )
$item1 = GUICtrlCreateTreeViewItem("Item1",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$item2 = GUICtrlCreateTreeViewItem("Item2",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$item3 = GUICtrlCreateTreeViewItem("Item3",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$item4 = GUICtrlCreateTreeViewItem("Item4",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$subitem1 = GUICtrlCreateTreeViewItem("SubItem1",$item1)
GUICtrlSetOnEvent(-1,"ItemSelection")
$subitem2 = GUICtrlCreateTreeViewItem("SubItem2",$item1)
GUICtrlSetOnEvent(-1,"ItemSelection")
$status = GUICtrlCreateLabel("0",350,10,50,20)

GUISetOnEvent($GUI_EVENT_CLOSE,"ExitGUI")

GUISetState()

While 1
    Sleep(10)
WEnd
Exit
Func ItemSelection()
    GUICtrlSetData($status,@GUI_CtrlId)
    If BitAnd($GUI_CHECKED,GUICtrlRead(@GUI_CtrlId)) Then Msgbox(0,"Event",@GUI_CtrlId,1)
EndFunc

Func ExitGUI()
    Exit
EndFunc

Regards

Holger

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@Larry: yeah, thats by design:

For instance: go to your "ControlPanel", choose "Add/Remove Programs" then "Add/Remove Windows components" (have XP in German, so I don't know the right descriptions) and then just move with the arrow keys up and down.

Do you see a changing description?

So I absolutely see no problem here but a scripting thing.

So why not just selecting all things first and then maybe with a "Next"-button read these information out...

So long...

Holger

like i.e.:

#include <GUIConstants.au3>
Opt("GUIOnEventMode",1)

GUICreate("test")
$treeview = GUICtrlCreateTreeView (6,6,300,334,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS,$TVS_CHECKBOXES,$TVS_TRACKSELECT ),$WS_EX_CLIENTEDGE )
$item1 = GUICtrlCreateTreeViewItem("Item1",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$startitem = $item1
$item2 = GUICtrlCreateTreeViewItem("Item2",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$item3 = GUICtrlCreateTreeViewItem("Item3",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$item4 = GUICtrlCreateTreeViewItem("Item4",$treeview)
GUICtrlSetOnEvent(-1,"ItemSelection")
$subitem1 = GUICtrlCreateTreeViewItem("SubItem1",$item1)
GUICtrlSetOnEvent(-1,"ItemSelection")
$subitem2 = GUICtrlCreateTreeViewItem("SubItem2",$item1)
GUICtrlSetOnEvent(-1,"ItemSelection")
$enditem = $subitem2
$status = GUICtrlCreateLabel("0",350,10,50,20)

$next = GUICtrlCreateButton("Next",70,350,70,20)
GUICtrlSetOnEvent(-1,"NextStep")

GUISetOnEvent($GUI_EVENT_CLOSE,"ExitGUI")
GUISetState()

While 1
    Sleep(10)
WEnd
Exit

Func ItemSelection()
    GUICtrlSetData($status,@GUI_CtrlId)
EndFunc

Func ExitGUI()
    Exit
EndFunc

Func NextStep()
    $itemtext = ""
    For $i = $startitem To $enditem
        If BitAnd(GUICtrlRead($i),$GUI_CHECKED) Then
            $iteminfo = GUICtrlRead($i,1)
            If IsArray($iteminfo) Then $itemtext = $itemtext & $iteminfo[0] & @LF
        EndIf
    Next
    If $itemtext <> "" Then Msgbox(0,"Items checked",$itemtext)
EndFunc
Edited by Holger

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