What do I need to do to deploy controls that target Windows XP Themes?

I have 3 projects 
1- A User control that has a button on it - FlatStyle is set to System.
2- I embed this control in a Windows Form Project and run it - The look is XP - good.
3- I embed the same control in an html page, I can see the button. The look is NOT XP - 

What am I missing here.

Sincerely
Arthur


Answer this question

What do I need to do to deploy controls that target Windows XP Themes?

  • Mark Broaddus

    Unfortunately, there seems to be only one way to get a downloaded Windows Forms control to use XP styles (that is, link with version 6 of the common controls DLL), and that is to put a manifest for IE itself on the client machine, in its program directory.  This hardly qualifies as "zero touch" deployment.

    The problem is that it is the application, not the control, which determines which version of the common controls it (and by extension, any DLL's it loads) will link with.  In the case of a control deployed in IE, the application is the browser itself.  I have tried just about every trick I could think of, including embedding a manifest in the control DLL.  Also, because IE creates a new application domain for each managed control it loads, and you can configure that domain with a config file using the LINK tag, I explored that, but the problem there is that while you can redirect the binding of managed DLL's in a config file, the common controls use the slightly different mechanism of "side-by-side" deployment, which only works with a manifest.

    Bottom line: if you are in an intranet environment, you can put an "iexplore.exe.manifest" file in "Program Files\Internet Explorer" directory on your client's machines, and get what you want, but if you are trying to do this transparently on a public web site, forget it.  Of course, there just might be some secret voodoo to make it work, but in a week of experimenting and searching the web, I never found a hint of it.

    <SOAPBOX>
    This is one of the many reasons I have soured on XP Visual Styles.  One of the presentations on MSDN discussing the introduction of Visual Styles in XP and version 6 of the common controls explained that a reason for the new library not being compatible with earlier Win32 operating systems was to create an upgrade incentive.  In other words, if you want the XP eye candy, you need to upgrade the OS.

    The problem is, that even when you use Windows XP, the latest version of IE, and the latest development tools, you don't get access to this "feature".  Considering the fact you can find "XP Style" controls in half a dozen toolkits, which work on any win32 OS, and in fact, even one in pure Java, which can run on Linux, it's pretty obvious that there is nothing in the new controls which required this rube goldberg multiple assembly solution which it seems to be taking years for MS to support in their own tools.
    </SOAPBOX>

    On a (happier ) note, it seems that there is a lot more interest in Office/Visual Studio "styles"
    than XP styles themselves.  These controls are, by definition, not part of the OS and you have to either write them yourself or use a 3rd party library to simulate them.

    Regards.
    Dave

  • Dianne Watson

    I'm bumping this very old thread, because after THREE YEARS there still does not seem to be a solution to this!

    I've just tried it with the IE7 beta and IT HAS THE SAME PROBLEM!

    This is, frankly, unbelievable!

    Surely there must be a solution to this problem

    Any ideas will be gratefully received!


  • Stoke

    Have you tried embedding the manifest in the assembly   because it won't be able to get at it to download it, I believe...even if you embed it though, i'm not so sure it will work at all anyway.  I've had quite a few problems with apps over the web and getting xp styles to work  :( 
  • TFC

    Hi,

    Well, I am the author of the long response above. It seems there is a solution for this: Just call Application.EnableVisualStyles() in your control's constructor, and make sure you've set FlatStyle=System for all your nested controls which support it. I guess the native calls to set up the activation context were always available to do this, though that would have made your control require unmanaged permissions before EnableVisualStyles was implemented. Also, it seems with 1.1, it was necessary to call Application.DoEvents immediately after, but that's not necessary fo2.0 and Visual Studio 2005.

    So, hosted Windows Forms controls can use XP visual styles, without requiring an iexplorer.exe.manifest file. Just in time to be rendered obsolete by XAML, I guess .

    Dave


  • What do I need to do to deploy controls that target Windows XP Themes?