Jump to content

Recommended Posts

Posted

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!

  • Moderators
  • Solution
Posted

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()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

  • Moderators
Posted

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

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:

  Reveal hidden contents

 

Posted

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?

  • Moderators
Posted

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()

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

  • Moderators
Posted

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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