Auto-Hide Docking Windows
Auto-hide docking windows are similar to the pinnable windows in Visual Studio. They are an extension to the Docking Windows architecture that deals specifically with the SECControlBar class. With this new feature, you can unpin a control bar, essentially hiding it while still keeping it docked to the corresponding dockbar. To unpin a control bar, simply click the pin button.
When a control bar is unpinned, a new control bar (the SECAutoHideBar) is displayed adjacent to the corresponding dockbar region (i.e., top, bottom, left, right). It will display a tab along that dockbar region for the newly hidden docking window. When the mouse is over the tabs of the auto-hide bar, the corresponding docking window is displayed in floating mode next to the auto hide bar. These floating windows can be repinned by clicking the pin button. This will, in turn, redock the docking window control bar in the position it was in previous to unpinning.
SECControlBars can be placed in the top dockbar region, but the top docking region is not limited to toolbars and menubars. To preserve the state of any existing SECControlBars that may be docked to the top, the auto-hide bar is docked to the very bottom of the top dockbar region. The auto-hide bar will be the last bar in the last row of control bars.
This means that any SECControlBars you dock to the top dockbar region will be displayed above the Auto Hide Bar. In order to keep the behavior of the auto -hide windows consistent, we do not recommend top docking auto-hide windows, even though it’s possible to do so.
If you must dock to the top and want to specify, for example, that certain derived objects cannot dock above toolbars and menubars, consider overriding OnLButtonUp() and specifying where the control bar should be docked. For more information, see the description of the SECMDIFrameWnd::DockControlBarEx() function in the Objective Toolkit Class Reference Guide.
Auto Hide is used with the existing SECFrameWnd and SECMDIFrameWnd classes.
Features
Auto Hide features include vertical frame docking, auto hide pins, vertical/horizontal text, floating grippers, auto-hide icons, and active windows.
Vertical Frame Docking
You can control the order of docking, allowing control bars to take up the full frame vertically. By default, docking order priority is Top, Bottom, Left, Right, with Top and Bottom docking taking priority across the frame.
You can specify the order of docking alignment by calling EnableDocking() from the frame class with all four alignment flags called separately. Calling EnableDocking with CBRS_ALIGN_ANY gives the default docking order. CBRS_ALIGN_ANY is called only once. If you specify the docking order, EnableDocking() is called exactly four times, as follows:
 
CMainFrame::OnCreate()
{
//Let’s specify the docking order.
EnableDocking(CBRS_ALIGN_TOP);
EnableDocking(CBRS_ALIGN_LEFT);
EnableDocking(CBRS_ALIGN_RIGHT);
EnableDocking(CBRS_ALIGN_BOTTOM );
...
}
Auto-Hide Pins
Auto-hide pins are displayed in the gripper bar of control bar windows that can be docked. Vertical pins represent a docked state.
Vertical/Horizontal Text
Text draws horizontally as well as vertically, depending on how the hidden control bar was previously docked.
Floating Grippers
Floating, or unpinned, auto-hide windows display the gripper horizontally across the top. The auto-hide pin is displayed on its side to represent an unpinned, or hidden, state. Since auto-hide docking windows need a gripper, set the following style flags:
 
CBRS_EX_COOL
CBRS_EX_BORDERSPACE
CBRS_EX_FLATSTYLE
Icons
Assigning an icon to a control bar that has auto-hide properties is optional but recommended. Hidden control bars that do not have an icon associated with them, such as the Output Window, display full text in the Auto Hide Bar. To set an icon to an auto-hide docking window, use the MFC function SetIcon(). You’ll need to pass as a parameter the handle to an icon that has already been loaded, such as via LoadIcon(). The following is an example:
 
HICON hndlYourIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
m_wndYourAutoHideCtrlBar.SetIcon(hndlYourIcon, FALSE);
Active Windows
Active displayed windows that are unpinned expand to text in the Auto Hide Bar. Inactive windows are displayed as icons. Hidden windows that are the only bar attached to an Auto Hide Bar, or that don’t have an icon associated with them, are always displayed as full text.
The delay of the active auto-hide window’s disappearance is set with SECControlBar’s SetAutoHideDelay() with a DWORD value in milliseconds. By default, it is set to 10 milliseconds.
Creating Auto-Hide Docking Windows
Your frame class should be derived from SECFrameWnd if you want SDI capability or from SECMDIFrameWnd is you want MDI capability. Auto-hide docking windows are SECControlBar-derived classes, with the SetAutoHide (TRUE) function called. By default, SECControlBar classes do not have Auto Hide enabled. As noted in “Floating Grippers” creation of the control bar should contain the CBRS_EX_COOL, CBRS_EX_BORDERSPACE, and CBRS_EX_FLATSTYLE style flags.
Following is an example showing how to turn a SECControlBar class into an Auto Hide enabled docking window:
 
//Project Workspace Window
if (!m_wndProjectWorkspace.Create(this,_T(“Project Workspace”),
CBRS_RIGHT | WS_VISIBLE | CBRS_SIZE_DYNAMIC,
CBRS_EX_STDCONTEXTMENU | CBRS_EX_ALLOW_MDI_FLOAT |
CBRS_EX_COOL | CBRS_EX_BORDERSPACE | CBRS_EX_FLATSTYLE,
ID_PROJECTWORKSPACE))
{
TRACE(_T(“Failed to create dialog bar\n”));
return -1;
}
m_wndProjectWorkspace.EnableDocking(CBRS_ALIGN_ANY);
DockControlBarEx(&m_wndProjectWorkspace, AFX_IDW_DOCKBAR_RIGHT, 0,
0 (float)1.00, 220);
HICON hicPW = AfxGetApp()->LoadIcon(IDI_ICON1);
m_wndProjectWorkspace.SetIcon(hicPW, FALSE);
m_wndProjectWorkspace.SetAutoHide(TRUE);
NOTE >> To see the complete implementation of auto-hide docking windows, see the Viz sample located at <installdir>\Samples\Toolkit\MFC\Docking\Viz\.