Solved

Disable view source

Posted on 2001-06-27
11
206 Views
Last Modified: 2010-08-05
Hi

Using Delphi 5.0 Pro. Is it possible to disable the 'View source' option on the pop-up menu that appears when you right click on the TWebBrowser component. Disabling the the pop-up menu completely is acceptable. I have tried adding my own pop-up menu and setting the popupmenu property of the web browser component to use this pop up menu, but it did not work, the default menu still appeared.

Thanks

John
0
Comment
Question by:nhoj
  • 5
  • 2
  • 2
  • +2
11 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6230969
You can protect your own pages in IE with:

<body oncontextmenu="return false" ...>
...
</body>
0
 

Expert Comment

by:jlislo
ID: 6231539
Add the following to you HTML

<script language="JavaScript">
<!--  
if (navigator.appName.indexOf("Internet Explorer") != -1)  
document.onmousedown = noSourceExplorer;  
function noSourceExplorer(){if (event.button == 2 | event.button == 3)  
{  
alert("your message here!");}
}  
//-->    
</script>

JL
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6231568
jlislo, what if it should disable the menu for all pages on the internet?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 1

Author Comment

by:nhoj
ID: 6231605
Epsylon's answer works just fine, and since this is a custom app using the Delphi web browser component I will accept this as an answer if Epsylon would like to post it as such.

Regards John
0
 

Expert Comment

by:jlislo
ID: 6231614
Epsylon,

Try add the javascript code to the document in run time. This is just a thought I don't have D5 at work, I have to try it at home tonight.
0
 
LVL 17

Expert Comment

by:inthe
ID: 6231818
if you wish to disable the popup menu or use your own you can do it this:

procedure MessageLoop(var Msg:TMsg;var Handled:Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.MessageLoop(var Msg: TMsg; var Handled: Boolean);
var
 mouse:Tpoint;
begin
if msg.hwnd = webbrowser1.Handle then
  begin
   if (Msg.Message = WM_RBUTTONDOWN) or (Msg.Message = WM_RBUTTONUP)
   then begin
    handled:=True;
     getcursorpos(Mouse); //popup your own menu
    popupmenu1.popup(Mouse.x,Mouse.y);
   end
  else Handled := False; //not rbutton
 end
else
Handled := false; //not webbrowser msg
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := MessageLoop;
end;
0
 
LVL 2

Expert Comment

by:SChertkov
ID: 6237655
It's not right.
You disable all popup menu from brower control
not only 'view source' option.
Right way is to implement IDocHostUIHandler,
and in IDocHostUIHandler:: ShowContextMenu
popup own menu.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6242133
nhoj, if you want to accept my answer you must reject jlislo's first...
0
 
LVL 1

Author Comment

by:nhoj
ID: 6243913
Epsylon's comment woorks fine and is simple to implement, the fact that the pop-up menu does not appear at all does not matter since there are other functions on this menu that W also wanted to disable e.g. "Print" as I have my own print function which will print over the page properly.

Thanks

Regards John
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6243959
Thank you, John.
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 6243961
:o)
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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