A SMALL PROJECT USING CHECK BOXES AND RADIO BUTTONS


8.      A SMALL PROJECT USING CHECK BOXES AND RADIO BUTTONS

A SMALL PROJECT USING CHECK BOXES AND RADIO BUTTONS
Step 1:-Select a NEW file.
Step 2:-Select a project tab from new window and from that select MFC application wizard [exe] option and give a project name as Flowers and click ok.
Step3:-
Þ    MFC Application Wizard window is appeared.
Þ    Select dialog based settings in step1, click next.
Þ    Select default settings from step2 to step6 and click finish.
Þ    New projects information on window will appear and click ok.
Step 4:-Add controls to the dialog editor, add two group boxes and name one has arrangements and the other has flowers. The default ID, IDC_STATIC will be given by the dialog editor.
Step 5:-Add four radio buttons in the arrangement group box and align them, name the radio buttons as type1, type2, type3, type4. The default ID provided for the radio buttons are IDC_RADIO1…….IDC_RADIO2 and add 4 check boxes in the flowers group box, name them with different flowers names.

Step 6:-The default ID provided for check boxes IDC_CHECK1……….IDC_CHECK4.
Step 7:- Drag and drop static text control(label) and one edit box, name the static text control as price.
Step 8:-view->class wizard->member variables->add variable->click IDC_CHECK1->add variable give name as m_check1 and make sure, the category is value and variable is bool. Make this same for other boxes with their respective names as m_check2……m_check4 and add a member variable m_text to the text in a text box.
Step 9:-view-> class wizard->message maps, under class name(CFlowersDlg) select the object ID’S IDC_RADIO1->BN_CLICKED-> OnRadio1()->ok. Do the same for remaining three radio buttons.
Step 10:-under class view or flowersDlg.cpp file, under on radio1 method, write the following code.
                        void CFlowersDlg::OnRadio1()
                        {
                                    m_check1 = true;
                                    m_check2 = true;
                                    m_check3 = true;
                                    m_check4 = true;
                                    m_text = “$4.36”;
                                    UpdateData(false);

                        }
void CFlowersDlg::OnRadio2()
                        {
                                    m_check1 = false;
                                    m_check2 = false;
                                    m_check3 = true;
                                    m_check4 = true;
                                    m_text = “$5.22”;
                                    UpdateData(false);
                        }
                        void CFlowersDlg::OnRadio3()
                        {
m_check1 = true;
                                    m_check2 = false;
                                    m_check3 = true;
                                    m_check4 = false;
                                    m_text = “$2.26”;
                                    UpdateData(false);
                        }
                        void CFlowersDlg::OnRadio4()
                        {
                                    m_check1 = true;
                                    m_check2 = false;
                                    m_check3 = false;
                                    m_check4 = true;
                                    m_text = “$4.36”;
                                    UpdateData(false);
                        }
Step 11:-Build………..Compile………….Execute.

No comments:

Post a Comment