I'm creating a dialog with the resource editor of Visual C++.
When I run the test button of the editor, components of the dialog are displayed with a modern look, while when running the application that creates and shows the dialog, it's displayed with an old look...I'm just using WINAPI calls to display the dialog, not MFC.
Here are the screenshot (the upper image is an example of UI look on design time, the other one is the UI look on run time):
Does anyone know what I'm doing wrong?
Does your application manifest specify that you want to use comctl32.dll version 6? This is one of the requirements of using visual styles and a more modern look in windows XP.
To create a manifest and enable your application to use visual styles.
Link to ComCtl32.lib and call InitCommonControls (see the Platform SDK documentation in the MSDN Library).
Add a file called YourApp.exe.manifest to your source tree that has the following XML format:
Add the manifest to your application's resource file as follows
Note: When you add the previous entry to the resource you must format it on one line. Alternatively, you can place the XML manifest file in the same directory as your application's executable file. The operating system will load the manifest from the file system first, and then check the resource section of the executable. The file system version takes precedence.
I have a solution for VC6, but I am not sure if it will work in VS 2008.
(also check this article for what is causing the problem)
Here is an example of a simple manifest file that I've used to solve it:
Create the below XML file,
First, let's add two lines to the resource.h file. Just copy and paste the following:
Now, open the application custom resource file. Usually, it's located in the res directory; the default extention is .rc2. Manually add the following line:
Replace ApplicationManifestXMLFile with the actual file name (the XML you have created).
Have you got a manifest correctly set up to use version 6 of commctl32.dll in your project? If not, you won't get the themed controls.
In later versions of Visual Studio, this is usually done with a #pragma, like so (this one is for x86, copied from a new project generated with VS2005):
If you add this to one of the source files in your project and rebuild, the manifest will be generated by the linker and added to your application. For other processor architectures, you'll need to change the "processorArchitecture" value. (Why VS can't figure this out for itself is a mystery left to the reader to solve...)
(As some others have noted, you can also manually generate the manifest and add it to the .rc file. This is more long-winded, but does give you complete control of the manifest's contents.)
Expanding on the existing answers...
MSDN: Build Requirements for Windows Vista Common Controls
Dropping the following into stdafx.h worked well for me, and helped to display at runtime the thin border styling shown in the VS dialog resource editor:
The question specifies C++ and this other question shows how to do it more cleanly.
For .Net 2.0+, please see >this MSDN article< for how to do it with one line of code, to wit:
I hope this helps someone searching this topic.