CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Location
    India
    Posts
    7

    [RESOLVED] Radio Buttons - WS_GROUP & WS_TABSTOP

    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

  2. #2
    Join Date
    Mar 2006
    Location
    New Jersey
    Posts
    120

    Re: Radio Buttons - WS_GROUP & WS_TABSTOP

    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:

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

  3. #3
    Join Date
    Jan 2007
    Location
    India
    Posts
    7

    Re: Radio Buttons - WS_GROUP & WS_TABSTOP

    http://msdn.microsoft.com/library/de...ndowStyles.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.

  4. #4
    Join Date
    Mar 2006
    Location
    New Jersey
    Posts
    120

    Re: Radio Buttons - WS_GROUP & WS_TABSTOP

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

  5. #5
    Join Date
    Jan 2007
    Location
    India
    Posts
    7

    Thumbs up Re: Radio Buttons - WS_GROUP & WS_TABSTOP

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured