Reading displayed windows title bars? 
Author Message
 Reading displayed windows title bars?

Hi,
    I'm looking for a way to read the title bars of all displayed
windows on a PC. Currently, the method I implement is to use the
GetWindow% and GetWindowText API calls in conjunction. However, the
GetWindow% call returns a handle to all "Windows" defined windows,
whereas I want only those windows which are actually displayed on the
screen. Anyone know how to do that?
    The code that I currently use is given below. Any help will be
appreciated.

Regards,
Mustafa Lokhandwala

Declare Function GetWindow% Lib "User32" (ByVal hWnd%, ByVal wCmd%)
Global Const GW_HWNDFIRST = 0
Global Const GW_HWNDNEXT = 2
Public Declare Function GetWindowText Lib "User32"
Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String,
ByVal cch As Long) As Long

w = GetWindow%(Me.hWnd, GW_HWNDFIRST)
Do While w <> 0
   y = GetWindowText(w, winCap, 254)
   b = Left(winCap, y)
   'do whatever processing is required
   w = GetWindow%(w, GW_HWNDNEXT)
Loop

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Tue, 25 Mar 2003 03:00:00 GMT  
 Reading displayed windows title bars?

This doesn't answer your question, but whan using the 32-bit API, GetWindow
takes Long parameters and return a long value.

Be careful when you use code that was written in 16-bit VB in a 32-bit app.
Many API calls will appear to compile, but will fail due to improper
declarations.

Tore.


Quote:
> Hi,
>     I'm looking for a way to read the title bars of all displayed
> windows on a PC. Currently, the method I implement is to use the
> GetWindow% and GetWindowText API calls in conjunction. However, the
> GetWindow% call returns a handle to all "Windows" defined windows,
> whereas I want only those windows which are actually displayed on the
> screen. Anyone know how to do that?
>     The code that I currently use is given below. Any help will be
> appreciated.

> Regards,
> Mustafa Lokhandwala

> Declare Function GetWindow% Lib "User32" (ByVal hWnd%, ByVal wCmd%)
> Global Const GW_HWNDFIRST = 0
> Global Const GW_HWNDNEXT = 2
> Public Declare Function GetWindowText Lib "User32"
> Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String,
> ByVal cch As Long) As Long

> w = GetWindow%(Me.hWnd, GW_HWNDFIRST)
> Do While w <> 0
>    y = GetWindowText(w, winCap, 254)
>    b = Left(winCap, y)
>    'do whatever processing is required
>    w = GetWindow%(w, GW_HWNDNEXT)
> Loop

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Tue, 25 Mar 2003 03:00:00 GMT  
 Reading displayed windows title bars?
I havent done it before, but I would suggest using EnumWindows. My
documentation claims that EnumWindows will enumerate all Top-Level windows,
passing the hWnd of each in turn to an application defined callback
function. Callbacks are a pain in the ass, especially if you dont know what
they do. Here is the URL of a good example from Randy Birch:

http://www.mvps.org/vbnet/code/enums/enumwindows.htm

--


Quote:
> Hi,
>     I'm looking for a way to read the title bars of all displayed
> windows on a PC. Currently, the method I implement is to use the
> GetWindow% and GetWindowText API calls in conjunction. However, the
> GetWindow% call returns a handle to all "Windows" defined windows,
> whereas I want only those windows which are actually displayed on the
> screen. Anyone know how to do that?
>     The code that I currently use is given below. Any help will be
> appreciated.

> Regards,
> Mustafa Lokhandwala

> Declare Function GetWindow% Lib "User32" (ByVal hWnd%, ByVal wCmd%)
> Global Const GW_HWNDFIRST = 0
> Global Const GW_HWNDNEXT = 2
> Public Declare Function GetWindowText Lib "User32"
> Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String,
> ByVal cch As Long) As Long

> w = GetWindow%(Me.hWnd, GW_HWNDFIRST)
> Do While w <> 0
>    y = GetWindowText(w, winCap, 254)
>    b = Left(winCap, y)
>    'do whatever processing is required
>    w = GetWindow%(w, GW_HWNDNEXT)
> Loop

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Wed, 26 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to show diffenent texts in Title Bar and Windows Task Bar

2. How to show diffenent Texts in Title Bar and Windows Task Bar

3. Q: Removing title bar and/or Menu bar from a window

4. Change Font in title bar of mdi child/Hide title bar

5. Change Font in title bar of mdi child/Hide title bar

6. How to display an icon in the title bar of a form

7. Prevent Icon Display in Title Bar

8. Color Common Dialog in VB3.0 does not display DialogTitle in title bar

9. Displaying Time in Title Bar?

10. Help: Need to read the title bar of a shelled app

11. Remove title bar from Userform or Window

12. Create window without title bar?

 

 
Powered by phpBB® Forum Software