Let's talk about statically created methods:
Radio buttons are also part of the CButton class, but because radio buttons are always used in groups, it differs from normal buttons in production and use.
Suppose you have three radio buttons that make up a group, and initially, the first radio button is selected.
Let's take a look at the static authoring method: Place three radio buttons in the dialog box and set the properties as follows:
Radio1 properties: Visible, Group, Tab stop, Auto
Radio2 properties: Visible, Tab stop, Auto
Radio3 properties: Visible, Tab stop, Auto
Such a property setting divides the three radio buttons into a group, they can only have one selected at a time, and if there are other groups of radio buttons in the dialog box, they will not interfere with each other. However, the first button is not selected at this time. Then use ClassWizard to add variables to this set of radio buttons, where you simply add a variable for the first radio button. Set variable named M_radio, type int. In the constructor ClassWizard set the value of M_radio to-1, we change it to 0 so that when you run the program you can see that the first radio button is selected. After that, you should also add a click response function with ClassWizard for three radio buttons, and modify the value of M_radio to correspond to three radio buttons.
At this static creation, the group property is manually specified. So how do you specify this property when you create it dynamically? I found a circle in all the methods, and I didn't find it.
That's where it's going to be set up, there's gotta be a way! That is the only way to save, is the ModifyStyle method, see if there is a corresponding style in this method!
I checked the style of the button first.
#defineBs_pushbutton 0x00000000l#defineBs_defpushbutton 0x00000001l#defineBs_checkbox 0x00000002l#defineBs_autocheckbox 0x00000003l#defineBs_radiobutton 0x00000004l#defineBs_3state 0x00000005l#defineBs_auto3state 0x00000006l#defineBs_groupbox 0x00000007l#defineBs_userbutton 0x00000008l#defineBs_autoradiobutton 0x00000009l#defineBs_pushbox 0x0000000al#defineBs_ownerdraw 0X0000000BL#defineBs_typemask 0X0000000FL#defineBs_lefttext 0x00000020l#if(WINVER >= 0x0400)#defineBs_text 0x00000000l#defineBs_icon 0x00000040l#defineBs_bitmap 0x00000080l#defineBs_left 0x00000100l#defineBs_right 0x00000200l#defineBs_center 0x00000300l#defineBs_top 0x00000400l#defineBs_bottom 0x00000800l#defineBs_vcenter 0x00000c00l#defineBs_pushlike 0x00001000l#defineBs_multiline 0x00002000l#defineBs_notify 0x00004000l#defineBs_flat 0x00008000l#defineBs_rightbutton Bs_lefttext#endif/* WINVER >= 0x0400 */
Find all the styles, there is no corresponding settings in the GROUP, and only a bs_groupbox, I tried, this style means that the button is transformed into a GROUPBOX, not the designated GROUP. No. In addition, you can only find a layer of style is the style of CWnd.
#defineWs_overlapped 0x00000000l#defineWs_popup 0x80000000l#defineWs_child 0x40000000l#defineWs_minimize 0x20000000l#defineWs_visible 0x10000000l#defineWs_disabled 0x08000000l#defineWs_clipsiblings 0x04000000l#defineWs_clipchildren 0x02000000l#defineWs_maximize 0x01000000l#defineWs_caption 0x00c00000l/* ws_border | Ws_dlgframe * *#defineWs_border 0x00800000l#defineWs_dlgframe 0x00400000l#defineWs_vscroll 0x00200000l#defineWs_hscroll 0x00100000l#defineWs_sysmenu 0x00080000l#defineWs_thickframe 0x00040000l#defineWs_group 0x00020000l#defineWs_tabstop 0x00010000l#defineWs_minimizebox 0x00020000l#defineWs_maximizebox 0x00010000l#defineWs_tiled ws_overlapped#defineWs_iconic ws_minimize#defineWs_sizebox Ws_thickframe#defineWs_tiledwindow Ws_overlappedwindow
There really is a ws_group, this is what I want, so
0);
Here's how to create a button group dynamically!
VC + + dynamically generate groups of RadioButton button groups