IE Hosted UserControl
-
I have a couple of questions regarding a System.Windows.Forms.UserControl derived control that is to be hosted in IE. Basic functionality seems to work, but I'm unable to figure out how to EnableVisualStyles...since IE is the parent application. All buttons on the control appear flat and square. Attempting to invoke the Application.EnableVisualStyles() call within my control's Load event causes IE to GPF. Attempting to host a Form within my control that contains a button with the flat style set to System still results in flat buttons. Also, I'm not able to get keyboard hot keys to work for any buttons on the user control. The tab key works for moving focus between buttons, and the mouse key works, but if I hit alt-char to invoke the hot key...nothing. Am I limited to creating owner draw buttons and handling keyboard events at the control level? Anyone have any experience in this area? Thank you in advance. Ron Ward
-
I have a couple of questions regarding a System.Windows.Forms.UserControl derived control that is to be hosted in IE. Basic functionality seems to work, but I'm unable to figure out how to EnableVisualStyles...since IE is the parent application. All buttons on the control appear flat and square. Attempting to invoke the Application.EnableVisualStyles() call within my control's Load event causes IE to GPF. Attempting to host a Form within my control that contains a button with the flat style set to System still results in flat buttons. Also, I'm not able to get keyboard hot keys to work for any buttons on the user control. The tab key works for moving focus between buttons, and the mouse key works, but if I hit alt-char to invoke the hot key...nothing. Am I limited to creating owner draw buttons and handling keyboard events at the control level? Anyone have any experience in this area? Thank you in advance. Ron Ward
I've done quite a bit of work in this area dating way back to the .NET 1.0 beta days. As far as hot keys, understand that only dialogs process characters and may or may not pass those messages to child controls, such as your
UserControl
. In the case of IE, it most likely won't because a site could hijack your settings (the web is a very dangerous place to visit, probably even more hostile than Iraq right now!). That would be my educated guess. As far as visual styles, callingApplication.EnableVisualStyles()
must be done in an application - not your control. What this does is load a general manifest from the .NET Framework directory (ex: %WINDIR%\Microsoft.NET\Framework\v1.1.4322) BEFORE controls are created, which encapsulate the Windows Common Controls. Once those are loaded into an address space for a process and used by a particular module, that module cannot use two different versions (but the process can, IIRC). You need to instead embed a manifest in your PE/COFF executable (not the assembly itself, rather, the manifest of resources) using a particular ID. For starters, read my article Windows XP Visual Styles for Windows Forms[^], which describes the "old" way (still supported) of embedding manifests as Win32 resources. You'll also want to read Visual Styles[^] on MSDN. Another article you may find interesting about making your embeddedUserControl
scriptable (as well as exposing events), take a look at a very old article of mine on a different site, User Controls for Winodws and the Web[^]. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]