现在的位置: 首页 > 综合 > 正文

VC++6 实现界面使用XP风格

2013年09月05日 ⁄ 综合 ⁄ 共 1189字 ⁄ 字号 评论关闭
VC++6 实现界面使用XP风格

看到有人需要这个东西,在英文下有很多文章,中文搜索发现不是很好,因此特意介绍下。

1.实现原理

  微软为Windows
XP提供了Themes服务。Themes可以让程序具有“XP风格”,看起来更美观,因为微软更新了Comctl32.dll(ver
6.0)这个“XP风格”的控件。微软还为了保留传统的Windows界面风格,特地留下了Comctl32.dll v5.8。VC6的推出时间早于WinXP,因此VC6的程序默认是不使用“xp风格”的。

  程序使用xp风格主要是内置了manifest这东东。因此只要让VC6的程序中包含即可。包含可以外置,也可以内置为资源。

2.实现方法:

  1.打开你的VC6 工程,找到资源试图(ResourceView),然后在视图中的树的根结点上点鼠标右键,选择菜单“插入(Insert)”。
 
  2.在弹出的“插入资源(Insert Resource)”对话框中选择“Custom”,在新对话框(“New Custom Resource”)输入框中输入 24。 因为manifest的类型是24, 点击“OK”按钮。
 
  3.在资源视图的树上面选择24下方的条目“DDR_DEFAULT1”上点右键,选择“Properties”,将ID:修改为1.
 
  4.双击刚才修改的“1”条目,然后在右方的编辑器窗口中输入下面的代码:

  1. <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
  2. <assembly 
  3.    xmlns="urn:schemas-microsoft-com:asm.v1" 
  4.    manifestVersion="1.0">
  5.  <assemblyIdentity 
  6.     processorArchitecture="x86" 
  7.     version="5.1.0.0"
  8.     type="win32"
  9.     name="test.exe"/>
  10.  <description>Test Application</description>
  11.  <dependency>
  12.   <dependentAssembly>
  13.     <assemblyIdentity
  14.          type="win32"
  15.          name="Microsoft.Windows.Common-Controls"
  16.          version="6.0.0.0"
  17.          publicKeyToken="6595b64144ccf1df"
  18.          language="*"
  19.          processorArchitecture="x86"/>
  20.   </dependentAssembly>
  21.  </dependency>
  22. </assembly>

  
  5.保存工程,重新编译 

附,前后对比图:

抱歉!评论已关闭.