We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


Loads a menu resource from the application's executable file and attaches it to the CMenu object.

BOOL LoadMenu( 
   LPCTSTR lpszResourceName  
BOOL LoadMenu( 
   UINT nIDResource  


Points to a null-terminated string that contains the name of the menu resource to load.


Specifies the menu ID of the menu resource to load.

Nonzero if the menu resource was loaded successfully; otherwise 0.

Before exiting, an application must free system resources associated with a menu if the menu is not assigned to a window. An application frees a menu by calling the DestroyMenu member function.

// CMainFrame::OnReplaceMenu() is a menu command handler for CMainFrame 
// class, which in turn is a CFrameWnd-derived class. It loads a new 
// menu resource and replaces the SDI application window's menu bar with 
// this new menu. CMainFrame is a CFrameWnd-derived class. 
void CMainFrame::OnReplaceMenu() 
   // Load the new menu.

   // Remove and destroy the old menu

   // Add the new menu

   // Assign default menu
   m_hMenuDefault = m_ShortMenu.GetSafeHmenu();  // or m_ShortMenu.m_hMenu;

Header: afxwin.h