我知道我可以为一组单选按钮创建一个整数变量,将其设置为一个整数,然后调用UpdateData(FALSE)使窗口突出显示适当的单选按钮控件。但是,我可能希望使用CButton控件,但是我不知道如何设置CButton状态,以便选中组中的特定单选按钮。有没有可能对MFC这样做呢?提前谢谢。
发布于 2009-06-18 20:25:02
因为我只需要在启动或重置状态时设置状态,所以在将它们切换到on之前,我将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);
...
}https://stackoverflow.com/questions/1010297
复制相似问题