General information
Category:
Windows API functions
Title:
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only