Custom dynamic control bars

Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

Dynamic control bars are designed to give you the maximum control over their properties and behavior. You create a CExtDynamicControlBar-derived class and modify the default behavior by overriding its virtual methods to completely meet your requirements. For example, you can override the CExtDynamicControlBar::OnSerializeDynamicProps() virtual method to serialize some properties of the child windows of your dynamic control bars:

virtual void OnSerializeDynamicProps( CArchive & ar )
{
// Serialize standard properties first
    CExtDynamicControlBar::OnSerializeDynamicProps( ar );
// Serialize the color of the child window or whatever you want here
    if( ar.IsStoring() )
        ar << m_clrEditorBackground;
    else
        ar >> m_clrEditorBackground;
}

NOTE: Do not forget to specify a name of your own CExtDynamicControlBar class as the fourth argument of the CExtDynamicBarSite::BarAlloc() method when you allocate instances of your custom class:

CExtDynamicBarSite::BarAlloc(
    strBarCaption,
    icon,
    0,
    RUNTIME_CLASS(CMyDynamicControlBar) //Should be inherited from CExtDynamicControlBar
);

Another example is the CExtDynamicControlBar::OnInitDbsMenu() method, which can be useful if you need to modify the pop-up menu with a list of dynamic control bars (see Figure 6). For instance, to add a separator, use code like this:

virtual bool OnInitDbsMenu (
    CExtPopupMenuWnd * pPopup,
    HWND hWndTrack,
    CObject * pHelperSrc,
    LPARAM lParamHelper = 0 
    )
{
    CExtDynamicControlBar::OnInitDbsMenu (
        pPopup,
        hWndTrack,
        pHelperSrc,
        lParamHelper 
        );
    pPopup->ItemInsert(
        (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR, 1);
    pPopup->ItemInsert(
        (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR, 3);
 
    return true;
}