Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ER - only allow the app to run once
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Titre:
ER - only allow the app to run once
Divers
Thread ID:
00688594
Message ID:
00688594
Vues:
66
It is possible for users to start up every MM's app. as many times as they'd like. For advanced users, this is OK. For MOST users, especially if they're not particularly computer literate, this is a problem. It's not uncommon to find that they have opened the app a dozen times because they don't realize it is already running. It would be nice if the framework would allow us to keep this from happening.

I've added a IsRunning() method to my goApp object:
#DEFINE SW_MAXIMIZE		   3   

LOCAL llRunning, ;
      lcCaption, ;
      lnHWnd

llRunning = .F.

* Temporarily rename the caption of 
* the screen, we don't want to find
* ourselves.

lcCaption = _SCREEN.Caption

_SCREEN.Caption = [_] + lcCaption

lnHWnd = FindWin(lcCaption)

IF lnHWnd <> 0   
   
   DECLARE INTEGER ShowWindow in user32 ;
           INTEGER hwnd, ;
           INTEGER nCmdShow
           
   ShowWindow(lnHWnd, SW_MAXIMIZE)
   llRunning = .T.
ENDIF

_SCREEN.Caption = lcCaption

RETURN llRunning
I've also modified the Setup.PRG and added the code:
		*---------------------------------------------------
		*-- Check to see if the app. is already running. If
		*-- it is, and it's only meant to be run once, let's
		*-- exit. The running app. will automatically be 
		*-- brought to the front, maximized.
		*---------------------------------------------------
		* PCM - 8/9/2002		
		IF goApp.lOnlyOneInstance
                   IF goApp.IsRunning()
                      QUIT
                   ENDIF
                ENDIF 
This code is put right after creating goApp (after the RELEASE code and before the *--- Support for Steven Black's INTL) line.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform