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

ID: Q131634


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 query words: FoxWin


Keywords          : FoxWin FxprgFoxtools 
Version           : 
Platform          : 
Issue type        : kbhowto 


Last Reviewed: August 18, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.