Upgraded MFC application still looks old

那年仲夏 提交于 2019-11-26 21:41:01

问题


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.

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?


回答1:


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>

See also Enabling Visual Styles

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

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 is Visual Studio specific. For other compilers you need to modify the manifest file




回答2:


Also make sure your linker setting ALLOWISOLATION is set to 'Yes' otherwise the manifest is not even considered.



来源:https://stackoverflow.com/questions/32728815/upgraded-mfc-application-still-looks-old

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!