04.08.2013 Views

Printing - FoxTalk - dFPUG-Portal

Printing - FoxTalk - dFPUG-Portal

Printing - FoxTalk - 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.

on a page frame, you'll need a subclass with the pages that will hold Containers objects.<br />

Use SetAll to set common properties<br />

One problem you may have run into with container classes (I'm talking about all container<br />

objects now) is setting certain attributes for all the items you'll want to create in that container.<br />

For example, you may decide that you want the BackColor property of all the option buttons<br />

within your option group to be gray.<br />

You don't want to create an option group with the maximum number of buttons you'll need with<br />

the expectation that you can reduce the number of buttons when you instantiate the option group.<br />

Although you can remove these buttons with RemoveObject() at runtime, you can't reduce the<br />

number of controls at design time. You also don't want to go through the hassle of having to set<br />

the BackColor for each and every button in the group. This fails to take advantage of container<br />

polymorphism.<br />

Instead of laboriously setting a property for each object, you can use SetAll(). Put this nifty<br />

command in the Init method of the container to change a specific property for all of a particular<br />

kind of item in that group. For example, the following code will change the BackColor of all the<br />

options within a group to gray:<br />

THIS.SetAll('BackColor',RGB(192,192,192),'OptionButton')<br />

Now, don't worry when you drop an option group on your form and the BackColor on all the<br />

options is white. Remember, you don't actually run the Init code until you run the form. Any<br />

properties that you set in this manner won't be visible until runtime.<br />

Of course, it's possible to create a builder to set all the properties at design time, or even to use<br />

SetAll() from the Command window at design time if you first select the container and get a<br />

handle to the form with ASELOBJ():<br />

=ASELOBJ(o,1)<br />

o[1].SetAll('BackColor',RGB(192,192,192),'OptionButton')<br />

If you need to change this property, it's easier to go to the container's Init method and change a<br />

single runtime SetAll() call. Also, if you use the runtime SetAll() and later add more objects to<br />

the container, they will automatically share the properties of the existing buttons. You don't have<br />

to remember to change the properties for the new objects. Personally, I find these advantages<br />

outweigh the disadvantage of not being able to see the property settings at design time, but you<br />

may feel differently.<br />

Is your data dragging you down?<br />

You've probably seen at least one Visual FoxPro demo where someone dragged an item from the<br />

data environment and dropped it on the form to create a text box for that item. If you want to use

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

Saved successfully!

Ooh no, something went wrong!