|
Technical answers from the trenches |
|
Accessing EditRegion objects
| ||||
Posted: 3 October 2000 |
||||
  |
Applies to: Paradox 5.0 and later |
|||
  |
Audience: Intermediate |
|||
Question: How can I attach a uiObject variable to the editRegion of a labelled field object?Answer: The following is a custom method that shows one way to do this: method getEditRegion( uiIn uiObject, var uiOut uiObject ) Logical
; ---------------------------------------------------------------
; When passed a labelled field object, this attaches to that
; object's EditRegion. Please note that this is done through the
; uiOut parameter. The return value is a logical indicating
; success or failure. The lets you control any messages
; displayed to the end user.
; ---------------------------------------------------------------
var
astrNames Array[] String ; holds names of child objects
loResult Logical ; value returned to caller
strEdtReg String ; possibly name of an edit region
uiEdtReg uiObject ; Temporary placeholder
endVar
loResult = FALSE; ; assume failure to reduce code
; first, get the objects of input value...
if uiIn.class = "Field" then
uiIn.enumObjectNames( astrNames )
; observation revealed that the third element in the
; array is the editRegion, so...
if ( astrNames.size() = 3 ) then
if uiEdtReg.attach( astrNames[ 3 ] ) then
loResult = ( uiEdtReg.class = "EditRegion" )
endIf
endIf
endIf
; if it worked, then assign the placeholder to the output
; parameter.
if loResult then
uiOut.attach( uiEdtReg )
endIf
return loResult
endMethod
In this example, we count on behavior observed with Paradox 8. Specifically, when you view an array populated using enumUIObjects against a labelled field, the third element of that array contains the name of the edit region. The following code, placed on a button with TabStop set to FALSE, shows how you might call this custom method: method pushButton(var eventInfo Event)
var
dstr Dynarray[] String
uio UIObject
endVar
if getEditRegion( active, uio ) then
uio.enumUIObjectProperties( dstr )
dstr.view( "Properties for " + uio.Name )
else
msgStop( "Unable to Find EditRegion", "Reason: The object " +
"named " + Active.Name + " does not appear to be " +
"a labelled field object." )
endIf
An demonstration is available in our download section. Please note that it requires the Customer table provided with Paradox's sample files. If you do not have these installed or cannot find them, we have a copy in our download section. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|