This task requires subclassing (really hooking), which are ways to
hook onto an object, and basically manipulate incoming messages.
FIRST, create a form and a module, and put a WebBrowser control onto
the form. Copy the following code in the respectful code sections:
FORM1.FRM SHOULD CONTAIN:
~~~~~~~~~~~~~~~~~~~~~~~~~
Private Declare Function SetWindowLong Lib "user32.dll" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong _
As Long) As Long
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 GetWindow Lib "user32" (ByVal hwnd As Long, ByVal _
wCmd As Long) As Long
Private Window As Long
Private Sub Form_Load()
WebBrowser1.Navigate "://www.google.com"
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Window, -4, OldProc
End Sub
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As _
Variant)
If Window = 0& Then
Window = GetWindow(GetWindow(FindWindowEx(hwnd, 0&, _
"Shell Embedding", vbNullString), 5&), 5&)
OldProc = SetWindowLong(Window, -4, AddressOf CustomWindowProc)
End If
End Sub
MODULE1.BAS SHOULD CONTAIN:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public OldProc As Long
Private Declare Function CallWindowProc Lib "user32.dll" _
Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _
ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function CustomWindowProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal _
wParam As Long, ByVal lParam As Long) As Long
If ((Msg <> &H7B&) And (Msg <> &H111&) And (Msg <> &H205&)) Then
CustomWindowProc = CallWindowProc(OldProc, hwnd, Msg, wParam, lParam)
End If
End Function
GOOD Luck!!!! |