Jump to content
Sign in to follow this  
ioctl

Checkboxes in a Treeview doesnt work OK

Recommended Posts

First a description of my problem :

I have a treeview with subitems.

Test1

------Programs1

------------------Mspaint.exe

------------------Calc.exe

------------------Notepad.exe

------------------Cmd.exe

------Programs2

------Programs3

Test2

Test3

When i check all programs automatically it works ok! The programs running...

But if i check it manually with my mouse cannot recognize that the GUICtrlCreateTreeViewItem is Checked!

If i use GUICtrlSetState(-1, $GUI_CHECKED) then it works again.

Iam doing something wrong or its a bug of GUI?

(If i use GuiCtrlCreateCheckbox i dont have any problems)

Here is the code to understand better.

Thanks in advance for anyone to help!

#include <GuiConstants.au3>

; GUI

GUICreate("Test -  ATK",530,400,-1,-1,BitOr($WS_MINIMIZEBOX,$WS_GROUP,$WS_CAPTION,$WS_POPUP,$WS_SYSMENU))

GuiSetIcon(@SystemDir & "\mobsync.exe", 0)

;Buttons

$Test = GuiCtrlCreateButton("Test Selected", 415, 210, 100, 20)

$Button_Checkall = GuiCtrlCreateButton("Check All", 415, 260, 100, 20)

$Button_Clearall = GuiCtrlCreateButton("Clear All", 415, 285, 100, 20)

$Settings = GUICtrlCreateButton ("Settings", 415, 235, 100, 20)

$Exit = GUICtrlCreateButton ("Exit",  415, 310, 100, 20)

Dim $Icon[39],$Checkbox[39],$Label[39],$Installs[39]

$Icon[0] = 38

$Checkbox[0] = 38

$Label[0] = 38

$Installs[0] = 38

;INSTALLS

$Installs[1]      = "mspaint.exe"

$Installs[2]    = "calc.exe"

$Installs[3]          = "notepad.exe"

$Installs[4]          = "cmd.exe"

$maingroup = GUICtrlCreateGroup ("Select your mode",5,10,180,195)

$maintree = GUICtrlCreateTreeView (15,30,160,165,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)

$treeItem1 = GuiCtrlCreateTreeViewItem("Test1", $maintree)

$treeItem2 = GuiCtrlCreateTreeViewItem("Test2", $maintree)

$treeItem3 = GuiCtrlCreateTreeViewItem("Test3", $maintree)

$OPEN_PROGRAMS = GuiCtrlCreateTreeViewItem("Programs1", $treeItem1)

$OPEN_WEP64 = GuiCtrlCreateTreeViewItem("Programs2", $treeItem1)

$OPEN_WEP128 = GuiCtrlCreateTreeViewItem("Programs3", $treeItem1)

;EMPTY BOX

$EMPTY_GROUP = GUICtrlCreateGroup ("",198,10,328,195)

$EMPTY_TREE = GUICtrlCreateTreeView (208,30,310,165,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)

;PROGRAMS1

$PROGRAMS_GROUP = GUICtrlCreateGroup ("Programs1",198,10,328,195)

GUICtrlSetState (-1,$GUI_HIDE)

$PROGRAMS_TREE = GUICtrlCreateTreeView (208,30,310,165,BitOr($TVS_HASBUTTONS,$TVS_CHECKBOXES,$TVS_DISABLEDRAGDROP),$WS_EX_CLIENTEDGE)

GUICtrlSetState (-1,$GUI_HIDE)

$Checkbox[1] = GUICtrlCreateTreeViewItem("MsPaint",$PROGRAMS_TREE)

$Checkbox[2] = GUICtrlCreateTreeViewItem ("Calc",$PROGRAMS_TREE)

$Checkbox[3] = GUICtrlCreateTreeViewItem ("Notepad",$PROGRAMS_TREE)

$Checkbox[4] = GUICtrlCreateTreeViewItem ("Command",$PROGRAMS_TREE)

; GUI MESSAGE LOOP

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

 

Case $msg = $GUI_EVENT_CLOSE

        ExitLoop 

 

Case $msg = $Exit

ExitLoop

 

Case $msg = $treeItem1

GUIctrlSetState ($PROGRAMS_GROUP,$GUI_HIDE)

GUIctrlSetState ($PROGRAMS_TREE,$GUI_HIDE)

GUIctrlSetState ($EMPTY_GROUP,$GUI_SHOW)

GUIctrlSetState ($EMPTY_TREE,$GUI_SHOW)

Case $msg = $OPEN_PROGRAMS

GUIctrlSetState ($EMPTY_GROUP,$GUI_HIDE)

GUIctrlSetState ($EMPTY_TREE,$GUI_HIDE)

GUIctrlSetState ($PROGRAMS_GROUP,$GUI_SHOW)

GUIctrlSetState ($PROGRAMS_TREE,$GUI_SHOW)

Case $msg = $treeItem2

GUIctrlSetState ($PROGRAMS_GROUP,$GUI_HIDE)

GUIctrlSetState ($PROGRAMS_TREE,$GUI_HIDE)

GUIctrlSetState ($EMPTY_GROUP,$GUI_SHOW)

GUIctrlSetState ($EMPTY_TREE,$GUI_SHOW)

Case $msg = $treeItem3

GUIctrlSetState ($PROGRAMS_GROUP,$GUI_HIDE)

GUIctrlSetState ($PROGRAMS_TREE,$GUI_HIDE)

GUIctrlSetState ($EMPTY_GROUP,$GUI_SHOW)

GUIctrlSetState ($EMPTY_TREE,$GUI_SHOW)

; CHECK ALL BOXES 

 

Case $msg = $Button_Checkall

GUICtrlSetState($Checkbox[1], $GUI_CHECKED)

GUICtrlSetState($Checkbox[2], $GUI_CHECKED)

GUICtrlSetState($Checkbox[3], $GUI_CHECKED)

GUICtrlSetState($Checkbox[4], $GUI_CHECKED)

; CLEAR ALL BOXES

Case $msg = $Button_Clearall

GUICtrlSetState($Checkbox[1], $GUI_UNCHECKED)

GUICtrlSetState($Checkbox[2], $GUI_UNCHECKED)

GUICtrlSetState($Checkbox[3], $GUI_UNCHECKED)

GUICtrlSetState($Checkbox[4], $GUI_UNCHECKED)

Case $msg = $Test

          for $i = 1 to $CheckBox[0]

              If (GUICtrlRead($CheckBox[$i]) == $GUI_CHECKED) Then RunWait($Installs[$i])

    Next

   

    Case Else

 

EndSelect

WEnd

Exit

Edited by ioctl

Share this post


Link to post
Share on other sites

Bug report is wrong cause it's not a bug.

Replace your line:

If (GUICtrlRead($CheckBox[$i]) == $GUI_CHECKED) Then RunWait($Installs[$i])

with this:

If (BitAnd(GUICtrlRead($CheckBox[$i]),$GUI_CHECKED)) Then RunWait($Installs[$i])

For your info: The last focused item also has the state $GUI_FOCUS so you have to check it only against $GUI_CHECKED with BitAnd()

Regards

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...