开发者

Win32 / WTL- My Checkbox imagelist state reverts to unchecked state

开发者 https://www.devze.com 2023-01-08 18:48 出处:网络
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 define

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 so开发者_高级运维mehow.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号