_WIZARD

Forms, FormCount

Forms is a collection property—it's an array containing one entry for each form in a form set. FormCount tells you how many forms there are, but, in VFP 3, it gets confused by toolbars.

Usage

frmForm = frsFormSet.Forms ( nIndex ) nFormCount = frsFormSet.FormCount
You can't change either of these properties directly. They're there for reference only.

For a form set, Forms shows you the forms in the set in creation order. Any toolbars in the set are included in the collection, whether they're docked or not.

When you apply Forms to _SCREEN, it gets a little more complicated. Every form displayed on the screen is listed, but the order in which they're listed changes based on which form is active. Then, there are toolbars. Custom toolbars that are displayed get included in _SCREEN's Forms collection. But in VFP 3.0, they disappear from Forms when you dock them. Visual FoxPro's built-in toolbars never appear in Forms.

In VFP 3, FormCount forgets to count toolbars at all, whether or not they're listed in Forms at that moment. Unless you're checking _SCREEN's FormCount. Then, it counts undocked toolbars, but not docked toolbars. (The behavior we describe here is in VFP 3.0b. We think it may have been different in 3.0.) These bugs are fixed in VFP 5 and later versions.


To add to the misery, you can't apply ALEN() to Forms to find out how many there really are. (In fact, even though the collection properties look like arrays, you can't apply any of the array functions to them.) And the FOR EACH loop that keeps you from needing ALEN() isn't available in VFP 3, where the bugs occur.

In VFP 5 and later versions, the Objects collection also gives you access to all the forms in a form set. For the _VFP application variable, Objects gives you access to all the active forms or form sets. But note that form sets get a single entry in Objects, not one for each form. You can then drill down to find the individual forms.

Example

* Check if a particular form is in a given form set FOR nCount = 1 TO ThisFormSet.FormCount    IF Forms[nCount].Name = cName       WAIT WINDOW "Found It"       EXIT    ENDIF ENDFOR

See Also

ControlCount, Controls, Objects, _SCREEN, _VFP


View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.



Hacker's Guide to Visual FoxPro 7. 0
Hackers Guide to Visual FoxPro 7.0
ISBN: 1930919220
EAN: 2147483647
Year: 2001
Pages: 899

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net