Adding the Windows XP visual style to Visual C++ 6.0 projects

Overview of steps to follow:

  • Create a .manifest file as a resource
  • Add definition for manifests to project.rc
  • Include manifest in project
  • Change all dialog fonts
When Windows XP was released, with it came a new visual style which I believe is called Luna, although I tend to refer to it as the cartoon interface :) It's the one with the curved green Start button, and a large red close button which has a rollover effect and rounded corners. Although your apps written in VC++ will pick up some of these features when your user has the Luna style enabled, the controls within your app don't match:

In order to achive this, create a file in your application's resource directory, with a name of the name of your main executable with .manifest appended. The file contents look like:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion=" 1.0">
<description>Styles - demonstrate XP styles</description>
    name="Microsoft.Windows.Common-Controls "
Don't copy from this web page or DevStudio might crash! Use the zip file below

You will of course want to alter the elements in Bold type to be something appropriate to your project.

Next, edit your project's resource.h file and the main resource file - in our example this will be called styles.rc. I find this simpler to do with Developer Studio closed so that it doesn't complain about having files modified underneath it.

Add the line:

MANIFEST_RESOURCE_ID    24      MOVEABLE PURE   "res\\styles.exe.manifest"

to the styles.rc file - and replace the part in bold again with whatever the file name is for your project.

Then open the resource.h file, and add the line:


at the start somewhere.

Finally, re-open Developer Studio, and change the fonts on all your dialog resources to be Tahoma and not MS Sans Serif. This font isn't a truetype one, so when the user selects ClearType, XP is not able to apply that option to MS Sans Serif.

If you've added a recent enough Platform SDK to your Developer Studio install, you may find the resource.h line isn't required.

블로그 이미지


불만있으면 떠나라...