WJST Posted January 16, 2012 Share Posted January 16, 2012 (edited) Hi,I go a question, probably a pretty easy and/or dumb one, but still; can't figure it out...Here it is;I go myself a cute little gui, containing a button;The button is $but1. But1 creates a new button, $but2:Case $but1 $but2 = GUICtrlCreateButton("button2", 400, 696, 97, 65) Case $but2 This doesnt work. It simply exits with a variable undeclined warning, which is obvious, since I only create the button upon but1 click.Is it nessecary to define $but2 somewhere before or how can I do this?Maybe I should make the question a bit different; more to the point:I want to create a GUI, which changes when clicked. So all elements on it should be removed and new elements should be places. How can I do this easily?Who can help this beginner out?Thanks!(ps, very shamefull, 2 stupid typo's in the title.. cant edit it..); --------------------------------------------------------------------Edited by Melba23 to correct the title as you need 5 posts to get the "Edit" button. To edit the title you need to select the "Use Full Editor" option while editing the first post. Edited January 16, 2012 by Melba23 Link to comment Share on other sites More sharing options...
lark Posted January 16, 2012 Share Posted January 16, 2012 (edited) Im first off going to assume that you had already started the switch, inside a loop, and are testing the guigetmsg() function. So the problem would be that, if your program runs through the switch, it will test Case $but2 if you had not clicked on the first button by then, $but2 would not exist, and so it will throw an error. what you could do to solve that is just to create Global $but2 = 15000 or something like that, just so that autoit will recognize that yes, the variable exists, but as we are testing guigetmsg(), it is not 15000. dont do that, though, its kind of a bad way to get around it, i would say. just create $but2 from the start, but set its state as hidden. then, when you are running through case $but1 in the switch, do GUICtrlSetState ($but2, $GUI_SHOW) so all in all, it would be something like #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 179, 126, 192, 124) $But1 = GUICtrlCreateButton("Click me", 40, 24, 75, 25) $But2 = GUICtrlCreateButton("New Button", 40, 64, 75, 25) GUICtrlSetState($But2, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $But1 GUICtrlSetState($But2, $GUI_SHOW) EndSwitch WEnd Edited January 16, 2012 by mischieftoo Link to comment Share on other sites More sharing options...
WJST Posted January 16, 2012 Author Share Posted January 16, 2012 (edited) Hm, yeah, thanks, thats a smart idea. There's just one nasty disadvantage; I need to enable and disable all controlls at every button. For instance, $but3 should enable $but4, then I should hide all other controls at every other click. Case $but1 GUICtrlSetState($but2,64) GUICtrlSetState($but3,32) GUICtrlSetState($but4,32) Case $but2 GUICtrlSetState($but3,64) GUICtrlSetState($but4,32) GUICtrlSetState($but1,32) And so on.. Not really convenient when having over 100 different items, check boxes, buttons etc.. Isn't it possible to for instance group a load of controlls and then show or hide them all at once? Edited January 16, 2012 by WJST Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 16, 2012 Moderators Share Posted January 16, 2012 WJST,Unfortunately not. You could put the ControlIDs into an array which would let you use a For...Next loop to run through them pretty quickly. But if you are really dealing with over 100 controls, I would seriously reconsider your GUI design. Perhaps take a look at my GUIExtender UDF (look in my sig for the link) - this will let you open and close sections of your GUI and might be a better way to deal with so many controls. M23P.S. I amended the thread title for you - see the first post for more details. 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 Link to comment Share on other sites More sharing options...
WJST Posted January 16, 2012 Author Share Posted January 16, 2012 Thanks! Still cant find it to be honest I'm gonna give the guiextender udf a try. Maybe that'll create less work Link to comment Share on other sites More sharing options...
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