ChrisRChamberlain
Programmer
Hi all
The following example code, modified from George Tasker's IsRunning.prg, iterates through the various windows and processes and returns the windows title.
What I am trying to identify is the active Windows window from within VFP, the Windows window title also being required.
I assume there are other properties that could be returned within such an example loop that could determine which Windows window is currently active.
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 ;
[tab]INTEGER hwnd ,;
[tab]INTEGER dflag
DECLARE INTEGER GetWindowText IN Win32API ;
[tab]INTEGER hwnd ,;
[tab]STRING @lptstr ,;
[tab]INTEGER cbmax
LOCAL lnhwnd ,;
[tab]lctitle_bar ,;
[tab]lntext_len
lnhwnd = GetDesktopWindow()
lnhwnd = GetWindow(lnhwnd,5)
lctitle_bar = []
DO WHILE !EMPTY(lnhwnd)
[tab]lctitle_bar = SPACE(200) + CHR(0)
[tab]lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
[tab]lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
[tab]IF !EMPTY(lctitle_bar)
[tab][tab]? lctitle_bar
[tab]ENDI
[tab]lnhwnd = GetWindow(lnhwnd,2)
ENDDO
TIA![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)
The following example code, modified from George Tasker's IsRunning.prg, iterates through the various windows and processes and returns the windows title.
What I am trying to identify is the active Windows window from within VFP, the Windows window title also being required.
I assume there are other properties that could be returned within such an example loop that could determine which Windows window is currently active.
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 ;
[tab]INTEGER hwnd ,;
[tab]INTEGER dflag
DECLARE INTEGER GetWindowText IN Win32API ;
[tab]INTEGER hwnd ,;
[tab]STRING @lptstr ,;
[tab]INTEGER cbmax
LOCAL lnhwnd ,;
[tab]lctitle_bar ,;
[tab]lntext_len
lnhwnd = GetDesktopWindow()
lnhwnd = GetWindow(lnhwnd,5)
lctitle_bar = []
DO WHILE !EMPTY(lnhwnd)
[tab]lctitle_bar = SPACE(200) + CHR(0)
[tab]lntext_len = GetWindowText(lnhwnd, @lctitle_bar, 200)
[tab]lctitle_bar = UPPER(LEFT(lctitle_bar, lntext_len))
[tab]IF !EMPTY(lctitle_bar)
[tab][tab]? lctitle_bar
[tab]ENDI
[tab]lnhwnd = GetWindow(lnhwnd,2)
ENDDO
TIA
FAQ184-2483 - the answer to getting answered.
Chris ![[pc2] [pc2] [pc2]](/data/assets/smilies/pc2.gif)