Capture keytrokes before AxWebBrowser

M

Martin Maat

Hi,

Is there an elegant way to capture/preview keystrokes in a Windows.Forms
application that has an AxWebBrowser control which is focused? The browser
seems to swallow anything while it has focus.

I also have a (related?) problem with back and forward buttons on the mouse.
They work just fine in a stand alone browser but not in my embedded
AxWebBrowser control.

Regards, Martin.
 
M

Martin Maat

Martin said:
Is there an elegant way to capture/preview keystrokes in a
Windows.Forms application that has an AxWebBrowser control which is
focused? The browser seems to swallow anything while it has focus.

I also have a (related?) problem with back and forward buttons on the
mouse. They work just fine in a stand alone browser but not in my
embedded AxWebBrowser control.

I forgot to mention I am using C#. I would also be happy with the VB
solution though, I suspect the solution would be framework or Win32 related
anyway.

Regards, Martin.
 
G

Guest

Check out the "KeyPreview" property on the Form class... I haven't tried
using this property yet, but it may accomplish what you're after.

If not (and this is probably going overboard...), then there's a cool code
sample from last month's MSDN Magazine (May 06) here:

http://msdn.microsoft.com/msdnmag/issues/06/05/BugBash/default.aspx?fig=true#fig4

Problem is, you want to keep that delegate around that captures *all*
keypress events regardless of the originating process, and not allow the GC
to dispose of it (the illustratory purpose of the code sample...) Check out
the article for details:

http://msdn.microsoft.com/msdnmag/issues/06/05/BugBash/default.aspx
 
M

Martin Maat

Andrew said:
Check out the "KeyPreview" property on the Form class... I haven't
tried using this property yet, but it may accomplish what you're
after.

No, doesn't work.
If not (and this is probably going overboard...), then there's a cool
code sample from last month's MSDN Magazine (May 06) here:

http://msdn.microsoft.com/msdnmag/issues/06/05/BugBash/default.aspx?fig=true#fig4

Problem is, you want to keep that delegate around that captures *all*
keypress events regardless of the originating process, and not allow
the GC to dispose of it (the illustratory purpose of the code
sample...) Check out the article for details:

http://msdn.microsoft.com/msdnmag/issues/06/05/BugBash/default.aspx

Hmmm... (sigh) Well okay, I already knew it couldn't be simple or the
examples would be all over the net. Thanks, I'll try to get my head around
it.

Regards, Martin.
 

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