Applying visual styles to MFC dialogs called from a C# .net program

377 Views Asked by At

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.

1

There are 1 best solutions below

2
On

"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.