Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to detect a form and release it ? 1

Status
Not open for further replies.

pxw

Programmer
Jan 6, 2002
86
AU
I have two forms, FORM1 and FORM2, in an app.

When activating FORM2, I need to detect FORM1 if it is activated. If yes, FORM1 should be released.

I don't know,
-how to detect FORM1 from FORM2 ?
-how to release the activated FORM1 from FORM2 ?

Any help would be greatly appreciated.

Peter



Any help will be greatly appreciated.

Peter
 
Peter,
Try the WEXISTS() function. It will return if the form exists. Try this code:


IF WEXISTS("FORM1")
ACTIVATE FORM1
ThisForm.Release
ENDIF

Best Regards,
Scott

Please let me know if this has helped [hammer]
 
pxw

DO FORM Form1 NAME oForm1 LINKED

will provide an object reference to Form1 which will enable you to release the object from Form2.


Place:-

RELEASE oForm1

in the .Destroy() or other suitable event in Form1.


In Form2.Init() place:-

IF VARTYPE(oForm1) = [O] && Object exists
[tab]WITH oForm1
[tab][tab].Hide()
[tab][tab].Release()
[tab]ENDW
ENDI


If you find the object reference goes out of scope in your app, use:-


PUBLIC oForm1
DO FORM Form1 NAME oForm1 LINKED


By creating an object reference, you can access and manipulate the PEMs of Form1 through the object oForm1. HTH

Chris [pc2]
 
hi Scott,

I have tried your codes. it doesn't work. Any suggestions?


Peter



 
hi Chris,

Many thanks for your advices. Your codes work very well.


Peter




 
Hi Scott,
Using your codes, FORM1 can be released properly from FORM2. However, FORM1 can not be called up again. What I want is to run FORM1 after FORM2 is released. Following is my test codes. It didn't work.

DO FORM Form1 NAME oForm1 LINKED

form1.Destroy()
RELEASE oForm1

Form2.Init()
IF VARTYPE(oForm1) = [O] && Object exists
WITH oForm1
.Hide()
.Release()
ENDW
ENDI

Form2.CmdExit.click()
Release thisform
IF VARTYPE(oForm1) <> [O] && Object deosn't exist
*/---test1-
DO FORM Form1 NAME oForm1 LINKED
*comment: with LINED, FORM1 did not show on the screen.

*/---test2-
*DO FORM Form1 NAME oForm1
*comment: Without LINKED, FORM1 can show on the screen but it can not be released.
*\---------

Are I doing something wrong? Your comments would be appreciated.



Peter




 
Peter

* Form2.CmdExit.click()
IF VARTYPE(oForm1) # [O]
[tab]DO FORM form1 NAME oForm1 LINKED
ENDI
THISFORM.Release()

HTH

Chris [pc2]
 
How about
_screen.formcount

Returns how many forms are open. Not available at design time.

For instance in the init of form2.
If _Screen.Formcount > 1 &&Then you know a form is opened.
....
endif

 
Hi,

You might try something like this:

**************************************
form2.init
if wexist(&quot;from1&quot;)
deactivate from1 &&Place from1 on the windows menu
endif


form2.buttonset1.cmdExit.click
thisform.release

form2.destroy
if wexist(&quot;form1&quot;)
activate form1 && place from1 back on the desktop
endif

******************************************

Also, you might take a look at the hide command. Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top