close another application 
Author Message
 close another application

how can I to close another application in current application written in
foxpro ?



Sun, 27 Aug 2000 03:00:00 GMT  
 close another application

: how can I to close another application in current application written in
: foxpro ?

Probably the easiest way is by calling the SendMessage function in the
Win32 API.  The following sample code will do this.  You can adapt it
to your own programs by removing the "Run Calculator" code and
replacing cWindowToClose with the TITLE of the window you want to
close (probably the application's top-level window).

* Declare DLL functions and parameters.
        DECLARE LONG FindWindow IN Win32API;

        DECLARE LONG SendMessage IN Win32API;
                LONG nHwnd, LONG nMessage, LONG nParam1, LONG nParam2
        nCloseMessage = 16      && Value of WM_CLOSE
        cWindowToClose = "Calculator"  && Title of window to close.

* Run Calculator.
        WAIT WINDOW "Press any key to run Calculator."
        RUN/N4 "CALC.EXE"

* Now, close Calculator.
        WAIT WINDOW "Switch back to VFP, then press any key to CLOSE Calculator."
        nHwnd=FindWindow(0,cWindowToClose)  && Get window handle.
        IF nHwnd=0
                =Messagebox("Sorry, "+cWindowToClose+" Window Not Found!",16)
        ELSE
                =SendMessage(nHwnd,nCloseMessage,0,0)  && Close window.
        ENDIF

RETURN

To learn more about the Win32API library, you can look on the MSDN
reference CD-ROM (if you have MSDN or Visual Studio) or at Microsoft's
MSDN website (http://premium.microsoft.com/msdn/library/).

Hope this helps!

Joe Adams
Founder and lead developer
Quality Data Division of JTAE
http://junior.apk.net/~joe/QualityData.html



Sun, 27 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How update DBF file without close the application?

2. Closing of Application

3. VFP 3.0, Close an application (EXE) with the X-Button

4. Closing an application from the toolbar

5. MAC question - clicking on close box from within application

6. Help: Closing FPWin in an application

7. Report From ... Closes application

8. Closing application when Windows shut down

9. Closing application

10. Win32 API calls: opening & closing applications

11. Close a vfp application

12. Simple Question, Closing Application?

 

 
Powered by phpBB® Forum Software