Google Answers Logo
View Question
 
Q: Visual Basic and the Internet Explorer control ( No Answer,   1 Comment )
Question  
Subject: Visual Basic and the Internet Explorer control
Category: Computers > Programming
Asked by: johngl-ga
List Price: $5.00
Posted: 28 Jun 2004 18:38 PDT
Expires: 28 Jul 2004 18:38 PDT
Question ID: 367520
How can I stop the Internet Explorer COM components context menu from
displaying?  Also the print feature?  Thank you.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Visual Basic and the Internet Explorer control
From: mikephoenix-ga on 28 Jun 2004 23:16 PDT
 
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!!!!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy