Why do I have old style buttons in an MFC dialog

Why do I have old style buttons in an MFC dialog

When I create a dialog based application in MFC, all of the buttons and controls have an old style (window 2000 or something) when I actually run the program. While I am designing the dialog or running the test it looks correct. Does anyone know why I am having this problem?

Brian is correct, you do need a manifest, however it's much easier in the modern era (circa VC 2005+) to get visual styles in your app.  If you're using VC 2005 or higher, you won't need to follow that white paper written back in 2001.    If you are using 6.0 then yes, follow that white paper. 

If you're using 2005 and higher and have this problem, I suspect you generated your app as a non-Unicode app.  Unicode apps generated by 2005 and higher use the new styles BY DEFAULT.  Non unicode apps are not.  

To fix this, you don't need to touch your manifest settings at all.  You simply need to open up your stdafx.h and go to the bottom of the file.  There, you will find a block of code like the following.  Take out the first "#ifdef _UNICODE" and the final "#endif" and then rebuild your app.  Now your non-Unicode app will have visual styles. 

#ifdef _UNICODE

#if defined _M_IX86

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")

#elif defined _M_IA64

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")

#elif defined _M_X64

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")

#else

#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

#endif

#endif

Copyright © 2007-2012 www.chuibin.com Chuibin Copyright