Jump to content

Radio button grouping


Recommended Posts

I need two sets of radio buttons. A set of 3 buttons, and beside it a set of 2 buttons

The 3 buttons are one group, and the 2 buttons a second group.

Here's the catch: The buttons need to have the same class and instance as the original app that I need to replicate, and be named consecutively. The original app buttons are [CLASS:Button; INSTANCE:1] through to [CLASS:Button; INSTANCE:5]

Problem is, I had to put the buttons inside a Group box, because they need to operate as 2 groups. Unfortunately, these groups are considered a button when I use the Window Info tool, so my buttons are no longer named consecutively. If I remove the group boxes, my Classname and instances are consecutive, but the buttons work as one group.

My question is: how do I get the radio buttons to work as two groups, yet keep the naming and instance consecutive?

(Hope this makes sense) :mellow:

EDIT: Sorry.. found the answer. All that I needed to do was insert "GUIStartGroup() above the radio button group I want to create.

Edited by VelvetElvis
Link to comment
Share on other sites

  • Moderators

VelvetElvis,

Use GUICreateGroup to get the Radio controls suitably grouped and then create the Group controls afterwards. :)

Here is an example - the Radio controls are artificially elongated to get them to show outside the Group boxes so that the Window Info tool can see them easily:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

GUIStartGroup()
$hRadio_1 = GUICtrlCreateRadio("Radio 1", 20, 30, 400, 20)
$hRadio_2 = GUICtrlCreateRadio("Radio 2", 20, 50, 400, 20)
$hRadio_3 = GUICtrlCreateRadio("Radio 3", 20, 70, 400, 20)
GUIStartGroup()
$hRadio_4 = GUICtrlCreateRadio("Radio 4", 20, 130, 400, 20)
$hRadio_5 = GUICtrlCreateRadio("Radio 5", 20, 150, 400, 20)
GUIStartGroup()

$hGroup_1 = GUICtrlCreateGroup("Group 1", 10, 10, 120, 90)
$hGroup_2 = GUICtrlCreateGroup("Group 2", 10, 110, 120, 70)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Works for me - good for you too? :mellow:

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

VelvetElvis,

Use GUICreateGroup to get the Radio controls suitably grouped and then create the Group controls afterwards. :)

Here is an example - the Radio controls are artificially elongated to get them to show outside the Group boxes so that the Window Info tool can see them easily:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

GUIStartGroup()
$hRadio_1 = GUICtrlCreateRadio("Radio 1", 20, 30, 400, 20)
$hRadio_2 = GUICtrlCreateRadio("Radio 2", 20, 50, 400, 20)
$hRadio_3 = GUICtrlCreateRadio("Radio 3", 20, 70, 400, 20)
GUIStartGroup()
$hRadio_4 = GUICtrlCreateRadio("Radio 4", 20, 130, 400, 20)
$hRadio_5 = GUICtrlCreateRadio("Radio 5", 20, 150, 400, 20)
GUIStartGroup()

$hGroup_1 = GUICtrlCreateGroup("Group 1", 10, 10, 120, 90)
$hGroup_2 = GUICtrlCreateGroup("Group 2", 10, 110, 120, 70)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Works for me - good for you too? :mellow:

M23

Yes, that's great. Thank you M23.

One question that I couldn't find the answer to, is what other controls does GUIStartGroup() apply to? The help says "This function is generally used when working with radio button controls. Does it apply to any other controls?

Link to comment
Share on other sites

  • Moderators

VelvetElvis,

Does it apply to any other controls?

I have no idea! :)

But off the top off my head I cannot think of any reason to have other controls in groups. I have noticed that Koda adds $WS_GROUP to all "button" controls, so there might well be one and I have just never needed it. :mellow:

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

VelvetElvis,

I have no idea! :)

But off the top off my head I cannot think of any reason to have other controls in groups. I have noticed that Koda adds $WS_GROUP to all "button" controls, so there might well be one and I have just never needed it. :mellow:

M23

Only reason I ask is if I had this in between other controls, instead of right before the GUISetState(), as in your example, I wouldn't want another control to get inadvertently grouped with the radio buttons. This would happen when you're trying to keep the tab order on your form.

As it turns out, on my code, it's not an issue with the controls following.

Thanks again, M23!

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