Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 792
  • Last Modified:

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

Hi,

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,
    Petr

P.S. I am using Windows 7 64-bit.
0
pepr
Asked:
pepr
  • 6
1 Solution
 
ZoppoCommented:
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='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

Open in new window

Hope that helps,

ZOPPO
0
 
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.
0
 
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LeeTutorretiredCommented:
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.
0
 
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.

0
 
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.  
0
 
peprAuthor Commented:
Thanks
0
 
peprAuthor Commented:
The problem was solved.  Have a look at http:Q_27563352.html if interested.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now