I'm using the sys(1272) function to get the complete hierarchy of an object.
also to retrieve that objects form.
unfortunatally this results only a form name as a characterstring
and not as an object reference.
So my question is .
how can I easily retrieve a form object reference.

this is the code to retrieve the forms name
csys_ = Sys(1272,oSource) &&complete form hierarchy
csys_ = Upper(Substr(csys_,1,At(".",csys_,1)-1)) &&only form.name

I'm using this a lot with drag&drop operations.
and would like something to enhance the code like this :

osys_= makeobjectreference(csys_)
With osys_
...
EndWith

In the past I was creating an array of each opened form
and scanned that array for the name but that's a bit confusing and overhead
for this simple task

thanks in advance
regards
Christophe

Re: object hierarchy by Olaf

Olaf
Fri Jun 29 07:58:45 CDT 2007

> In the past I was creating an array of each opened form
> and scanned that array for the name but that's a bit confusing and
> overhead
> for this simple task

the only overhead I see from it is, that
this array already exists.

Drag&Drop operations already give you object references of
the objects involved.

You could add a property form to your draggable objects/controls
and make an form_access method RETURN THISFORM.

or you go up the Parent reference until finding a form.

Bye, Olaf.



Re: object hierarchy by Roger

Roger
Fri Jun 29 08:40:37 CDT 2007


"christophe" <nothingtosend@empty.com> wrote:

> I'm using the sys(1272) function to get the complete hierarchy of an
> object.
> also to retrieve that objects form.
> unfortunatally this results only a form name as a characterstring
> and not as an object reference.
> So my question is .
> how can I easily retrieve a form object reference.
>
> this is the code to retrieve the forms name
> csys_ = Sys(1272,oSource) &&complete form hierarchy
> csys_ = Upper(Substr(csys_,1,At(".",csys_,1)-1)) &&only form.name
>
> I'm using this a lot with drag&drop operations.
> and would like something to enhance the code like this :
>
> osys_= makeobjectreference(csys_)
> With osys_
> ...
> EndWith
>
> In the past I was creating an array of each opened form
> and scanned that array for the name but that's a bit confusing and
> overhead
> for this simple task

Since you've already got an object reference for oSource ...

loObject = loSource
loForm = Null
lcObject = 'loObject'
Do While .T.
If loObject.BaseClass = 'Form'
loForm = loObject
Exit
Else
loObject = Evaluate(lcObject+ '.Parent')
EndIf
EndDo

?loForm.Caption

-Roger



Re: object hierarchy by christophe

christophe
Fri Jun 29 08:56:17 CDT 2007

lovely
thanks

christophe
"Roger Ansell" <notmy@realemailaddress.net> schreef in bericht
news:ebYdPKluHHA.1184@TK2MSFTNGP04.phx.gbl...
>
> "christophe" <nothingtosend@empty.com> wrote:
>
>> I'm using the sys(1272) function to get the complete hierarchy of an
>> object.
>> also to retrieve that objects form.
>> unfortunatally this results only a form name as a characterstring
>> and not as an object reference.
>> So my question is .
>> how can I easily retrieve a form object reference.
>>
>> this is the code to retrieve the forms name
>> csys_ = Sys(1272,oSource) &&complete form hierarchy
>> csys_ = Upper(Substr(csys_,1,At(".",csys_,1)-1)) &&only form.name
>>
>> I'm using this a lot with drag&drop operations.
>> and would like something to enhance the code like this :
>>
>> osys_= makeobjectreference(csys_)
>> With osys_
>> ...
>> EndWith
>>
>> In the past I was creating an array of each opened form
>> and scanned that array for the name but that's a bit confusing and
>> overhead
>> for this simple task
>
> Since you've already got an object reference for oSource ...
>
> loObject = loSource
> loForm = Null
> lcObject = 'loObject'
> Do While .T.
> If loObject.BaseClass = 'Form'
> loForm = loObject
> Exit
> Else
> loObject = Evaluate(lcObject+ '.Parent')
> EndIf
> EndDo
>
> ?loForm.Caption
>
> -Roger
>



Re: object hierarchy by Gene

Gene
Fri Jun 29 10:23:18 CDT 2007

"christophe" <nothingtosend@empty.com> wrote:

>I'm using the sys(1272) function to get the complete hierarchy of an object.
>also to retrieve that objects form.
>unfortunatally this results only a form name as a characterstring
>and not as an object reference.
>So my question is .
>how can I easily retrieve a form object reference.

What about
thisform
?

[snip]

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.