共用方式為


CMFCPopupMenu::Create

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

virtual BOOL Create(
   CWnd* pWndParent,
   int x,
   int y,
   HMENU hMenu,
   BOOL bLocked = FALSE,
   BOOL bOwnMessage = FALSE
);

Parameters

  • [in] pWndParent
    The parent window for the CMFCPopupMenu.

  • [in] x
    The horizontal screen coordinate for the location of the pop-up menu

  • [in] y
    The vertical screen coordinate for the location of the pop-menu.

  • [in] hMenu
    A handle to a menu resource.

  • [in] bLocked
    A Boolean parameter that indicates whether the menu is customizable. FALSE indicates that the pop-up menu is customizable.

  • [in] bOwnMessage
    A Boolean parameter that indicates how the framework routes the menu messages. See the Remarks section for more details.

Return Value

TRUE if the method is successful; otherwise FALSE.

Remarks

If bOwnMessage is TRUE, the framework routes any menu messages to pWndParent. pWndParent must not be NULL if bOwnMessage is TRUE. If bOwnMessage is FALSE, the framework routes the menu messages to the parent pop-up menu.

Example

The following example demonstrates how to use the Create method of the CMFCPopuMenu class. This code snippet is part of the Custom Pages sample.

     CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;
        // CPoint point 
        // CMenu* pPopup 
        // The this pointer points to CMainFrame class which extends the CFrameWnd class.
        pPopupMenu->Create (this, point.x, point.y, pPopup->Detach ());

Requirements

Header: afxpopupmenu.h

See Also

Reference

CMFCPopupMenu Class

Hierarchy Chart