Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC problem. How do i create an Radio button IN a Groupbox in runtime?

Status
Not open for further replies.

dcgsmix

Programmer
Dec 20, 2001
35
IL
Hey,

I'm Creating three CButton
And calling their ::Create procedure to create them

first, i'm creating one group box with style BS_GROUPBOX
and then the other two i'm creating Radio buttons with style BS_AUTORADIOBUTTON

My point is to create it in runtime, not to make resources.
only the dialog is created as a resource.

thanks,
daniel gindi
dcgsmix@gmx.net
 
You'll still need to reserve resource ID(s) that you can assign to your dynamically created resource(s). Then, go ahead and create them using resource ID(s) that you reserved.

If you still have a problem, be more specific and show us what you've got already. If you post code, don't forget to use:

[
Code:
code]

  // your source code goes here

[
/code]
 
How to i insert the radio buttons into the group box?

you know, when you check one, the others are automatically unchecked. if you insert radio buttons into group box, then you will have a group like that. but how do i do it in runtime?
 
Create all the radio buttons in the group contiguously.

Use the WS_GROUP style flags in the first radio button Create() call only (for all of the other radio buttons in the group, do not use the WS_GROUP style flag)

As soon as you start creating a different type of control (i.e. edit box) or if you create a new radio button with the WS_GROUP flag, the original grouping stops.

From MSDN:

"In general, the first control in a group must have the WS_GROUP style and all other controls in the group must not have this style. All controls in the group must be contiguous — that is, they must have been created consecutively with no intervening controls."

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top