{"id":5255,"date":"2014-03-30T20:02:50","date_gmt":"2014-03-30T20:02:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/hwndsource-win32-integration-with-ribbons-and-keytips-collection-of-common-programming-errors\/"},"modified":"2014-03-30T20:02:50","modified_gmt":"2014-03-30T20:02:50","slug":"hwndsource-win32-integration-with-ribbons-and-keytips-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/hwndsource-win32-integration-with-ribbons-and-keytips-collection-of-common-programming-errors\/","title":{"rendered":"HwndSource win32 integration with Ribbons and KeyTips-Collection of common programming errors"},"content":{"rendered":"<p>My situation is rather complex, but I&#8217;ve seen other people do this. Unfortunately, there is no mention of my specific problem. I am in the process of trying to integrate a WPF UserControl including a Ribbon into a Win32 host application. So far, everything has been working pretty neat (to my surprise, even). I am using HwndSource to create a raw Win32 child-window and embed this into a Win32 host top-level window. I have tried TabControls, Buttons, RadioButtons, WebBrowsers and everything inside the UserControl and they all are usable from within my Win32 host application. And, of course, there is a Ribbon control at the top row of the UserControl&#8217;s Grid.<\/p>\n<p>Here&#8217;s basically what I am doing:<\/p>\n<pre><code>mHwnd = new HwndSource (\n    0, 0x40000000 | 0x10000000, \n    0, \n    left, \n    top, \n    width, \n    height, \n    \"CIntegrationTest\", \n    parentHandle);\nmUserCtrl = new UserControl1 ();\nmHwnd.RootVisual = mUserCtrl;\n<\/code><\/pre>\n<p>This works rather good. I have some other controls (like an edit and a few buttons) in UserControl1 below the Ribbon. When the keyboard focus is inside one of these controls, I can use Alt+ to access the KeyTips of the RibbonTabs and it&#8217;s elements. But when the focus is not inside of the WPF UserControl, but some control from the Win32 host, the hotkeys do not work.<\/p>\n<p>I had a look at the implementation of the hotkeys and found out that a class called KeyTipService (found in RibbonControlsLibrary\\Microsoft\\Windows\\Controls\\KeyTipService.cs) uses InputManager.Current.PostProcessInput and InputManager.Current.PreProcessInput to handle the KeyTip hotkeys.<\/p>\n<p>Unfortunately, I&#8217;m totally out of ideas how I could forward the necessary key events from the Win32 application to the Ribbon. I don&#8217;t even know how I could identify the messages that need to be forwarded.<\/p>\n<p>Maybe someone here ran into a similar problem or has some more clue about WPF message processing and can help me or give some hints.<\/p>\n<p>P.S.: I&#8217;m running Visual Studio 2010 Premium on Windows XP SP3 here and am using the Microsoft Ribbons for WPF from October 2010.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My situation is rather complex, but I&#8217;ve seen other people do this. Unfortunately, there is no mention of my specific problem. I am in the process of trying to integrate a WPF UserControl including a Ribbon into a Win32 host application. So far, everything has been working pretty neat (to my surprise, even). I am [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5255","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5255"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5255\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}