VS2008或2010 字符集改用多字节字符集时界面发生变化的解决方法

来源:互联网 发布:java在线聊天系统 编辑:程序博客网 时间:2024/06/04 04:21
关于 VS2008 字符集改用多字节字符集时,控件显示样式变为旧样式的问题的解决
 
问题描述:

再Win7系统下,用 VS2008建立工程后,默认的字符集为:使用 Unicode 字符集。由于该字符集使用比较麻烦,我常常将默认字符集该为:使用多字节字符集。但是当运行程序时发现程序中的很多控件的显示风格变为旧风格,很不好看。

解决方案:

在认真比对后,发现是stdafx.h文件的问题。主要为:

#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


大家可能很快就看出了问题,

直接将上面的文件该为:

//#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

即去掉了是否使用_UNICODE的判断就可以了

0 0