Win32 / WTL-我的复选框图像列表状态恢复为未选中状态

发布于 2024-09-11 08:06:14 字数 1281 浏览 3 评论 0原文

我正在 WTL 中创建一个自定义窗口来保存 DirectShow 应用程序的视频控件。

我创建了一组复选框,我希望它们以“类似推”的方式运行(BS_PUSHLIKE)。它们在对话框的 .rc 文件中定义如下:

CONTROL         "",IDC_VID1,"Button",BS_AUTOCHECKBOX | BS_BITMAP | BS_PUSHLIKE | WS_GROUP | WS_TABSTOP,6,7,19,18

我还加载了按钮的图像列表,当按钮处于 LButtonDown 和 LButtonUp 状态时,它可以正确显示相应的图像:

在下面的代码中,定义了 m_btnVid1作为 WTL::CBitmapButton

m_ilBtnVid1.CreateFromImage( IDB_TV, 25, 1, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION );
m_btnVid1.SubclassWindow( (HWND) ::GetDlgItem(m_hWnd, IDC_VID1) );
m_btnVid1.SetImageList( m_ilBtnVid1.m_hImageList );
m_btnVid1.SetImages(0,1);

一旦我释放鼠标按钮,复选框状态就会恢复为“未选中”状态。

我已将 COMMAND_ID_HANDLER_EX 添加到 IDC_VID1 控件以确定控件的状态,但 nState 变量始终读取 0:

void OnVid1(UINT uNotifyCode, int nID, CWindow wndCtl)
{       
    CBitmapButton* btn = &m_btnVid1;
    int nState = btn->GetCheck();       

    switch( nState )
    {
        case BST_UNCHECKED:
            btn->SetCheck( BST_CHECKED );
            nState = btn->GetCheck();
            break;

        default:
            btn->SetCheck( BST_UNCHECKED );
            break;
    }
}

任何人都可以建议为什么这可能是 - 我是否缺少 CBitmapButton 中的创建样式?

如果有帮助,我确信我可以以某种方式在线发布 VC2008 解决方案文件。

I'm creating a custom window in WTL to hold video controls for a DirectShow app.

I've created a set of check boxes that I wish to behave in the "push like" manner (BS_PUSHLIKE). They appear defined in the .rc file for the dialog like so:

CONTROL         "",IDC_VID1,"Button",BS_AUTOCHECKBOX | BS_BITMAP | BS_PUSHLIKE | WS_GROUP | WS_TABSTOP,6,7,19,18

I've also loaded an image list for the button, which correctly shows the appropriate image when the button is in LButtonDown and LButtonUp states:

In the code below, m_btnVid1 is defined as a WTL::CBitmapButton

m_ilBtnVid1.CreateFromImage( IDB_TV, 25, 1, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION );
m_btnVid1.SubclassWindow( (HWND) ::GetDlgItem(m_hWnd, IDC_VID1) );
m_btnVid1.SetImageList( m_ilBtnVid1.m_hImageList );
m_btnVid1.SetImages(0,1);

As soon as I release the mouse button, the checkboxes state reverts to "unchecked" state.

I've added a COMMAND_ID_HANDLER_EX to the IDC_VID1 control to determine the state of the control, but the nState variable always reads 0:

void OnVid1(UINT uNotifyCode, int nID, CWindow wndCtl)
{       
    CBitmapButton* btn = &m_btnVid1;
    int nState = btn->GetCheck();       

    switch( nState )
    {
        case BST_UNCHECKED:
            btn->SetCheck( BST_CHECKED );
            nState = btn->GetCheck();
            break;

        default:
            btn->SetCheck( BST_UNCHECKED );
            break;
    }
}

Can anyone suggest why this might be - am I missing a creation style in the CBitmapButton?

If it helps, I'm sure I can post the VC2008 solution file online somehow.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文