xxxxmyxxxx Posted July 3, 2011 Share Posted July 3, 2011 (edited) Hi Im writing a simple GUI as a plug-in for other software Ive written. It calls for a few tabs and some option within each tab. Ive decided to use radio buttons to toggle the options within each tab but it seems that perhaps radio buttons were not mean to be used in this way. I do not have tons of experience with GUI programming and would like some advice about what type of control (if not radio buttons) would best suit my needs, which are as follows: Under each tab there would be radio buttons One radio button (lets call it R1) would be default and would have one set of stuff drawn to the window If I click radio button 2 (R2) I would have another set of input & stuff drawn to the window and set 1 would disappear etc It seems that the control_ID's for each set of stuff get used and re-used when I go from one radio button to another and things just dont quite workout. Sometimes things get stuck in the window when I choose one radio button over another, other times it goes into an infinite loop of creating the control. Im stating to think that radio buttons are not the way to go with this. Please advise. Thanks! Edited July 3, 2011 by xxxxmyxxxx Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 3, 2011 Moderators Share Posted July 3, 2011 xxxxmyxxxx,Welcome to the AutoIt forum. As you have discovered, AutoIt reuses ControlIDs when controls are deleted and then recreated. This can be very useful in certain circumstances, but can also give problems if the numbers of deleted and recreated controls are not the same. Some explanation. AutoIt stores its ControlIds in an internal array - the ControlID you get is actually the index of the element of the array holding the data for that control. AutoIt will always use the lowest available empty index to store the data for a newly created control (a very sensible policy to save space) but this means that if you delete a number of controls and then create a larger number you get the ControlIDs spread all over the array. In your case, radio buttons seem to be the correct way to go to reconfigure the controls, but I assume you are deleting and recreating the various controls when you change the configuration. I would strongly suggest creating all the controls you will need initially and then using GUICtrlSetState($CID, $GUI_HIDE/SHOW) to make the ones you need visible. There are a number of tricks involving arrays you can use to optimise your code if you do it this way, but we can come to them later. Give that a try. If you still have problems, please post your code as otherwise it is pretty hard offering anything other than very general advice. M23 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...
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