BCGControlBar Pro for MFC
virtual CBCGPDockingControlBar* CBCGPDockingControlBar::AttachToTabWnd ( CBCGPDockingControlBar pTabControlBarAttachTo,
BCGP_DOCK_METHOD  dockMethod,
BOOL  bSetActive = TRUE,
CBCGPDockingControlBar **  ppTabbedControlBar = NULL 
)
virtual

Attaches the control bar to another control bar creating a tabbed control bar.

Returns
A pointer to this control bar, if this control bar is not a tabbed control bar; otherwise it returns a pointer to a tabbed control bar this bar has been attached to. The return value is NULL if this control bar or another control bar are non-attachable or another error occurs.

When one docking control bar is being attached to another control bar using the AttachToTabWnd() method, the following occures:

  1. The framework checks whether the target control bar pTabControlBarAttachTo is a regular docking control bar or derived from CBCGPBaseTabbedBar.
  2. If the target bar is a tabbed control bar, this bar is simply added to it as a new tab.
  3. If the target bar is a regular docking control bar, a new tabbed control bar is created.
    • The framework calls pTabControlBarAttachTo->CreateTabbedControlBar. The style of the newly created tabbed control bar (regular or outlook) depends on the m_pTabbedControlBarRTC member. This member is set by default to the runtime class of CBCGPTabbedControlBar. If you pass CBRS_BCGP_OUTLOOK_TABS style as the dwTabbedStyle parameter to the Create() function, the runtime class object will be set to the runtime class of CBCGPOutlookBar. You can alter this member anytime changing the style of the resulted control bar.
    • When a new tabbed control bar is created, the framework replaces the pointer to pTabControlBarAttachTo control bar in its container (if the bar is docked or floating in multiminiframe window) to a pointer to the newly created tabbed control bar.
    • The pTabControlBarAttachTo control bar is added to the created tabbed control bar as a first tab and then adds this control bar as a second tab.
  4. If this control bar (the bar that is being attached) is derived from CBCGPBaseTabbedBar, all its tabs are moved from this control bar to pTabControlBarAttachTo and this control bar is destroyed. Therefore, you need to take care when calling the AttachToTabWnd method, because a pointer to the control bar being attached may be invalid when the function returns.

If you attach one bar to another while building a docking layout, set dockMethod to BCGP_DM_SHOW.

The following example creates a tabbed control bar dynamically, attaching the ResourceView bar to the ClassView bar, adds the third FileView bar and makes the second tab non-detachable.

Copy
DockControlBar(&m_wndClassView);
CBCGPTabbedControlBar* pTabbedBar = NULL;
m_wndResourceView.AttachToTabWnd(&m_wndClassView, BCGP_DM_SHOW, TRUE, (CBCGPDockingControlBar**) &pTabbedBar);
m_wndFileView.AttachToTabWnd(pTabbedBar, BCGP_DM_SHOW, TRUE, (CBCGPDockingControlBar**) &pTabbedBar);
pTabbedBar->GetUnderlinedWindow()->EnableTabDetach(1, FALSE);

It's recommended to dock the first control bar before you attach the second control bar to it.

See also
CBCGPFrameWnd::DockControlBar, CBCGPBaseTabbedBar, CBCGPTabbedControlBar, CBCGPOutlookBar, CBCGPBaseTabWnd, CBCGPBarContainer
Parameters
pTabControlBarAttachToA pointer to a docking control bar (target bar) this docking control bar will be attached to.
dockMethodSpecifies the docking method.
bSetActiveSpecifies whether the attached bar should be activated.
ppTabbedControlBarOut parameter. When the function returns it contains a pointer to the tabbed control bar this bar has been attached to.