WebBrowser in .NET Compact Framework eats my events

G

Guest

The .NET WebBrowser control in the Compact Framework 2.0 is a major
headache.

Once it takes the focus (e.g. by the user tapping on it) it keeps it
and keyboard events are not passed to the form anymore even though
KeyPreview is set to true.
If there are no other controls on the form we don't get them at all to
start with.

I added a tiny textbox with same colors as the form so we can at least
get the focus and be passed keyboard events. This works as long as it
has the focus and also when I give it focus again with SetFocus().

I tried adding a handler for the WebBrowser's KeyDown but that does not
help.

Next I put the browser control on a panel, setting the panel's Enabled
to false. This works, but the we cannot use the arrows in the browser,
scrollbars don't work, and so on.

Next I tried adding a timer which keeps setting the focus to the
textbox, this way the scrollbars still work but key events like the
arrows don't get to the browser (even when I enable the panel again).

What I did next is disable the panel again, and post a Windows message
to the browser control for interesting key events (if the panel is not
disabled, things start looping). But this does not help for the
scrollbars (and I don't know to intercept scrollbar events and pass
them on to the browser control).

Anybody any ideas?

I am using VS 2005.

Thanks,

Ruud
 
R

Ruud Laanbroek

Thanks. I did not use the OpenNETCF WebBrowser after all, but you
pointed me in the right direction.

I used the OpenNETCF ApplicationEx class and IMessageFilter interface:
- used the ApplicationEx.Run instead of Application.Run
- added a PreFilterMessage() method to my form (now also inheriting the
IMessageFilter interface)
- added ApplicationEx.AddMessageFilter(this) to the constructor of the
form
 

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