jstrom122099
asked on
SendMessage problem!
Hi!
Why isn't this working:
In a module:
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex 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 Const WM_GETTEXT = &HD
Public Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1.List1.AddItem hwnd
Call EnumChildWindows(hwnd, AddressOf EnumChildProc, &H0)
EnumWindowProc = 1
End Function
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1.List2.AddItem hwnd
Dim Buffer As String * 255
If GetWindowLong(hwnd, -16) And &H20 <> 0 Then ' If a textbox
SendMessage hwnd, WM_GETTEXT, 255, Buffer
Debug.Print Buffer
End If
EnumChildProc = 1
End Function
In a form (there should be 2 listboxes there):
In a commandbutton:
Call EnumWindows(AddressOf EnumWindowProc, &H0)
This just give me an illegal operation...
/Johan
Why isn't this working:
In a module:
Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex 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 Const WM_GETTEXT = &HD
Public Function EnumWindowProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1.List1.AddItem hwnd
Call EnumChildWindows(hwnd, AddressOf EnumChildProc, &H0)
EnumWindowProc = 1
End Function
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1.List2.AddItem hwnd
Dim Buffer As String * 255
If GetWindowLong(hwnd, -16) And &H20 <> 0 Then ' If a textbox
SendMessage hwnd, WM_GETTEXT, 255, Buffer
Debug.Print Buffer
End If
EnumChildProc = 1
End Function
In a form (there should be 2 listboxes there):
In a commandbutton:
Call EnumWindows(AddressOf EnumWindowProc, &H0)
This just give me an illegal operation...
/Johan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.