Solutions Sample Overview

The Visual FoxPro Solutions sample is a collection of independent samples designed to illustrate particular features of Visual FoxPro. As you go through these samples, you can see how to accomplish specific tasks in Visual FoxPro.

To run the Solutions Sample application

DO (HOME() + 'samples\solution\solution')

The samples are organized into the following categories: ActiveX, Controls, Databases, Forms, Menus, Reports, Toolbars, and WinAPI. To see all of the components in this treeview, choose the Expand All button and scroll through the components.

When you select a component, you can:

After you close the form or designer that is opened, you are returned to the main Solutions form.

How the Solutions Sample Works

Each component of the Solutions sample is listed in SOLUTION.DBF. This table stores the following:

There are two additional tables used to provide filtered list access to the components: XREF.DBF and REFTEXT.DBF.

The FillTree method of the SOLUTION.SCX reads the information from SOLUTION.DBF to fill the treeview control.

* FillTree
o = THIS.pgf1.pagTree.oleTree

SCAN
	IF ALLTRIM(parent) = '0'
		oNode = o.nodes.add(,1,ALLTRIM(key),ALLTRIM(text),,)
	ELSE
		oNode = o.nodes.add(ALLTRIM(parent),4,ALLTRIM(key), ALLTRIM(text),,)
	ENDIF
	* add images to the treeview
	IF !empty(image)
		oNode.Image = ALLTRIM(image)
	ENDIF
ENDSCAN

Forms

Each form in the Solutions suite contains an object based on the c_solutions class in SOLUTION.VCX. This class provides a single place for environment and localization settings. When the c_solutions object is destroyed, old settings are restored and, if the Solutions form exists, it is redisplayed.

The custom class is used in the Solutions sample because it provides greater flexibility: you can add it to existing forms, and, if you want, you can delete it from the forms in the Solutions suite and customize the forms for your own use. Instead of using a custom class to manage the environment settings, you can provide this functionality in one form class from which all forms in the Solutions sample are derived.

Form records in SOLUTION.DBF have a value of “F” stored to the type field. In the code associated with cmdRun and cmdSee, the form is run or modified.

* extract from cmdRun.Click
	CASE solutions.type = "F" && form
		DO FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file))

Note In the Data Environment of SOLUTION.SCX, the cursor for SOLUTION.DBF is given an alias of “Solutions.”

Reports and Queries

Report records in SOLUTION.DBF have a value of “R” stored to the type field and queries have a type of “Q”. You can run the reports and queries in the code associated with cmdRun, and you can modify them in the code associated with cmdSee.

* extract from cmdRun
	CASE solutions.type = "R" && report
		REPORT FORM (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file)) PREVIEW NOCONSOLE
		THISFORM.Visible = .T.

Running a query opens the result set in a Browse window. By default, a Browse is displayed in the currently active window, which, in this sample would be the Solutions form. To display the Browse in a separate window, this code defines and activates another window, runs the query, then releases the separate window:

	CASE solutions.type = "Q" && query
		#DEFINE TITLE_LOC "Results of query "
		DEFINE WINDOW brow_wind FROM 1,1 TO 30, 100 TITLE TITLE_LOC + UPPER(ALLTRIM(file))+ ".QPR " ;
			FLOAT GROW MINIMIZE ZOOM CLOSE FONT "Arial",10
		ACTIVATE WINDOW brow_wind NOSHOW
		DO (ALLTRIM(solutions.path) + "\" + ALLTRIM(solutions.file) + ".QPR")
		RELEASE WINDOW brow_wind
		THISFORM.Visible = .T.
ENDCASE