Win32 / WTL-我的复选框图像列表状态恢复为未选中状态
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论