Partager via


CMFCPopupMenu Class

Implements Windows pop-up menu functionality and extends it by adding features such as tear-off menus and tooltips.

class CMFCPopupMenu : public CMiniFrameWnd

Members

Protected Constructors

Name

Description

CMFCPopupMenu::CMFCPopupMenu

Constructs a CMFCPopupMenu object.

Public Methods

Name

Description

CMFCPopupMenu::ActivatePopupMenu

 

CMFCPopupMenu::AlwaysShowEmptyToolsEntry

Sets whether a pop-up menu is enabled to show empty entries for user-defined tools.

CMFCPopupMenu::AreAllCommandsShown

 

CMFCPopupMenu::CheckArea

Determines the location of a point relative to the pop-up menu.

CMFCPopupMenu::CloseMenu

 

CMFCPopupMenu::Create

Creates a pop-up menu and attaches it to the CMFCPopupMenu object.

CMFCPopupMenu::DefaultMouseClickOnClose

 

CMFCPopupMenu::EnableMenuLogo

Initializes the logo for a pop-up menu.

CMFCPopupMenu::EnableMenuSound

Enables menu sound.

CMFCPopupMenu::EnableResize

 

CMFCPopupMenu::EnableScrolling

 

CMFCPopupMenu::EnableVertResize

 

CMFCPopupMenu::FindSubItemByCommand

 

CMFCPopupMenu::GetActiveMenu

Returns the currently active menu.

CMFCPopupMenu::GetAnimationSpeed

Returns the animation speed for pop-up menus.

CMFCPopupMenu::GetAnimationType

Returns the current type of pop-up menu animation.

CMFCPopupMenu::GetDropDirection

 

CMFCPopupMenu::GetForceMenuFocus

Indicates whether the focus is returned to the menu bar when a pop-up menu is displayed.

CMFCPopupMenu::GetForceShadow

 

CMFCPopupMenu::GetHMenu

Returns a handle to the attached menu resource.

CMFCPopupMenu::GetMenuBar

Returns the CMFCPopupMenuBar embedded inside the pop-up menu.

CMFCPopupMenu::GetMenuItem

Returns a pointer to the menu item at the specified index.

CMFCPopupMenu::GetMenuItemCount

Returns the number of items in a popup menu.

CMFCPopupMenu::GetMessageWnd

Returns a pointer to the window where the framework routes the pop-up menu messages.

CMFCPopupMenu::GetParentArea

 

CMFCPopupMenu::GetParentButton

Returns a pointer to the parent toolbar button.

CMFCPopupMenu::GetParentPopupMenu

Returns a pointer to the parent pop-up menu.

CMFCPopupMenu::GetParentRibbonElement

 

CMFCPopupMenu::GetParentToolBar

Returns a pointer to the parent toolbar.

CMFCPopupMenu::GetQuickCustomizeType

 

CMFCPopupMenu::GetSelItem

Returns a pointer to the currently selected menu command.

CMFCPopupMenu::HasBeenResized

 

CMFCPopupMenu::HideRarelyUsedCommands

Indicates whether the pop-up menu can hide rarely used commands.

CMFCPopupMenu::InCommand

 

CMFCPopupMenu::InsertItem

Inserts a new item into the pop-up menu at the specified location.

CMFCPopupMenu::InsertSeparator

Inserts a separator into the pop-up menu at the specified location.

CMFCPopupMenu::IsAlwaysClose

 

CMFCPopupMenu::IsAlwaysShowEmptyToolsEntry

 

CMFCPopupMenu::IsCustomizePane

Indicates whether the pop-up menu is functioning as a QuickCustomizePane.

CMFCPopupMenu::IsEscClose

 

CMFCPopupMenu::IsIdle

Indicates whether a pop-up menu is currently idle.

CMFCPopupMenu::IsMenuSound

 

CMFCPopupMenu::IsQuickCustomize

Determines whether the associated CMFCToolBarMenuButton Class is in QuickCustomize mode.

CMFCPopupMenu::IsResizeble

 

CMFCPopupMenu::IsRightAlign

Indicates whether the menu is right-aligned or left-aligned.

CMFCPopupMenu::IsScrollable

 

CMFCPopupMenu::IsSendMenuSelectMsg

Indicates whether the framework notifies the parent frame when the user selects a command from the pop-up menu.

CMFCPopupMenu::IsShown

Indicates whether the pop-up menu is currently visible.

CMFCPopupMenu::MoveTo

 

CMFCPopupMenu::OnCmdMsg

  (Overrides CFrameWnd::OnCmdMsg.)

CMFCPopupMenu::PostCommand

 

CMFCPopupMenu::PreTranslateMessage

  (Overrides CFrameWnd::PreTranslateMessage.)

CMFCPopupMenu::RecalcLayout

Called by the framework when the standard control bars are toggled on or off or when the frame window is resized. (Overrides CFrameWnd::RecalcLayout.)

CMFCPopupMenu::RemoveAllItems

Clears all the items from a pop-up menu.

CMFCPopupMenu::RemoveItem

Removes the specified item from a pop-up menu.

CMFCPopupMenu::SaveState

 

CMFCPopupMenu::SetAnimationSpeed

Sets the animation speed for pop-up menus.

CMFCPopupMenu::SetAnimationType

Sets the animation type for the pop-up menu.

CMFCPopupMenu::SetAutoDestroy

 

CMFCPopupMenu::SetDefaultItem

Sets the default command for the pop-up menu.

CMFCPopupMenu::SetForceMenuFocus

Forces the input focus to return to the menu bar when a pop-up menu is displayed.

CMFCPopupMenu::SetForceShadow

Forces the framework to draw menu shadows when pop-up menus appear outside the main frame.

CMFCPopupMenu::SetMaxWidth

Set the maximum width for the pop-up menu.

CMFCPopupMenu::SetMessageWnd

 

CMFCPopupMenu::SetParentRibbonElement

 

CMFCPopupMenu::SetQuickCustomizeType

 

CMFCPopupMenu::SetQuickMode

 

CMFCPopupMenu::SetRightAlign

Sets the menu alignment for pop-up menus.

CMFCPopupMenu::SetSendMenuSelectMsg

Sets a flag that controls whether the pop-up menu notifies its parent frame when the user selects a command.

CMFCPopupMenu::ShowAllCommands

Forces the pop-up menu to display all commands.

CMFCPopupMenu::TriggerResize

 

CMFCPopupMenu::UpdateAllShadows

Updates the shadows for all opened pop-up menus.

CMFCPopupMenu::UpdateShadow

Updates the shadow for the pop-up menu.

Protected Methods

Name

Description

CMFCPopupMenu::CreateTearOffBar

 

CMFCPopupMenu::OnChangeHot

 

CMFCPopupMenu::OnChooseItem

 

Remarks

Normally, MFC creates pop-up menus automatically. If you want to create a CMFCPopupMenu object manually, allocate one on the heap and then call CMFCPopupMenu::Create.

Example

The following example demonstrates how to configure a pop-up menu object. The example shows how to set the logo and the sound of the pop-up menu, set the animation speed and type, draw menu shadows when the pop-up menu appears outside the main frame, set the maximum width, and set the right menu alignment of the pop-up menu. This code snippet is part of the Custom Pages sample.

        // 30 is the size of the logo in pixels.
        pPopupMenu->EnableMenuLogo(30);
        pPopupMenu->EnableMenuSound();
        // 500 is the animation speed in milliseconds.
        pPopupMenu->SetAnimationSpeed(500);
        pPopupMenu->SetAnimationType(CMFCPopupMenu::SLIDE);
        pPopupMenu->SetForceShadow(true);
        // 200 is the maximum width of the pop-up menu in pixels.
        pPopupMenu->SetMaxWidth(200);
        pPopupMenu->SetRightAlign();
        pPopupMenu->InsertSeparator();

Inheritance Hierarchy

CObject

   CCmdTarget

      CWnd

         CFrameWnd

            CMiniFrameWnd

               CMFCPopupMenu

Requirements

Header: afxpopupmenu.h

See Also

Reference

Hierarchy Chart

CMFCPopupMenuBar Class

Other Resources

MFC Classes