Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interform comm- multiple return vals/ best methods?
Message
From
22/12/2002 12:33:36
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Interform comm- multiple return vals/ best methods?
Miscellaneous
Thread ID:
00735260
Message ID:
00735260
Views:
56
I have read some threads on here regarding the various methods for 'inter-form communication', returning multiple values, etc. However, I am still unclear on some things. I have tried a couple of different strategies:


STRATEGY #1
I have two forms - forma and formb. Formb is modal, and is called by forma. I created a form property in formb called - ocallersobject. In formb's init I have:

lparameters toForm
thisform.oCallersObject=toForm

In the click method of a command button in forma I have:

do form formb with thisform

In formb I can set the controlsource of some of my objects as follows:

thisform.txt1.controlsource=thisform.oCallersObject.someformproperty

Then I can change the value in formb - then issue:

thisform.oCallersObject.Refresh() and the values refresh in forma.

However, note that the values change automatically this way in forma. I want to also be able to have an OK, Cancel in formb, such that if I click cancel, the values are reverted to what they were originally.

I suppose that I could have no controlsource in my objects in formb. Then in the init of formb - I could set the controls' value properties to the properties of the form passed in from forma. Then, if the user clicks OK on formb, I can set the properties for forma by doing something like:
thisform.oCallersObject.someproperty= thisform.txt1.value

If they click cancel. Then I don't do anything, and forma's values remain the same

Note that here I don't even return a value to forma

STRATEGY #2
I have read some of the threads here about using a 'parameter object'. If I understand correctly, I can:

1) create some object on forma - such as 'oParamObject' Add some properties to it.
2)

In forma I could issue:

local loretval
do formb to loretval with oParamObject
release loretval && btw - do I need to do this?

and in forma's init
lparameters toParamObject
thisform.oinBoundParamObject=toParmObject

and in formb's unload:

return thisform.toParamObject

then, set the properties in formb. Maybe one property could be something like 'laccept'

Then, when I come back to forma if laccept was set to true, then set the rest of the properties in forma to the returned values
*********************************************************
Questions:

Which of these strategies is better? Or does it depend on the context? It seems as if I pass in thisform - and set the properties directly, I have a built in mechanism for controlling ALL of forma's properties from formb.

But if I pass in a separate object, that is on forma, then I can either a) set its properties directly in formb, and then decide, when I get back to forma, whether to accept the property changes via a property such as laccept, or b)set other properties or controls on formb to the values of the parameter object passed in, and then, in formb, decide via an OK cancel button whether to write the formb properties back to the parameter object properties.

I hope this all makes sense! Any suggestions would be appreciated!

TIA - and Happy Holidays to all
Next
Reply
Map
View

Click here to load this message in the networking platform