Compartilhar via


CMFCMenuBar::CreateEx

Creates a CMFCMenuBar object with specified extended styles.

virtual BOOL CreateEx(
   CWnd* pParentWnd,
   DWORD dwCtrlStyle = TBSTYLE_FLAT,
   DWORD dwStyle = AFX_DEFAULT_TOOLBAR_STYLE,
   CRect rcBorders = CRect( 1, 1, 1, 1),
   UINT nID =AFX_IDW_MENUBAR
);

Parameters

  • [in] pParentWnd
    Pointer to the parent window of the new CMFCMenuBar object.

  • [in] dwCtrlStyle
    Additional styles for the new menu bar.

  • [in] dwStyle
    The main style of the new menu bar.

  • [in] rcBorders
    A CRect parameter that specifies the sizes for the borders of the CMFCMenuBar object.

  • [in] nID
    The ID for the child window of the menu bar.

Return Value

Nonzero if the method is successful; otherwise 0.

Remarks

You should use this function instead of CMFCMenuBar::Create when you want to specify styles in addition to the toolbar style. Some frequently used additional styles are TBSTYLE_TRANSPARENT and CBRS_TOP.

For lists of additional styles, see Toolbar Control and Button Styles, common control styles, and common window styles.

Example

The following example demonstrates how to use the CreateEx method of the CMFCMenuBar class. This code snippet is part of the IE Demo sample.

    CMFCMenuBar m_wndMenuBar;


...


    // The this pointer points to CMainFrame class which extends the CFrameWnd class.
    if (!m_wndMenuBar.CreateEx (this, TBSTYLE_TRANSPARENT))
    {
        TRACE0("Failed to create menubar\n");
        return -1;      // fail to create
    }

Requirements

Header: afxmenubar.h

See Also

Reference

CMFCMenuBar Class

Hierarchy Chart