DOCUMENT:Q109060 30-APR-1996 [foxpro] TITLE :How to Use FoxTools to Switch to Another Application PRODUCT :Microsoft FoxPro PROD/VER:2.50 2.50a 2.50b OPER/SYS:WINDOWS KEYWORDS:kbprg kbcode ---------------------------------------------------------------------- The information in this article applies to: - Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b ---------------------------------------------------------------------- SUMMARY ======= The program below demonstrates how you can use FOXTOOLS.FLL to call Windows Software Development Kit (SDK) functions that switch the active application window on the desktop. MORE INFORMATION ================ * Switch test program * * Example of using FOXTOOLS.FLL to make Windows calls to switch * the active application window. * * This program uses FindWindow to retrieve the HWND of a particular * application's window and SetActiveWindow to make that the active * window. * * Then a DO loop is used to keep that application active until another * call is made to return the last window (which should be FoxPro) to * active status. * * Uses FoxTools library for generic DLL access. SET LIBRARY TO SYS(2004)+"foxtools.fll" ADDITIVE * FindWindow takes two parameters and returns the HWND of the * application if it was found. getwind = regfn("FindWindow", "CC", "I") * SetActiveWindow takes the HWND of the desired application and returns * the HWND of the last active application. setactwind = regfn("SetActiveWindow", "I", "I") * Set the first parameter of the call to getwind to 0 as null. wclass=0 winname="Program Manager" pmhand=callfn(getwind,wclass ,winname) * If the call was not successful don't try to switch the windows. IF pmhand<>0 WAIT WINDOW "Switching to PM and back after an interval." NOWAIT lastwind=callfn(setactwind,pmhand) ii=1 DO WHILE ii<500000 ii=ii+1 ENDDO lastwind=callfn(setactwind,lastwind) ELSE WAIT WINDOW "Cannot find that window" ENDIF Additional reference words: FoxWin 2.50 2.50a 2.50b foxtools fll KBCategory: kbprg kbcode KBSubcategory: FxprgFoxtools ============================================================================= 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. Copyright Microsoft Corporation 1996.