Upgraded MFC application still looks old(升级后的 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 应用程序看起来仍然很旧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:升级后的 MFC 应用程序看起来仍然很旧
基础教程推荐
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01