The ribbon controls and customizable toolbars are based on non-HWND
elements. So we will describe how to repaint a built-in text/combo field in the ribbon bar. You should use the following ribbon node class
class CRibbonNodeCustomComboBox : public CExtRibbonNode
{
public:
DECLARE_SERIAL( CRibbonNodeCustomComboBox );
CRibbonNodeCustomComboBox(
UINT nCmdIdBasic = 0L,
CExtRibbonNode * pParentNode = NULL,
DWORD dwFlags = __ECTN_TBB_COMBO,
LPARAM lParam = 0L
)
: CExtRibbonNode(
nCmdIdBasic,
nCmdIdBasic,
pParentNode,
dwFlags,
_T(""),
_T(""),
_T(""),
lParam
)
{
RibbonILE_RuleArrayGet().RemoveAll();
}
CRibbonNodeCustomComboBox(
CRibbonNodeCustomComboBox & other
)
: CExtRibbonNode( other )
{
RibbonILE_RuleArrayGet().RemoveAll();
}
virtual ~CRibbonNodeCustomComboBox();
{
}
virtual CRuntimeClass * _OnRibbonGetButtonRTC();
{
ASSERT_VALID( this );
RibbonILE_RuleArrayGet().RemoveAll();
return RUNTIME_CLASS( CCustomDrawnComboButton );
}
};
The
CCustomDrawnComboButton
is the name of your class which implements a custom-drawn combo field in toolbar. It should be derived from
CExtBarTextFieldButton
and implement the
CExtBarButton::PaintCompound()
virtual method like in this way:
class __PROF_UIS_API CCustomDrawnComboButton : public CExtBarTextFieldButton
{
public:
DECLARE_DYNCREATE( CCustomDrawnComboButton );
CCustomDrawnComboButton(
bool bComboField = flse,
INT nTextFieldWidth = __EXT_MENU_DEF_INPLACE_EDIT_WIDTH,
CExtToolControlBar * pBar = NULL,
UINT nCmdID = ID_SEPARATOR,
UINT nStyle = 0
);
: CExtBarTextFieldButton(
bComboField,
nTextFieldWidth,
pBar,
nCmdID,
nStyle
)
{
}
virtual ~CCustomDrawnComboButton()
{
}
virtual void PaintCompound(
CDC & dc,
bool bPaintParentChain,
bool bPaintChildren,
bool bPaintOneNearestChildrenLevelOnly
)
{
ASSERT_VALID( this );
ASSERT_VALID( (&dc) );
ASSERT( ! IsSeparator() );
if( ! IsPaintAble( dc ) )
return;
if( AnimationClient_StatePaint( dc ) )
return;
if( bPaintParentChain )
PaintParentChain( dc );
CRect rcTBB = *this;
if( ( ! IsVisible() )
|| ( GetStyle() & TBBS_HIDDEN) != 0
|| ( ! dc.RectVisible( &rcTBB ) )
)
return;
// TO-DO: Insert your combo box painting code here.
// (You can use the CExtBarTextFieldButton::PaintCompound() method as example)
if( bPaintChildren )
PaintChildren( dc, bPaintOneNearestChildrenLevelOnly );
}
};