Add a menu

Now the controls on the dialog are complete and the dialog appearance has been set, we'll add the finishing touch: a menu. Open the Menu Editor using the toolbar button image\bm71.gif (or use the Tools | Menu Editor menu item, or use the CTRL+SHIFT+M hot-key).

Ensure that the Pop-up option is selected (ALT+O), then in the Caption field, enter "&File" and press the ENTER key. The Menu-item option should now be automatically set, ready for the next menu item to be created.

In the Caption field, type "&Open File" and use the TAB key to move on to the ID Name field. From the drop-down list (ALT+DOWN), select %IDC_BUTTON2 from the list (or the name if the "Open File" button if you used an alternative name. The reason for selecting the same ID Name is to ensure that the menu item will produce the same result as when the user clicks on the "Open File" button on the dialog proper. After selecting that item, click the Next button (or press the ENTER key).

Next, select the Separator option by either clicking on the item, or pressing the ALT+S hot-key, then press the ENTER key to accept the item. The Menu-item option selection will automatically revert, ready for entry of the next menu item.

Now we will repeat these last two steps of the procedure to add a "O&ptions" item, followed by another separator. The Options item should be assigned the ID Name of %ID_BUTTON1, which was the ID Name automatically created for the Options button control.

Finally, create the last menu item by entering "E&xit" in the Caption field, and then press the ENTER key.

At this point the menu structure in the lower window should look like this:

&File

--&Open File

--<__Separator__>

--O&ptions

--<__Separator__>

--E&xit

Now we will create another top-level menu item, but in this case, we want the top-level item to act as would a normal menu item rather than a pop-up. This means that when the application is running, clicking on the menu item will produce an immediate click event that is sent to the application, rather than presenting a drop-down menu, as the first top-level menu item is intended to produce.

We make the "immediate" nature of the menu item evident to the end-user simply by appending an exclamation point to the menu item name. For example, "Quit!".

To create this menu item, enter "&About!" in the Caption field, then TAB to the ID Name field, and enter "%IDC_ABOUT". Next, TAB to the ID Value field, and set the control value to 1007 (the next available ID Value number in our project so far).

Finally, click the Left Arrow button to move the menu item to the left side of the structure diagram (which automatically flags it as a top-level menu item). The complete menu structure diagram should now look like this:

&File

--&Open File

--<__Separator__>

--O&ptions

--<__Separator__>

--E&xit

&About!

At this point, you can test the menu with the Test button or the ALT+T hot-key. In the test mode you can clearly see the effect of using a menu-item in the top-level position in a menu.

After testing, close the Menu Editor, and return to the design mode environment.

 

Next Step: Divider line