>I have written an app in VFP5.0a I need to find a way to check if my app is already running when a user starts it. If the app is already running I then need to move focus to the one previously started.
>
>any help in this matter will be greatly appreciated.
Craig,
Try putting this code in your MAIN.PRG. It won't move focus to the active instance but it will keep users from starting your app 20 times!
Notice that when you create the .app file, you'll get the message "RegFn not found" and "CallFn not found". I just ignore these and it works fine.
*********************************************************************
* only start if not already running
SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE
* FindWindow() takes two parameters and returns the handle of the window, HWND, if it was found.
GetWind = RegFn("FindWindow", "CC", "I")
* Set the first parameter of the call to getwind to 0, null.
wclass=0
winname="MY APPLICATION"
apphand=CallFn(GetWind,wclass ,winname)
* If the call was successful, stop processing.
IF apphand<>0
WAIT WINDOW "The program is already running."
QUIT
ELSE
MODIFY WINDOW SCREEN TITLE winname
.
.
.
* start your system
.
.
.
ENDIF
*********************************************************************
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement