You know FoxPro is good with
tables, but did you know that it saves almost everything
as a table? I'm talking about reports, form, and
classes. You can actually open these as tables and
look at them "low-level". To open a form,
use the VFP "Data Session" window and
click on "Open". Select "All files"
in the "Files of types:" box. Navigate
to the directory where the form resides, and select
the *.scx file. The file will open in a regular
browse window. You can do the same to classes by
opening the *.vcx class file and to reports by opening
the *.frx file. Be careful here as any change you
make will be permanent and might cause trouble,
so it is strongly recommended that you backup the
files before you make any changes.
OK so how is this useful? Since
you are dealing with tables, you can take some nice
and quick shortcuts. For example, you can easily
change the parent class of a VFP object directly.
Let's say you have a form with 5 text boxes, and
you want to change the parent of these boxes from
the native VFP textbox class to the CoolTextBox
class you just created. Instead of having to worry
how to do this from the graphical interface, you
can open your form as a table and change some fields
manually to quickly change the parent class of these
text boxes.
Start by dropping your CoolTextBox
class on a blank form and save it. Next open that
form as a table and look for the record that has
your CoolTextBox. Look in the "Class"
and "Classloc" fields to see what VFP
has saved for your CoolTextBox. Now open the form
that you want to change, locate the records for
the text boxes you want to change, and replace their
"Class" and "Classloc" fields
with the ones from the CoolTextBox form.
If you're wondering how to
find the appropriate records to change, one way
is to look in the "Objname" column. All
you have to do is to give your controls a name on
the form, and when you open the form as a table,
do a locate on objname='control_name'.
Of course you can automate
this whole process in code. For the example, you
can write a small program that opens a form as
a table and changes the parent class of all the
textboxes to the Foxy Classes SmartTextBox class:
use myform.scx
replace class with 'SmartTextBox', ;
classloc with 'c:\FoxyClasses\Classes\Global.vcx'
;
for lower(class) == 'textbox'
use
You can adjust the above code
to work with all your forms and quickly change the
parent class of all the text boxes or any other
control in your project.