I have this in a module
Code:Option Explicit On Module Module2 Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Integer, ByVal lParam As Integer) As Boolean Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Integer, ByVal lpString As String, ByVal cch As Integer) As Integer Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Integer) As Integer Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Public Function EnumWindowsProc(ByVal hWnd As Integer, ByVal lParam As Integer) As Boolean Dim sWindowText As String Dim Ret As Long Ret = GetWindowTextLength(hWnd) sWindowText = Space(Ret) GetWindowText(hWnd, sWindowText, Ret + 1) If Ret > 0 Then If sWindowText Like "notpad*" Then ' Debug.Print sWindowText MessageBox "Found it" End If End If EnumWindowsProc = True End Function End Module
and this in a button click
EnumWindows(AddressOf EnumWindowsProc, 0)
I keep get this
'UPGRADE_WARNING: Add a delegate for AddressOf EnumWindowsProc Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
so I add this to the Module
but that didn't seem to helpCode:Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
here the vb6 code before I change it
Code:Option Explicit Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean 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 EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Boolean Dim sWindowText As String Dim Ret As Long Ret = GetWindowTextLength(hWnd) sWindowText = Space(Ret) GetWindowText hWnd, sWindowText, Ret + 1 If Ret > 0 Then If sWindowText Like "notpad*" Then ' Debug.Print sWindowText MsgBox "found it" End If End If EnumWindowsProc = True End Function EnumWindows AddressOf EnumWindowsProc, ByVal 0&




Reply With Quote