Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How Do I Prevent Multiple Instances Of The Same Form
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00255528
Message ID:
00255574
Views:
17
>How can I test for whether or not a form is already running, and just activate it, instead of DOing another instance?


Doug, I'm using a CodeBook/VFE framework so I'm not sure how much of this will apply to your code. I faced the same problem and solved it my modifying the DoForm utility in the SETUP.PRG CodeBook program. My mod looks like this and has worked well:

*RS 1999.05.30 SYS {
loForm = goApp.oForms.get(tcClassName)
if type("loForm.name")="C"
loForm.SelectForm()
return
endif
*RS 1999.05.30 }

SelectForm is a method I wrote which activates and shows an existing form. The entire DoForm function is attached below.

I would love to know more about your VLS app. I have about ten main non-modal forms which stay open once opened so that the user can bounce around without having to rebuild a form each time. Sounds like you are doing something similar.

Peter Robinson





Attachment:

************************************************************
* FUNCTION DoForm()
************************************************************
* Author............: Paul Bienick
* Project...........: Codebook 3.0
* Created...........: 07/24/95 14:08:45
* Copyright.........: (c) Flash Creative Management, Inc., 1995
*) Description.......: Creates and shows forms, and returns values
*) : if appropriate
* Calling Samples...: =DoForm("musicianform")
* : IF !DoForm("preferenceform")
* Parameter List....: tcClassName = name of form class to create
* : tuParm1 = optional parameter to pass to form being
* : created
* Major change list.: WMF, added change of mouse pointer while form is loading
* History.....: Rodes Software changes
&& 1999.05.30 Don't create form is already instantiated.
**********************************************************************

function DoForm(tcClassName, tuParm1)
local ;
loObject, ;
lnMousePointer, ;
luRetVal

lnMousePointer = _screen.mousepointer
_screen.mousepointer = MOUSE_HOURGLASS

*RS 1999.05.30 SYS {
loForm = goApp.oForms.get(tcClassName)
if type("loForm.name")="C"
loForm.SelectForm()
return
endif
*RS 1999.05.30 }

if PCOUNT() < 2
loObject = createobject(tcClassName)
else
loObject = createobject(tcClassName, @tuParm1)
endif

_screen.mousepointer = lnMousePointer

if type("loObject") == "O" and !isnull(loObject)
loObject.show()
if type("loObject.uRetVal") <> "U"
luRetVal = loObject.uRetVal
loObject.destroy()
release loObject
return luRetVal
endif
endif

endfunc
Peter Robinson ** Rodes Design ** Virginia
Previous
Reply
Map
View

Click here to load this message in the networking platform