我在基于对话框的应用程序中添加了一个radio box并起了个资源名叫IDC_Ryes,但不知如何为其在class wizard/member variables中为其添加一个相对应的成员变量。请赐教。

解决方案 »

  1.   

    MFC中并没有提供现成的CRadio类,其实对一组Radio进行操作的话,使用API函数CheckRadioButton即可。
    BOOL CheckRadioButton(    HWND hDlg, // handle to dialog box
        int nIDFirstButton, // identifier of first radio button in group
        int nIDLastButton, // identifier of last radio button in group
        int nIDCheckButton // identifier of radio button to select
       );
      

  2.   

    能否给出一个具体的例程?我想得到哪一个radio box被选中。
      

  3.   

    如果在程序中标识各radio box?帮助中所说的integer identifier是指什么?
      

  4.   

    如果你要获得哪一个按钮被选中,则需要用一个循环遍历这组Radio的ID,在循环中使用IsDlgButtonChecked函数。
    int GetCheckedRadio(HWND hDlg, int nFirst, int nLast)
    {
      int nResult;
      for (int i = nFirst; i <= nLast; i++)
        if (BST_CHECKED == IsDlgButtonChecked(hDlg, i))
          nResult = i;
      return nResult;
    }
      

  5.   

    想知道ID,打开resource.h看看就知道了。