MFC应用程序中使用XP控件外观(VC++ 6.0)

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

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

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

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

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<assembly 
   
xmlns="urn:schemas-microsoft-com:asm.v1" 
   manifestVersion
="1.0">
 
<assemblyIdentity 
    
processorArchitecture="x86" 
    version
="5.1.0.0"
    type
="win32"
    name
="test.exe"/>
 
<description>Test Application</description>
 
<dependency>
  
<dependentAssembly>
    
<assemblyIdentity
         
type="win32"
         name
="Microsoft.Windows.Common-Controls"
         version
="6.0.0.0"
         publicKeyToken
="6595b64144ccf1df"
         language
="*"
         processorArchitecture
="x86"/>
  
</dependentAssembly>
 
</dependency>
</assembly>

 

  5.保存工程,重新编译

附,前后对比图:

posted on 2010-04-24 19:25  笨笨狼  阅读(1259)  评论(0)    收藏  举报

导航