Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtCheckBox on toolbar Collapse All
Subject Author Date
Darius Mikalauskas Nov 28, 2007 - 8:34 AM

Hello,

how properly handle CExtCheckBox button on toolbar. I created it as described in example with combo box, but after button is checked and mouse pointer is removed from button- sometimes button unchecks.

Thank you in advance.
Darius

Technical Support Nov 29, 2007 - 2:14 PM

A CExtToolControlBar window contains a set of CExtBarButton-based objects implementing toolbar buttons. These objects are non-HWND based UI elements. If a button common control is attached to a toolbar button object (push button, check box or radio button), then the checked/pressed state of button window is controlled by MFC’s command updating mechanism which should be used to set checked/unchecked state of the button. It’s not recommended to attach button common controls to button objects inside the CExtToolControlBar window. Please use a non-HWND based CExtBarCheckBoxButton object instead. It works exactly like a simple toolbar button but has a look like a check box common control with a consistent toolbar background. By default, the CExtBarCheckBoxButton window instantiates CExtBarButton objects for all its buttons. You can insert a CExtBarCheckBoxButton check box button or any other type of toolbar button (color picker, undo/redo, etc.) by invoking the CExtToolControlBar::InsertSpecButton() method. Alternatively you can create and use a custom CExtToolControlBar-derived class which implements CExtToolControlBar::OnCreateBarCommandBtn()

class CMyToolBar : public CExtToolControlBar
{
public:
      virtual CExtBarButton * OnCreateBarCommandBtn(
            UINT nCmdID,
            UINT nStyle = 0
            )
      {
            ASSERT_VALID( this );
            if( nCmdID == ID_YOUR_CHECK_BOX_BUTTON_IN_TOOLBAR )
            {
                  CExtBarCheckBoxButton * pCheckBoxTBB = new CExtBarCheckBoxButton ( this, nCmdID, nStyle );
                  ASSERT_VALID( pCheckBoxTBB );
                  return pCheckBoxTBB;
            }
            return CExtToolControlBar::OnCreateBarCommandBtn( nCmdID, nStyle );
      }
};