Resizable control bars

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

Add the m_wndResizableBar bar property of CExtControlBar type to your frame window declaration:

CExtControlBar m_wndResizableBar;

Add the resizable bar creation code to the OnCreate() method:

if( ! m_wndResizableBar.Create(
      _T( "Resizable bar name" ),
      this,
      ID_YOUR_RESIZABLE_BAR
      )
    )
{
    TRACE0( "Failed to create resizable bar" );
    return -1;
}

Create any window that you want to insert into the resizable bar and specify m_wndResizableBar as the parent of this window.

Now we need to enable the resizable bar to be docked. This can be done with two methods:

EnableDocking( &m_wndResizableBar ) //enables control bar to be docked
CExtControlBar::FrameEnableDocking(this)//single call for entire frame
//window; enables drag-n-drop of control bars inside frame

You can set the initial state of a resizable bar (docked, floating, or placed inside a tab container? if docked, then how exactly it should be docked?) with the following methods of CExtControlBar: DockControlBar(), DockControlBarIntoTabbedContainer() and FloatControlBar().

DockControlBar() allows you to dock a resizable bar with one of the frame sides: top, bottom, left, or right. Since resizable bars can be docked in a nested way, you should also specify a nested level with the second parameter, which must be equal to or greater than 1.

m_wndResizableBar.DockControlBar( AFX_IDW_DOCKBAR_LEFT, 1, this, false );

The second overload of DockControlBar() enables you to arrange a resizable bar relative to others, which are already docked. In the code below, first, the OtherBar bar is docked, and then it is placed next to the bar specified with m_wndResizableBar:

OtherBar.DockControlBar( AFX_IDW_DOCKBAR_LEFT, 1, this, false );
OtherBar.DockControlBar( &m_wndResizableBar, true, false, NULL, false );

The DockControlBarIntoTabbedContainer() method, as it is obvious from its name, allows you to place resizable bars inside the Prof-UIS tab container and FloatControlBar() makes resizable bars initially floating.

You may implement a Show or Show/Hide command for your resizable bar. For example, to toggle between the visible and invisible states, you need to add the following lines to the main frame window's message map:

ON_COMMAND_EX(ID_YOUR_RESIZABLE_BAR, OnBarCheck)
ON_UPDATE_COMMAND_UI(ID_YOUR_RESIZABLE_BAR, OnUpdateControlBarMenu)

To enable the auto hide feature for control bars, add the following lines:

if( !CExtControlBar::FrameInjectAutoHideAreas(this) )
{
    ASSERT( FALSE );
    return -1;
}

You may also add declaration and implementation code for the OnUpdateControlBarMenu() and OnBarCheck() methods. For example, if you use the auto hide feature and want to implement the ID_YOUR_RESIZABLE_BAR command, then you should add the following code to your application.

//declaration:
afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);
afx_msg BOOL OnBarCheck(UINT nID);
//implementation:
void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)
{
    // CFrameWnd::OnUpdateControlBarMenu( pCmdUI );
    CExtControlBar::DoFrameBarCheckUpdate(
        this,
        pCmdUI,
        false
      );
}
BOOL CMainFrame::OnBarCheck(UINT nID)
{
    // return CFrameWnd::OnBarCheck( nID );
    return
      CExtControlBar::DoFrameBarCheckCmd(
        this,
        nID,
        false
      );
}

In this case, the ID_YOUR_RESIZABLE_BAR command will only activate (or show) the resizable bar. You cannot hide it with the corresponding menu items. This behavior is implemented in the Visual Studio .NET IDE.