0

I have a .NET C# program that references some C++/CLI dlls which in turn can launch some legacy MFC forms/dialogs. However when these dialogs are launched they do not launch with the current Windows theme, aka visual styles, applied. They open as the old Windows 98 style.

These dialogs do launch with visual styles if we launch through the original C++/CLI project with the pragma comment included in the stdafx.h of the Application Exe project.

I've tried several of the suggestions within the referenced Microsoft article about applying visual styles to C++ projects. However none of them work, since I assume the article is targeted towards a pure C++ solution rather than a hybrid C# solution referencing old MFC dialogs.

tl;dr Can launch MFC dialogs from C# program, but dialogs are not visually styled.

Alan Stokes
  • 18,815
  • 3
  • 45
  • 64

1 Answers1

1

"If you want your application to use visual styles, you must add an application manifest or compiler directive that indicates that ComCtl32.dll version 6 should be used if it is available."

Source: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773175(v=vs.85).aspx

An application manifest should work.

Dan Korn
  • 1,274
  • 9
  • 14
  • Hi Dan, appreciate the response, but I've already tried the application manifest. As I mentioned in the original post, I've been to that link and tried everything that was suggested. When I add the application manifest, my C# application does not compile. It complains with this error: Error 1 Could not find file 'Microsoft.Windows.Common-Controls, Version=6.0.0.0, Culture=*, PublicKeyToken=6595b64144ccf1df, ProcessorArchitecture=*, Type=win32' The only solution I found was to comment it out, which defeats the purpose of adding this to the application manifest. – Shao Skywalker Jan 30 '16 at 21:29
  • So add ComCtl32.dll version 6 or later to your project references. (What version of Visual Studio are you running, on what version of Windows?) At the very least, you should be able to put a standalone XML manifest file next to your executable, with the same name as the executable file with ".manifest" added to the end. – Dan Korn Feb 01 '16 at 18:31