Sign in to follow this  
Followers 0
xxxxmyxxxx

GUI Programming Standards

2 posts in this topic

#1 ·  Posted (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 by xxxxmyxxxx

Share this post


Link to post
Share on other sites



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. :D

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. :D

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._______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

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