views:

675

answers:

2

Hi, how do I enable visual styles when my project is a class library and it's being loaded into a program that does not have Application.EnableVisualStyles() set. I have been struggling with this for 2 days now. This is in C# (I've seen some examples for older C++ and some things that may work for VB, but nothing has been clearly laid out for C# and if it's even possible).

I have tried to run Application.EnableVisualStyles() from my Class Library before creating any controls, but it seems that needs to be done before an Application.Run() is done, and I don't have control when an Application.Run() is called since this is going into a 3rd party app as a plugin (VMware's Virtual Infrastructure Client).


I have tried to create a manifest file and after compiling the class library I link in the manifest file to my ProgressBar.dll with: mt.exe -manifest ProgressBar.dll.manifest -outputresource:ProgressBar.dll;2

Except this doesn't work. If I make a dummy Application that uses my ProgressBar class library and link the manifest to that Application's exe, then the visual styles come up (basically it's doing the long way of specifying the Manifest file in the Project Properties, Application section).

Right now my buttons look ugly, but the biggest thing that is irritating is that the ProgressBar control doesn't work in Marquee style. I'm very soon going to have to resort to making my own Marquee-style ProgressBar or just throwing in an animated GIF in it's place. With regards to the buttons, I guess I can start using Infragistics buttons in order to get a more consistent result.

Please and thanks as always!

A: 

How can you be sure that there are no controls created yet when you call Application.EnableVisualStyles? Created does not necessarily mean that the controls are also visible on a form.

Since you are working with a closed 3rd-party component I would invest my time rather in creating my own controls if the look and feel is that important.

0xA3
A: 

You'll have to use the OpenThemeData Win32 api in your control:

MSDN: Using Windows XP Visual Styles

taoufik