We failed reproduce the sticking menu problem. We checked both XP and Vista.
If you need custom ribbon buttons, you should implement two C++ classes. The first is a CExtBarButton
-derived class which implements the CExtBarButton::CalculateLayout()
and CExtBarButton::PaintCompound()
virtual methods.
class CYourBarButton : public CExtBarButton
{
public:
DECLARE_DYNCREATE( CYourBarButton );
CYourBarButton( CExtToolControlBar * pBar = NULL, UINT nCmdID = ID_SEPARATOR, UINT nStyle = 0 )
: CExtBarButton( pBar, nCmdID, nStyle )
{
}
virtual CSize CalculateLayout( CDC & dc, CSize sizePreCalc, BOOL bHorz )
{
. . .
}
virtual void PaintCompound( CDC & dc, bool bPaintParentChain, bool bPaintChildren, bool bPaintOneNearestChildrenLevelOnly )
{
if( ! IsPaintAble( dc ) )
return;
if( AnimationClient_StatePaint( dc ) )
return;
if( bPaintParentChain )
PaintParentChain( dc );
. . .
}
};
IMPLEMENT_DYNCREATE( CYourBarButton, CExtBarButton )
The second is a
CExtRibbonNode
-derived class which should be used in ribbon tree and which creates your
CYourBarButton
button instance:
class CYourRibbonNode : public CExtRibbonNode
{
public:
DECLARE_SERIAL( CYourRibbonNode );
CYourRibbonNode(
UINT nCmdIdBasic = 0L, UINT nCmdIdEffective = 0L, CExtRibbonNode * pParentNode = NULL, DWORD dwFlags = 0L,
__EXT_MFC_SAFE_LPCTSTR strTextInToolbar = NULL, __EXT_MFC_SAFE_LPCTSTR strTextInMenu = NULL, __EXT_MFC_SAFE_LPCTSTR strTextUser = NULL,
LPARAM lParam = 0L, CExtCmdIcon * pIconCustomized = NULL
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
, INT nTextFieldWidth = 100,
INT nDropDownWidth = -2, // (-1) - auto calc, (-2) - same as button area
INT nDropDownHeightMax = 250
#endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
)
: CExtRibbonNode (
nCmdIdBasic, nCmdIdEffective, pParentNode, dwFlags, strTextInToolbar, strTextInMenu, strTextUser, lParam, pIconCustomized
#if (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
, nTextFieldWidth, nDropDownWidth, nDropDownHeightMax
#endif // (!defined __EXT_MFC_NO_BUILTIN_TEXTFIELD)
)
{
}
CYourRibbonNode(
CYourRibbonNode & other
)
: CExtRibbonNode( other )
{
}
virtual CRuntimeClass * _OnRibbonGetButtonRTC()
{
return ( RUNTIME_CLASS( CYourBarButton ) );
}
};
IMPLEMENT_SERIAL( CYourRibbonNode, CExtRibbonNode, VERSIONABLE_SCHEMA|1 );