Solucion
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
· Enter thefollowing in the Command window:
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:
· Read a brief description of the samplein the description area at the bottom of the main Solutions form,
· Run the sample by choosing Run Sample,
· See the code by choosing See Code.
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:
· The key and parentkey ids required to add nodes to a treeview control.
· The image id in the ImageList control for the picture to be displayed beside the item in the treeview control.
· The file name and path of the components.
· The method to open when you choose See Code.
· The description to be displayed in the Visual FoxPro Solutions form.
There are two additional tables used to provide filtered listaccess 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 tothe 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 customclass 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 arederived.
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"...
Regístrate para leer el documento completo.