PC Review


Reply
Thread Tools Rate Thread

Question about WebBrowser

 
 
Adam
Guest
Posts: n/a
 
      1st Nov 2007
Hello,

I want to disable context menu on WebBrowser component.

Is possible to catch mouse clik on WebBrowser component? To catch key
events I have to set KeyPreview to true. OK, but what with mouse click.

Or maybe some special html tag? I tried with JavaScrip scripts to disable
right click but they works only on Internet Explorer (full IE, like in XP
windows etc...)

How disable context menu on WebBrowser in mobile device?
 
Reply With Quote
 
 
 
 
Adam
Guest
Posts: n/a
 
      1st Nov 2007
Dnia Thu, 1 Nov 2007 19:06:40 +0100, Adam napisał(a):

> Hello,
>

[cut]
> How disable context menu on WebBrowser in mobile device?


I found something like this:
http://tinyurl.com/38f4vc
It works but
--
//instead of the normal Application.Run(new Form1); we must manually
display
the form
Form1 formInstance = new Form1();
formInstance.Visible = true;

PeekMsg msg = new PeekMsg();
while (1 == 1)
{
PeekMessage(out msg, formInstance.Handle, 0, 0, WM_REMOVE);
--

is crazy. Never ending loop on windows mobile?
What about battery life?

Is there any PROPER WAY?
Is possible to set Hook on mouse? How can I do this?
 
Reply With Quote
 
Jin Chang
Guest
Posts: n/a
 
      3rd Nov 2007
On Nov 1, 4:54 pm, Adam <spam...@wp.pl> wrote:
> Dnia Thu, 1 Nov 2007 19:06:40 +0100, Adam napisał(a):
>
>
>
> > Hello,

>
> [cut]
> > How disable context menu on WebBrowser in mobile device?

>
> I found something like this:http://tinyurl.com/38f4vc
> It works but
> --
> //instead of the normal Application.Run(new Form1); we must manually
> display
> the form
> Form1 formInstance = new Form1();
> formInstance.Visible = true;
>
> PeekMsg msg = new PeekMsg();
> while (1 == 1)
> {
> PeekMessage(out msg, formInstance.Handle, 0, 0, WM_REMOVE);
> --
>
> is crazy. Never ending loop on windows mobile?
> What about battery life?
>
> Is there any PROPER WAY?
> Is possible to set Hook on mouse? How can I do this?


Two quick comments about this.

First, I also found the context menu to be an issue and looked for
ways to disable/prevent it. Based on the answers I found, there is
simply no "proper" way of doing this. The next release may address
this oversight and provide a way to disable it. On a similar note,
the progress-bar that appear when the WebBrowser control content is
loaded may also become optional.

Second, what you've found may not be a bad solution. Your concern
about the battery life being depleted by the loop shouldn't be of
concern because that's what Windows CE/Mobile does anyway -- the
message loop.

- Jin

 
Reply With Quote
 
Peter Foot [MVP]
Guest
Posts: n/a
 
      5th Nov 2007
You need to send a DTM_ENABLECONTEXTMENU message to the control handle
(WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.

Peter

--
Peter Foot
Microsoft Device Application Development MVP
www.peterfoot.net | www.inthehand.com
In The Hand Ltd - .NET Solutions for Mobility

"Adam" <(E-Mail Removed)> wrote in message
news:nizcguomncc3.td81osxj1nk4$.(E-Mail Removed)...
> Dnia Thu, 1 Nov 2007 19:06:40 +0100, Adam napisał(a):
>
>> Hello,
>>

> [cut]
>> How disable context menu on WebBrowser in mobile device?

>
> I found something like this:
> http://tinyurl.com/38f4vc
> It works but
> --
> //instead of the normal Application.Run(new Form1); we must manually
> display
> the form
> Form1 formInstance = new Form1();
> formInstance.Visible = true;
>
> PeekMsg msg = new PeekMsg();
> while (1 == 1)
> {
> PeekMessage(out msg, formInstance.Handle, 0, 0, WM_REMOVE);
> --
>
> is crazy. Never ending loop on windows mobile?
> What about battery life?
>
> Is there any PROPER WAY?
> Is possible to set Hook on mouse? How can I do this?


 
Reply With Quote
 
Adam
Guest
Posts: n/a
 
      5th Nov 2007
Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisał(a):

> You need to send a DTM_ENABLECONTEXTMENU message to the control handle
> (WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.
>


I have a problem with this.
I simply put a WebBrowser and button component on a form and add this code
to Button onClick event:

IntPtr handle = webbrowser1.Handle;
const int WM_CLOSE = 0x10;
const int WM_USER = 0x0400;
const int DTM_ENABLECONTEXTMENU = WM_USER + 110;

1.//Message msg = Message.Create(handle, DTM_ENABLECONTEXTMENU,
IntPtr.Zero, (IntPtr) 1);
1.//MessageWindow.SendMessage(ref msg);


2.SendMessage(handle, DTM_ENABLECONTEXTMENU, 0, 0);

and
[DllImport("coredll.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);

If I use 1 (Message etc..) with WM_CLOSE, webbrowser1 dissapear.
If I use 2 (with native SendMessage) with WM_CLOSE, webbrowser1 dissapear.

If I use 1 or 2 with DTM_ENABLECONTEXTMENU nothing change and webbrowser
still have a context menu.

What am I doing wrong and what is the correct way of doing it?
 
Reply With Quote
 
Adam
Guest
Posts: n/a
 
      5th Nov 2007
Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisał(a):

> You need to send a DTM_ENABLECONTEXTMENU message to the control handle
> (WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.
>


I have a problem with this.
I simply put a WebBrowser and button component on a form and add this code
to Button onClick event:

IntPtr handle = webbrowser1.Handle;
const int WM_CLOSE = 0x10;
const int WM_USER = 0x0400;
const int DTM_ENABLECONTEXTMENU = WM_USER + 110;

1.//Message msg = Message.Create(handle, DTM_ENABLECONTEXTMENU,
IntPtr.Zero, (IntPtr) 0);
1.//MessageWindow.SendMessage(ref msg);


2.SendMessage(handle, DTM_ENABLECONTEXTMENU, 0, 0);

and
[DllImport("coredll.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);

If I use 1 (Message etc..) with WM_CLOSE, webbrowser1 dissapear.
If I use 2 (with native SendMessage) with WM_CLOSE, webbrowser1 dissapear.

If I use 1 or 2 with DTM_ENABLECONTEXTMENU nothing change and webbrowser
still have a context menu.

What am I doing wrong and what is the correct way of doing it?
 
Reply With Quote
 
Adam
Guest
Posts: n/a
 
      6th Nov 2007
Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisał(a):

> You need to send a DTM_ENABLECONTEXTMENU message to the control handle
> (WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.


Ok, I use Windows CE Remote Spy and i see that WebBrowser on my Form look
like this:

Form1 (my application with embedded webbrowser)
- <no name> #NETCF_AGL_CONTAINER
- <no name> (IExplore)
-<no name> (MSPIE Status)
-<no name> (PIEHTML)
of course with different window handle. I try to send message
"DTM_ENABLECONTEXTMENU" to every of them but with no result.
In Windows CE Remote Spy I see that event like tap, tap&hold etc.. are
catched only by PIEHTML.

What am I doing wrong and what is the correct way of doing it?
 
Reply With Quote
 
carnivore
Guest
Posts: n/a
 
      7th Nov 2007
Peter Foot [MVP] pisze:
> You need to send a DTM_ENABLECONTEXTMENU message to the control handle
> (WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.


Nevermind, I do this with override my form WndProc.

Thanks.
 
Reply With Quote
 
RDub
Guest
Posts: n/a
 
      4th Dec 2007
I also was not able to get the code you posted to disable the context menu
in a Flash ActiveX hosted by a (OpenNETCF 1.4) web browser control. I
wanted to stop the Flash Settings menu from appearing. If you hit the
"Advanced" button in that dialog the OS will throw up a balloon that could
allow the user to break out of my Kiosk mode type application.

What I finally wound up doing was to add a timer to the form that fired
every couple seconds. In the timer tick event I enumerate all of the
running processes looking for the one that opened the balloon. When it
finds the process (remnet.exe), it simply Kills it. Kind'a brutal way to
deal with this, but it seems to be working OK.

If anyone is able to get the Context Menu from displaying in the first pace,
I'd love to know how you made it happen. Please post back here.

Ron W
"Adam" <(E-Mail Removed)> wrote in message
news:57ft5rn74ysw$.oxac79c8sjmy$.(E-Mail Removed)...
> Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisał(a):
>
>> You need to send a DTM_ENABLECONTEXTMENU message to the control handle
>> (WM_USER + 110). Set the LPARAM to 0 to disable, 1 to enable.
>>

>
> I have a problem with this.
> I simply put a WebBrowser and button component on a form and add this code
> to Button onClick event:
>
> IntPtr handle = webbrowser1.Handle;
> const int WM_CLOSE = 0x10;
> const int WM_USER = 0x0400;
> const int DTM_ENABLECONTEXTMENU = WM_USER + 110;
>
> 1.//Message msg = Message.Create(handle, DTM_ENABLECONTEXTMENU,
> IntPtr.Zero, (IntPtr) 0);
> 1.//MessageWindow.SendMessage(ref msg);
>
>
> 2.SendMessage(handle, DTM_ENABLECONTEXTMENU, 0, 0);
>
> and
> [DllImport("coredll.dll")]
> public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam,
> int
> lParam);
>
> If I use 1 (Message etc..) with WM_CLOSE, webbrowser1 dissapear.
> If I use 2 (with native SendMessage) with WM_CLOSE, webbrowser1 dissapear.
>
> If I use 1 or 2 with DTM_ENABLECONTEXTMENU nothing change and webbrowser
> still have a context menu.
>
> What am I doing wrong and what is the correct way of doing it?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on WebBrowser control Dom Microsoft C# .NET 3 14th Apr 2008 09:01 AM
Webbrowser control question. smerf Microsoft VB .NET 1 6th Oct 2006 05:39 AM
Question about webBrowser zeeway Microsoft C# .NET 3 1st Jun 2006 11:28 AM
WebBrowser ActiveX Question =?Utf-8?B?QmVuV2ViZXI=?= Microsoft Access VBA Modules 0 31st May 2006 10:39 PM
webbrowser.DocumentStream question =?Utf-8?B?VG9tYSBNYXJpbm92?= Microsoft Dot NET 4 13th Jan 2006 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:33 PM.