Sign in to follow this  
Followers 0
kkelley

GUI dynamics

8 posts in this topic

Hello!

I am currently making a GUI for running a software application.  I was wondering if there was a way to make it so if I clicked on a button it would bring up GUI functions.  For instance; I click on the button and two user input fields appear with labels, with a combo box for selecting an item; and if I click on another button I get three combo boxes for selections and another button....etc.  I am currently using the Koda FormDesigner, and I cannot really figure out if this is possible.  Thanks for you help!

Share this post


Link to post
Share on other sites



Hi, kkelley. Check out GuiCtrlSetState in the help file. Perhaps something like this:

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

GUICreate("Test", 300, 200)
$lbl1 = GUICtrlCreateLabel("Input 1", 10, 10, 100, 20)
$lbl2 = GUICtrlCreateLabel("Input 2", 10, 70, 100, 20)

$input1 = GUICtrlCreateInput("", 10, 30, 280, 30)
$input2 = GUICtrlCreateInput("", 10, 90, 280, 30)

    GUICtrlSetState($lbl1, $GUI_HIDE)
    GUICtrlSetState($lbl2, $GUI_HIDE)
    GUICtrlSetState($input1, $GUI_HIDE)
    GUICtrlSetState($input2, $GUI_HIDE)

$gobtn = GUICtrlCreateButton("Go", 10, 150, 40, 30)
$exit = GUICtrlCreateButton("Exit", 200, 150, 40, 30)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $exit
                ExitLoop
            Case $gobtn
                GUICtrlSetState($lbl1, $GUI_SHOW)
                GUICtrlSetState($lbl2, $GUI_SHOW)
                GUICtrlSetState($input1, $GUI_SHOW)
                GUICtrlSetState($input2, $GUI_SHOW)
        EndSwitch
    WEnd

GUIDelete()
1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

kkelley,

Or look at my GUIExtender UDF (look in my sig for the link) which lets you expand/contract sections of the GUI so that only the parts you want are visible. :)

M23

1 person likes this

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

Thanks JLogan3o13, and Melba23! While I have your attention, I am curious how to get them to switch now? So for instance if I click on one button it has a few options like a combo box and a user input, when I click on another it doesn't switch the views it just keeps what it was before.  What would be a way to debug that?

Share this post


Link to post
Share on other sites

You could revert, something like this:

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

GUICreate("Test", 300, 200)
$lbl1 = GUICtrlCreateLabel("Input 1", 10, 10, 100, 20)
$lbl2 = GUICtrlCreateLabel("Input 2", 10, 70, 100, 20)

$input1 = GUICtrlCreateInput("", 10, 30, 280, 30)
$input2 = GUICtrlCreateInput("", 10, 90, 280, 30)

    GUICtrlSetState($lbl1, $GUI_HIDE)
    GUICtrlSetState($lbl2, $GUI_HIDE)
    GUICtrlSetState($input1, $GUI_HIDE)
    GUICtrlSetState($input2, $GUI_HIDE)

$gobtn = GUICtrlCreateButton("Go", 10, 150, 40, 30)
$revert = GUICtrlCreateButton("Revert", 100, 150, 40, 30)
$exit = GUICtrlCreateButton("Exit", 200, 150, 40, 30)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $exit
                ExitLoop
            Case $gobtn
                GUICtrlSetState($lbl1, $GUI_SHOW)
                GUICtrlSetState($lbl2, $GUI_SHOW)
                GUICtrlSetState($input1, $GUI_SHOW)
                GUICtrlSetState($input2, $GUI_SHOW)
                ConsoleWrite("User pressed Go" & @CRLF)
            Case $revert
                GUICtrlSetState($lbl1, $GUI_HIDE)
                GUICtrlSetState($lbl2, $GUI_HIDE)
                GUICtrlSetState($input1, $GUI_HIDE)
                GUICtrlSetState($input2, $GUI_HIDE)
                ConsoleWrite("User pressed Revert" & @CRLF)
        EndSwitch
    WEnd

GUIDelete()

But if you just want, say, nothing to happen when they hit $revert, you just code whatever notification you want and leave the controls hidden:

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

GUICreate("Test", 300, 200)
$lbl1 = GUICtrlCreateLabel("Input 1", 10, 10, 100, 20)
$lbl2 = GUICtrlCreateLabel("Input 2", 10, 70, 100, 20)

$input1 = GUICtrlCreateInput("", 10, 30, 280, 30)
$input2 = GUICtrlCreateInput("", 10, 90, 280, 30)

    GUICtrlSetState($lbl1, $GUI_HIDE)
    GUICtrlSetState($lbl2, $GUI_HIDE)
    GUICtrlSetState($input1, $GUI_HIDE)
    GUICtrlSetState($input2, $GUI_HIDE)

$gobtn = GUICtrlCreateButton("Go", 10, 150, 40, 30)
$revert = GUICtrlCreateButton("Revert", 100, 150, 40, 30)
$exit = GUICtrlCreateButton("Exit", 200, 150, 40, 30)

GUISetState(@SW_SHOW)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $exit
                ExitLoop
            Case $gobtn
                GUICtrlSetState($lbl1, $GUI_SHOW)
                GUICtrlSetState($lbl2, $GUI_SHOW)
                GUICtrlSetState($input1, $GUI_SHOW)
                GUICtrlSetState($input2, $GUI_SHOW)
                ConsoleWrite("User pressed Go" & @CRLF)
            Case $revert
                ConsoleWrite("User pressed Revert but I didn't do 'nuthin." & @CRLF)
        EndSwitch
    WEnd

GUIDelete()
1 person likes this

When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Thanks again JLogan3013! That made for a nice GUI.

Share this post


Link to post
Share on other sites

Glad to be of service. As you get farther along with your project I would encourage you to take to heart Melba's suggestion; his GUIExtender UDF will allow you to do much more.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

Noted! I will look into it further.

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