PDA

Click to See Complete Forum and Search --> : How do I capture every Window ??


Zleepy
Nov 13th, 1999, 04:03 PM
I want to capture every window and create a picturebox for each window in the size of each window, and I want to know the caption of each window.....and when I move the picturebox, I want the window with that caption to move..

Huntedman
Nov 14th, 1999, 10:04 PM
Sounds like you want to joke around huh?

Well it's a long story involving findwindow, getdc, and stuff like that.

good luck!

Hunted

Serge
Nov 15th, 1999, 12:30 AM
Add Msflex Grid control to your form.

Module Code:


Public Const MAX_PATH = 260
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Type udtWin
hWnd As Long
ClassName As String
Caption As String
End Type
Public tWin() As udtWin
Public Function EnumWindowProc(ByVal hWnd As Long, ByVal lParam As Long) As Long
Dim strCaption As String
Dim strClass As String
Static i As Integer

strCaption = Space(MAX_PATH)
strClass = Space(MAX_PATH)
Call GetClassName(hWnd, strClass, MAX_PATH)
Call GetWindowText(hWnd, strCaption, MAX_PATH)

'Strip off null character
strCaption = Left(strCaption, InStr(strCaption, vbNullChar) - 1)
strClass = Left(strClass, InStr(strClass, vbNullChar) - 1)

'Add to array
ReDim Preserve tWin(i)
tWin(i).hWnd = hWnd
tWin(i).ClassName = strClass
tWin(i).Caption = strCaption

i = i + 1
'To cintinue, must return true
EnumWindowProc = 1
End Function



Form Code:


Private Sub Form_Load()
Dim i As Integer
Dim strItem As String

Call EnumWindows(AddressOf EnumWindowProc, &H0)

MSFlexGrid1.Cols = 3
MSFlexGrid1.TextMatrix(0, 0) = "hWnd"
MSFlexGrid1.TextMatrix(0, 1) = "Class Name"
MSFlexGrid1.TextMatrix(0, 2) = "Caption"

For i = 0 To UBound(tWin)
strItem = tWin(i).hWnd & vbTab & tWin(i).ClassName & vbTab & tWin(i).Caption
MSFlexGrid1.AddItem strItem
Next
'Remove empty row
MSFlexGrid1.RemoveItem 1
End Sub


This will enumerate all windows (including the ones on the background) and put them in a MsFlexGrid.


Regards,
------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)


[This message has been edited by Serge (edited 11-15-1999).]

Zleepy
Nov 15th, 1999, 11:13 AM
I just wanted to know how to get information from all Windows that are visible, and send information to a specific window....that's all.