Jump to content

Trouble with checkboxes


MadBoy
 Share

Recommended Posts

I've got this code that you choose Radio box and after that TreeView with checkboxes apear. Now when i select one by one i want them to 'show' some label in other part of the screen (example below). And the code below does that. But it always show it in place i preset it to do so. So if i check only checkbox2 program will use Label2 instead of Label1 which is better is the first label. So what i want to achieve is some kind of way when i select any check box is uses first label1 .. when i select next checkbox it uses next free label. Of course when i uncheck them it disapears and the field can be used by another checkbox. It's a bit complicated but hope you guys know what i mean. Any help with this will be appreciated as i tried to fight it for a while now, especially that later on i will add option that if button "install" is pressed and any of the checkboxes are set it will do "needed" commands. Thanks

Case $msg = $check1 OR $msg = $check2 OR $msg = $check3 OR $msg = $check4 OR $msg = $check5 OR $msg = $check6 OR $msg = $check7 OR $msg = $check8 OR $msg = $check9
         If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED Then
             GUICtrlSetData( $Label1, "Dupe1", $GUI_SHOW)
         EndIf
         If BitAnd(GUICtrlRead($check1),$GUI_UNCHECKED) = $GUI_UNCHECKED Then
             GUICtrlSetData( $Label1, "")
         EndIf
         If BitAnd(GUICtrlRead($check2),$GUI_CHECKED) = $GUI_CHECKED Then
             GUICtrlSetData( $Label2, "Dupe2", $GUI_SHOW)
         EndIf
         If BitAnd(GUICtrlRead($check2),$GUI_UNCHECKED) = $GUI_UNCHECKED Then
             GUICtrlSetData( $Label2, "")
         EndIf

Example of labels:

$Label2= GUICtrlCreateLabel ("", $position1, $position2 + 15, 150, 20)

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

maybe

Case $msg = $check1 
        If BitAnd(GUICtrlRead($check1),$GUI_CHECKED) = $GUI_CHECKED Then
             GUICtrlSetData( $Label1, "Dupe1", $GUI_SHOW)
         Else
             GUICtrlSetData( $Label1, "")
         EndIf

do this for each checkbox

8)

NEWHeader1.png

Link to comment
Share on other sites

Well that's the problem. If i do that for every checkbox it will always use "Label1" so if CHECK1 is GUI_CHECKED and CHECK2 is GUI_CHECKED then Label1 will be replaced by text from CHECK2. And what i want is to have ability to check like 5 boxes and each check box should use next Label .. like check1 - label1, check2 - label2, check3 - label3 but if check2 isn't checked and check 3 is then check3 will use label2 (the last free label). Damn that's a lot of check words ;p

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

To explain it more:

[x] CheckBox 1

[x] CheckBox 2

[x] CheckBox 3

Each time i select/deselect Checkbox some TEXT apears/deapears on other part of the screen. If all 3 checkboxes are checked then screen would look like:

LABEL1

LABEL2

LABEL3

If

[x] CheckBox 1

[ ] CheckBox 2

[x] CheckBox 3

Screen would look like

LABEL1

LABEL3 (in the place where LABEL2 should be)

If

[ ] CheckBox 1

[ ] CheckBox 2

[x] CheckBox 3

Screen:

LABEL3 (in the place where LABEL1 should be)

Hope that explains it.

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

heres an effort

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

Dim $Checkbox_[6], $Label_[6], $Chck_num = 5, $data

;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("MyGUI", 442, 316,(@DesktopWidth-442)/2, (@DesktopHeight-316)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Checkbox_[1] = GuiCtrlCreateCheckbox("Checkbox1", 20, 20, 100, 20)
$Checkbox_[2] = GuiCtrlCreateCheckbox("Checkbox2", 20, 70, 100, 30)
$Checkbox_[3] = GuiCtrlCreateCheckbox("Checkbox3", 20, 130, 100, 20)
$Checkbox_[4] = GuiCtrlCreateCheckbox("Checkbox4", 20, 190, 100, 30)
$Checkbox_[5] = GuiCtrlCreateCheckbox("Checkbox5", 20, 260, 100, 20)
$Label_[1] = GuiCtrlCreateLabel("", 160, 30, 220, 20)
$Label_[2] = GuiCtrlCreateLabel("", 160, 80, 220, 20)
$Label_[3] = GuiCtrlCreateLabel("", 160, 130, 220, 20)
$Label_[4] = GuiCtrlCreateLabel("", 160, 200, 220, 20)
$Label_[5] = GuiCtrlCreateLabel("", 160, 260, 220, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
    
    For $x = 1 To $Chck_num
        If $msg = $Checkbox_[$x] Then
            If BitAnd(GUICtrlRead($Checkbox_[$x]),$GUI_CHECKED) = $GUI_CHECKED Then
                If $x =1 Then $data = "Dupe1"
                If $x =2 Then $data = "Dupe2"
                If $x =3 Then $data = "Dupe3"
                If $x =4 Then $data = "Dupe4"
                If $x =5 Then $data = "Dupe5"
                Check_Labels($data)
            EndIf
        EndIf
    Next
WEnd
Exit
#endregion --- GuiBuilder generated code End ---


Func Check_Labels($data)
    For $i = 1 To $Chck_num
        If GUICtrlRead($Label_[$i]) = "" Then
            GUICtrlSetData($Label_[$i], $data)
            Return
        EndIf
    Next
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

Yeap, that's basically it :o Just now would be nice if the labels would dissapear when unchecked :geek: I'm too tired to understand it today. Gotta go home.Maybe will have more brain power tomorow. Tnx for help. If you know what can be done to achieve this. lemme know.

Edited by MadBoy

My little company: Evotec (PL version: Evotec)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...