Windows XP introduced an updated, more modern User Interface. With a small amount of work, you can take advantage of the Windows XP visual styles in your applications.
There are three basic steps:
Version 1.1 of the .NET Framework introduced a simplified method of incorporating XP themes in your applications by using the Application.EnableVisualStyles method in the application’s entry point:
' VB
Public Shared Sub Main()
System.Windows.Forms.Application.EnableVisualStyles()
System.Windows.Forms.Application.Run(New Form1)
End Sub// C#
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
However, this method has been proven unreliable. Some controls may not pick up the theme, and images have been known to disappear from ToolBars, TreeViews, and ListViews. Microsoft suggests calling Application.DoEvents as a workaround, but developers have reported memory leaks and unhandled exceptions using this workaround.
The safest way to ensure your application’s integrity is to stick with the manifest approach.
Some controls support XP styles with no additional work, however controls that derive from the ButtonBase class (Button, CheckBox, RadioButton) and the GroupBox control must have their FlatStyle property set to System. Setting this property to System lets the operating system determine how the control displays.
Your application must include a manifest file that tells Windows XP that it supports themes. The easiest way to create this file is to use another application's manifest as a template, or use the template below:
<? xml version ="1.0" encoding ="UCS-2" standalone ="yes"?>
< assembly xmlns ="urn:schemas-microsoft-com:asm.v1" manifestVersion ="1.0">
< assemblyIdentity
version ="1.0.0.0"
processorArchitecture ="X86"
name ="MyApplicationName"
type ="win32"
/>
< description >My 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 >
To do this, include the manifest as a file and place it in the same directory as your assembly (exe or dll).
The file should be named as follows:
application_name.exe.manifest
or
application_name.dll.manifest
Where application_name is the name of your application. For example, if your application is called Editor.exe, your manifest file name would be:
editor.exe.manifest
Alternatively, you can include your manifest as a resource by following these steps:
Thank you! Thank you! I just finished reading this document, which was part of a link in the recent Buzz newsletter. I have printed it for others to read, especially those skeptical on the powers of Access and its capabilities.
Darren D.
All Our Microsoft Access Products