.WFM file structure
The following code was generated by
Dragging a table from the Navigator table’s page onto the Form design surface
Adding a pushbutton from the Component palette
Selecting the onClick event in the Inspector and clicking its tool button
Writing simple code for an event handler that tells how many rows are in the table when the form is run and the button is clicked.
Here is the code:
** END HEADER -- do not remove this line
*
* Generated on 08/24/02
*
parameter bModal
local f
f = new UntitledForm( )
if (bModal)
f.mdi = .F. && ensure not MDI
f.ReadModal( )
else
f.Open( )
endif
CLASS AnatomyForm OF FORM
this.Height = 12
this.Left = 30
this.Top = 0
this.Width = 40
this.Text = ""
this.animals1 = new Query( )
this.animals1.parent = this
with (this.animals1)
Left = 10
Top = 4
SQL = 'SELECT * FROM "C:\PROGRAM FILES\dBASE\Plus\Samples\Animals.dbf"'
Active = True
endwith
this.pushbutton1 = new pushbutton(this)
with (this.pushbutton1)
onClick = class::PUSHBUTTON1_ONCLICK
Height = 1.1176
Left = 20
Top = 3
Width = 15.875
Text = "PUSHBUTTON1"
Metric = 0
FontBold = False
Group = True
endwith
this.Rowset = this.animals1.Rowset
// {Linked Method} Form.pushbutton1.onClick
function PUSHBUTTON1_onClick
this.text = form.rowset.count( )
ENDCLASS
There are four major sections in a .WFM file:
The first part is the optional Header section. This is any code above the ** END HEADER line. Comments that describe the file are usually put here.
Between the header and the beginning of the CLASS definition is the standard bootstrap code. This code instantiates and opens a form when you run the form, similar to the way the boot sector of a disk starts the system when you turn on your computer. The standard bootstrap code allows you to open the form in two ways:
If you DO the .WFM with no parameters, the form is opened with the open( ) method. The form is modeless.
If you DO the .WFM with the parameter True, the form is opened with the readModal( ) method. The form is modal. A modal form cannot be MDI, so the form’s MDI property is set to False first.
The main CLASS definition constitutes the bulk of most .WFM files. This is the code representation of forms designed visually in the Form designer.
Everything after the main class definition, if anything, makes up the General section. This is a place for other functions and classes.