7.1 Menus and Menu Items

A menu is a list of items that, to a user, are your application's commands. Each menu item can be displayed as text or as a bitmap. By choosing a menu item (with the mouse or the keyboard), the user tells the application to perform the command associated with that item. Windows responds to this action by sending the application a message that identifies which command the user chose.

To use a menu in your application, follow these general steps:

1.Define the menu in your resource-definition file.

2.Specify the menu in your application code. There are two common ways to do this:

When registering the window class, specify a menu (called the class menu) for that entire window class.

When creating a window, specify a menu for that window.

3.Initialize the menu, if necessary.

When you have defined and initialized a menu for your application, the user can choose commands from the menu, and you can have your application add, change, or replace items, or even the entire menu, as necessary.