Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RunAll as SetAll but for methods
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01159583
Message ID:
01159923
Views:
17
I Agree with Doug's solution by using the _Assign method to the property... I've actually gone another step to add a secondary property to flag if certain other conditions may be needed... such as enable / disable based on certain conditions... ie: some controls you may ALWAYS want as read-only, and via something like an _Assign to the read-only method, and a custom property for "AlwaysReadOnly", the assign can look at the second flag and always ignore the setting and keep read-only = .t.




>While SetAll() can be used to change all properties, I sometimes want to run a method on all of my edit controls in a form. These controls can be in containers, grids or pages of a page frame so I only want to run the method for those objects having it - but I want to drill down into containers (that don't have the method.
>
>So, I've written a RunAll() method for my form. Here's the code. I'd like this to be a public domain sort of thing with anyone modifying the code to make it more robust. Any comments?
>
>
>LPARAMETERS oObj, cMethod
>LOCAL nX, oComp
>DO CASE
>
>* If this object has the method, run it
>CASE PEMSTATUS(oObj, cMethod, 5)
>    EVALUATE ([oObj.] + cMethod + "()")
>
>* If this doesn't have a baseclass we can get to... (VFPSkins has this issue)
>CASE PEMSTATUS(oObj, [BaseClass], 2)
>    *...we don't know  to do
>	
>* If this has a Controls array, go thru each component
>CASE PEMSTATUS(oObj, [ControlCount], 5) AND oObj.ControlCount > 0
>    FOR nX = 1 TO oObj.ControlCount
>        oComp = oObj.Controls[nX]
>        THISFORM.RunAll(oComp, cMethod)
>    ENDFOR
>
>* If this is a Grid, go thru each column
>CASE oObj.BaseClass = [Grid] AND oObj.ColumnCount > 0
>    FOR nX = 1 TO oObj.ColumnCount
>        oComp = oObj.Columns[nX]
>        THISFORM.RunAll(oComp, cMethod)
>    ENDFOR
>
>* If this is a PageFrame, go thru each page
>CASE oObj.BaseClass = [Pageframe] AND oObj.PageCount > 0
>    FOR nX = 1 TO oObj.PageCount
>        oComp = oObj.Pages[nX]
>        THISFORM.RunAll(oComp, cMethod)
>    ENDFOR
>
>* If we got here, we can't do anything with this object
>ENDCASE
>
Previous
Reply
Map
View

Click here to load this message in the networking platform