Previous | Table of Contents | Next

Page 392

Figure 14.13.
Testing the WHEN-
WINDOW-ACTIVATED
trigger.

Elements of a Menu

Like a form, a menu is defined by a collection of objects. Some of these objects are mandatory, and some are optional. Each object may be one of the following:

You're now going to build a menu for your multi-form application and call it MAIN_MENU.

Building a Menu

To begin with, use the Forms Designer to open C:\Orawin95\Forms45\Demos\Dfltmenu\menudef by selecting File | Open from the menu (see Figure 14.14). This is the default path to use if you have installed Developer/2000 on Windows 95. Using the Object Navigator, expand the Menus object node. If you look at the Properties for MENUDEF, you'll see a property named Main Menu, which is set to Main_Menu. This property identifies the highest-level menu.

Page 393

Figure 14.14.
Opening the default
menu.

Beneath the Menus object node, you will see the following menus:

These menus constitute the highest-level menus. However, this is the default menu, and you'll want to add three high-level menus:

To add the three high-level menus to the default menu, select the Menus object node with the mouse or arrow keys, and click + on the vertical toolbar. A menu named MENU0 will appear; click the menu until it turns blue and change the name to DATA_ENTRY. Do the same to create the BROWSE and REPORTS menus (see Figure 14.15). Drag the three menus below RECORD.

Page 394

Figure 14.15.
Creating new menus.

Incorporating New Menus

Although it is difficult to tell by looking at the menus with the Object Navigator, MAIN_MENU is the highest-level menu.

  1. Expand the Items object node beneath MAIN_MENU.
  2. To add the Data Entry menu to the main menu, select the Items object node and click + on the vertical toolbar. You will see a new item named ITEM followed by a number.
  3. Click on the new item, and rename it as DATA_ENTRY.
  4. If the properties are not displayed for DATA_ENTRY, right-click Properties, scroll down to the Command Type property, and change it to Menu (see Figure 14.16).
  5. Scroll down to the Command Text property, and click the More button at the top of the Properties window. The Command Text property contains the command that will be executed when the menu item is selected. A window named Command Text will appear.
  6. Enter DATA_ENTRY, and click OK (see Figure 14.17).
  7. Scroll down to the Label property, and enter Data Entry. This will be the text that is displayed on the menu bar.

Page 395

Figure 14.16.
Setting the Command
Type property for the
new menu item.

Figure 14.17.
Setting the Command
Text property for the
new menu item.

  1. If you look at the items that belong to MAIN_MENU, you'll see that DATA_ENTRY is the first item. This isn't where you want it to appear on the menu bar.
    To move it between EDIT and BLOCK, select DATA_ENTRY with the mouse, hold down the left mouse button, drag it until the horizontal line appears below EDIT, and release the left mouse button.
  2. To incorporate the Browse and Reports menus at the top level of MAIN_MENU, follow steps 3 through 8. To test the appearance of the menu, double-click the icon to the left of MENUDEF. Figure 14.18 displays what you should see.

Page 396

Figure 14.18.
Testing the appear-
ance of the menu.

Adding Items to a Menu

Although you've created three new menus, none of the menus has any items. Let's add two items to the Data Entry menu.

  1. Use the Object Navigator to expand the DATA_ENTRY menu (not item in MAIN_MENU).
  2. Select the Items object node, and click + on the vertical toolbar.
  3. In the Properties window, change the name of the item to INSTRUCTOR.
  4. Scroll down to the Command Type property. As you can see, it is set to PL/SQL. Don't change it; this is the value that you want.
  5. Scroll down to the Command Text property and click on More at the top of the Properties window. The PL/SQL Editor will appear.
  6. Enter call_form(`Instructor',NO_HIDE,NO_REPLACE). This PL/SQL statement invokes the built-in Forms procedure, call_form, which will display the Instructor form.
  7. Click Compile and Close.
  8. In the Properties window, scroll down to the Label property, and enter Instructor.

You also will need to create an item for the Browse and Reports menu. If you don't, the Forms Generator will generate an error message when you try to generate an MMX file for the menu.

Page 397

  1. For the Browse menu, create an item named INSTRUCTOR_BROWSE.
  2. In the Command Text property for this item, enter the following: call_form(`Instructor_Browse',NO_HIDE,NO_REPLACE.
  3. For the Reports menu, create an item named COURSE_CATALOG.
  4. In the Command Text property for this item, enter Null; by specifying NULL, the menu item will appear in the menu but it won't perform any action—yet.

In the next lesson, you will learn how to invoke an Oracle Report from a menu item.

Saving the Menu

Before you go any further, you should rename the menu.

  1. Select MENUDEF.
  2. Select File | Save As from the menu.
  3. Be sure to specify a directory designated for your application as the location for saving to.
  4. In the Save As Type field, select Menus (*.mmb).
  5. In the File name field, enter Main_menu.
  6. Click Save.

Generating the Menu

When you save a menu in the file system, the file has an extension of .mmb. However, Forms Runtime can run only an MMX menu file, which is generated from an MMB file. To generate an MMX file for Main_menu, select File | Administration | Generate from the menu or press Ctrl+t.

Building a Multiform Application

NEW TERM
Up to this point, you have only tested individual forms within the Forms Designer. Now, you are going to go through the steps of building a multiple-forms application. The first step is to create a form that will contain the root window for the application; this window will always display the menu and the console, consisting of the message and status lines.
  1. To do this, select File | New | Form from the menu. A new form will appear in the Object Navigator.
  2. Change the name of this form to MDI_FRAME.
  3. Expand the Window object node, select the single window that was automatically created, and right-click Properties.
  4. Change the name of the window to ROOT_WINDOW.

Previous | Table of Contents | Next

Используются технологии uCoz