Solved

Web Browser control - any way to disable sub-menu

Posted on 1998-07-16
10
199 Views
Last Modified: 2010-05-03
I'm using a couple of web browser controls to create a help system, by using HTML. Only thing is that the user could view the HTML source by right-clicking on the web control, which I don't really want to happen. I know there is such a thing as compiled HTML, but don't really know anything about this or if it would be a solution. Really I just want to be able to disable the sub-menu. Thanks in advance.
0
Comment
Question by:dgb001
10 Comments
 

Expert Comment

by:ImmanuelOnse
ID: 1465960
1) The web browser control may have a method which allows you to add/remove options from the context sensitive (right-click) menu. If so, then try using it to remove the option allowing source viewing - query the control's vendor re this option

2) intercept the right click when it is over the control & generate your own context sensitive (right-click) menu. If you find this difficult with a third party control then lay a frame or some form of transparent window over the co-ords of the control & it should be able to intercept the mouse. Pass through all events except the right-mouse.
0
 
LVL 1

Author Comment

by:dgb001
ID: 1465961
Thanks for the input Immanuel, but there is no option as you suggested where you can remove/add items to the sub-menu - also, this is not a third party control, it's Microsoft's own ActiveX browser control which ships with VB5.
 
0
 
LVL 1

Expert Comment

by:rocca
ID: 1465962
If you were to setup a handler which watched all the windows messages and cancelled a right-mouse click to the handle of the WebBrowser component you should be able to disable the menu completely.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:dgb001
ID: 1465963
I'm sure you may well be right, but I was really hoping for something a little more simple. However, given that I haven't any alternatives yet then I'd be interested to know exactly how I would go about doing this, not having played with window handles etc. But I appreciate your response, thankyou.

0
 
LVL 1

Expert Comment

by:rocca
ID: 1465964
There may be an easier answer, but I think you would have to use something like SetWindowsHook with the WH_GETMESSAGE parameter and point it to your message filter.  You would then use something like PeekMessage in that filter procedure and remove any WM_RBUTTONDOWN messages going to the handle of the WebBrowser control.
0
 
LVL 1

Expert Comment

by:rocca
ID: 1465965
0
 
LVL 1

Expert Comment

by:Jason_Row
ID: 1465966
dgb001,

Here's another solution. Try using the MS HTML Help program. It might do what you want your program to do. You can find more info at the following URL.

http://www.microsoft.com/workshop/c-frame.htm#/workshop/author/htmlhelp/default.asp
0
 
LVL 1

Author Comment

by:dgb001
ID: 1465967
Thanks Jason, I'm not rejecting it (well only temporarily) - I'll have a look to see what the MS stuff is like - if I find it does what I want then we'll work a way to give you the points. The only reason I'm doing this is just so other people can have an opportunity to answer as well. Thanks again.

0
 

Accepted Solution

by:
madumas earned 20 total points
ID: 1465968

I found that... I haven't tryed it, but it should work....

In your module.bas file you *need* to add this code:

'Declarations for Preventing Right-Click in WebBrowser Control:
Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA"
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal
dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long)
As Long
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal
nCode As Long, ByVal wParam As Long, lparam As Any) As Long
Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal
hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As
Long

Public Const WM_RBUTTONUP = &H205
Public Const WH_MOUSE = 7

Type POINTAPI
    x As Long
    y As Long
End Type

Type MOUSEHOOKSTRUCT
    pt As POINTAPI
    hwnd As Long
    wHitTestCode As Long
    dwExtraInfo As Long
End Type

Public l_hMouseHook As Long

Then you need to add this in your program:

Private Function MouseHookProc(ByVal nCode As Long, ByVal wParam As
Long, mhs As MOUSEHOOKSTRUCT) As Long
'Prevent Right-Click in WebBrowser Control:
    If (nCode >= 0 And wParam = WM_RBUTTONUP) Then
        Dim sClassName As String
        Dim sTestClass As String
        sTestClass = "HTML_Internet Explorer"
        sClassName = String$(256, 0)
        If GetClassName(mhs.hwnd, sClassName, Len(sClassName)) > 0 Then
            If Left$(sClassName, Len(sTestClass)) = sTestClass Then
                MouseHookProc = 1
                Exit Function
            End If
        End If
    End If
        MouseHookProc = CallNextHookEx(l_hMouseHook, nCode, wParam, mhs)
End Function

I took this at:
http://www.geocities.com/CapeCanaveral/Lab/1961/dismouse.txt
0
 
LVL 1

Author Comment

by:dgb001
ID: 1465969
Yes, that looks good, so the points are yours - though I'm presently unable to actually understand all of it. If you know how to actually get it to work then I'd be glad to know more. (ie. I assume that the function gets called from somewhere and that MOUSEHOOKINSTRUCT needs setting up before you do this, or maybe I'm missing the point somewhere along the line) - many thanks anyway.
                 davidbird@softhome.net

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Spell Check in VB6 13 127
MsgBox 4 69
VB6 ListBox Question 4 49
VB6 common control 6 sp6 object library not registerd 3 23
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question