开发者

Webbrowser control not receiving Tab / Delete / Back keys when placed inside Outlook Add-in

开发者 https://www.devze.com 2023-01-31 05:34 出处:网络
I am building an Outlook add-in which exposes a custom task pane. From this pane upon some user actions,

I am building an Outlook add-in which exposes a custom task pane. From this pane upon some user actions,

  1. I create a new UserControl (that has a WebBrowser control inside it)
  2. Get hold of the Outlook messages window (using Win API FindWindow("rctrl_renwnd32" ...) )
  3. Resize the messages window to 0 width
  4. Set the parent of my UserControl to the main Outlook explorer window (using Win API User32.SetParent)
  5. Set the size of my UserControl to occupy the messages window's place

Everything is good, except for the fact that Outlook chews away Delete / Back / Tab keys (and I'm sure that there are more), from being passed on to the control.

Inside this UserControl, I launch an internal site which requires the user to perform login. The WebBrowser accepts regular input, but does nothing when Tab / Delete / Back keys are pressed!

I am at my wits ends! I have been searching the net for a couple of weeks now and don't seem to know what is going on.

Does anybody know what is going on here and how to fix it? I have implemented a low-level keyboard hook and am able to trap the required keys. I have tried using User32.PostMessage but still no luck.

Thanks, Harsha

p.s.: I co开发者_Go百科me from a Java background and so I'm somewhat of a novice when it comes to .NET & P/Invoke.


The WebBrowser control responds to the WM_GETDLGCODE message with DLGC_WANTARROWS | DLGC_WANTCHARS. That's why it won't handle certain keys such as Tab, Back and Delete. It told the parent to not handle those keys.

You can write a windows hook then call the webbrowser control's IOleInPlaceActiveObject ::TranslateAccelerator implementation.

Check "WebBrowser Keystroke Problems" by Scott Roberts, Microsoft Internet Developer April 1999 for more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消