Click to See Complete Forum and Search --> : [RESOLVED] Radio Buttons - WS_GROUP & WS_TABSTOP
dsmbala
January 31st, 2007, 04:18 AM
Could someone clarify the proper usage of WS_GROUP style. I have a dialog box with 2 sets of mutually exclusive radio buttons. The first set has 3 buttons and the second set has 5 buttons. I have set the style parameter of the first control in the first set of radio button as follows:
WS_CHILD|WS_GROUP|WS_AUTORADIOBUTTON|WS_TABSTOP
and the rest of the radio buttons to be
WS_CHILD|WS_AUTORADIOBUTTONS
Does WS_GROUP have to come in pairs - meaning should the last control of the radio set also have the WS_GROUP styling or should the control immediately following the last control of the set have WS_GROUP styling.
Would it be possible to draw a horizontal seperator line inside a dialog box using createwindowex?
cheers,
bala
Brenton S.
January 31st, 2007, 06:01 AM
Hi dsmbala,
Well, here's an excerpt from Microsoft's documentation about the use of WS_GROUP:
WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins).
Therefore it would not be necessary to include the WS_GROUP style for both the first and last radio button in each group.
As for drawing a horizontal bar, I believe it is possible to do using CreateWindow. Mabye something like this:
hwnd = CreateWindowEx(WS_EX_LEFT | WS_EX_LTRREADING | WS_STATICEDGE,
"STATIC",
(LPCTSTR)NULL,
WS_CHILD | WS_VISIBLE,
0,
0,
375,
1,
hwndParent,
(HMENU)NULL,
hInstance,
(LPVOID)NULL);
I hope I've been of some help. :wave:
dsmbala
January 31st, 2007, 06:25 AM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Windows/WindowReference/WindowStyles.asp
-------------------------------------------------------------------------------------------
WS_GROUP
Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys.
----------------------------------------------------------------------------------------------
Thanks for the reply. My confusion is if I have only one Group (set) of controls apart from the other controls, how do I inform that this is where the group ends and from then on, the controls are all independent and should receive focus on tab keys being pressed. For Ex. My Tab Sequence may be 2 edit controls, 3 radio buttons, 2 edit controls, and finally 3 buttons. Apart from assigning WS_CHILD to all the controls, i can assign WS_GROUP|WS_TABSTOP to the first control of the "3 radio buttons". But then, how would I tell the dialog that my group is only the "3 radio buttons" and not the controls after that. I hope my query is clear.
Brenton S.
January 31st, 2007, 06:36 AM
Hi again,
But then, how would I tell the dialog that my group is only the "3 radio buttons" and not the controls after that. I hope my query is clear.
The system should automatically determine that:
For example, if you have a set three radio buttons that should be distinguished as one group, and a set of two edit boxes that should be distinguished as a seperate group, you would include the WS_GROUP style in the first radio button and edit box of each group respectively. The system would then recognize where the WS_GROUP style was begins a new group and in turn ends a previous group. Here's a graphical representation:
Group #1
Radio Button - WS_GROUP
Radio Button - No
Radio Button - No
-------------------------
Group #2
Edit Box - WS_GROUP <- Begins new group and in turn ends Group #1
Edit Box - No
-------------------------
Group #3 ... So and so forth ... :)
dsmbala
January 31st, 2007, 07:01 AM
Thanks Brenton, I have it now. Adding WS_TABSTOP to the control immediately following the last control of the group informs the system, that the group has ended. The line drawing also worked. thanks a lot.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.