I am a little confused on what are the factors that contribute to the appearance of the UI elements (like buttons) on windows dialogs. My confusion appears out of the following observations:
1- I have visual studio 2010 installed on my system and when I create a MFC dialog , the buttons on the .rc have a sophisticated look , slightly rounded corners etc. when I build the MFC application same appearance comes in the resulting exe.
2- Now I get an application that is developed in VC 6, convert it to new vs 2010 project. When I open the .rc file the UI look is same as described above
but when I build and run the app , the ui look of the buttons is old , unsophisticated.
3- I include InitcommonControlEx() in the old code , and that changes nothing.Perhaps it is not related to this.
My question is what is controlling this look and feel of the ui elements? Is it something to do with the manifest file which directs which version of windows library the application should use?
if so, how can I update the manifest file of the old project , so that I get the new UI look and feel?
You are right. You need to embed a manifest file.
The proper way to embed manifest into MFC application with VS2010 is via Properties->Linker->Manifest File->Generate Manifest. To enable XP theme just use the following in the
Additional Manifest Dependencies
field:In VS2010, use the New Project wizard to create an MFC dialog application (actually any MFC application will do). Choose defaults for all options and let the wizard generate the code.
When it's done, look in the file
stdafx.h
and copy/paste the following block into yourstdafx.h
You can also do this via Project/Properties, but by doing it in the code, it won't break if you share the source with other projects.
Note that there is an
#ifdef _UNICODE
in there because a small number of common controls only work correctly for UNICODE builds. However, if you need and non-UNICODE build and are only using "standard" Windows controls (e.g. no List Views or Tree Views, etc.) it's ok to remove the#ifdef
.If you would rather not remove the #ifdef _UNICODE statement, you can just copy the line
and place it at the end of your stdafx.h file. This does EXACTLY the same thing as the the steps recommended by "cha" above, but in fewer steps.