Radio Buttons

  1. Design a form shown below to get input from users.
    ex-radio.png
  2. There should be three groups of radio buttons. For each main radio button in a group, don't forget to set its Group property to True.
  3. To detect the state of the check box, you need to call the member function GetState() and use the bitwise AND to get the value of the flag BSD_CHECKED as follows:
    
    CButton* pCheckBox = static_cast(GetDlgItem(IDC_CHECK1));
    UINT nCheck = pCheckBox->GetState();
    if ( nCheck & BST_CHECKED)
    	m_str.SetAt(3, 'Y');
    else
    	m_str.SetAt(3, 'N');
    
    
  4. In your CView class, you may declare a private data member m_str with initial value _T("0000").
    1. The first character indicates the college:
      • H - Humanity
      • E - Education
      • M - Management
      • S - Science and Technology
    2. The second character indicates the gender:
      • 1 - Male
      • 2 - Female
    3. The third character indicates the grade:
      • 1 - Freshman
      • 2 - Sophomore
      • 3 - Junior
      • 4 - Senior
    4. The fourth character indicates whether the student agrees to the proposition or not.
      • Y - agree
      • N - disagree
  5. When the user clicks a radio button or the check box, the m_str data member is updated, the shown in the edit box.
  6. When the Clear button is clicked, all radio buttons and the check box are reset.
  7. When the Save button is clicked, the m_str is converted from Unicode to ASCII code by the macro CT2A(), and appended to a file "log.txt". You may want to automatically call the OnBnClickedButtonClear() to reset all radio buttons and the edit box.
  8. The "log.txt" file can be found under the same directory as your .cpp program. The path may be something like "D:\VisualStudio2010\Projects\questionnaire\questionnaire".