Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Running only one instance of an application
Message
From
24/05/1998 09:40:37
Mark Austen
Schooner Software Limited
Msida, Malta
 
 
To
23/05/1998 09:56:05
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00101181
Message ID:
00101492
Views:
22
The following is another way using DDE. Just call DDEServe at the start of the app. I use this in FPW2.6 but it should work in VFP although I've not tried it yet.
*==========================================================================
*-- Title......: DDEServe
*-- Abstract...: Procedure to detect if another instance of the application
*--            : already exists. If so, that instance is maximised and this
*--            : instance is closed. If no detected, then the DDE Server is
*--            : set up and the application continues.
*-- Parameters.: name of EXE file
*==========================================================================
*
procedure DDEServe
parameters ;
   tcExeName
*
#define sSYSTEM "SYSTEM"
#define sDEFINE "DEFINE"
#define sSAFETY "SAFETY"
*
if empty(tcExeName)
   wait window "name of EXE file not passed to DDEServer."
   *
else
   private ;
      jnChannel
   *
   *** Don't show warning dialog if server not found
   *
   = DDESetOption(sSAFETY, .f.)
   *
   *** Try to establish a link to the DDE server
   *
   jnChannel = DDEInitiate(tcExeName, sSYSTEM)
   *
   *** If found cancel
   *
   if jnChannel # -1
      = DDETerminate(jnChannel)
      cancel
      *
   endif
   *
   *** Set up new DDE server
   *
   = DDESetService(tcExeName, sDEFINE)
   *
   *** Create the topic name for the Detected function
   *
   = DDESetTopic(tcExeName, sSYSTEM, "Detected")
   *
endif
*
return
*
*
*==========================================================================
*-- Title......: DDEReset
*-- Version....: 1.0 A
*-- Abstract...: Procedure to reset the DDE server set up in DDEServe
*-- Parameters.: name of EXE file
*==========================================================================
*
procedure DDEReset
parameters ;
   tcExeName
*
if empty(tcExeName)
   wait window "EXE name not passed to DDEReset"
   *
else
   *
   *** Reset DDE server
   *
   = DDESetService(tcExeName, "RELEASE")
   *
endif
*
return
*
*
*==========================================================================
*-- Title......: Detected
*-- Abstract...: Procedure to maximise the application. Used in DDEServe
*-- Parameters.: None used, however, parameters must be specified since the
*--            : DDE sends values.
*==========================================================================
*
function Detected
parameters ;
   tnChannel, ;
   tcAction, ;
   tcItem, ;
   txData, ;
   txFormat, ;
   tnAdvise
*
zoom window screen max
*
return .t.
*
*
*--------------------------------------------------------------------------
*--------------------------------------------------------------------------
Regards,

MarkA
Previous
Reply
Map
View

Click here to load this message in the networking platform