|
-
Jan 18th, 2000, 02:47 AM
#1
Thread Starter
New Member
This may be an easy question. If I have a hWnd, what declare do I use to grab the windows name property? I've accomplished the reverse, type in the name of a window and have it return it's number (using FindWindow), but I want to fill in a list box of these using their names, not numbers. I'm VERY new at this, so the more info, the better. Thanks!!
-
Jan 18th, 2000, 03:05 AM
#2
Use the GetWindowText() API to return the Windows Caption, ie.
Code:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Function GetWindowCaption(ByVal lhWnd As Long) As String
Dim sCaption As String
sCaption = Space(255)
GetWindowCaption = Left$(sCaption, GetWindowText(lhWnd, ByVal sCaption, 255))
End Function
Usage:
sWindowCaption = GetWindowCaption(lTheHwnd)
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jan 18th, 2000, 11:53 AM
#3
Addicted Member
and if what you want isn't the windows text try GetClassName
here are two function one get the handle of a window the mouse is over the second usees the first to get the class name of the window the mouse is over
you'll need to add getcursorpos,pointapi,windowfrompoint,and getclassname for these functions to work
Public Function wHwndFromPoint() As Long
Dim point As POINTAPI, pointX As Long, pointY As Long
Dim Hndl As Long
Call GetCursorPos(point)
pointX& = point.X
pointY& = point.Y
Hndl& = WindowFromPoint(pointX&, pointY&)
If Hndl& <> 0& Then
wHwndFromPoint& = Hndl&
Else
wHwndFromPoint& = 0&
Exit Function
End If
End Function
Public Function wClassFromPoint() As String
Dim Hndl As Long, wClass As String * 100, w As String
Hndl& = wHwndFromPoint&
w$ = GetClassName(Hndl&, wClass$, 100)
wClassFromPoint$ = Left(wClass$, w$)
End Function
------------------
SomeTimes Coffee Just Isn't Enough.
Zan Magi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|