Previous | Table of Contents | Next

Page 432

Developing a System Startup Application

A system menu is usually linked to a startup application. This application is a nonbase table form used to set up the system. It contains the name of the menu used in the system, initializes the global variables used in the system, logs the operator on the database, and accepts security values from the operator. This application often has a photo image of something representative of the system's entity displayed on the startup canvas.

As an example of the preceding, the following will describe the development of a startup application for the Employee system.

NOTE
Some of these steps are condensed since we have performed them in numerous examples in previous sections.
  1. The first step is to create a new form module in Forms Designer.
  2. Create a nonbase table block called one.
  3. Set the canvas and window properties width and height properties.
  4. Open the Layout Editor. Select Edit, Import, Image. This will open the Import Image dialog box.
  5. Select the WHITEH.PCX image from the CD. Figure 16.27 displays the canvas after the image was imported.
  6. The image should be resized to cover the entire canvas by grabbing a handle and stretching the image.

FIG. 16.27
The Startup Application
canvas with the
imported image before
it is resized.




  1. Create two text items that will allow the operator to enter the payroll number and password values used for system security. These items should be on block one and are called payroll_number and password respectively. Figure 16.28 displays the two text items as they appear on the canvas.

Page 433

FIG. 16.28
The Startup Application
canvas and the payroll
number and password
text items.




    Each of the text items has post-change triggers. The payroll number item trigger assigns the value to the global variable payroll_number. The code for the password item is contained in Figure 15.10.


  1. Create a post-change for the password item. Enter the code from Figure 15.10 into the trigger.

  2. Create a post-change trigger for the payroll number item. The trigger should contain the following code:
    :global.payroll_number := :one.payroll_number;
    


  3. Link the menu to the form by placing the menu name in the Form's Menu Module property. The menu module is "empmenu.mmx."

    Forms are usually executed in Forms Runtime. In order to avoid having the user log on the database, an on-logon trigger is generally created to log the operator on the database. Figure 16.29 shows this trigger. The first command logs the operator on the system. The first setting in the command is the database user account and the second is the password. Following the command, the system's global variables are initialized.

  4. Create an on-logon trigger for the startup form. Use the script contain in Figure 16.29.

  5. Generate and run the form.

This completes the Employee system. Figure 16.30 displays the startup form and the system menu. All system applications are now available from the menu.

NOTE
The CD has the completed components of the Employee system. The startup application is called EMPSTART.FMX. It may be executed from Forms Runtime.

Launching the Employee System from an IconThe Employee system can be launched by opening Forms Runtime and specifying the start up application, EMPSTART.FMX. However,

Page 434

the number of steps to launch the system can be reduced by creating a Windows icon to launch the system.

FIG. 16.29
The on-logon trigger
that logs the operator
into the Oracle
database.




FIG. 16.30
The Employee System
startup form displaying
the Employees menu
options.




The command line expression for the Windows icon consists of two parts. The first part of the expression launches Forms Runtime. The second part of the expression contains the name of the startup file. Figure 16.31 shows the command to launch the Employee system. It assumes Forms Runtime is loaded on the PC and the file is contained on the CD.

Maximizing the Initial ScreensWhen a form is initially displayed, it is presented in the normal Window size. This window size does not cover the entire screen. Because I design for

Page 435

a maximized screen, the window does not display the entire canvas. The operator needs to click the Maximize window icon to properly see the form. I generally correct for this problem by maximizing the window size for the startup application. Once the window is maximized, all other forms displayed will use that window size unless the Windows size is changed.

In order to maximize the window, create a form When-new-form-instance trigger that contains the statement shown in Figure 16.32.

FIG. 16.31
The command to a
launch the Employee
System from a Windows
icon.




FIG. 16.32
The command to
dynamically maximize
a window.




Calling Forms within the SystemThroughout this chapter there have been PL/SQL commands that call another form. In the references the file path was included. In the case of this

Page 436

chapter, the file path used in the examples consists of "d:", the assumed CD drive. These path expressions are hard coded into the application. Each form and menu in the system would need to be modified and regenerated with a new file path if the applications are moved to another location. Hard coding the file path also causes problems when the applications are distributed on different servers. The applications may reside on different directories on different servers. The developer would have to have a different set of applications for each server.

In order to overcome this problem, I populate a global variable with the file path used throughout the system. The global variable is populated in a When-new-form-instance trigger on the startup application. Each of the call_form commands in the system must be changed to include the global variable as part of the concatenated expression denoting the location of the called form. Following this approach, the developer will only need to modify the When-new-form-instance trigger of the start up application when the code location is changed. Figure 16.33 illustrates this syntax.

FIG. 16.33
The syntax of the
call_form command
using a concatenated
global variable as part
of the file path
expression.




NOTE
The location of the menu module is hard coded in the start up form's Menu Module property. This technique will not work on that value. It must remain hard coded.

Creating a Toolbar

Toolbars are graphical user interface (GUI) objects that allow the user to poke at an image or icon to perform an action. We have seen numerous toolbars in this part of the chapter. The Object Navigator, screen painter, and the property sheet each contain a toolbar. A form can also

Previous | Table of Contents | Next