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 General Discussion » how to insert a CWnd-derived class into CExtRibbonBar? Collapse All
Subject Author Date
Vladimir VladimirKozatchenko Jun 3, 2007 - 1:21 PM

Hello Guys,

subj, basically.
has anybody tried this?

Vladimir

PS:
also, an alternative solution to my "problem" would be to be able to use combobox-node-standard-node (__ECTN_TBB_COMBO) but to be able to draw the both drop-down part of it and normal state (it is a part ot Ribbon itself... according to the spy++)

Vladimir VladimirKozatchenko Jun 6, 2007 - 1:41 AM

It is clear!
Thank you for the explanation.
Vlad

Technical Support Jun 4, 2007 - 3:55 AM

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 );
      }
};