|
-
Feb 15th, 2002, 11:37 PM
#1
Thread Starter
Frenzied Member
hWnd of child window?
Hi,
After much frustration of trying to subclass the text portion of a ComboBox, I found something interesting using the Spy++ included with Visual Studio.
It turns out that a ComboBox actually has an Edit control in it that contains a different hWnd of the parent, ComboBox.
So my question is, is there a way for me to get at the hWnd of the child window, in this case, the Edit control that is within the ComboBox?
Any help would be appreciated...
Dan
-
Feb 16th, 2002, 09:48 AM
#2
Use EnumChildWindows - here is sample code, but it is not working on a ComboBox and it's children.
Code:
'in a form
Private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Me.AutoRedraw = True
EnumChildWindows GetDesktopWindow, AddressOf EnumChildProc, ByVal 0&
End Sub
'in a module
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sSave As String
'Get the windowtext length
sSave = Space$(GetWindowTextLength(hwnd) + 1)
'get the window text
GetWindowText hwnd, sSave, Len(sSave)
'remove the last Chr$(0)
sSave = Left$(sSave, Len(sSave) - 1)
If sSave <> "" Then Form1.Print sSave
'continue enumeration
EnumChildProc = 1
End Function
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
|