Customization Tips for the MFC Extensions

This topic provides some tips for customizing your application by using the Visual C++ 2008 Feature Pack. This is not a complete list of customizations that are available with the Visual C++ 2008 Feature Pack, but it will get you started. The topic also discusses things that you should consider when you use some of the new features.

General Customizations

You can save and load the state of your application to the registry. When you enable this option, your application will load its initial state from the registry. If you change the initial docking layout for your application, you will have to clear the registry data for your application. Otherwise, the data in the registry will override any changes that you made to the initial layout.

CBasePane Tips

The Visual C++ 2008 Feature Pack introduces dockable control bars, known as panes. The following customization tips deal with the CBasePane Class and any classes that inherit from it:

  • When you create a new pane, you can apply several new styles:

    • AFX_CBRS_FLOAT - makes the pane float.

    • AFX_CBRS_AUTOHIDE - enables auto-hide mode.

    • AFX_CBRS_CLOSE - pane can be closed (hidden).

    These are flags that you can combine with a bitwise-OR operation.

    CBasePane implements the following virtual Boolean methods to reflect these flags: CBasePane::CanBeClosed, CBasePane::CanAutoHide, CBasePane::CanFloat. You can override them in derived classes to customize their behavior.

  • You can customize docking behavior by overriding CBasePane::CanAcceptPane. Have your pane return FALSE from this method to prevent another pane from docking to it.

  • If you want to create a static pane that cannot float and that prevents any other pane from docking before it (similar to the Outlook bar in the OutlookDemo example), create it as non-floating and override CBasePane::DoesAllowDynInsertBefore to return FALSE. The default implementation returns FALSE if the pane is created without AFX_CBRS_FLOAT style.

  • Create all panes with IDs other than -1.

  • To determine pane visibility, use CBasePane::IsVisible. It correctly handles the visibility state in tabbed and auto-hide modes.

  • If you want to create a non-floating resizable pane, create it without AFX_CBRS_FLOAT style and call CFrameWnd::DockControlBar.

  • To exclude a pane from a docking layout or to remove a toolbar from its dock bar, call CBasePane::UndockPane. Do not call this method for panes in auto-hide mode or for panes that reside in tabs of tabbed windows.

  • If you want to float or undock a pane that is in auto-hide mode, you must call CDockablePane::SetAutoHideMode with FALSE as the first argument before you call CBasePane::FloatPane or CBasePane::UndockPane.

Tab Control Customizations

The Visual C++ 2008 Feature Pack expands the functionality of the tab control. The following tips deal with the CMFCBaseTabCtrl Class and any classes that inherit from it:

  • If you enable detachable tabs, do not keep pointers to the tabbed windows. These detachable tabs can be created and destroyed dynamically. Therefore, pointers can become invalid.

  • You can configure the tab control so that users can move tabs dynamically on a tab control by using the mouse. This functionality is built into the CMFCBaseTabCtrl class. To enable it, call CMFCBaseTabCtrl::EnableTabSwap.

  • By default, tabs are detachable when you add them to a tab control. You can also add non-detachable tabs by using CMFCBaseTabCtrl::AddTab. If you set the parameter bDetachable to FALSE, the tab will not be detachable. You can also change whether tabs are detachable by calling the method CMFCBaseTabCtrl::EnableTabDetach.

  • Any objects that are derived from the CWnd Class can be put on a dockable control bar or dockable tab. For the whole control to be docked, you must make the CWnd object dockable. To accomplish this, the Visual C++ 2008 Feature Pack uses a wrapper class. This wrapper class is the CDockablePaneAdapter Class. Any CWnd objects that are added to a dockable control bar or dockable tab will be wrapped inside a CDockablePaneAdapter object. You can disable the automatic wrapping by setting the parameter m_bEnableWrapping of your CMFCBaseTablCtrl object to FALSE. You can also change what class your application will use as a wrapper by using the method CMFCBaseTabCtrl::SetDockingBarWrapperRTC.

CDockingManager Tips

The following tips apply to CDockingManager objects:

CDockablePane Tips

The following tips apply to CDockablePane objects:

  • If you call CDockablePane::AttachToTabWnd for two non-tabbed, dockable panes, a pointer to a tabbed window will be returned in the ppTabbedControlBar parameter. You can continue adding tabs to the tabbed window by using this parameter.

  • The type of tabbed pane that is created by CDockablePane::AttachToTabWnd is determined by the CDockablePane object in the pTabControlBarAttachTo parameter. You can call CDockablePane::SetTabbedPaneRTC to set the type of tabbed pane that the CDockablePane will create. The default type is determined by the dwTabbedStyle of CDockablePane::Create when you first create the CDockablePane. If dwTabbedStyle is AFX_CBRS_OUTLOOK_TABS the default type is CMFCOutlookBar Class; if dwTabbedStyle is AFX_CBRS_REGULAR_TABS the default type is CTabbedPane Class.

  • If you want to dock one dockable pane to another, you call the CDockablePane::DockToWindow method. The original pane must be docked somewhere before you call this method.

  • The member variable CDockablePane::m_bHideInAutoHideMode controls how dockable panes behave in auto hide mode when you call CDockablePane::ShowPane. If this member variable is set to TRUE, dockable panes and their auto hide buttons will be hidden. Otherwise, they will slide in and out.

  • You can disable auto hide animation by setting the CDockablePane::m_bDisableAnimation member variable to TRUE.

See Also

Concepts

MFC Feature Pack for Visual C++ 2008