CMFCAutoHideButton Class

A button that displays or hides a CDockablePane Class that is configured to hide.

For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

Syntax

class CMFCAutoHideButton : public CObject

Members

Public Methods

Name Description
CMFCAutoHideButton::BringToTop
CMFCAutoHideButton::Create Creates and initializes the auto-hide button.
CMFCAutoHideButton::GetAlignment Retrieves the alignment of the auto-hide button.
CMFCAutoHideButton::GetAutoHideWindow Returns the CDockablePane object associated with the auto-hide button.
CMFCAutoHideButton::GetParentToolBar
CMFCAutoHideButton::GetRect
CMFCAutoHideButton::GetSize Determines the size of the auto-hide button.
CMFCAutoHideButton::GetTextSize Returns the size of the text label for the auto-hide button.
CMFCAutoHideButton::HighlightButton Highlights auto hide button.
CMFCAutoHideButton::IsActive Indicates whether the auto-hide button is active.
CMFCAutoHideButton::IsHighlighted Returns highlight state of auto hide button.
CMFCAutoHideButton::IsHorizontal Determines whether the auto-hide button is horizontal or vertical.
CMFCAutoHideButton::IsTop
CMFCAutoHideButton::IsVisible Indicates whether the button is visible.
CMFCAutoHideButton::Move
CMFCAutoHideButton::OnDraw The framework calls this method when it draws the auto-hide button.
CMFCAutoHideButton::OnDrawBorder The framework calls this method when it draws the border of an auto-hide button.
CMFCAutoHideButton::OnFillBackground The framework calls this method when it fills the background of an auto-hide button.
CMFCAutoHideButton::ReplacePane
CMFCAutoHideButton::ShowAttachedWindow Shows or hides the associated CDockablePane Class.
CMFCAutoHideButton::ShowButton Shows or hides the auto-hide button.
CMFCAutoHideButton::UnSetAutoHideMode

Remarks

On creation, the CMFCAutoHideButton object is attached to a CDockablePane Class. The CDockablePane object is hidden or displayed as the user interacts with the CMFCAutoHideButton object.

By default, the framework automatically creates a CMFCAutoHideButton when the user turns on auto-hide. The framework can create an element of a custom UI class instead of the CMFCAutoHideButton class. To specify which custom UI class the framework should use, set the static member variable CMFCAutoHideBar::m_pAutoHideButtonRTS equal to the custom UI class. By default, this variable is set to CMFCAutoHideButton.

Example

The following example demonstrates how to construct a CMFCAutoHideButton object and use various methods in the CMFCAutoHideButton class. The example shows how to initialize a CMFCAutoHideButton object by using its Create method, show the associated CDockablePane class, and show the auto-hide button.

CMFCAutoHideButton *autoHideButton = new CMFCAutoHideButton();
CDockablePane cPane;
// CMFCAutoHideBar* pParentBar
if (!autoHideButton->Create(pParentBar, &cPane, CBRS_ALIGN_LEFT))
{
   return 0;
}
autoHideButton->ShowAttachedWindow(true);
autoHideButton->ShowButton(true);

Inheritance Hierarchy

CObject

CMFCAutoHideButton

Requirements

Header: afxautohidebutton.h

CMFCAutoHideButton::BringToTop

void BringToTop();

Remarks

CMFCAutoHideButton::Create

Creates and initializes an auto-hide button.

virtual BOOL Create(
    CMFCAutoHideBar* pParentBar,
    CDockablePane* pAutoHideWnd,
    DWORD dwAlignment);

Parameters

pParentBar
[in] A pointer to the parent toolbar.

pAutoHideWnd
[in] A pointer to a CDockablePane object. This auto-hide button hides and shows that CDockablePane.

dwAlignment
[in] A value that specifies the alignment of the button with the main frame window.

Return Value

Nonzero if successful; otherwise 0.

Remarks

When you create a CMFCAutoHideButton object, you must associate the auto-hide button with a specific CDockablePane. The user can use the auto-hide button to hide and show the associated CDockablePane.

The dwAlignment parameter indicates where the auto-hide button resides in the application. The parameter can be any one of the following values:

  • CBRS_ALIGN_LEFT

  • CBRS_ALIGN_RIGHT

  • CBRS_ALIGN_TOP

  • CBRS_ALIGN_BOTTOM

CMFCAutoHideButton::GetAlignment

Retrieves the alignment of the auto-hide button.

DWORD GetAlignment() const;

Return Value

A DWORD value that contains the current alignment of the auto-hide button.

Remarks

The alignment of the auto-hide button indicates where the button resides on the application. It can be any one of the following values:

  • CBRS_ALIGN_LEFT

  • CBRS_ALIGN_RIGHT

  • CRBS_ALIGN_TOP

  • CBRS_ALIGN_BOTTOM

CMFCAutoHideButton::GetAutoHideWindow

Returns the CDockablePane object associated with the auto-hide button.

CDockablePane* GetAutoHideWindow() const;

Return Value

A pointer to the associated CDockablePane object.

Remarks

To associate an auto-hide button with a CDockablePane, pass the CDockablePane as a parameter to the CMFCAutoHideButton::Create method.

CMFCAutoHideButton::GetParentToolBar

CMFCAutoHideBar* GetParentToolBar();

Return Value

Remarks

CMFCAutoHideButton::GetRect

CRect GetRect() const;

Return Value

Remarks

CMFCAutoHideButton::GetSize

Determines the size of the auto-hide button.

CSize GetSize() const;

Return Value

A CSize object that contains the button size.

Remarks

The calculated size includes the size of the border of the auto-hide button.

CMFCAutoHideButton::GetTextSize

Returns the size of the text label for the auto-hide button.

virtual CSize GetTextSize() const;

Return Value

A CSize object that contains the size of the text for the auto-hide button.

CMFCAutoHideButton::IsActive

Indicates whether the auto-hide button is active.

BOOL IsActive() const;

Return Value

TRUE if the auto-hide button is active; FALSE otherwise.

Remarks

An auto-hide button is active when the associated CDockablePane Class window is shown.

CMFCAutoHideButton::IsHorizontal

Determines whether the auto-hide button is horizontal or vertical.

BOOL IsHorizontal() const;

Return Value

Nonzero if the button is horizontal; 0 otherwise.

Remarks

The framework sets the orientation of a CMFCAutoHideButton object when you create it. You can control the orientation by using the dwAlignment parameter in the CMFCAutoHideButton::Create method.

CMFCAutoHideButton::IsTop

BOOL IsTop() const;

Return Value

Remarks

CMFCAutoHideButton::IsVisible

Indicates whether the auto-hide button is visible.

virtual BOOL IsVisible() const;

Return Value

TRUE if the button is visible; FALSE otherwise.

CMFCAutoHideButton::OnDraw

The framework calls this method when it draws the auto-hide button.

virtual void OnDraw(CDC* pDC);

Parameters

pDC
[in] A pointer to a device context.

Remarks

If you want to customize the appearance of auto-hide buttons in your application, create a new class derived from CMFCAutoHideButton. In your derived class, override this method.

CMFCAutoHideButton::OnDrawBorder

The framework calls this method when it draws the border of an auto-hide button.

virtual void OnDrawBorder(
    CDC* pDC,
    CRect rectBounds,
    CRect rectBorderSize);

Parameters

pDC
[in] A pointer to a device context.

rectBounds
[in] The bounding rectangle of the auto-hide button.

rectBorderSize
[in] The border thickness for each side of the auto-hide button.

Remarks

If you want to customize the border of each auto-hide button in your application, create a new class derived from the CMFCAutoHideButton. In your derived class, override this method.

CMFCAutoHideButton::OnFillBackground

The framework calls this method when it fills the background of an auto-hide button.

virtual void OnFillBackground(
    CDC* pDC,
    CRect rect);

Parameters

pDC
[in] A pointer to a device context.

rect
[in] The bounding rectangle of the auto-hide button.

Remarks

If you want to customize the background for auto-hide buttons in your application, create a new class derived from the CMFCAutoHideButton. In your derived class, override this method.

CMFCAutoHideButton::ShowAttachedWindow

Shows or hides the associated CDockablePane Class.

void ShowAttachedWindow(BOOL bShow);

Parameters

bShow
[in] A Boolean that specifies whether this method shows the attached CDockablePane.

CMFCAutoHideButton::ShowButton

Shows or hides the auto-hide button.

virtual void ShowButton(BOOL bShow);

Parameters

bShow
[in] A Boolean that specifies whether to show the auto-hide button.

CMFCAutoHideButton::Move

void Move(int nOffset);

Parameters

[in] nOffset

Remarks

CMFCAutoHideButton::ReplacePane

void ReplacePane(CDockablePane* pNewBar);

Parameters

[in] pNewBar

Remarks

CMFCAutoHideButton::UnSetAutoHideMode

Disable auto-hide mode.

virtual void UnSetAutoHideMode(CDockablePane* pFirstBarInGroup);

Parameters

pFirstBarInGroup
[in] A pointer to the first bar in the group.

Remarks

CMFCAutoHideButton::HighlightButton

Highlights the auto hide button.

virtual void HighlightButton(BOOL bHighlight);

Parameters

bHighlight
Specifies the new auto hide button state. TRUE indicates the button is highlighted, FALSE indicates the button is not highlighted.

Remarks

CMFCAutoHideButton::IsHighlighted

Returns the highlight state of the auto hide button.

virtual BOOL IsHighlighted() const;

Return Value

Returns TRUE if the auto hide button is highlighted; otherwise FALSE.

Remarks

See also

Hierarchy Chart
Classes
CMFCAutoHideBar Class
CAutoHideDockSite Class