首先在MSDN裏Using Windows XP Visual Styles對Visual Styles的使用有詳細描述,特別是對我一直很迷惑的XPMan單元,有了解釋。在XPMan單元裏有很重要的一行,{$R WindowsXP.res}。裏面用XML描述了一些信息,結合msdn
Attribute | Description |
---|---|
version | Version of the manifest. The version must be in the form major.minor.revision.build (that is, n.n.n.n, where n <=65535). |
processorArchitecture | Processor for which your application is developed. |
name | Includes company name, product name and application name. |
type | Type of your application, such as Microsoft Win32. |
下面的表格是assemblyIdentity屬性區(The following table shows the attributes set by the assemblyIdentity element in the manifest description section)
Attribute | Description |
---|---|
type | Type of the dependency component, such as Win32. |
name | Name of the component. |
version | Version of the component. |
processorArchitecture | Processor that the component is designed for. |
publicKeyToken | Key token used with this component. |
language | Language of the component. |
這是MSDN的例子。
<?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="CompanyName.ProductName.YourApplication"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApplication"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
這是Delphi的WindowsXP.res裏的xml文件
<xml="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="DelphiApplication"
version="1.0.0.0"
processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
</assembly>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="DelphiApplication"
version="1.0.0.0"
processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
</assembly>
Delphi程序裏包含了WindowsXp.res,也就有了Visual Styles的風格。
Delphi還有一個包裝了uxTheme.dll的類,TThemeServices。
這方面csdn上出自《 Delphi 完全時尚手冊之 Visual Style 篇---使非標準 Win32 控件或自畫控件也具有 Windows XP 的界面風格》http://blog.csdn.net/happyjoe/archive/2003/05/13/8542.aspx的文章有比較詳細的描述。由於我也沒有實際用過,只是按照上文所述例子大概實驗了一下,所以不再做深入評論。
另外要注意的一小點是,XP系統必須使用Windows Xp樣式,在外觀裏選用的。ThemeServices.ThemesEnabled 才爲True。