简体   繁体   English

从VS2010升级到VS2013失去了视觉风格

[英]Upgrading from VS2010 to VS2013 has lost the visual styles

I have upgraded from Visual Studio 2010 to Visual Studio 2013. 我已从Visual Studio 2010升级到Visual Studio 2013。

I have also installed the Multibyte MFC Library for Visual Studio 2013 . 我还为Visual Studio 2013安装了多字节MFC库

Since upgrading, the visual styles no longer apply to the controls created in the MFC dialogs. 自升级以来,视觉样式不再适用于在MFC对话框中创建的控件。

I will point out that Visual Studio previews (renders) it semi correctly (wrong background but generally the correct controls), it's only at runtime (Debug or Release etc) does this strange change happen. 我将指出,Visual Studio会半正确地预览(渲染)(错误的背景,但通常是正确的控件),只有在运行时(调试或发布等)才会发生这种奇怪的变化。

I have added a new MFC application to my current solution. 我在当前解决方案中添加了一个新的MFC应用程序。 When I debug this MFC app it renders with Visual Styles. 当我调试此MFC应用程序时,它将使用视觉样式进行渲染。

Edit 编辑

I have followed the advice found in How to enable visual styles without a manifest 我遵循了如何在没有清单的情况下启用视觉样式中的建议

This means, in the MFC project I have a stdafx.h . 这意味着,在MFC项目中,我有一个stdafx.h Since I'm using a version later than VS2005 (and since there is no manifest file), I have added the following to stdafx.h 由于我使用的版本比VS2005晚(并且没有清单文件),因此我将以下内容添加到stdafx.h

#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif

Edit 编辑

If it matters, this project's default Character Set is set to Use Multi-Byte Character Set 如果有关系,该项目的默认字符集将设置为“ Use Multi-Byte Character Set

Edit 编辑

There is no manifest file for this project. 该项目没有清单文件。 It is embedded. 它是嵌入式的。

Edit 编辑

Comparing the .exe file (opened with notepad) of the VS2010 build and VS2013 build shows the same manifest file with 1 exception 比较VS2010版本和VS2013版本的.exe文件(使用记事本打开)时,显示相同的清单文件,但有1个例外

VS2010 VS2010

<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="http://schemas.microsoft.com/SMI/2005/WindowsSettings" xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</ms_windowsSettings:dpiAware>

VS2013 VS2013

<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>

However, I don't see how the DPI would affect this. 但是,我看不到DPI将如何影响这一点。

Edit 编辑

I've just realised there is another project in this solution which also uses MFC dialogs. 我刚刚意识到此解决方案中还有另一个项目也使用MFC对话框。 The same issue persists to that as well. 同样的问题仍然存在。

Update 更新

I have ensured the project settings are as identical between a new MFC project and my C++ projects (with the difference being MFC exports to an Application where as I export my project to a .dll) 我已经确保新MFC项目和C ++项目之间的项目设置相同(区别是MFC导出到Application,而我将项目导出到.dll)

I have ensured the stafx.h in my project is the same as a new MFC project (with the difference that my C++ project requires ActiveX Control includes) 我已确保项目中的stafx.h与新的MFC项目相同(不同之处在于,我的C ++项目需要ActiveX Control包括)

Please note, the manifest is embedded, and was created via the properties pane. 请注意,清单是嵌入式的,并且是通过属性窗格创建的。 There was no manually configured xml file. 没有手动配置的xml文件。

Very hard to guess what could possibly have gone wrong in the project conversion. 很难猜测项目转换中可能出了什么问题。 Or for that matter how you ensured in VS2010 that the proper manifest was generated for the program. 或就此而言,您如何在VS2010中确保为程序生成了正确的清单。 You really need to address that detail in your question. 确实需要解决您的问题中的细节。

Noodling a bit about it, pretty crucial these days to ensure that an EXE file has a good manifest. 有点麻烦了,这对于确保EXE文件有一个良好的清单,这些天非常关键。 Not just important to enable Visual Styles, it also declares the program compatible with UAC. 不仅对启用视觉样式很重要,它还声明该程序与UAC兼容。 That manifest should always be embedded as a resource, not deployed as a separate file. 该清单应始终作为资源嵌入,而不是作为单独的文件部署。 Done by the linker. 由链接器完成。 The #pragmas you added can only work when the linker embeds the manifest. 您添加的#pragmas仅在链接器嵌入清单时才有效。

You can double-check that this manifest is embedded properly with File > Open > File > select the EXE from your build directory. 您可以使用文件>打开>文件>从构建目录中选择EXE来仔细检查此清单是否已正确嵌入。 Try this with c:\\windows\\notepad.exe for comparison. 尝试使用c:\\​​ windows \\ notepad.exe进行比较。 You should see the RT_MANIFEST node, open it to see resource ID #1. 您应该看到RT_MANIFEST节点,将其打开以查看资源ID#1。 You can double-click it to see the content, but that gives a hex-dump that is hard to read. 您可以双击它以查看内容,但这会导致难以阅读的十六进制转储。 Alternative is to right-click it > Export > save to a file with a .txt extension and open it in your text editor. 替代方法是右键单击它>导出>保存到扩展名为.txt的文件,然后在文本编辑器中将其打开。

And you'll want to check your project's build options to ensure that manifest generation is enabled. 您将需要检查项目的构建选项,以确保清单生成已启用。 Best to do so by starting VS again and creating a new MFC project with the wizard, allowing you to compare known-good settings with your project's settings. 最好的方法是再次启动VS,并使用向导创建一个新的MFC项目,使您可以将已知良好的设置与项目的设置进行比较。 The ones you want to compare are located in Linker > Manifest File and Manifest Tool > all settings. 要比较的文件位于链接器>清单文件和清单工具>所有设置中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 LINQ设计时间错误从VS2010升级到VS2013 - LINQ Design Time Errors Upgrading From VS2010 to VS2013 从VS2010升级到VS2013(或VS2012)后,无法打开Visual Studio C#解决方案,错误消息“不支持给定路径的格式” - Can not open Visual Studio C# solution after upgrading from VS2010 to VS2013 (or VS2012), error message “The given path's format is not supported” 将VS2013和VS2010与TFS2010一起使用 - Using VS2013 and VS2010 with TFS2010 将VS2010 CodeGenerator扩展移植到VS2013 - Port VS2010 CodeGenerator extension to VS2013 从VS2010升级的VS2013 winforms项目中缺少一些图标和文本 - some icons and text missing from VS2013 winforms project upgraded from VS2010 从VS2010迁移到VS2013后生成警告 - Build warnings after migrating from VS2010 to VS2013 从C#调试C ++ dll在VS2013中有效,但在VS2010中无效 - Debug C++ dll from C# works in VS2013, but not VS2010 无法构建-将VC ++代码从VS2010迁移到VS2013 - Unable to build - Migrating VC++ code from VS2010 to VS2013 从VS2010迁移到VS2013后的代码覆盖问题 - Code coverage issues after migrating from VS2010 to VS2013 C#-SQL Server数据工具-如何从VS2010迁移到VS2013 - C# - SQL Server Data Tools - How to migrate from VS2010 to VS2013
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM