Jump to content
Sign in to follow this  
MistakenSanity

Dropdown Menu to check check boxes.

Recommended Posts

MistakenSanity

I have been trying to figure this out for some time now and haven't found much help in the forums.

I have a script that uses checkboxes do complete a list of tasks. The list has grown so big that it becomes a pain to check or uncheck tons of boxes depending on what you are doing. I want to add a drop down with "profiles" you can select and depending on what profile you select a different selection of boxes will be checked.

I tried using an if statement but the gui wasnt refreshing to effect the change to the drop down. Below is a modified version of the script so you can see what I am trying to do. If anyone could help or point me in the right direction I would greatly appreciate it!!!!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>






#Region ### START Koda GUI section ### Form=D:\Frank's Documents\Auto-It Scripts Archive\Scripts in Devlopment\Form1.kxf



$Form1 = GUICreate("Window Title", 327, 530, 193, 125)
    ;_GUIScrollBars_Generate($Form1,0,700)



    
    
    $option1 = "Config 1"
    $option2 = "Config 2"
    $option3 = "Config 3"
    $DropDown = GuiCtrlCreateCombo($Option1, 25, 10, 280, 20)
        GUICtrlSetData(-1, $option2)
        GUICtrlSetData(-1, $option3)
    
    

$Chk_Number1 = GUICtrlCreateCheckbox("Number 1", 25,30, 250, 15)
$Chk_Number2 = GUICtrlCreateCheckbox("Number 2", 25,50, 250, 15)
$Chk_Number3 = GUICtrlCreateCheckbox("Number 3", 25,70, 250, 15)

    
    


$btnok = GUICtrlCreateButton("OK", 25, 100, 75, 25)
GUISetState(@SW_SHOW)
$Checked_State = False





GUICtrlSetState($Chk_Number1,$GUI_CHECKED)







#EndRegion ### END Koda GUI section ###


;TrayTip("Checkbox State",$STATE,1)




While 1
    
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        
    
        ;Allows Close Button At Top Right Corner To Exit The Script
        Exit
        
    
    
    
    Case $btnok
    
    

    
    
    GuiSetState(@SW_HIDE)
    
    
    
    
    ;Number1
    If BitAnd(GUICtrlRead($Chk_Number1),$GUI_CHECKED) = $GUI_CHECKED THEN;
        
        
    ElseIf BitAnd(GUICtrlRead($Chk_Number1),$GUI_UNCHECKED) = $GUI_UNCHECKED THEN;
        
    EndIf
    
    
    
    
    
    
    ;Number2
    If BitAnd(GUICtrlRead($Chk_Number2),$GUI_CHECKED) = $GUI_CHECKED THEN;
        
        
    ElseIf BitAnd(GUICtrlRead($Chk_Number2),$GUI_UNCHECKED) = $GUI_UNCHECKED THEN;
        
    EndIf
    
    
    
    
    
    
    ;Number3
    If BitAnd(GUICtrlRead($Chk_Number3),$GUI_CHECKED) = $GUI_CHECKED THEN;
        
        
        
    ElseIf BitAnd(GUICtrlRead($Chk_Number3),$GUI_UNCHECKED) = $GUI_UNCHECKED THEN;
        
    EndIf
    
    
    
    
    
    
    
    
    
    
    
    

Exit


    EndSwitch
    
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

        Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Melba23

MistakenSanity,

You should have mentioned you were using one of my UDFs! :idiot:

This will give you the basic idea of how to link the combo to the checkboxes: ;)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>

$Form1 = GUICreate("Window Title", 327, 530, 193, 125)

$option1 = "Config 1"
$option2 = "Config 2"
$option3 = "Config 3"
$DropDown = GUICtrlCreateCombo("", 25, 10, 280, 20)
GUICtrlSetData(-1, "Config 1|Config 2|Config 3")

$Chk_Number1 = GUICtrlCreateCheckbox("Number 1", 25, 100, 250, 15)
$Chk_Number2 = GUICtrlCreateCheckbox("Number 2", 25, 120, 250, 15)
$Chk_Number3 = GUICtrlCreateCheckbox("Number 3", 25, 140, 250, 15)

$btnok = GUICtrlCreateButton("OK", 25, 180, 75, 25)
GUISetState(@SW_SHOW)
$Checked_State = False

GUICtrlSetState($Chk_Number1, $GUI_CHECKED)

$sCurrCombo = ""

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $btnok


    EndSwitch

    $sCombo = GUICtrlRead($DropDown)
    If $sCurrCombo <> $sCombo And _GUICtrlComboBox_GetDroppedState($DropDown) = False Then
        $sCurrCombo = $sCombo
        Switch $sCombo
            Case "Config 1"
                GUICtrlSetState($Chk_Number1, $GUI_CHECKED)
                GUICtrlSetState($Chk_Number2, $GUI_UNCHECKED)
                GUICtrlSetState($Chk_Number3, $GUI_UNCHECKED)
            Case "Config 2"
                GUICtrlSetState($Chk_Number1, $GUI_UNCHECKED)
                GUICtrlSetState($Chk_Number2, $GUI_CHECKED)
                GUICtrlSetState($Chk_Number3, $GUI_UNCHECKED)
            Case "Config 3"
                GUICtrlSetState($Chk_Number1, $GUI_UNCHECKED)
                GUICtrlSetState($Chk_Number2, $GUI_UNCHECKED)
                GUICtrlSetState($Chk_Number3, $GUI_CHECKED)
        EndSwitch
    EndIf

WEnd

Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
MistakenSanity

Thank you so much for your help!!! Sorry for the PM :-).

This is almost how I was trying to do it, but i was a bit off it appears. Thanks!!!!

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  

×