Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Identifying the active Windows window
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Identifying the active Windows window
Miscellaneous
Thread ID:
00742546
Message ID:
00742546
Views:
54
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
Map
View

Click here to load this message in the networking platform