Microsoft KB Archive/157723

= How To Extend the Visual FoxPro Solutions Sample =

Article ID: 157723

Article Last Modified on 6/30/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q157723



SUMMARY
You can easily extend the Visual FoxPro Solutions.exe sample by adding new components. This article describes the steps required to add a new form, query, view, or report to the Solutions sample.



Adding a New Component to Solution.dbf
To add a new component to the Solutions sample, add a new record to Solution.dbf and fill in the following fields.

The Key Field:

The Key field must be unique, and it must be a number followed by an underscore, 205_ for example. The Key field is used to populate the treeview control (oleTree) in Solution.scx.

The Parent Field:

The Parent field must match the Key value of the record for the parent node of the sample in the treeview. For example, if you want to add a new component to be displayed under "ActiveX\ActiveX Controls" in the Solution.scx treeview, replace the Parent field with 101_. A Parent of 0_ indicates that the item is added to the root level of the treeview control.

The Text Field:

The text you enter in the Text field is displayed in the treeview control and the filtered list view in Solution.scx.

The Image Field:

The Image field specifies the picture to be displayed beside the component in the treeview. If you are adding a component to be run, set the picture to "dot."

To see all the images, right-click oleImages in Solution.scx and choose ImageList Control Properties.

The File Field:

The File field contains the name of the new sample file.

The Type Field:

Fill in the Type field as follows:   N -- Not a sample F -- Form V -- View Q -- Query R -- Report The Path Field:

The path of the new sample file, relative to the directory that Solution.scx is located in.

The Descript Field:

The Descript field contains the description that is displayed in Solution.scx when the sample is selected in the treeview or in the list box.

The Method Field (for forms only):

If you want a form to be opened in design mode with a particular method opened by default, specify the method in the Method field.

Customizing a Form for the Solutions Sample
Queries, reports, and views don't need any special coding to be good Solution application citizens, but forms do need a little customization.

 Add the c_solutions class from VFP\Samples\Solution\Solution.vcx in Visual FoxPro 5.0 or the MSDN directory under Samples\vfp98\Solution\Solution.vcx in Visual FoxPro 6.0 to your form. Keep the default name of c_solutions1.  Add the following lines to the Activate event of the form: IF TYPE('THIS.c_solutions1') = "O" THISFORM.c_solutions1.SaveHelp ENDIF   Add the following lines to the Deactivate event of the form: IF TYPE('THIS.c_solutions1') = "O" THIS.c_solutions1.RestoreHelp ENDIF  Add the behindscenes class from Vfp\Samples\Solution\Solution.vcx or the MSDN directory under Samples\vfp98\Solution\Solution.vcx in Visual FoxPro 6.0 to your form, and make sure the HelpContextID of the form is set to 0, the default. This opens the solutions overview topic when a user chooses the Behind the Scenes button or presses F1.

If you want to provide a Help topic for your component, you need to make a change to c_solution and make sure that the user gets the updated copy. The cHelpFile property of c_solution is protected, but it should not be. When you create a help file for your new component, set the cHelpFile property of c_solutions1 to the name of your help file.

Adding a New Component to the Filtered List View
The filtered list isn't a filtered list at all: the list displays one side of a many-to-many relationship. Each Solutions component can be listed under multiple "filters" and each "filter" can contain many components. The tables involved in the relationship are as follows:   Solution.dbf--The list of components Reftext.dbf--The list of "filters" and an ID  Xref.dbf--A juncture table between Solution and Reftext If your new component belongs under one or more of the existing filters, add records to Xref.dbf with the ID of the filter in Reftext.dbf and the Key value for your component from Solution.dbf. If you want to add another filter, add the new filter to Reftext.dbf.

