HOWTO: Pausing Program Execution while RUN /N Command is Running

Last reviewed: September 10, 1997
Article ID: Q131634
2.60a WINDOWS kbprg kbcode

The information in this article applies to:

  • Microsoft FoxPro for Windows, version 2.6a

SUMMARY

When the RUN /N command starts another Windows application from within FoxPro for Windows, the program invokes the next line of FoxPro code (the line following the RUN /N command) immediately without pausing execution. Sometimes it is useful to halt the execution of the FoxPro program until the other application closes. There is no switch on the RUN command to accomplish this, so this article shows you how to use FOXTOOLS.FLL to control program execution.

MORE INFORMATION

The following code employs FOXTOOLS.FLL and the RegFn() function to register the Windows API function GetActiveWindow(). Then GetActiveWindow() determines if the FoxPro for Windows application is on top. If FoxPro is the active window, the program execution continues.

   WAIT WINDOW 'Beginning of program'
   RUN /N notepad.exe
   IF NOT 'FOXTOOLS' $ SET('LIBRARY')
      SET LIBRARY TO SYS(2004)+"FoxTools"
   ENDIF

   FoxWind = MAINHWND()
   GetActive=RegFn('GetActiveWindow','','I') && Determine if FoxPro is
                                             && on top
   DO WHILE .T.    && Keep looping until the ActiveWindow = FoxWind
      IF FoxWind = CallFn(GetActive)
         EXIT
      ENDIF
   ENDDO

   WAIT WINDOW 'Program paused while Notepad was up...End of program'
   SET LIBRARY TO

The application started by the RUN /N command cannot be opened as inactive. Therefore, the RUN /N cannot contain the values 4 (Inactive and normal size) or 7 (Inactive and minimized) after the /N parameter.

REFERENCES

Microsoft Windows 3.1 Programmer's Reference, Volume 2, page 319.

Windows version 3.1 Software Development Kit (SDK) Help File included with Visual Basic, Visual C++, and the Windows SDK.


Additional reference words: FoxWin 2.60a
KBCategory: kbprg kbcode
KBSubcategory: FxprgFoxtools
Keywords : FoxWin FxprgFoxtools
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.