Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Working with 2 forms..
Message
From
29/04/2009 03:11:14
 
 
To
28/04/2009 23:46:42
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01396857
Message ID:
01396869
Views:
88
>I have two forms, form1 and form2 show at the same time with form2 as the active form..
>
>I want to set caption to a button in form1 when form2 is active..
>
>How do I do this?
>

You'll need an object reference. The way how to get it might depend on how the two are related -
One option: By default, Vfp keeps track of running forms in _screen.Forms, so you can loop thru it:
LOCAL loForm as Form
FOR EACH loForm IN _screen.Forms
	? loForm.Name
ENDFOR
Inside the loop, you can check if m.loForm is the desired one, perhaps by comparing the loForm.Name if it is unique.
Or use PemStatus() to see whether it has a certain custom method that you created in the Form Designer, e.g. "SetCaption()" or so.


Or another option: you can pass object references directly, instead of scanning _screen.Forms: say form1 runs form2 in a button.Click(). In that case you can do something like:
* form1.someButton.Click():
Do Form form2.SCX With Thisform
.... and in form2.Init() receive the parameter:
LParameters toCallingForm
Thisform.oForm1 = m.toCallingForm && you added that custom property in the Form Designer
Now you can use the "Thisform.oForm1" reference in any method of form2 or its members.



hth
-Stefan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform