Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Names of current windows
Message
De
01/09/2005 09:33:11
 
 
À
31/08/2005 14:59:54
Tim Muller
Innovative Solutions, Inc.
West New York, New Jersey, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
01045635
Message ID:
01045799
Vues:
21
There should be a Win 32 API function that I can use to get the names of all of the open/running windows.
LOCAL loRetVal, lnFoxHwnd, lnWindow, lnWhich, lcText, lnLen, lnAppCnt, lnRes
LOCAL ARRAY laJunk[1]

loRetVal = CREATEOBJECT( [empty] )
ADDPROPERTY( loRetVal, "aApps[ 1 ]" )
**********************************************************
*** Check that the library has been set up and open it if not already done.
**********************************************************
lnRes = ADLLS( laJunk )
IF lnRes = 0 OR  NOT ( ASCAN( laJunk, 'GetWindow', 1, -1, 1, 15 ) > 0)
  DECLARE INTEGER GetWindow IN Win32Api ;
      INTEGER lnWindow, ;
      INTEGER lnWhich
ENDIF

IF lnRes = 0 OR  NOT ( ASCAN( laJunk, 'GetWindowText', 1, -1, 1, 15 ) > 0)
  DECLARE INTEGER GetWindowText IN Win32Api ;
      INTEGER lnWindow, ;
      STRING   @lcText, ;
      INTEGER lnLen
ENDIF

IF lnRes = 0 OR  NOT ( ASCAN( laJunk, 'IsWindowVisible', 1, -1, 1, 15 ) > 0)    
  DECLARE INTEGER IsWindowVisible IN Win32Api ;
      INTEGER lnWindow
ENDIF
 
lnAppCnt = 0

*** Loop through all the running applications
*** Find the next window in the z-order
lnWindow = GetWindow( _VFP.hWnd, 2 )
DO WHILE lnWindow # 0
  *** Only deal with windows that are not owned windows
  *** (i.e, dialogs or messageboxes) and make sure the window is visible
  IF GetWindow( lnWindow, 4 ) = 0 AND IsWindowVisible( lnWindow ) # 0
    lcText = SPACE( 254 )
    lnLen  = GetWindowText( lnWindow, @lcText, LEN( lcText ) )
     
    *** Add this to the array
    IF lnLen > 0
      lnAppCnt = lnAppCnt + 1
      DIMENSION loRetVal.aApps[ lnAppCnt ]
      loRetVal.aApps[ lnAppCnt ] = LEFT( lcText, lnLen )
    ENDIF
  ENDIF

  *** See if there is another running application
  lnWindow = GetWindow( lnWindow, 2 )
ENDDO
 
RETURN loRetVal
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform