kkelley Posted June 19, 2014 Posted June 19, 2014 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 JLogan3o13 Posted June 19, 2014 Moderators Solution Posted June 19, 2014 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() kkelley 1 "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 Melba23 Posted June 19, 2014 Moderators Posted June 19, 2014 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 kkelley 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kkelley Posted June 19, 2014 Author Posted June 19, 2014 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 JLogan3o13 Posted June 19, 2014 Moderators Posted June 19, 2014 You could revert, something like this: expandcollapse popup#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: expandcollapse popup#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() kkelley 1 "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!
kkelley Posted June 19, 2014 Author Posted June 19, 2014 Thanks again JLogan3013! That made for a nice GUI.
Moderators JLogan3o13 Posted June 19, 2014 Moderators Posted June 19, 2014 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now