Specifying the Menu for a Window Class

When you register a window class, you are setting the default attributes for windows in that class. You can specify a menu as the default menu for a window class; this default menu is known as the class menu. You specify the class menu when you register the window class. To do so, you assign the name of the menu, as given in the resource file, to the lpszMenuName field of the window-class structure. For example:

wc.lpszMenuName = “SampleMenu”;

In this example, the lpszMenuName field is part of a WNDCLASS data structure named wc. The menu name SampleMenu is the name given to the menu in the application's resource script file.

Once a window class has been registered, each window of that class will have the specified class menu. You can override this default menu by explicitly supplying a menu handle when you create a window of that class.