我知道我可以为一组单选按钮创建一个整数变量,将其设置为整数,然后调用UpdateData(FALSE)使窗口高亮显示相应的单选按钮控件。但是,我想使用CButton控件,但我不知道如何设置CButton状态,以便检查组中的特定单选按钮。甚至可以为MFC这样做吗?提前谢谢。

有帮助吗?

解决方案

由于我只需要在启动或重置状态时设置状态,我将CButton控件与CButton控件的相应id标志相关联,然后再将其打开。 CButton控件稍后可以包含其他值,因为onclicked()处理程序用于我正确映射选定的单选按钮值。

void UserControls::DoDataExchange(CDataExchange* pDX)
{
    ...
    // Mapping the integer variables to the Radio control for proper
    // displaying
    // not the id of the first radio button of the group for both of them
    DDX_Control(pDX, IDC_NOBTL, nobCtrl);         
    DDX_Control(pDX, IDC_UIHARD, uiCtrl);
    ...
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top