1
votes

I have upgraded from Visual Studio 2010 to Visual Studio 2013.

I have also installed the Multibyte MFC Library for Visual Studio 2013.

Since upgrading, the visual styles no longer apply to the controls created in the MFC dialogs.

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.

I have added a new MFC application to my current solution. When I debug this MFC app it renders with Visual Styles.

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. Since I'm using a version later than VS2005 (and since there is no manifest file), I have added the following to 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

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

<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

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

However, I don't see how the DPI would affect this.

Edit

I've just realised there is another project in this solution which also uses MFC dialogs. 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)

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)

Please note, the manifest is embedded, and was created via the properties pane. There was no manually configured xml file.

1
Looks like the problem with your manifest file.Andrew Komiagin
Please note that you have to delete manifest file from the project if you are going to embed manifest using #pragma commentAndrew Komiagin
Please also post what you have in CWinApp::InitInstance() to initialize common controls.Andrew Komiagin
@AndrewKomiagin, there is no manifest file for this project. I've searched the computer for .manifest and nothing relates to this project (there is one for the main project but that doesn't contain any details about styles (and it's used as we have ActiveX controls and want to overwrite registry calls). Please note, the MFC stuff is part of our C++ project, there is no actual MFC project, just MFC code, as such there is no CWinApp()::InitInstance()MyDaftQuestions

1 Answers

2
votes

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. 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. Not just important to enable Visual Styles, it also declares the program compatible with 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.

You can double-check that this manifest is embedded properly with File > Open > File > select the EXE from your build directory. Try this with c:\windows\notepad.exe for comparison. You should see the RT_MANIFEST node, open it to see resource 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.

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. The ones you want to compare are located in Linker > Manifest File and Manifest Tool > all settings.