| How to Use FoxTools to Switch to Another ApplicationLast reviewed: April 30, 1996Article ID: Q109060 | 
| The information in this article applies to: 
 
 SUMMARYThe 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 
 © 1998 Microsoft Corporation. All rights reserved. Terms of Use. |