Windows Forms: XP Theme Support
Demonstrates how to enables support for XP themes in your application.
Featured Highlights:
To enable XP theme support in your application you have to write very little
code. The main task is to create a manifest file and associate it with your
application.
At this point controls that support XP Themes will appear "themed" in your
application.
This application displays three tabs that highlight the following:
Controls that support Visual Themes without any changes to property settings
Three controls that support visual styles but which are not
demonstrated on this form are H ScrollBar and
V ScrollBar, and the TrackBar control.
Controls that require the flatStyle property to be set to system.
Certain controls that do not support themes or that have limited support are
also demonstrated.
Requirements:
Microsoft Visual Studio.NET Professional or greater.
Windows XP Home or Professional
Running the Sample:
Simply press F5.
Note: The application contains only static data and controls as the only
purpose of this sample is to demonstrate the use of Themes.
If you want to create your own Windows Forms application here are the steps
you will have to perform:
Set each control with a FlatStyle property to FlatStyle.System
Create a manifest file to bind your app to comctl6. The sample manifest file
below can be used to bind any app (managed or unmanaged) to comctl6. Just
copy it to the location of the .exe and rename it to <app
name>.exe.manifest.
You must then add a Win32 resource to your application. This is
accomplished by first opening up the *.exe.
1. Open your exe in VS (file -> open file)
2. Right click on it and select add resource
3. Click "Import..." from the dialog
4. Select your manifest file
5. In the "Resource Type" field, enter "RT_MANIFEST"
6. In the property grid, change the resource ID from "101" to "1".
7. Save the exe.
8. Make sure the manifest is keep at the same directory level as the
executable. (In this How-To it is placed in the bin directory of the
solution)
A sample manifest is also included and is named Sample_Manifest.xml.
Here is the Manifest
Cut-------------------------------------------------------------------------
------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="Your
App name here" type
="win32" />
<description>.NET control deployment tool</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
End
cut-------------------------------------------------------------------------