Date: 2010apr27
Updated: 2023mar27
OS: Windows
Product: MSVC
Keywords: flat, Aero
Q. MSVC++: Flat look dialogs / embed a manifest
A. Starting with Vista manifests have two purposes (that I know of):
- Turning on the flat look of the controls
- Turning on elevated security for your program when UAC is enabled
The manifest usually lives in a file called <YourProgram>.exe.manifest in
the same folder as your .cpp files.
For flat look make it contain this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="[YourProgamHumanName]" type="win32" />
<!-- the <description> tag is required but you don't have to fill it out -->
<description></description>
<!-- for flat dialogs add this ... Usually you DO want this -->
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
<!-- for elevated permissions add this... Usually you do NOT want this -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
Here's how you embed it in your program.
In Microsoft Visual C++ 2005 and later add it as add would a .cpp file
(under "Source Files") and it will be correctly embedded when you build.
In Borland C++ 5.02 open your .rc (resource) file in a text editor
and paste in:
#define RT_MANIFEST 24
#define APP_MANIFEST 1
APP_MANIFEST RT_MANIFEST <YourProgram>.exe.manifest
and build.
It would be nice to be able to embed a manifest in a DLL.
Eg make your DLL use flat-look when invoked by a older EXE (that doesn't have a
manifest). You can embed a manifest in a DLL but my experiments have shown
that its ignored. Maybe because the common controls are already initialized
by the time the DLL is called?
In VC++ 2005 and later you add this to a .cpp file for flat controls
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
This doesn't require an extra file but then if you use an extra file it will be easier to edit and syntax-highlighted.