Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How go through all objects?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00031811
Message ID:
00031999
Views:
47
>>>>>>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.
>
>Are you referring to the SetAll method or are you referring to a 3rd party utility? While the SetAll method is very powerful, and I do use it, it does have its limitations. One very destinctive one is that in many cases you cannot scan through all controls and set a property based on a condition.

Early in this thread I encouraged Mr. Shevchenko to look at the .SetAllProp method of the txtbtns class in WIZSTYLE.VCX, which is the class the form wizard uses to make, among other things, the one-to-many form. The txtbtns class handles pretty much everything the form needs to do, including calling other classes in WIZSTYLE which do searches and things. .SetAllProp sets .Enabled and .Readonly for objects in THISFORM depending on base class and current value of the editmode property of txtbtns. I thought that this code did most of what he wanted, and was mentioning its limits.
Previous
Reply
Map
View

Click here to load this message in the networking platform