Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I tell if another Windows application is running
Message
 
To
05/02/1999 19:23:52
Dennis Schuette
Customized Business Services, Llc
Yuma, Arizona, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00184604
Message ID:
00184689
Views:
21
>I want to be able to run another Windows application from within VFP5. How can I tell if it is currently running, and if it is, how do I bring it to the screen.
>
>Also, how do I stop execution of the VFP program while this application is running?
>

Hi Dennis,

Check the file download section here at the UT in the Win32 and other APIs section. Look for "Is a Windows Application Running". You'll be able to download a function I wrote called Is_Run32(). You simply pass the function the known portion of the application's title bar. If it returns 0 the application isn't running. If it's greater than 0 the application is running. This value is the window handle

Once you have the window handle, you can use the ShowWindow() API call to bring it to restore it to it's last size and postion:
DECLARE SHORT ShowWindow IN Win32API;
  INTEGER hWnd, INTEGER nCmdShow
* Call the Is_Run32 function
lnhWnd = Is_Run32('Whatever title bar')
IF lnhWnd > 0
  * It's running
  = ShowWindow(lnhWnd, 9) &&Restore it
ENDIF
Once you determine if the application's running, there are a number of things you could do. Assign value to a form property that could be evaluated before certain processing took. You could use a loop based on the return value of Is_Run32(), but I wouldn't recommend it. It'd be too easy to get stuck in it.

As a side note, thanks to John for the kind words.

hth,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform