zoukankan      html  css  js  c++  java
  • [MFC] UNICODE和非UNICODE工程在UI上的区别

    MFC工程最初是基于英文系统开发,由于外部DLL只提供了非UNICODE版本,为了开发方便将客户端系统设置为非UNICODE。近日由于要提供多语言支持。需要将工程设置为UNICODE,但是系统运行后,界面风格变了。

    刚才以为是资源文件被修改了。经过网上多次google发现是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

    如果采用UNICODE版本,上述代码将会执行。
    在msddn中,#pragma comment用法如下:

    #pragma comment( comment-type [,"commentstring"] )
    linker
    Places a linker option in the object file. You can use this comment-type to specify a linker option instead of passing it to the command line or specifying it in the development environment. For example, you can specify the /include option to force the inclusion of a symbol:
    #pragma comment(linker, "/include:__mySymbol")
    Only the following (comment-type) linker options are available to be passed to the linker identifier:
    /DEFAULTLIB
    /EXPORT
    /INCLUDE
    /MANIFESTDEPENDENCY
    /MERGE
    /SECTION
    总而言之,语句“ #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")”将导致连接器修改manifest文件中的外部依赖部分,从而让应用程序调用不同的系统控件。所以导致UI出现不同。
  • 相关阅读:
    HTTP客户端
    获取IP地址和域名
    SQL语句、PL/SQL块和SQL*Plus命令之间的区别
    oracle中的游标
    oracle表问题
    精简版web浏览器
    oracle的存储过程
    数据库中的视图
    第一次作业
    折半查找
  • 原文地址:https://www.cnblogs.com/ityujian/p/3070191.html
Copyright © 2011-2022 走看看