Figure 1815

A .NET application with the standard Windows XP look and feel

Another option you can use to apply themes to your application is to produce a manifest file. The manifest file includes information that will let your application know which version of the common controls library to use. By specifying that the application should use version 6.0 of the common controls library, you can be assured that all your controls will be drawn according to the selected theme.

To create the manifest file, copy the following text to a file.

<?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="Executable Name" type="win32"

<description>Application description</description> <dependency>

<dependentAssembly> <assemblyIdentity type="win32"

name="Microsoft.Windows.Common-Controls"

version="6.0.0.0"

processorArchitecture="X86"

publicKeyToken="6595b64144ccf1df"

language="*"

</dependentAssembly> </dependency> </assembly>

You will have to save the file with the same name of your application and append the extension ".manifest." For example, if the application is named WindowsApplication1.exe, you would save the manifest file as WindowsApplicationl.exe.manifest and place it in the same directory where the executable resides. You also have to set the Flatstyle property for any control System. Running the application by using the manifest file shows the controls displaying the Windows XP styled theme the operating system currently has, as shown in Figure 18.15.

Each of the options previously mentioned have their own strengths and weaknesses. The manifest file does not involve writing code in your application to work, but using it risks having the user delete the manifest file and render your application themeless. The EnableVisualStyles procedure is easy to implement, but it requires the modification of your source code.

The question of whether you should support themes in your application depends on how complete you would like your application to look. As previously mentioned, themes in Windows XP are on by default. An application that does not support themes may send the wrong message to your users; it might appear as if it was unfinished or not fully supported.

0 0

Post a comment