升级后的MFC应用程序看起来仍然很旧 [英] Upgraded MFC application still looks old

查看:80
本文介绍了升级后的MFC应用程序看起来仍然很旧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用VC6编写的MFC应用程序.我已经将其升级到VS2015,并且可以构建和运行.该应用程序是一个主要exe文件,其中包含许多具有对话框的DLL.

I have an MFC application written with VC6. I have upgraded it to VS2015 and it builds and runs. The application is a main exe with many DLL's that have dialogs in them.

但是,该应用程序看起来仍然像是用VC6构建的一样.没有一个GUI组件具有Windows 7的外观和感觉,它们仍然看上去都是旧样式.

However the application still looks like it is built with VC6. None of the GUI components have the Windows 7 look and feel, they all still look old style.

如何使现有应用程序看起来更现代?

How can I make my existing application look more modern?

推荐答案

您至少应将此行添加到项目中,例如,将其添加到stdafx.h

You should at least add this line to your project, for example add it to stdafx.h

#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

或将以下内容添加到清单文件中:

Or add the following to your manifest file:

<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="*"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>

另请参见启用视觉样式

对于所有者绘制控件而言,它变得更加复杂.请参阅此参考: 使用自定义样式和所有者绘制的控件

It gets more complicated for owner draw controls. See this reference: Using Visual Styles with Custom and Owner-Drawn Controls

对于ListView和TreeView控件,您可以调用此函数以获得更现代的外观(尽管在Windows 10中没有任何区别)

For ListView and TreeView controls, you can call this function for a more modern look (although it doesn't make any difference in Windows 10)

SetWindowTheme(m_ListView.m_hWnd, L"Explorer", NULL);
SetWindowTheme(m_TreeView.m_hWnd, L"Explorer", NULL);

* #pragma comment是特定于Visual Studio的.对于其他编译器,您需要修改清单文件

* #pragma comment is Visual Studio specific. For other compilers you need to modify the manifest file

这篇关于升级后的MFC应用程序看起来仍然很旧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆