SetMenu

The SetMenu function assigns a new menu to the specified window.

BOOL SetMenu(
  HWND hWnd,  // handle to window
  HMENU hMenu // handle to menu
);
 

Parameters

hWnd
Handle to the window to which the menu is to be assigned.
hMenu
Handle to the new menu. If this parameter is NULL, the window's current menu is removed.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The window is redrawn to reflect the menu change.

The SetMenu function replaces the previous menu, if any, but it does not destroy it. An application should call the DestroyMenu function to accomplish this task.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also

Menus Overview, Menu Functions, DestroyMenu, GetMenu