Question about WebBrowser

A

Adam

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?
 
A

Adam

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?
 
J

Jin Chang

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
 
P

Peter Foot [MVP]

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 said:
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?
 
A

Adam

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?
 
A

Adam

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?
 
A

Adam

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?
 
C

carnivore

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.
 
R

RDub

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 said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top