Follow the steps described below to create a form in VPM Enterprise.
1. New Object Type Dialog
You can begin creating a new form from a menu prompt on the Object Builder or as a called object from another Application Object’s Called Objects list. (See How to Begin Creating a New Application Object.) Either way VPM Enterprise displays the New Object Type dialog. With the Form option button selected, click OK.
2. New Object Name Dialog
VPM Enterprise displays the New Object Name dialog. Enter a file name for your form. Click OK.
3. Form Editor
VPM Enterprise displays the Form Editor.
Click the Edit button on the Form Editor.
4. New Form Dialog
VPM Enterprise displays the New Form dialog.
The New Form dialog lets you choose among:
· Starting with a blank form based on a form class you specify,
· Starting with a blank form based on the default form class template, or
· Starting with a copy of any existing form.
If you choose to start with a blank form based on a form class you specify, VPME displays the Select Form Class dialog allowing you to select the form class you want.
If you choose to start with a copy of an existing form, VPME displays the Open dialog allowing you to select the existing form to copy.
The steps described below assume you choose to create a blank form based on the default form class template.
With the Blank – Template Class option button selected, click OK. VPM Enterprise brings up the Visual FoxPro Form Designer with your default form class template displayed.
5. Set Up the Form Designer Work Space
If the Form Designer is not set up the way you like, take a moment to set it up. You need a lot of space on your computer screen to work with the Form Designer. Here are some suggestions:
· Maximize the VPM Enterprise desktop window if it is not already maximized.
· Maximize the Form Designer window.
· Dock the Form Controls Toolbar under the VPM Enterprise menu or at the right edge of the screen. You may be using the Form Controls Toolbar a good bit and you’ll want to be able to find it easily.
6. Change the Form Class
If the form that is displayed when the Form Designer first appears is not based on the class you want, change the form class.
1. Click the View Classes icon on the Form Controls Toolbar. (It's the icon with the books.) On the menu popup select the form class library you are using (either Vpmforms, Devforms or Proforms). The Controls Toolbar will change to show a list of form class icons.
2. Move the mouse pointer over the form class icons and use the tool tips to locate the form class you want. Click the icon of the form class you want.
3. Move the mouse pointer over the form displayed in the Form Designer window. The pointer changes to a form icon. Click the left mouse button. The Form Designer adds a form based on the form class you selected and creates a form set.
4. Remove Unwanted Form: Remove the original form based on the form class you don't want. Move the form you want until the form you don't want is visible. Click on the form you don't want. Click the Remove Form option on the Form menu.
5. Remove Form Set: Remove the form set. Click the Remove Form Set option on the Form menu.
Tip – Remove Form Set: The Number 1 mistake people seem to make when they change a form class is forgetting step 5 — removing the form set. Don’t let that happen to you.
7. Enter a Unique Form Name and a Form Caption
Enter a unique form name and a caption to display in the title bar of the form window.
1. If the Properties window is not displayed, click the form or the white space surrounding the form with your right mouse button and click the Properties option on the popup menu.
2. Select the form in the Object box on the Properties window.
3. Click the Other tab. Click the Name property. Enter a unique name for the form in the Property Settings box on the Properties window. The name you enter should be different than the name you give any other form in your application.
Tip: VPM Enterprise uses the form name to keep track of data needed to implement certain form-level functionality. Therefore, you must give each form in an application a unique name.
4. Click the Layout tab. Click the Caption property. Enter the caption in the Property Settings box on the Properties window.
8. Add Data from Tables, Views and CursorAdapters to the Form
Use the Data Environment window to add data from tables, views and CursorAdapters to the form.
1. Tables and Views: To add tables and views to the Data Environment, click the form with your right mouse button. Click the Data Environment option on the popup menu. The Form Designer displays the Data Environment window and the Add Table or View dialog.
Add all the tables and views you will use on the form to the Data Environment window.
2. CursorAdapters: To add a CursorAdapter to the Data Environment:
· If it’s not already open, open the Data Environment of the form.
· Right-click on the Data Environment window.
· Select the Builder option on the right-click menu. Note: If you select the Add CursorAdapter option on the right-click menu, an empty CursorAdapter will be added to the Data Environment that is based on the default VFP CursorAdapter class, which is not what you want.
· In the DataEnvironment Builder form activate the Cursors page.
· Click the Add button.
· In the Open dialog find the class library that contains the CursorAdapter class that you want to add to the Data Environment. Then, select the desired CursorAdapter class and click the OK button.
· Important: In the CursorAdapter Builder form that comes up, click the Cancel button. See Avoiding a VFP CursorAdapter Builder Error.
· The selected CursorAdapter will then appear in the list of CursorAdapters in the DataEnvironment Builder form. Click the OK button and the CursorAdapter will be added to the DE.
3. Data Environment: Add all the tables, views and CursorAdapters you will use on the form to the Data Environment window. Set any relations needed.
4. Drag and Drop: Drag and drop the fields you want on the form from the tables, views and CursorAdapters in the Data Environment window to the form. The Form Designer will place the appropriate control on the form for each field you drag and drop from the Data Environment window. However, the controls are based on the Visual FoxPro base control classes, which is not what you want. The control classes will be changed to the VPME control classes in step 10 below.
5. Important - InitialSelectedAlias Property: Set the Data Environment InitialSelectedAlias property to the name of the form's main, or active, table, view or CursorAdapter. If the Properties window is not visible, click the Data Environment window with your right mouse button and click the Properties option on the popup menu. Select "Dataenvironment" in the Object box on the Properties window. Click the Data Tab. Click the InitialSelectedAlias property. Select the name of the active table, view or CursorAdapter from the list in the Property Settings box.
Tip - Cursor vs. Table, View or CursorAdapter Name: When the Data Environment window is active, the Visual FoxPro Properties window denotes each table, view or CursorAdapter in the Data Environment as Cursor1, Cursor2, Cursor3, etc. When you select one of the Cursors in the Object box on the Properties Window, the CursorSource property shows you the name of the table.
6. BeforeOpenTables Event: For every form you create that includes a view or CursorAdapter in the Data Environment, add the following two lines of code to the BeforeOpen Tables Event of the Data Environment:
SET TALK OFF
SET DELETED ON
Matching Remote Views: If you will be using matching remote views with the form, add the following line of code to the BeforeOpenTables event:
7. Order Property for Tables: Set the Order property of the cursor for the form's main, or active, table if you want to specify the order of the table when the form first appears.
· cInitialTag Property for Views and CursorAdapters: While you can set the initial order for an InitialSelectedAlias (ISA) table through the Order property of the cursor. You cannot do that if the ISA is a view or CursorAdapter. Instead, use the cInitialTag property of the form. In the cInitialTag property of the form enter the Tag Name in the Data Builder for the tag definition that you want to use to set the initial order for a view or CursorAdapter ISA. If you like, you can also use this property to set the order for ISA tables instead of the Order property of the cursor.
8. NoDataOnLoad Property - Views: Set every filtered view's Data Environment cursor NoDataOnLoad property to .T. to prevent Visual FoxPro from displaying parameter prompts when a form loads.
9. NoData Property – CursorAdapters: Set every filtered CursorAdapter’s Data Environment cursor NoData property to .T. to prevent Visual FoxPro from displaying prompts when a form loads.
10. Private Data Sessions: Decide whether you want to use a private data session for the form. Generally, if you want multiple instances for your form or if the tables, views and CursorAdapters the form uses could be used by other forms at the same time, you should use a private data session. By default VPME forms that edit tables, views and CursorAdapters use private data sessions. To turn off a private data session for a form, set the form’s DataSession property to “1”.
Tip: Multiple instances means the ability to run the same form more than once.
9. Find Form - lStartWithFind property
You can choose to display the VPME Standard or SQL Find Form at form startup by setting the form's lStartWithFind property to .T. See Find Forms to learn more about the VPME Standard and SQL Find Forms.
10. Run the ProMatrix Control Builder
When you drag and drop fields from the Data Environment Window to the form, the controls added to the form are based on the Visual FoxPro base control classes. You need to run the ProMatrix Control Builder to change them to the VPME control classes. The VPME controls for fields contain properties and methods that link the fields to the VPM Enterprise data dictionary.
1. Select the controls you added to the form from the Data Environment Window. Include the label controls in your selection. Use Shift-Click to click the controls or drag a selection box around the controls.
2. With the mouse arrow over one of the selected controls, click your right mouse button. Select the Builder option on the popup menu.
3. Select the ProMatrix Control Builder from the Builder selection dialog. Click OK.
Field Labels and Autosizing: The VPM Enterprise Control Builder changes the class of the selected field controls and at the same time inserts field labels from the Data Builder. The Control Builder also automatically resizes the text boxes you added to the form to reflect the actual field sizes as defined in the Data Builder.
11. Add Controls from the VPME Class Library
If you need to add any controls from the VPME control class library to the form, now is the time to do it. First you need to display the VPME controls on the Form Controls Toolbar.
1. Click the View Classes icon on the Form Controls Toolbar. (It's the icon with the books.) On the menu popup select the control class library you are using (either Vpmctrls, Devctrls or Proctrls). The Controls Toolbar will change to show a list of the VPME control icons.
2. Now you can place the controls on the form, size them and set their properties and methods as desired.
Tip – Picklist Help: If a field is a foreign key set up in the Data Builder with Referential or Set validation, choose a VPME textbox or combobox control for the field and set up the control properties to get the Picklist behavior you want. See Building Data: Picklist Help.
12. Run the ProMatrix Toolbar List Builder
If your form is based on the VPM Enterprise Form_Toolbar class or a subclass thereof, run the ProMatrix Toolbar List Builder to create a customized toolbar List control grid for the form. See ProMatrix Toolbar List Builder.
13. Run the ProMatrix Condition Field List Builder:
If your form is based on the VPM Enterprise Form_Toolbar class or a subclass thereof, run the ProMatrix Condition Field List Builder to select the fields that will appear in the form’s Condition Builder Field list. See ProMatrix Condition Field List Builder.
14. Beautify the Form
Take some time to create a well-balanced attractive form. Use boxes to group related controls. Space controls symetrically.
15. Set the Tab Order
Tab order means the order in which the focus moves from one field or object to the next as you press the Tab key. You change the tab order of a form through the Tab Order option on the View menu.
Tip: Always check the tab order when you create a form. Change the tab order if it doesn’t lead one logically through the fields on the form. Refer to Visual FoxPro Help to learn how to use the Visual FoxPro Tab Order tools.
16. Run the Form to Test It
You can run the form to test it from the Form Designer or by clicking the Run button on the Form Editor, providing that the form uses standard VPME classes and objects. If you modify the VPME classes or objects or use your own, you may need to test the form by building and running the application.
To run the form from the Form Designer, select the Run option on the Form menu or right-click the form and select Run from the popup menu.
17. Build the Application
Before you can view the form in your application, you must rebuild the application. Click the Build Application button on the Object Builder to rebuild.