About Non-Modal Programming

The discussion of form processing in the previous chapter dealt with modal forms. There are several differences between processing a modal form and processing a non-modal form.

There are two ways for the user to leave a modal form. He can exit from the form, or he can quit from the form. If he exits from a data form, the information that he or she has typed into the form is converted and saved into the underlying data variables for the form. If he quits from the form, the data is not saved. In either case, however, the user must decide whether to keep or discard the data he has entered; there is no way to temporarily stop working with the form, do something else, and then return to the partially-completed form.

There are three ways for the user to leave a non-modal form. As with a modal form, he can exit from the form and save his data, or quit from the form and discard his data. In addition, the user can suspend a non-modal form, menu or window, leaving his data in an incomplete state. Later, he can reactivate this form, finish working with it, and then choose to quit or exit from the form. Non-modal programming provides a way to allow the user to temporarily stop working with a form, without deciding whether to discard or keep the data.

A is one in which the user can perform other tasks before he finishes the task he is currently working on. A non-modal form, menu, window, or choice list can be suspended while the user performs another task.

A is one in which the user must finish what she is doing before she can do something else. A modal form, menu, window, or choice list forces the user to decide whether to save or discard information before she can move on to perform another task.

It is possible, and frequently desirable, to use both modal and non-modal forms, menus, and windows in the same application. You can decide whether to use a modal or a non-modal panel by determining whether the user should be able to leave this task without completing or aborting it.

In the past, Vermont Views programs could only be modal. An example may clarify the difference between modal and non-modal applications. A typical Vermont Views application might include a data form, and an event function that allows the user to bring up a second data form. This program could be either modal or non-modal, depending on how the programmer implements it. In either case, the event function brings up the second form, and the user types information into the second form.

If the application is modal, the user must finish typing the information into the second form and either quit or exit (usually by pressing F10 or Esc) to get back into the first form and finish processing it. When the user leaves the second form, Vermont Views does its normal end-form processing: it calls the form validation function if necessary; it calls the end-form function; and, if the user exited instead of quit, it converts the data into the underlying data variables. Typically, the second form is taken off the screen when the user has finished with it.

If the application is non-modal, the user can move back into the first form before he completes the second form, and can then move freely back and forth between the two forms. As the user switches between forms, Vermont Views does not try to validate the form or call the end-form function, because the user has not truly exited or quit from either form. Only when the user actually presses the Exit or Quit key (or pushbutton) does Vermont Views do the processing that normally accompanies leaving a form.

Another example of modal and non-modal program is found in Microsoft Windows and other, similar programs. A non-modal window is one that can be iconized or suspended while the user switches to another window and performs another task; a modal window is one that the user must either cancel or accept before he can move to another window.


Home Contents Previous Next