Information générale
Catégorie:
Fonctions Windows API
Titre:
Identifying the active Windows window
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement