MFC:CButton 突出显示一组单选按钮

发布于 2024-07-25 01:15:39 字数 155 浏览 1 评论 0原文

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

I know that I can create an integer variable for a group of radio buttons, set it to an integer, and then call UpdateData(FALSE) to make the window highlight the appropriate radio button control. However, I would like to perhaps use a CButton control instead, but I don't know how to set the CButton state so that a particular radio button of the group is checked. Is it even possible to do so for MFC? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清眉祭 2024-08-01 01:15:40

由于我只需要在启动或重置状态时设置状态,因此在将 CButton 控件打开之前,我将 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);
    ...
}

As I only need to set the states upon startup or reset states, I linked the CButton control with the appropriate id flag for the CButton control before switch them to on. The CButton control can later contain other values as onclicked() handlers are used for me to map selected radio button values properly.

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);
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文