Not a problem. You can add a couple other APIs and modify the code a little that Aaron provided to get to know if the MessageBox is displayed:
Regards,Code:Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long Private Const WS_POPUP = &H80000000 Private Const WS_SYSMENU = &H80000 Private Const WS_BORDER = &H800000 Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU) Private Const GWL_STYLE = (-16) Private Sub Form_Load() Timer1.Interval = 100 End Sub Private Sub Timer1_Timer() Dim lHwnd As Long Dim lHwndStatic As Long Dim strBuffer As String Dim lngLen As Long 'Check For the Dialog Class Do lHwnd = FindWindowEx(0, lHwnd, "#32770", vbNullString) If lHwnd Then 'Check to see if it's a Messagebox If (GetWindowLong(lHwnd, GWL_STYLE) And WS_POPUPWINDOW) = WS_POPUPWINDOW Then 'Get the static class (a label) hWnd Do lHwndStatic = FindWindowEx(lHwnd, lHwndStatic, "Static", vbNullString) If lHwndStatic Then lngLen = GetWindowTextLength(lHwndStatic) strBuffer = Space(lngLen) If GetWindowText(lHwndStatic, strBuffer, Len(strBuffer)) Then If InStr(strBuffer, "Internet Explorer cannot open") > 0 Then MsgBox "You found the Message Box in Explorer", vbInformation, "Found IE" End If End If End If Loop Until lHwndStatic = 0 End If End If Loop Until lHwnd = 0 End Sub
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819




Reply With Quote