LoadMenu

2.x

  HMENU LoadMenu(hinst, lpszMenuName)    
  HINSTANCE hinst; /* handle of application instance */
  LPCSTR lpszMenuName; /* menu-name string or menu resource identifier */

The LoadMenu function loads the specified menu resource from the executable file associated with the given application instance.

Parameters

hinst

Identifies an instance of the module whose executable file contains the menu to be loaded.

lpszMenuName

Points to a null-terminated string that contains the name of the menu resource to be loaded. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. The MAKEINTRESOURCE macro can be used to create this value.

Return Value

The return value is the handle of the menu resource if the function is successful. Otherwise, it is NULL.

Comments

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 function.

Example

The following example loads a menu resource, and then assigns the menu to a window:

HMENU hmenu;

hmenu = LoadMenu(hinst, "ColorMenu");
SetMenu(hwnd, hmenu);

See Also

DestroyMenu, LoadMenuIndirect, SetMenu