Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One Instance
Message
De
23/11/2004 00:43:55
 
 
À
04/11/2004 07:11:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
00957965
Message ID:
00963721
Vues:
13
Hi Marcia,

I applied your code in my main.prg and built the executable. I ran it for the first time and it was fine. I ran it again, I added a message to let the user know what's going on before quitting the application (another instance of the app). But screen came up again without the toolbars. If I minimized and maximized several times the application eventually quit. Strange!

P.S. Thank all for helping me (Cetin Basoz, Jon Neale & Marcia Akins)

Here is my code (Main.prg):
SET MULTILOCKS ON
SET EXCLUSIVE OFF
SET DELETED ON

_Screen.Caption = "Project Safety"

AppRun = IsAppRunning()
IF !AppRun  THEN
	_Screen.Visible = .F.
	DO FORM CURDIR() + "FORMS\Intro.SCX"
	SET CLASSLIB TO CURDIR() + "Library\MyTools" ADDITIVE

	oStandard = CREATEOBJECT('Standard')
	oStandard.Dock(0)

	READ EVENTS

ELSE
	=MESSAGEBOX("Only one instance of this application can be run at a time.",64,"Project Safety")
	Quit
ENDIF

FUNCTION IsAppRunning
LOCAL lnHWND, lcTitle, llRetVal

*** Set UP API Calls
Declare Integer FindWindow IN Win32Api String, String
Declare BringWindowToTop   IN Win32APi Integer
Declare ShowWindow         IN Win32Api Integer, Integer

*** Get the current Screen Caption
lcTitle = _Screen.Caption

*** Change it to avoid finding THIS instance
_Screen.Caption = SYS(3)

*** Now locate another instance
lnHWND = FindWindow( NULL, lcTitle )

*** And restore the original caption
_Screen.Caption = lcTitle

*** Check the results
IF lnHWND > 0
  *** We have found something!
  *** So make it uppermost and maximize it (ShowWin => 3)
  BringWindowToTop( lnHWND )
  ShowWindow( lnHWND, 3 )
  *** Set the Return Value
  llRetVal = .T.
ENDIF

*** Return Status for action
RETURN llRetVal
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform