Create Form, Modify Form, Create Screen, Modify Screen

These commands open the Form Designer.

Usage

CREATE FORM | SCREEN [ FormName | ? ]
       [ AS ClassName FROM ClassLib ]
       [ NOWAIT ] [ SAVE ] [ DEFAULT ]
       [ WINDOW DefinitionWindow ]
       [ IN [ WINDOW ] ContainerWindow | IN SCREEN ]
MODIFY FORM | SCREEN [ FormName | ? ]
       [ METHOD MethodName ]
       [ NOENVIRONMENT ] [ NOWAIT ] [ SAVE ]
       [ WINDOW DefinitionWindow ]
       [ IN [ WINDOW ] ContainerWindow | IN SCREEN ]
You can specify a form to open, specify ? to be prompted, or omit the form name entirely. With CREATE, omitting FormName opens the Form Designer with a default name, while ? brings up a special form of the Save As dialog. With MODIFY, either omitting the name or using ? brings up the File | Open dialog. If you use CREATE FORM with a file that already exists and SAFETY is set on, a dialog lets you know the file already exists. You can either throw it out (by choosing "Yes") or open it (by choosing "No"). With SAFETY set off, the same command simply opens the existing form.MODIFY FORM with a nonexistent file name behaves like CREATE FORM—it opens the Form Designer with an empty form.DEFAULT is a really neat clause, though we don't use it much. You can (and should) specify a form template class in the Options dialog. Normally, every new form you create is based on the specified template. But if, for some reason, you want to base a form on FoxPro's Form base class, specify DEFAULT in the CREATE FORM command. Starting in VFP 6, we finally have the clause we really want in CREATE FORM. The new AS ClassName FROM ClassLib clause lets us specify the base class for a new form on the fly. It works the same way here as in CREATE CLASS. If, for some reason (we can't think of one), you include both AS and DEFAULT clauses, the DEFAULT clause wins and the form is based on the VFP base form class.The METHOD clause of MODIFY FORM was added in VFP 5. It lets you open a form and, at the same time, open a method-editing window to a particular method. It doesn't matter whether or not the specified method has code in it, which is very cool. WINDOW DefinitionWindow specifies an existing window from which the Form Designer borrows size and position. Unlike some other commands with WINDOW clauses, other characteristics of DefinitionWindow (such as its title) are ignored.IN WINDOW works here pretty much as it does elsewhere, letting you imprison the Form Designer in ContainerWindow. As far as we can tell, IN SCREEN makes no difference whatsoever and can safely be ignored.As with other CREATE and MODIFY commands, NOWAIT lets you open an editing window in a program and leave it there while you go on to other tasks. SAVE, as elsewhere, is unnecessary as long as you have NOWAIT. In a program, without NOWAIT or SAVE, clicking on another window that's not part of the Form Designer closes it.The NOENVIRONMENT clause, included for backward compatibility, doesn't do anything.The SCREEN versions of these commands (CREATE SCREEN and MODIFY SCREEN) are included for backward compatibility as is the "quick screen" version of CREATE SCREEN (its syntax isn't shown above). In FoxPro 2.x, the optional FROM clause lets you create a new screen programmatically without the Screen Builder even appearing. This clause and its other options are ignored in Visual FoxPro—this form of the command opens the Form Designer, just like any other version. (You can create forms programmatically in Visual FoxPro, but you'd probably do it with a builder. The builder could use CreateObject() to create the initial form, then manipulate the form properties and contents, and finally use the SaveAs method to store the newly populated form.)

Example

* Open the FD, specifying the base class for a form.
CREATE FORM MyNewForm AS MyBaseForm FROM MyClasses
* Open the FD in a program, prompting for a form to edit.
MODIFY FORM ? NOWAIT

See Also

Compile Form, Do Form


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .