The CExtBarButton::CanBePressedInDisabledState()
virtual method returns a flag which indicates whether disabled toolbar buttons are click-able. We have enabled mouse clicks and popup menu displaying from disabled toolbar buttons due to numerous customer requests. To disable this feature, you should use the following toolbar button class:
class CYourBarButton : public CExtBarButton
{
public:
DECLARE_DYNCREATE( CYourBarButton );
CExtBarColorButton( CExtToolControlBar * pBar = NULL, UINT nCmdID = ID_SEPARATOR, UINT nStyle = 0 )
: CExtBarButton( pBar, nCmdID, nStyle )
{
}
virtual bool CanBePressedInDisabledState()
{
ASSERT_VALID( this );
if( IsDisabled() )
return false;
return CExtBarButton::CanBePressedInDisabledState();
}
};
IMPLEMENT_DYNCREATE( CYourBarButton, CExtBarButton );
You will also need to create your
CExtToolControlBar
-derived class which implements the
CExtToolControlBar::OnCreateBarCommandBtn()
virtual method for instantiating instances the of your
CExtToolControlBar
class instead of
CExtBarButton
class:
CExtBarButton * CYourToolControlBar::OnCreateBarCommandBtn(
UINT nCmdID,
UINT nStyle // = 0
)
{
ASSERT_VALID( this );
CExtBarButton * pTBB = new CYourBarButton( this, nCmdID, nStyle );
ASSERT_VALID( pTBB );
return pTBB;
}
If you are using customizable toolbars, then you will also need to make customize site creating instances of the
CYourToolControlBar
toolbars. You should override the
CExtCustomizeSite::OnUserBarCreate()
virtual method:
virtual CExtToolControlBar * CExtCustomizeSite::OnUserBarCreate(
__EXT_MFC_SAFE_LPCTSTR strName,
UINT nBarID, // = 0 // 0-alloc any, other-alloc specified
bool bCreateInvisible, // = false
CExtToolControlBar * pBarNew // = NULL
)
{
__PROF_UIS_MANAGE_STATE;
if( pBarNew == NULL )
pBarNew = new CYourToolControlBar;
return CExtCustomizeSite::OnUserBarCreate( strName, nBarID, bCreateInvisible, pBarNew );
}