04.08.2013 Views

Chapter 10 Using VFP's Object- Oriented Tools - dFPUG-Portal

Chapter 10 Using VFP's Object- Oriented Tools - dFPUG-Portal

Chapter 10 Using VFP's Object- Oriented Tools - dFPUG-Portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

266 The Fundamentals of Visual FoxPro 6.0<br />

Thus, when you ship an application, you need to include the classes—the .VCX files—<br />

along with your menus, forms, reports, and other files. Or, if you’re building an executable file,<br />

the build process will compile the classes used in your application just as it does ordinary<br />

programs.<br />

Thus, here’s the answer to the question, “How do changes to a class library get reflected in<br />

the application?” When you change a class, you must ship the new .VCX or a new .EXE that<br />

reflects the new .VCX to the location where the application is running, just as when you<br />

updated a procedure library file.<br />

I’d like to discuss the contents of the .VCX and .SCX files in a bit more depth before<br />

moving on, using a real example to illustrate where all the pointers go.<br />

Suppose your form base class consists of a Visual FoxPro base form and two command<br />

buttons, both from a Visual FoxPro command-button base class, as shown in Figure <strong>10</strong>.1. The<br />

form base class is named frmBase, and the VCX that holds this form class is named<br />

BASECLASSES.VCX. If you open BASECLASSES.VCX, you’ll see five records. The first is<br />

just a placeholder. The next three records represent the three objects that make up this class: a<br />

VFP form and two VFP command buttons. If you examined the Class field of these three<br />

records, you’d see they reference Visual FoxPro’s built-in objects. The last record is another<br />

placeholder that you shouldn’t worry about. The key point is that this class definition consists<br />

of three records.<br />

Figure <strong>10</strong>.1. A sample form base class consisting<br />

of a Visual FoxPro form and two Visual FoxPro<br />

command buttons.<br />

Next, suppose you were to instantiate a form from this class (don’t worry about exactly<br />

how that process works quite yet), and name this form MYSAMPLE.SCX, as shown in<br />

Figure <strong>10</strong>.2. If you opened MYSAMPLE.SCX as a table with the USE command, what would<br />

you see? If you had created a regular form, you’d expect to see three records—one for the form<br />

and one for each of the command buttons, right? But we created this form from a class, which<br />

means that this form is essentially just a pointer to a class. That means you’re going to see only<br />

one record in the .SCX file. The Class field in that record is going to point to frmBase, and the<br />

ClassLoc (class location) field in that record is going to point to BASECLASSES.VCX.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!