CMenuTearOffManager Class

Manages tear-off menus. A tear-off menu is a menu on the menu bar. The user can remove a tear-off menu from the menu bar, causing the tear-off menu to float.

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

Syntax

class CMenuTearOffManager : public CObject

Members

Public Constructors

Name Description
CMenuTearOffManager::CMenuTearOffManager Constructs a CMenuTearOffManager object.

Public Methods

Name Description
CMenuTearOffManager::Build
CMenuTearOffManager::GetRegPath
CMenuTearOffManager::Initialize Initializes a CMenuTearOffManager object.
CMenuTearOffManager::IsDynamicID
CMenuTearOffManager::Parse
CMenuTearOffManager::Reset
CMenuTearOffManager::SetInUse
CMenuTearOffManager::SetupTearOffMenus

Remarks

In order to use tear-off menus in your application, you must have a CMenuTearOffManager object. In most cases, you won't create or initialize a CMenuTearOffManager object directly. This is handled for you when you call the CWinAppEx::EnableTearOffMenus function.

Example

The following example demonstrates how to construct and initialize a CMenuTearOffManager object by calling the CWinAppEX::EnableTearOffMenus method. This code snippet is part of the Word Pad sample.

// The EnableTearOffMenus method is inherited from the CWinAppEx class.
EnableTearOffMenus(NULL, ID_FREE_TEAROFF1, ID_FREE_TEAROFF2);

Inheritance Hierarchy

CObject

CMenuTearOffManager

Requirements

Header: afxmenutearoffmanager.h

CMenuTearOffManager::Build

void Build(
    UINT uiTearOffBarID,
    CString& strText);

Parameters

[in] uiTearOffBarID

[in] strText

Remarks

CMenuTearOffManager::CMenuTearOffManager

Constructs a CMenuTearOffManager object.

CMenuTearOffManager();

Remarks

In most cases, you should not create a CMenuTearOffManager manually. The framework of your application creates the CMenuTearOffManager object when you call CWinAppEx::EnableTearOffMenus.

CMenuTearOffManager::GetRegPath

LPCTSTR GetRegPath() const;

Return Value

Remarks

CMenuTearOffManager::Initialize

Initializes a CMenuTearOffManager object.

BOOL Initialize(
    LPCTSTR lpszRegEntry,
    UINT uiTearOffMenuFirst,
    UINT uiTearOffMenuLast);

Parameters

lpszRegEntry
[in] A string that contains the path of a registry entry. Your applications stores the settings for tear-off bars in this registry entry.

uiTearOffMenuFirst
[in] The first menu ID for a tear-off menu.

uiTearOffMenuLast
[in] The last menu ID for a tear-off menu.

Return Value

Nonzero if successful; otherwise 0.

Remarks

The range of menu IDs from uiTearOffMenuFirst to uiTearOffMenuLast must be a continuous interval. The interval defines the number of tear-off menus that can appear at the same time in the application.

CMenuTearOffManager::IsDynamicID

BOOL IsDynamicID(UINT uiID) const;

Parameters

[in] uiID

Return Value

Remarks

CMenuTearOffManager::Parse

UINT Parse(CString& str);

Parameters

[in] str

Return Value

Remarks

CMenuTearOffManager::Reset

void Reset(HMENU hmenu);

Parameters

[in] hmenu

Remarks

CMenuTearOffManager::SetInUse

void SetInUse(
    UINT uiCmdId,
    BOOL bUse = TRUE);

Parameters

[in] uiCmdId

[in] bUse

Remarks

CMenuTearOffManager::SetupTearOffMenus

void SetupTearOffMenus(HMENU hMenu);

Parameters

[in] hMenu

Remarks

See also

Hierarchy Chart
Classes
CWinAppEx Class