> I am trying to enumerate through the form elements of another
> program's window with just a window handle. Is this possible?
[quoted text clipped - 4 lines]
> simple enough to do, but I am unable to determine if this is posible
> and if so, how to do it.
Some of VB's "controls" are implemented by VB itself and don't have
a handle visible to other running programs or even to Windows at all.
--
Joe Foster <mailto:jlfoster%40znet.com> Sacrament R2-45 <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above They're coming to
because my cats have apparently learned to type. take me away, ha ha!
>I am trying to enumerate through the form elements of another
>program's window with just a window handle. Is this possible?
[quoted text clipped - 4 lines]
>simple enough to do, but I am unable to determine if this is posible
>and if so, how to do it.
Try examining the Form with this Snooper
- however as Joe pointed out, Labels (in VB) have no Window Handle
Option Explicit
' Add one Timer
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos _
Lib "user32" _
(lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint _
Lib "user32" _
(ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
Private Declare Function GetClassName _
Lib "user32" _
Alias "GetClassNameA" _
(ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Const WM_GETTEXT = &HD
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 500
End Sub
Private Function WindowInf() As String
Dim Hnd As Long, Buff$, Q&
Dim PT As POINTAPI
GetCursorPos PT
Hnd = WindowFromPoint(PT.X, PT.Y)
WindowInf = Str$(Hnd)
' ---
Buff$ = Space$(255)
Q& = GetClassName(Hnd, Buff$, Len(Buff$))
WindowInf = WindowInf + ":" + Left$(Buff$, Q)
' ---
Q& = SendMessage(Hnd, WM_GETTEXT, Len(Buff$), ByVal Buff$)
WindowInf = WindowInf + ":" + Left$(Buff$, Q)
End Function
Private Sub Timer1_Timer()
Me.Caption = WindowInf
End Sub