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 Tech Support » Controlling Docking Programatically Collapse All
Subject Author Date
Andrew Harding Jan 11, 2006 - 9:20 AM

Say that I have 2 CExtControlBar’s which are docked on a CFrameWnd.  I then drag one of the docked windows onto the other so that they both take up 100% of the CFrameWnd’s client area.  The user can click a tab to bring that window to the foreground, essentially it has turned the windows into a tab pane.  See diagram below:


-----------------
|                   |
|                   |
|                   |
|                   |
|                   |
|_a_|_b_|````



I would like to be able to do this programatically.  With that in mind:


1. How do I make one CExtControlBar dock onto another one as seen above?
2. How do I determine the tab order?
3. How do I re-arrange the tab order?
4. How do I tell what docking state a window is in? ie: AFX_IDW_DOCKBAR_LEFT

Technical Support Jan 12, 2006 - 1:08 PM

The CExtControlBar::DockControlBarIntoTabbedContainer() performs the tabbed bar docking. You should dock or float one bar initially and then tab-dock other bars with it. Here is the sample code:

    m_wndBarA.DockControlBarInnerOuter(
        AFX_IDW_DOCKBAR_LEFT, true );
    wndBarA.DockControlBarIntoTabbedContainer(
        &wndBarB, -1, NULL, false );
    wndBarA.DockControlBarIntoTabbedContainer(
        &wndBarC, -1, NULL, false );
    wndBarA.DockControlBarIntoTabbedContainer(
        &wndBarD, -1, NULL, false );
This source code docks the m_wndBarA bar to the left inner part of the main frame window. Then the m_wndBarB, m_wndBarC and m_wndBarD bars are tab-docked into the m_wndBarA bar’s area.

Here is the declaration of the CExtControlBar::DockControlBarIntoTabbedContainer() method:
    virtual bool DockControlBarIntoTabbedContainer(
        CExtControlBar * pBar,
        INT nIndex = -1, // append
        CFrameWnd * pDockSite = NULL, // can be NULL only if bar already was at once docked
        bool bRecalcLayout = true
        );
The nIndex parameter allows you to specify where the newly tab-docked bar should appear. The CExtControlBar::DockControlBarIntoTabbedContainer() method can be used both for initial docking and for re-docking with re-arranging the tab order. Detecting the tab-order is a bit more complex task. First of all you should include the following file:
#include <../Src/ExtControlBarTabbedFeatures.h>
This is essential because we will detect the type of bar’s parent window:
CWnd * pWndParent = m_wndBarA.GetParent();
    if( ! pWndParent->IsKindOf( RUNTIME_CLASS( CExtDockDynTabBar ) ) )
        return; // bar A is not inside the tabbed bar container
Now we can get a pointer to the tabbed control bar window which is also derived from the CExtControlBar class:
CExtDynTabControlBar * pTabbedBar =
        STATIC_DOWNCAST( CExtDynTabControlBar, pWndParent->GetParent() );
Now we can detect how much bars are inside the tabbed bar group, traverse them and detect whether each of them is visible (the tabbed bar group may contain invisible bars and tabs):
LONG nBarIndex, nBarCount = pTabbedBar->GetSwitcherItemCount();
    for( nBarIndex = 0; nBarIndex < nBarCount; nBarIndex ++ )
    {
        CExtControlBar * pBar = pTabbedBar->GetBarAt( nBarIndex, false );
        BOOL bBarIsVisible = pBar->IsVisible();
    }
We can also get the selection and change it:
LONG nSel = pTabbedBar->GetSwitcherSelection();
 
pTabbedBar->SetSwitcherSelection( new_selected_index, true, true );


Andrew Harding Jan 12, 2006 - 2:06 PM

Thank you, I appreciate the extra effort you put into the response.