Jump to content

Group Controls?


Cyri
 Share

Recommended Posts

I'm trying to figure out the best way to group controls together. I see there is a groupbox, but it's not a real groupbox. The controls in the groupbox aren't bound to it. If you hide the groupbox the controls that were on it still show. I also started looking at layered windows, but the main problem I had with that is when clicking a control (or even an empty space) in the layered window causes the layered window to take focus.

I'm trying to create a wizard install where the main window is static except for the main section of the window. In that section I just show or hide the appropriate screen (with pre-populated controls) when a user clicks next or back. Anyone know of a better way to create a wizard install? I'm trying to avoid a bunch of extra code and logic each time someone clicks back or next. Grouping the controls for each screen and then just showing and hiding the appropriate screen seems like the best way to do that.

Link to comment
Share on other sites

  • Moderators

Cyri,

The ControlIDs for every control you create are consecutive numbers, so if you create a group of them one immediately after another you can then use a small loop to hide/show them as one:

$hGroup = GUICtrlCreateGroup ( "Select Item", 10, 10, 130, 180);200)
Opt("GUICoordMode",0); Relative coords
$Radio_Array[0] = GUICtrlCreateRadio("Radio 1",  5, 15, 110, 20)
$Radio_Array[1] = GUICtrlCreateRadio("Radio 2",  -1, 20, 110, 20)
...
$Radio_Array[n] = GUICtrlCreateRadio("Radio n",  -1, 20, 110, 20)
Opt("GUICoordMode",1); GUI coords

For $i = $hGroup To $Radio_Array[n]
    GUICtrlSetState($i, $GUI_HIDE)
Next

I have used this in the past to "group" controls with some success. You could even save the first and last ControlIds in a 2-D array which would give you a nice way of setting the loop parameters - each group could then be hidden/shown using For $i = $array[$group_number][0] To $array[$group_number][1].

Hope this is helpful,

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:

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

 

Link to comment
Share on other sites

Thanks for the reply. I like the idea of using an array to control this. I should be able to use a 2-d array with one element being the control itself and the second element an index of what screen it's part of. I also found another post on the boards that showed using the dummy control. Here is a link to it:

http://www.autoitscript.com/forum/index.ph...rt=#entry526183

This would work, but would be more code than using an array.

Link to comment
Share on other sites

  • Moderators

Cyri,

All the dummy control does is to eat up a ControlID so that you have a start and end point defined. If you are going to use the controls later - which is normally the case - you are probably going to assign the IDs to variables when you create them and therefore they are available to use directly.

Six of one, half a dozen of the other, really.

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:

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

 

Link to comment
Share on other sites

I use dummy controls for doing this. Yes, it eats up a ControlID, but something like this:

$hLabelStart=GUICtrlCreateDummy()
GUICtrlCreateLabel(blah,blah)
GUICtrlCreateLabel(Blah,Blah)
GUICtrlCreatelabel(Blah,Blah)
GUICtrlCreateButton("Enter",blah)
$hLabelEnd=GUICtrlCreateDummy()

A group can now quickly be hidden:

For $i=$hLabelStart+1 To $hLabelEnd-1
GUICtrlSetState($i,$GUI_HIDE)
Next

and even the button can be ID'd without an explicit variable name as $hLabelEnd-1 If there are only a couple of items then dummy controls might not be efficient, but for completely changing large portions of your GUI I find it helpful.

Bob

EDIT: Guess I should have read the link as I nearly restate rasims post.

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

Link to comment
Share on other sites

I use dummy controls for doing this. Yes, it eats up a ControlID, but something like this:

$hLabelStart=GUICtrlCreateDummy()
 GUICtrlCreateLabel(blah,blah)
 GUICtrlCreateLabel(Blah,Blah)
 GUICtrlCreatelabel(Blah,Blah)
 GUICtrlCreateButton("Enter",blah)
 $hLabelEnd=GUICtrlCreateDummy()

A group can now quickly be hidden:

For $i=$hLabelStart+1 To $hLabelEnd-1
 GUICtrlSetState($i,$GUI_HIDE)
 Next

and even the button can be ID'd without an explicit variable name as $hLabelEnd-1 If there are only a couple of items then dummy controls might not be efficient, but for completely changing large portions of your GUI I find it helpful.

Bob

EDIT: Guess I should have read the link as I nearly restate rasims post.

What are the dummy controls for? Why not just write

$hLabelStart=GUICtrlCreateLabel(blah,blah)
 GUICtrlCreateLabel(Blah,Blah)
 GUICtrlCreatelabel(Blah,Blah)
 $hLabelEnd=GUICtrlCreateButton("Enter",blah)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

What are the dummy controls for? Why not just write

$hLabelStart=GUICtrlCreateLabel(blah,blah)
 GUICtrlCreateLabel(Blah,Blah)
 GUICtrlCreatelabel(Blah,Blah)
 $hLabelEnd=GUICtrlCreateButton("Enter",blah)
That's OK if all your doing is performing an action against the entire block. In a wizard you may perform an action against just one of those elements at one point and then against all of them at another. By using the code above you lose the ability to control them individually as well as in a group.
Link to comment
Share on other sites

That's OK if all your doing is performing an action against the entire block. In a wizard you may perform an action against just one of those elements at one point and then against all of them at another. By using the code above you lose the ability to control them individually as well as in a group.

Not true. Even if the control isn't explicitly assigned to a variable name, it still has a control id. All controls are created in increasing order thus the first control created will have the control id 1, the next one will have control id 2. It gets dangerous using the above method if you start deleting these controls because new ones created after old ones have been deleted will take the next open number. For instance, if you create three controls they will be numbered 1,2 and 3. If you delete the 2nd one and make a new one it will not be numbered 4 but rather 2.

If you have a starting point, you can always get the control id by adding 1 to each subsequent control id until you reach the one you are looking for. It means keeping better track of how your controls are created.

@martin

I guess you could do the same thing without the dummy controls, but in my non-programming mind it looks neater.

Bob

You can't see a rainbow without first experiencing the rain.

Link to comment
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
 Share

  • Recently Browsing   0 members

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