Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How go through all objects?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00031811
Message ID:
00031855
Vues:
46
>>>>Hello All!
>>>>
>>>>I have a little question. How can I go through the ierarchy
>>>>of objects that appeared on screen. I know how make it with
>>>>the form object, but can't imagine how can I go through the
>>>>pageframe or grid object or another container object? My
>>>>primary goal is to determine that object referenced as
>>>>thisform.controls[i] is an container and to determine count
>>>>of controls of this object. I'm really sick with this problem.
>>>>
>>>>Have a nice day,
>>>>
>>>>Vladimir
>>>
>>>Besides Controls(i) you should use ControlCount property and Type function. They are available for Pageframes, Grid, etc (any container). Cheer up!
>>
>>Look at txtbtns.setallprop in WIZSTYLE.VCX. Its purpose is to set .enabled and .readonly for objects on your form. It loops through .controls(i) for i = 1 TO controlcount, and calls itself recursively if .BaseClass = "container".
>>
>>However, the .BaseClass of a PageFrame is not "container" and it doesn't have a .ControlCount property. Therefore, .SetAllProp misses all the objects in your pageframe, which you may have noticed if you tried to use the wizard to make a form and then put a pageframe in it. I originally made a dumb workaround involving my own method, before I realized that PageFrames have a Pages() property and a PageCount property. Pages themselves are containers. If you can get a method similar to .SetAllProp to call itself when it hits a PageFrame and loop through Pages() instead of Controls(), it should solve your problem.
>
>
>All containers have some array which stores the controls of that container, although they are named differently. Here is how I resolved the problem...
>
>FUNCTION enable
>LPARAMETERS poControl
>lcBaseClass = UPPER(poControl.baseclass)
>DO CASE
>CASE lcBaseClass $ "FORM~PAGE~CONTAINER"
> IF poControl.ControlCount > 0
> FOR lnYY = 1 to poControl.ControlCount
> Thisform.m_enable(poControl.controls[lnYY])
> ENDFOR
> ENDIF
>
>CASE lcBaseClass $ "OPTIONGROUP~COMMANDGROUP"
> IF poControl.ButtonCount > 0
> FOR lnYY = 1 to poControl.ButtonCount
> Thisform.m_enable(poControl.Buttons[lnYY])
> ENDFOR
> ENDIF
>
>CASE lcBaseClass = "PAGEFRAME"
> IF poControl.PageCount > 0
> DIMENSION laoCtrl[poControl.PageCount]
> FOR lnYY = 1 to poControl.PageCount
> Thisform.m_enable(poControl.Pages[lnYY])
> ENDFOR
> ENDIF
>
>CASE lcBaseClass = "GRID"
> IF poControl.ColumnCount > 0
> DIMENSION laoCtrl[poControl.ColumnCount]
> FOR lnYY = 1 to poControl.ColumnCount
> Thisform.m_enable(poControl.columns[lnYY])
> ENDFOR
> ENDIF
>
>OTHERWISE
> * Do whatever processing you need to all controls within the container
>ENDCASE
>
>
>Hope this helps :)
I think .SetAllProp was made recursive to account for the possibility of containers within containers, and, in general, the possibility that some controls within a container don't have an .enable method, or must be handled differently for some reason. It handles objects according to their various base classes. I have VFP3, by the way.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform