My initial thought was to use a delegate for EnumWindows but the EnumWindowsProc1 gets in the way of that idea.
And of course the VBA.left$ does not work even after adding the dll MSVB6M that accesses VBA it does not recognize left, right, or ucase as members.. my thought was to places this outside and say Ucase( VBA... but there is no member that connects to anything as such. Please help !
And of course the VBA.left$ does not work even after adding the dll MSVB6M that accesses VBA it does not recognize left, right, or ucase as members.. my thought was to places this outside and say Ucase( VBA... but there is no member that connects to anything as such. Please help !
Code:
Public Function GetDlgText(ByVal hwndMsgBox As Long) As String
Dim sBuf As String
Dim lRet As Long
GetDlgText = ""
sBuf = String(1025, 0)
lRet = GetDlgItemText(hwndMsgBox, &HFFFF&, sBuf, 1024)
If lRet > 0 Then
Debug.Print(VBA.Left$(sBuf, lRet))
GetDlgText = VBA.Left$(sBuf, lRet)
End If
End Function
Sub CloseChildWindows(ByVal parentTitle As String)
Dim ECWD As ECWDelegate = AddressOf EnumWindows
m_pWnd = FindParentWindow(parentTitle)
EnumWindows(m_pWnd, ECWD.Invoke(EnumWindowsProc1, False), 0)
Call EnumWindows(AddressOf EnumWindowsProc1, False)
End Sub
Private Function EnumWindowsProc1(ByVal hWnd As Long, ByVal lParam As Long) As Long
Static WindowText As String
Static nRet As Long
'
' Make sure we meet visibility requirements.
'
If lParam Then 'window must be visible
If IsWindowVisible(hWnd) = False Then
EnumWindowsProc1 = True
Exit Function
End If
End If
'
' Retrieve windowtext (caption)
'
WindowText = Space$(256)
nRet = GetWindowText(hWnd, WindowText, Len(WindowText))
If nRet Then
'
' Clean up window text and prepare for comparison.
'
WindowText = VBA.Left$(WindowText, nRet)
If m_CaseSens = False Then
WindowText = UCase$(WindowText)
End If
'
' Use appropriate method to determine if
' current window's caption either starts
' with, contains, or matches passed string.
'
If GetWinHandle(hWnd) = m_pWnd Then
PostMessage(hWnd, &H10, 0&, 0&)
'@TODO
'ExitChildWindow
End If
End If
'
' Return True to continue enumeration if we haven't
' found what we're looking for.
'
EnumWindowsProc1 = (m_hWnd = 0)
End Function