ID: Q131634
2.60a WINDOWS kbprg kbcode
The information in this article applies to:
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.
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.
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
Last Reviewed: September 11, 1997