Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to generically set readonly to .T.?
Message
From
24/08/1999 15:06:58
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00257234
Message ID:
00257253
Views:
16
>I have a form class that is used by several forms. There are multiple databounded fields in each form. I would like to set the fields as readonly or not with one single generic method.
>What would be the best approach?

If thisform.SetAll() (and then digging into containers that have their own SetAll) and you haven't made provision for the controls used on your form to reference a common form property as necessary to detrmine if they're read-only or not (this is what I do), you need code that will build a list of the contained objects in the form during the Form's Init (this will work only if you don't programmatically add controls later) using AMEMBERS(). You'll need to spin down through this recursively (containers can contain controls, which may be containers...) something like:
PROCEDURE MakeAllObjReadOnly
LPARAMETER oObjToCheck
LOCAL aObjsInThis, nNumObj, i
nNumObj = AMEMBERS(aObjsInThis,oObjToCheck,2)
FOR i = 1 TO nNumObj
   =MakeAllObjReadOnly(aObjsInThis[i])
ENDFOR
IF TYPE('oObjToCheck.ReadOnly') = 'L'   
   oObjToCheck.ReadOnly = .T.
ENDIF
RETURN
Then in your form's Init:

=MakeAllObjReadOnly(thisform)

This is not tested code; there's no error handling or checking to make sure that the ReadOnly property can be set at runtime in the code above. it should give you a simple starting place to write your own code for your forms.

Note that this function is recursive, and it can create problems of its own with very deep containership.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform