Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Identifying the active Windows window
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Identifying the active Windows window
Divers
Thread ID:
00742546
Message ID:
00742546
Vues:
55
Hi

The following example code, modified from George Tasker's IsRunning.prg, iterates through the various windows and processes and returns the window's title.

What I am trying to identify is the active Windows window from within VFP, the Windows window title also being required.

The WinAPI call GetActiveWindow() will only return the active window handle to the active window associated with the thread that calls the function, and therefore won't work in this situation.

CLEA

DECLARE INTEGER GetDesktopWindow IN Win32API
DECLARE INTEGER GetWindow IN Win32API ;
INTEGER hwnd ,;
INTEGER dflag
DECLARE INTEGER GetWindowText IN Win32API ;
INTEGER hwnd ,;
STRING @lptstr ,;
INTEGER cbmax

LOCAL lnhwnd ,;
lctitle_bar ,;
lntext_len

lnhwnd = GetDesktopWindow()
lnhwnd = GetWindow(lnhwnd,5)
lctitle_bar = []

DO WHILE !EMPTY(lnhwnd)
lctitle_bar = SPACE(200) + CHR(0)
lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
IF !EMPTY(lctitle_bar)
? lctitle_bar
ENDI
lnhwnd = GetWindow(lnhwnd,2)
ENDDO

TIA

Chris
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform