I am building an Outlook add-in which exposes a custom task pane. From this pane upon some user actions,
- I create a new UserControl (that has a WebBrowser control inside it)
- Get hold of the Outlook messages window (using Win API FindWindow("rctrl_renwnd32" ...) )
- Resize the messages window to 0 width
- Set the parent of my UserControl to the main Outlook explorer window (using Win API User32.SetParent)
- 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.
精彩评论