Many thanks, Dave
Dave Crozier wrote:
Paul,
The simple answer is you can't really as focus will onl;y pass to the
calling program once the firm itself has been destroyed unfortunately and
the object reference disappears after the form is closed but BEFORE the next
line of code.
I think I'd do the following:
1. Create a custom object called some derivative of the form object e.g
oForm_Return_Object from within the form (within the init() function or even
the unload() function which is JUST before the form object is released)
2. Create the return value as a property of the Return Object
(oObj.Addproperty(<<cname>>, <<,vValue>>) in the Unload() event.
3. In your program flow, the form instance will then be released when you
close the form (release()) in the normal way and control returned to your
mainline program. You can examine the oForm_Return_Object and extracting the
return value before releasing/destroying it.
Hope this helps.
Dave Crozier
The secret to staying young is to live honestly, eat slowly, and to lie
about your age
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Paul Newton
Sent: 02 November 2006 14:43
To: [email protected]
Subject: Re: Return value from form created in code
Dave
Tx for the reply. I have been playing around with your code for a few
minutes and have two questions.
1. How would you modify the code to make the form modal ?
2. Why is the "Close" button invisible until I grab and move the form with
the mouse ? I have tried putting btnClose.Visible = .T. in various places
and am getting some weird results (like the form background not
showing)
TIA
Dave Crozier wrote:
Paul,
Mistake in your coding in that you don’t pass the "init() parameter"
as a string
Also you can use non modal forms to do the same thing - just as an
aside - see below!
* Returning data back from a non modal form
*
? Create_Form("Hello")
***********
* Create the Form and return Back Values
*
Procedure Create_Form(pcVar)
Local o
Local lnRetVal
o = CREATEOBJECT("MyForm", pcVar)
o.Show(2)
Do While .t.
DoEvents
Wait Window Nowait Noclear o.nStatus
If o.nStatus=-1
lnRetval=o.cRetvar
Release o
exit
Endif
Enddo
*
Return lnRetVal
************
* Form Class
*
DEFINE CLASS MyForm AS Form
Add Object btnClose as CommandButton
cRetVar = 0
nStatus=0
PROCEDURE Init()
PARAMETERS tcRetVar
This.btnClose.Caption="Close"
=BindEvent(This.btnClose,"Click",This,
"SomeProcThatSetsTheReturnValue")
THIS.cRetVar = tcRetVar
ENDPROC
PROCEDURE SomeProcThatSetsTheReturnValue
This.cRetVar="Hello Modified"
STORE -1 TO THISFORM.nStatus
ENDPROC
*
ENDDEFINE
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.