Sign in to follow this  
Followers 0
joshiieeii

Detect Checked State Within Multiple Tabs

3 posts in this topic

Ok, I have a basic GUI with 4 tabs. Within those 4 tabs are numerous checkboxes. I am trying to figure out how I would:

1) Disable the checking of anymore checkboxes upon clicking a button

2) Go through each tab and detect the checked state

Ultimately, I plan on doing some checking to see if certain things are checked so that other things are added by default. Then write the results of the checked items to another ini file.

Here is a sample of my code:

#include <GUIConstants.au3>

Dim $PCname = "Test"
Dim $font="Arial"
Dim $shareletter = "V:"
Dim $sharepath = "\\share\folder"


GUICreate ("Select Applications to Install")
    
    GUISetBkColor(0x00E0FFFF)
    GUISetFont(9, 300)
    GUICtrlCreateLabel ( "PC Name: ", 10, 375, 60, 15)
    $PCnameinput = GUICtrlCreateInput ( $PCName, 70, 370, 200, 20)
    GUIctrlSetState ($PCnameinput, $GUI_DISABLE)
    $tab=GUICtrlCreateTab (10,10,380,350)
    $tab0=GUICtrlCreateTabitem ("Configuration")
    $left = 30
    $top = 120
    GUICtrlCreateLabel ( "Select machine type: ", 15, 45, 120, 20)
    $PCDesktop = GUICtrlCreateRadio ( "Desktop", 140, 43, 80, 20)
    $PCLaptop = GUICtrlCreateRadio ( "Laptop", 220, 43, 80, 20)
    GUICtrlCreateGroup ("Standard Applications", 20, 100, 360, 250)
    $CreatePCappProfile = GUICtrlCreateButton ( "&Create PC Profile", 275, 365, 115, 30)
    $tab0var = IniReadSectionNames ($shareletter & "\config\Std_Applications.ini")
    If @error Then 
            MsgBox(4096, "", "Error occurred, not able to find " & $shareletter & "\config\Std_Applications.ini")
        Else
    For $i = 1 To $tab0var[0]
                GUICtrlCreateCheckbox ( $tab0var[$i], $left, $top, 150, 15)
            $top = $top + 20
            If $top > 320 Then
                $left = 200
                $top = 120
            EndIf
            Next
            
            
    EndIf
    
    ;$stdApps = 
    

    $tab1=GUICtrlCreateTabitem ("Engineer Apps")
            $left = 15
            $top = 40
                $tab1var = IniReadSectionNames($shareletter & "\config\Eng_Applications.ini")
            If @error Then 
            MsgBox(4096, "", "Error occurred, not able to find " & $shareletter & "\config\Eng_Applications.ini")
            Else
            For $i = 1 To $tab1var[0]
                GUICtrlCreateCheckbox ( $tab1var[$i], $left, $top, 150, 15)
            $top = $top + 20
            If $top > 340 Then
                $left = 200
                $top = 40
            EndIf
            Next
            EndIf
    $tab2=GUICtrlCreateTabitem ("Dev Apps")
            $left = 15
            $top = 40
                $tab2var = IniReadSectionNames($shareletter & "\config\Dev_Applications.ini")
            If @error Then 
            MsgBox(4096, "", "Error occurred, not able to find " & $shareletter & "\config\Dev_Applications.ini")
            Else
            For $i = 1 To $tab2var[0]
                GUICtrlCreateCheckbox ( $tab2var[$i], $left, $top, 150, 15)
            $top = $top + 20
            If $top > 340 Then
                $left = 200
                $top = 40
            EndIf
            Next
            EndIf
    $tab3=GUICtrlCreateTabitem ("Other Apps")
            $left = 15
            $top = 40
                $tab3var = IniReadSectionNames($shareletter & "\config\Other_Applications.ini")
            If @error Then 
            MsgBox(4096, "", "Error occurred, not able to find " & $shareletter & "\config\Other_Applications.ini")
            Else
            For $i = 1 To $tab3var[0]
                GUICtrlCreateCheckbox ( $tab3var[$i], $left, $top, 150, 15)
            $top = $top + 20
            If $top > 340 Then
                $left = 200
                $top = 40
            EndIf
            Next
            EndIf

    
    GUISetState ()
    
    ; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $CreatePCappProfile
            WriteAppsIni ()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop

    EndSelect
Wend

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

To detect a check use an If statement like so:

If If GUICtrlRead($checkbox) = $GUI_CHECKED Then ; add what you want to happen here

For disabling check boxes, look up the $BS_3STATE style (Not fully sure about this one)

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Thanks Bala

I guess I need help with giving the checkboxes a variable so I have something to actually check, how would I give the checkboxes variables based on $i??

So what I am trying to do is get a variable like this $tab0chk1, $tab0chk2, ect...

$tab0var = IniReadSectionNames ($shareletter & "\config\Std_Applications.ini")
    If @error Then 
            MsgBox(4096, "", "Error occurred, not able to find " & $shareletter & "\config\Std_Applications.ini")
        Else
            
    For $i = 1 To $tab0var[0]       
        $tab0chk($i)  = GUICtrlCreateCheckbox ( $tab0var[$i], $left, $top, 150, 15) ;Trying to give a variable relating to $i
            $top = $top + 20
            If $top > 320 Then
                $left = 200
                $top = 120
            
            EndIf
            Next
            
            
    EndIf

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