referencing properties in a non-active form 
Author Message
 referencing properties in a non-active form

Excuse the terminally dull subject title, but I couldn't think of a better way
to summarise my question.  I have two forms open. One has a push button which,
when clicked passes a value to a property of the second form. At least that's
what I would like it to do. I am having trouble figuring out what syntax I need
to refer to the property in the second form. If I use (formname.property) then
I of course get a message saying that 'formname' doesn't exist. I know this is
probably a ridiculously simple problem, but I am suffering from a mental block
at the moment and would appreciate any assistance.
Thank you, thank you and thrice thank you.
- Alex



Fri, 15 Sep 2000 03:00:00 GMT  
 referencing properties in a non-active form

Alex,

Pass a reference from the first form to the second. In the click:

do form second with thisform

In the second form Init() method:

lparameter oCallingForm
wait window oCallingForm.Caption

If you want to use the reference later, in another method you'll need to store it in a
form property, and make sure that you clear the reference in the Destroy

df    - (Microsoft FoxPro MVP) http://www.geocities.com/ResearchTriangle/9834/

Quote:

>Excuse the terminally dull subject title, but I couldn't think of a better way
>to summarise my question.  I have two forms open. One has a push button which,
>when clicked passes a value to a property of the second form. At least that's
>what I would like it to do. I am having trouble figuring out what syntax I need
>to refer to the property in the second form. If I use (formname.property) then
>I of course get a message saying that 'formname' doesn't exist. I know this is
>probably a ridiculously simple problem, but I am suffering from a mental block
>at the moment and would appreciate any assistance.
>Thank you, thank you and thrice thank you.
>- Alex



Fri, 15 Sep 2000 03:00:00 GMT  
 referencing properties in a non-active form

WD,

You sure can, provided _screen.ActiveForm is currently pointing to the correct form. You
could also pass a reference from the _screen.Forms[] collection

df    - (Microsoft FoxPro MVP) http://www.geocities.com/ResearchTriangle/9834/

Quote:

>Can't you also use "do form1 with _screen.activeform", if, for instance,
>you want to use a menu instead of a form object event to interact with
>form2?



Fri, 15 Sep 2000 03:00:00 GMT  
 referencing properties in a non-active form

Can't you also use "do form1 with _screen.activeform", if, for instance,
you want to use a menu instead of a form object event to interact with
form2?

WD



Quote:
> Alex,

> Pass a reference from the first form to the second. In the click:

> do form second with thisform

> In the second form Init() method:

> lparameter oCallingForm
> wait window oCallingForm.Caption

> If you want to use the reference later, in another method you'll need to
store it in a
> form property, and make sure that you clear the reference in the Destroy

> df    - (Microsoft FoxPro MVP)

http://www.geocities.com/ResearchTriangle/9834/
Quote:




Quote:
> >Excuse the terminally dull subject title, but I couldn't think of a
better way
> >to summarise my question.  I have two forms open. One has a push button
which,
> >when clicked passes a value to a property of the second form. At least
that's
> >what I would like it to do. I am having trouble figuring out what syntax
I need
> >to refer to the property in the second form. If I use

(formname.property) then

- Show quoted text -

Quote:
> >I of course get a message saying that 'formname' doesn't exist. I know
this is
> >probably a ridiculously simple problem, but I am suffering from a mental
block
> >at the moment and would appreciate any assistance.
> >Thank you, thank you and thrice thank you.
> >- Alex



Sat, 16 Sep 2000 03:00:00 GMT  
 referencing properties in a non-active form

Firstly, thanks for the advice.
I think I understand what you are saying, but in this specific case both forms
have been activated so I can't use the init() method of the second form to
accept the parameters.  I have a bit of a messy way around the problem but I
was hoping that there was a way that I could pass values between two separate
but activated forms.
Thanks for taking the time to answer, I really appreciate it.
-- Alex



Sat, 16 Sep 2000 03:00:00 GMT  
 referencing properties in a non-active form

If the active form doesn't have an existing object reference for the second
form, you can cycle through the forms collection of the _SCREEN object. See
the FORMS property in the on line help for _SCREEN...

Here's an example...

FOR x = 1 TO _SCREEN.FormCount
        IF _SCREEN.Forms(x).NAME = "Whatever Form Name You're Looking For"
                _SCREEN.Forms(x).SomeProperty = Something different
                EXIT
        ENDIF
ENDFOR

You could also stuff the object reference of the second form in a property
of the first one if you want to refer to it later.

FOR x = 1 TO _SCREEN.FormCount
        IF _SCREEN.Forms(x).NAME = "Whatever Form Name You're Looking For"
                THISFORM.r_ObjectProperty = _SCREEN.Forms(x)
                EXIT
        ENDIF
ENDFOR

Then you could refer to it later this way...

THISFORM.r_ObjectProperty.SomeProperty = Something Different

Just remember to release the object reference before you try to close
either of the forms, otherwise you will have outstanding object references.

THISFORM.r_ObjectProperty = .F.

--
William Fields
US Bankruptcy Court
Phoenix, AZ



Quote:
> Excuse the terminally dull subject title, but I couldn't think of a
better way
> to summarise my question.  I have two forms open. One has a push button
which,
> when clicked passes a value to a property of the second form. At least
that's
> what I would like it to do. I am having trouble figuring out what syntax
I need
> to refer to the property in the second form. If I use (formname.property)
then
> I of course get a message saying that 'formname' doesn't exist. I know
this is
> probably a ridiculously simple problem, but I am suffering from a mental
block
> at the moment and would appreciate any assistance.
> Thank you, thank you and thrice thank you.
> - Alex



Sat, 16 Sep 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Referencing properties on non-active form

2. Can't reference on forms properties from another form

3. Addressing non-active form from .prg file

4. Form array properties: passing by reference

5. Cant Reference other Forms Properties

6. reference form property in a function

7. problem using EVAL() with form property referencing

8. Referencing form properties

9. Referencing properties from another form

10. Form hierarchy non-Modal, but non-Modeless ? :-(

11. Q: Form hierarchy non-Modal, but non-Modeless ? :-(

12. Non-Default Properties Only in VFP7 ???

 

 
Powered by phpBB® Forum Software