VS 2010 C++: How to create a manifest to enhance the GUI look?


I have a problem with creating and embeding the manifest file for the C++ native application for Windows in Visual Studio 2010 C++.  The problem is that when embeding my manifest, the application does not run on Windows XP mode of the Windows 7.  The executable cannot be launched at all.

The simplest possible application (that does not work for me after adding the manifest) is probably a message box with the OK button:

The message box with "old" GUI look -- see the OK button and around.
See the old look of the OK button and of the background around.  How can I add the manifest to make the button look the new way?

The testing example can be created this way:

1. Launch the Visual Studio 2010 C++.
2. Choose from the menu: File -- New -- Project... (Ctrl+Shift+N)
3. From the Installed Templates choose: Visual C++ -- Win32 -- Win32 Project
4. Choose the Location for the project, type-in the Name: test  (see the picture)

 Creating the new C++ project.
5. Press OK, Next >, and then check the Additional options: Empty project, and finally press the button Finish (see the image)

 Finishing the empty project.
6. In Solution Explorer, click the right mouse button over the Source Files -- Add -- New Item... (Ctrl+Shift+A)

 Add New Item...
7. ... select the C++ File (.cpp), give it the name main.cpp and press the Add button.

 Adding the main.cpp
8. Copy/paste the following code into the main.cpp.

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, 
                   HINSTANCE hPrevInstance, 
                   LPTSTR lpCmdLine, 
                   int nShowCmd)
    MessageBox(NULL, "test", "test", MB_ICONINFORMATION);
    return 0;

Open in new window

9. Now, open the Project -- test Properties... (Alt+F7), unfold the Configuration Properties, choose General and change the Character Set to the value "Not Set" and press OK (shown for Debug on the following picture, you can do the same for the Release if you want to compile also the Release version).

 Changing the Project properties...
10. Compile it (F7) and run it (F5) and you should see...

 The message box with "old" GUI look -- see the OK button and around.

Now, can you show how exactly should I add the manifest file and what should be its content?

Thanks for your time and experience,

P.S. I am using Windows 7 64-bit.
LVL 30
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi pepr,

here you can find info about how to enable visual styles: http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175%28v=vs.85%29.aspx

One easy way mentioned there (which I usually use) is to add a pragma like this i.e. in 'stdafx.h':
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Open in new window

Hope that helps,


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peprAuthor Commented:
Thanks Zoppo.  I will try in Monday.  Actually, had used the manifest earlier.  The problem is that I have discovered just recently that the application cannot be launched on Win XP (better to say in Win XP mode of the Win 7 virtual machine).  If interested, have a look at http:Q_27414344.html.

The #pragma way is new to me.  Thanks again.
peprAuthor Commented:
I am loosing my last hairs.  Nothing from above works for me.  Can you recommend some full example sources to compile that include also the manifest.  The goal is to try if the GUI visual enhancement works in my environments.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
peprAuthor Commented:
Sorry for not closing the question earlier.  I feel that Zoppo's answer is correct and I have learned the #pragma version of doing that.  It simply seems that I have some problem with my environment or I have overlooked something.  I am planning to return to that later, but I did not find time, yet.

peprAuthor Commented:
Please accept the Zoppo's answer with A (fully understandable and easy to follow, from official documentation).  I cannot do it now as it is blocked.  
peprAuthor Commented:
peprAuthor Commented:
The problem was solved.  Have a look at http:Q_27563352.html if interested.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.