1. Group Single-choice buttons:
Set attributes for the first single-choice button in each group: group, tabstop, and auto. Set attributes for other buttons: tabstop and auto.
For example:
Radio1, Radio2, and radio3 are a group, and radio4 and radio5 are a group.
Set radio1 attributes: group, tabstop, auto
Set the Radio2 attribute: tabstop, auto
Set the radio3 attribute: tabstop, auto
Set radio4 attributes: group, tabstop, and auto
Set the radio5 attribute: tabstop, auto
2. Use classwizard to define variables for single-choice controls. Each group can only define one variable. For example, m_radio1 and m_radio4.
3. Use classwizard to generate the click message function of each radio button and add the following content:
Void cweditview: onradio1 ()
{
M_radio1 = 0; // The first radio button is selected.
}
Void cweditview: onradio2 ()
{
M_radio1 = 1; // The second radio button is selected.
}
Void cweditview: onradio3 ()
{
M_radio1 = 2; // The third radio button is selected.
}
Void cweditview: onradio4 ()
{
M_radio4 = 0; // The fourth radio button is selected.
}
Void cweditview: onradio5 ()
{
M_radio4 = 1; // The fifth radio button is selected.
}
When the control variable value is 0, the first radio button of the corresponding group is selected.
Bool cdzyapp: initinstance ()
...{
Afxenablecontrolcontainer ();
......
// The one and only window has been initialized, so show and update it.
M_pmainwnd-> setwindowpos (null, 750,555, 750, swp_nomove); // set the initial size of the window to 555 *
M_pmainwnd-> showwindow (sw_show );
M_pmainwnd-> updatewindow ();
Return true;
}
M_pmainwnd-> centerwindow (getdomaintopwindow ());
Int cmainframe: oncreate (maid ){
If (cframewnd: oncreate (lpcreatestruct) =-1)
Return-1;
......
// Todo: delete these three lines if you don't want the toolbar
// Be dockable
M_wndtoolbar.enabledocking (cbrs_align_any );
Enabledocking (cbrs_align_any );
Dockcontrolbar (& m_wndtoolbar );
Centerwindow (getshorttopwindow (); // place the window in the center of the screen when it is opened
Return 0;
}
Bool ctexteditordoc: onnewdocument (){
If (! Cdocument: onnewdocument ())
Return false;
// Todo: Add reinitialization code here
// (SDI documents will reuse this document)
Settitle ("Unnamed .txt"); // you can specify the document title.
Return true;
}