Starting with a Form

Most application windows are represented in WFC programming as forms. A form is used wherever you want a separate overlapping, graphical component, such as a main application window or dialog box. Forms act as containers for controls, allowing you to visually compose applications. Forms have their own properties, which can be set in the Properties window. Syntactically, a form is a Java class derived from the com.ms.wfc.ui.Form class. The Form class extends the com.ms.wfc.ui.Control class, as do the controls that you place on a form. Control encapsulates a Win32 window.

When you create a new project, and choose Windows Application from the New Projects dialog box, a form is automatically created for you. You can add other forms by choosing either Add Item or Add Form from the Project menu.

Once a form is added to your project, the form can be viewed either in design mode or in the Text editor. You can use the Forms Designer to size it and set properties by choosing View Designer from the shortcut menu of the form in Project Explorer. Each form belongs to a nonvisual Application object that contains the main thread of the application. Forms and controls represent the visual Windows components. The integration of the visual and nonvisual aspects of the window are handled completely by WFC framework.

When you open the Text editor on a new form, you'll see the template-based class created for you that contains the necessary syntax of the Form class, including a constructor and a main() method with code that instantiates your form. When you work in design mode, adding controls, setting properties, and so forth, the Forms Designer inserts and modifies a section of this class. See Creating a Form to learn about adding forms to your project.