Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
0 MFC
Applications
This article was contributed by Alexander Simanov.
Environment: VC6 SP5, Windows 2000 SP2, and Windows XP SP1
The main reason for writing this article is that Visual C++ 6.0 wizards-generated MFC
applications don't use the XP look and feel controls if you run them under XP. If you are using
Microsoft Visual C++.NET, that is not an issue. I had a goal to develop an application running
under any Microsoft 32-bit OS and use the new UI look and feel if it runs under XP.
The solution is very simple. All you need to do is add a custom resource to the project and add
a couple of lines to the InitInstance method of the CWinApp derived class.
Create a file with its contents as shown above in the project resources folder (res by default).
Replace YourApplication with an appropriate name. That should do it for our case. For further
information about manifest files, see the MSDN for Visual Studio .NET.
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:
// Add manually edited resources here...
IDR_MANIFEST RT_MANIFEST MOVEABLE PURE
"res\\ApplicationManifestXMLFile"
#else
Enable3dControlsStatic(); // Call this when linking to MFC
// statically
#endif
// the rest of the code
}
4. Conclusion
This is it. No magic, but it works. You've got all the dialog controls, menus, and toolbars
looking like their brothers and sisters in native XP applications. You can still develop under
Windows 2000, but now I know that the UI of your applications will have a nice look under
XP.
These screenshots illustrate how the same application looks under Windows 2000 and
Windows XP:
If you have any questions or ideas about this article, please drop me a couple of lines at
alex@simanov.com.
Alexander Simanov
Downloads
I've created a simple project (MFC dialog-based), demonstrating this technique.
Download demo project - 20 Kb.
History
Date Posted: November 7, 2002