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 应用程序看起来仍然很旧


- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- C++ 协变模板 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 近似搜索的工作原理 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 从python回调到c++的选项 2022-11-16
- 使用/clr 时出现 LNK2022 错误 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01