Jump to content

Sub-items in combo box not changing


Recommended Posts

I'm trying to create different controls based on the combo box selection made. The issue is that it doesn't change the controls when I select another option from the combo box. Posted Image

Below is my code. I think I'm missing something Posted Image but not sure what it is. Any help is appreciated. Thank you Posted Image .

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 166, 298, 302, 218)
$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option2|Option3", "Option2")

        Switch GUICtrlRead($Combo1)
            Case "Option1"
    $Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
    $Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)
    
            Case "Option2"
    $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
    $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
    $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
    $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)
                
            Case "Option3"
    $Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
    $Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
    $Button1 = GUICtrlCreateButton("Button1", 16, 104, 115, 25, $WS_GROUP)
    $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 24, 184, 97, 17)

        EndSwitch


GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit

EndSwitch
WEnd
Edited by sliceofpie
Link to comment
Share on other sites

  • Moderators

sliceofpie,

The best way to do this is to create all the controls initially and then just show/hide them according to the combo option. The trick is to use _GUICtrlComboBox_GetDroppedState so that we do not action the various combo values until the selection is made - try removing that condition and see what happens! :)

So your code becomes:

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

#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 166, 298, 302, 218)
$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option2|Option3", "Option2")

; Create all controls and hide them

$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)

_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$sCurrCombo = ""

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    ; Wait until the combo is closed and then see if the value has changed
    If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then
        $sCurrCombo = GUICtrlRead($Combo1)
        Switch $sCurrCombo
            ; For each option, hide all controls and then just show the ones we want
            Case "Option1"
                _Hide_All()
                For $i = $Button1 To $Button3
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option2"
                _Hide_All()
                For $i = $Checkbox1 To $Checkbox4
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option3"
                _Hide_All()
                For $i = $Input1 To $Checkbox5
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

        EndSwitch
    EndIf


WEnd

Func _Hide_All()

    For $i = $Button1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc

All clear? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Func _Hide_All()

    For $i = $Button1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc

Lol, didn't know that was possible. ;)

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • Moderators

AlmarM,

Only if you create the controls in IMMEDIATE sucession and do not delete any of them. ;)

AutoIt uses an internal array to keep track of created controls - hence the 65532 limit on controls per script. A new control takes the first available slot in the array and not the next highest - which is why the controls must be created in immediate succession and none deleted. Otherwise you have no idea what might be in that slot now! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

I modified the code a bit to include a button. When pressed, it will display the combo box with options to choose. It works great but how do I stop the combo box from flickering?

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

Global $sCurrCombo = "",$sCurrGenericData = "", $var

#Region ### START Koda GUI section ### Form=

$Form3 = GUICreate("Form3", 166, 298, 302, 218)

$Button5 = GUICtrlCreateButton("Button5", 48, 256, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button5, "ShowMenu")

; Create all controls and hide them

$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option2|Option3", "Option2")
$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)


_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ShowMenu()


Func ShowMenu()
 
 While 1
  $msg = GUIGetMsg()
  Select
   Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
   Case $msg = $Button5
    Show()
  EndSelect
 WEnd
EndFunc

 

Func Show()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
  EndSwitch

GUICtrlSetState($Combo1, $GUI_SHOW)

    If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then
    $sCurrCombo = GUICtrlRead($Combo1)
    Switch $sCurrCombo
            Case "Option1"
                _Hide_All()
                For $i = $Button1 To $Button3
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option2"
                _Hide_All()
                For $i = $Checkbox1 To $Checkbox4
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option3"
                _Hide_All()
                For $i = $Input1 To $Checkbox5
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

        EndSwitch
    EndIf

 


WEnd
EndFunc

Func _Hide_All()

    For $i = $Combo1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc
Link to comment
Share on other sites

  • Moderators

sliceofpie,

Modified and over complicated! :)

All you need to do is show the combo, not start a new loop: ;)

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

Global $sCurrCombo = "", $sCurrGenericData = "", $var

#Region ### START Koda GUI section ### Form=

$Form3 = GUICreate("Form3", 166, 298, 302, 218)

$Button5 = GUICtrlCreateButton("Button5", 48, 256, 75, 25, $WS_GROUP)
;GUICtrlSetOnEvent($Button5, "ShowMenu") ; Not in OnEvent mode so useless <<<<<<<<<<<<<<<<<<<<<<<<

; Create all controls and hide them
$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option2|Option3", "Option2")
$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)

_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ShowMenu()

Func ShowMenu()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button5
                GUICtrlSetState($Combo1, $GUI_SHOW) ; All you need do is to show the combo! <<<<<<<<<<<<<<<<<<<<<<<<
        EndSelect

        If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then

            $sCurrCombo = GUICtrlRead($Combo1)
            Switch $sCurrCombo
                Case "Option1"
                    _Hide_All()
                    For $i = $Button1 To $Button3
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option2"
                    _Hide_All()
                    For $i = $Checkbox1 To $Checkbox4
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option3"
                    _Hide_All()
                    For $i = $Input1 To $Checkbox5
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

            EndSwitch
        EndIf

    WEnd

EndFunc   ;==>ShowMenu

Func _Hide_All()

    For $i = $Combo1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc   ;==>_Hide_All

If you do not understand why I have commented out the GUICtrlSetOnEvent line, you need to re-read the Help file <GUI Reference - GUI Concepts> again. Ask if you have any questions. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

thanks for your response M23 Posted Image I had overcomplicated this one Posted Image .

I don't know if its only on my machine but when I do this, it displays the options for the combo box without the combo box being there. When pressing "$Button5" it will then show the combo box.

Edited by sliceofpie
Link to comment
Share on other sites

  • Moderators

sliceofpie,

Certainly does not do that for me! :)

Try altering the combo creation code to this: ;)

$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData($Combo1, "Option2|Option3", "Option2")
_GUICtrlComboBox_ShowDropDown($Combo1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This should force the combo to close. No guarantees - let me know what happens. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Your answer makes sense but it wasn't what I wanted the script to do.

I wasn't clear with what I'm trying to create so I'll be more specific Posted Image .

- When Showing the GUI, only Button5 should be viewable.

- After pressing the button, the drop box should appear with drop down data and default values.

This was kind of working (everything but the flickering) but it was too complicated.. so I modified it see below:

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

Global $sCurrCombo = "",$sCurrGenericData = "", $var

#Region ### START Koda GUI section ### Form=

$Form3 = GUICreate("Form3", 166, 298, 302, 218)

$Button5 = GUICtrlCreateButton("Button5", 48, 256, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent($Button5, "ShowMenu")

; Create all controls and hide them

$Combo1 = GUICtrlCreateCombo("Option1", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option2|Option3", "Option2")

$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)


_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ShowMenu()


Func ShowMenu()

While 1
  $msg = GUIGetMsg()
  Select
   Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
   Case $msg = $Button5
    Show()
  EndSelect
WEnd
EndFunc



Func Show()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
  EndSwitch

GUICtrlSetState($Combo1, $GUI_SHOW)

    If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then
    $sCurrCombo = GUICtrlRead($Combo1)
    Switch $sCurrCombo
            Case "Option1"
                _Hide_All()
                For $i = $Button1 To $Button3
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option2"
                _Hide_All()
                For $i = $Checkbox1 To $Checkbox4
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

            Case "Option3"
                _Hide_All()
                For $i = $Input1 To $Checkbox5
                    GUICtrlSetState($i, $GUI_SHOW)
                Next

        EndSwitch
    EndIf




WEnd
EndFunc

Func _Hide_All()

    For $i = $Combo1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc

but I just can't get passed the flickering.

I tried putting the combo box in an IF statement to stop it from redrawing.. like this:

....

  Select
   Case $msg = $GUI_EVENT_CLOSE
    ExitLoop
   Case $msg = $Button5
    $CurrCombo = $Combo1
    Show()
    
  EndSelect



Func Show()

If $sCurrCombo = $Combo1 Then GUICtrlSetState($Combo1, $GUI_SHOW)

$sCurrCombo = ""

....

And it doesn't work.

I apologize for not explaining myself clearly. I don't think I'm approaching this correctly. M23, maybe you tried telling me something that I'm not seeing Posted Image .

Edited by sliceofpie
Link to comment
Share on other sites

  • Moderators

sliceofpie,

- When Showing the GUI, only Button5 should be viewable.

- After pressing the button, the drop box should appear with drop down data and default values.

Try this: ;)

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

Global $sCurrCombo = "Option 1", $sCurrGenericData = "", $var

#Region ### START Koda GUI section ### Form=

$Form3 = GUICreate("Form3", 166, 298, 302, 218)

$Button5 = GUICtrlCreateButton("Button5", 48, 256, 75, 25, $WS_GROUP)

; Create all controls and hide them
$Combo1 = GUICtrlCreateCombo("", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option1|Option2|Option3", "Option 2")
$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)

_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ShowMenu()

Func ShowMenu()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button5
                GUICtrlSetState($Combo1, $GUI_SHOW)
        EndSelect

        If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then

            ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            $sCurrCombo = GUICtrlRead($Combo1)
            Switch $sCurrCombo
                Case "Option1"
                    _Hide_All()
                    For $i = $Button1 To $Button3
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option2"
                    _Hide_All()
                    For $i = $Checkbox1 To $Checkbox4
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option3"
                    _Hide_All()
                    For $i = $Input1 To $Checkbox5
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

            EndSwitch
        EndIf


    WEnd

EndFunc   ;==>ShowMenu

Func _Hide_All()

    For $i = $Combo1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc   ;==>_Hide_All

I get a blank GUI apart from Button5. When the button is pressed I get the combo appearing and when I select one of the 3 options I get the appropriate controls with the combo vanishing again.

Is that what you get and is it what you want? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

sliceofpie,

So remove the combo from the _Hide_All function and hide it when you first create it: ;)

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

Global $sCurrCombo = "Option 1", $sCurrGenericData = "", $var

#Region ### START Koda GUI section ### Form=

$Form3 = GUICreate("Form3", 166, 298, 302, 218)

$Button5 = GUICtrlCreateButton("Button5", 48, 256, 75, 25, $WS_GROUP)

; Create all controls and hide them
$Combo1 = GUICtrlCreateCombo("", 8, 16, 145, 25)
GUICtrlSetData(-1, "Option1|Option2|Option3", "Option 2")
GUICtrlSetState(-1, $GUI_HIDE)
$Button1 = GUICtrlCreateButton("Button1", 8, 56, 75, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 8, 96, 75, 25, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Button3", 8, 136, 75, 25, $WS_GROUP)

$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 16, 56, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 88, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 16, 120, 97, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 16, 152, 97, 17)

$Input1 = GUICtrlCreateInput("Input1", 16, 64, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 144, 121, 25)
$Button4 = GUICtrlCreateButton("Button4", 16, 104, 115, 25, $WS_GROUP)
$Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 24, 184, 97, 17)

_Hide_All()

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

ShowMenu()

Func ShowMenu()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button5
                GUICtrlSetState($Combo1, $GUI_SHOW)
        EndSelect

        If GUICtrlRead($Combo1) <> $sCurrCombo And _GUICtrlComboBox_GetDroppedState($Combo1) = False Then

            ConsoleWrite(GUICtrlRead($Combo1) & @CRLF)

            $sCurrCombo = GUICtrlRead($Combo1)
            Switch $sCurrCombo
                Case "Option1"
                    _Hide_All()
                    For $i = $Button1 To $Button3
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option2"
                    _Hide_All()
                    For $i = $Checkbox1 To $Checkbox4
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

                Case "Option3"
                    _Hide_All()
                    For $i = $Input1 To $Checkbox5
                        GUICtrlSetState($i, $GUI_SHOW)
                    Next

            EndSwitch
        EndIf


    WEnd

EndFunc   ;==>ShowMenu

Func _Hide_All()

    For $i = $Button1 To $Checkbox5
        GUICtrlSetState($i, $GUI_HIDE)
    Next

EndFunc   ;==>_Hide_All

You have enough examples now - over to you to for any further changes. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

sliceofpie,

Glad I could help! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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...