Windows XP style without manifest

Just a quickie on the Windows XP style:

The .NET Framework 1.0 and 1.1 support Windows applications with Windows XP look. It will give this look to controls with the FlatStyle property set to System. To activate the Windows XP look you can create a manifest file and place that inside the folder of the executable assembly. As an alternative you can embed it as a resource inside the assembly.

The 1.1 Framework also has a method Application.EnableVisualStyles() that will allow you to work without a manifest file and still get the same results. This may lead to some weird behavior, though. You can expect a System.Runtime.InteropServices.SEHException from out of nowhere or missing images on toolbars and other controls. This is a known bug, that can be circumvented by calling Application.DoEvents() right after Application.EnableVisualStyles(), like so:

void Main()
{
  Application.EnableVisualStyles();
  Application.DoEvents();
  Application.Run(new Form1());
}

Comments

# Dennis v/d Stelt said:

Thanks for the info!What's the difference in applications with visual styles enabled, against one that hasn't? Are buttons and such any different to the not enabled version? Is there more info on this?And a question I still have after months, where do I get icons and pictures to include into my application to enhance the WinXP look? And by icons, I mean hi-res icons.Another thing I ran into lately, no matter what kind of toolbar I use (.NET toolbar, CommandBar, Xceed, Infragistics) the icons with shadow always screw up the alphablending. This results in shadow being al #000000 instead of nice shadows, which results in a really ugly black line beside/below my icons, which makes the unusable.

dinsdag 18 mei 2004 11:16
# Eric said:

Dennis, the difference between enabling VisualStyles and not is the difference between using the default XP theme and using the Classic theme -- if you don't enable VisualStyles, your buttons and dropdowns etc will look as if the user has the Classic style selected, even if they don't.  Enabling VisualStyles will make buttons etc follow the user's theme, with one caveat.That is that you must go through your project and set the FlatStyle property on anything that has it (buttons, dropdowns, labels, tabs, etc) to System rather than the default Standard.

vrijdag 25 juni 2004 23:30