Harsha Ramesh
unread,Oct 19, 2011, 6:43:44 AM10/19/11You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hi All,
I have gone through the various postings all over the web and this group and still cant find a solution to my problem. May be because I do not understand C++ / COM programming properly. Please help me out here.
.NET 3.5 / VS 2008 / Outlook 2007 / VSTO Add-in
-----------------------------------------------
I have setup a menu item in Outlook. On clicking on the menu item, I launch a new WebBrowserControl embedded inside Outlook and hide the "messages" window. The following code snippet shows how I am embedding the control. I believe something is either not right, or I am just looking at the wrong places .. Additionally, I am not sure how the TranslateMessage / DispatchMessage needs to be invoked on the control.
[code]
Outlook.Explorer explorerWnd; // Handle to the Outlook explorer window
IntPtr olMainWndHnd; // This is the handle to the main window that contains the messages window
IntPtr olMsgWndHnd; // This is the handle to the messages window in outlook
// FindOutlookMessagesWindow
String caption = explorerWnd.GetType().InvokeMember("Caption", System.Reflection.BindingFlags.GetProperty, null, explorerWnd, null).ToString();
olMainWndHnd = User32.FindWindow(OUTLOOK_WINDOW_CLASS, caption);
if (olMainWndHnd != IntPtr.Zero)
{
olMsgWndHnd = User32.FindWindowEx(olMainWndHnd, IntPtr.Zero, OUTLOOK_WINDOW_CLASS, null);
}
// create a subclassed window for managing outlook resize events.
SubclassedWindow mSubClassedWindow = new SubclassedWindow();
mSubClassedWindow.AssignHandle(olMsgWndHnd);
mSubClassedWindow.SizeChanged += new EventHandler(SubClassedWindowSizeChanged);
// Create a new instance of the webbrowser control. This is a user control that just embeds a WebBrowser within it.
WebbrowserControl mEmbeddedContainer = new WebbrowserControl();
// Set the parent of the webbrowser to be outlook window.
// I am not sure if this needs to be done or not.
User32.SetParent(mEmbeddedContainer.Handle, olMainWndHnd);
[/code]
Now based on what I have been reading, I understand that I can setup a keyboard hook (also coded in .NET). I have done that and I am able to trap the keyboard events of interest.
Here is where things are bouncing off my head. Everyone talks about TranslateMessage & DispatchMessage .. I understand that these are methods defined in some COM Interface. But how do I associate them with the browser control?
Secondly, when I trap the keyevents, I have the keycode with me. How do I pass this information across to the browser (everyone talks about passing a message, but I am not sure on how to construct this message object).
Really looking forward to your expert guidance.
Thanks,
Harsha