Loading a Menu-Template Resource

To load a menu-template resource, use the LoadMenu function, specifying the handle of the module that contains the resource and the menu template's identifier. The LoadMenu function returns a menu handle that you can use to assign the menu to a window. This window becomes the menu's owner window, receiving all the messages generated by the menu.

To create a menu from a menu template that is already in memory, use the LoadMenuIndirect function. This is useful if your application generates menu templates dynamically.

To assign a menu to a window, use the SetMenu function or specify the menu's handle in the hMenu parameter of the CreateWindowEx function when creating a window. Another way you can assign a menu to a window is to specify a menu template when you register a window class; the template identifies the specified menu as the class menu for that window class.

To have Windows automatically assign a specific menu to a window, specify the menu's template when you register the window's class. The template identifies the specified menu as the class menu for that window class. Then, when you create a window of the given class, Windows automatically assigns the specified menu to the window.

To create a class menu, include the identifier of the menu-template resource as the lpszMenuName member of a WNDCLASS structure and then pass the address of the structure to the RegisterClass function.