我从下面这个网址里下载了一个Demo程序,目的是为了实现CListCtrl排序问题。
该Demo程序在多字节模式下编译没用问题,并且允许正常。
但是在Unicode下编译报错,由于该类大部分都是以模板的方式写的,看不明白请坛子里的高手帮忙看看!!http://www.codeproject.com/KB/cpp/ListCtrlSort.aspx

解决方案 »

  1.   

    报什么错呢?贴出来看看http://hi.baidu.com/gookings/blog/item/8d8b4d3d5e947ae73d6d971a.html
      

  2.   

    代码应该要改,比如 char 改为 TCHAR ,把编译错误的地方改下就应该可以了
      

  3.   

    如果是编码的问题,那就在工程属性里面设置去掉UNICODE,选择多字节字符。
      

  4.   

    错误如下提示如下:
    1>------ 已启动生成: 项目: TestSDI01, 配置: Debug Win32 ------
    1>正在编译...
    1>ListCtrlSort.cpp
    1>d:\测试程序\testsdi01\testsdi01\listctrlsort.h(20) : error C2664: “CRegexpT<CHART>::CRegexpT(const CHART *,int)”: 不能将参数 1 从“const wchar_t [17]”转换为“const unsigned short *”
    1>        with
    1>        [
    1>            CHART=unsigned short
    1>        ]
    1>        与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(19): 编译类 模板 成员函数“int ListCtrlSortHelper<T>::Compare(const CString &,const CString &)”时
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(116): 参见对正在编译的类 模板 实例化“ListCtrlSortHelper<T>”的引用
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>TestSDI01.cpp
    1>d:\测试程序\testsdi01\testsdi01\listctrlsort.h(20) : error C2664: “CRegexpT<CHART>::CRegexpT(const CHART *,int)”: 不能将参数 1 从“const wchar_t [17]”转换为“const unsigned short *”
    1>        with
    1>        [
    1>            CHART=unsigned short
    1>        ]
    1>        与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(19): 编译类 模板 成员函数“int ListCtrlSortHelper<T>::Compare(const CString &,const CString &)”时
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(116): 参见对正在编译的类 模板 实例化“ListCtrlSortHelper<T>”的引用
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>TestSDI01View.cpp
    1>d:\测试程序\testsdi01\testsdi01\testsdi01view.cpp(106) : warning C4244: “参数”: 从“time_t”转换到“unsigned int”,可能丢失数据
    1>d:\测试程序\testsdi01\testsdi01\listctrlsort.h(20) : error C2664: “CRegexpT<CHART>::CRegexpT(const CHART *,int)”: 不能将参数 1 从“const wchar_t [17]”转换为“const unsigned short *”
    1>        with
    1>        [
    1>            CHART=unsigned short
    1>        ]
    1>        与指向的类型无关;转换要求 reinterpret_cast、C 样式转换或函数样式转换
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(19): 编译类 模板 成员函数“int ListCtrlSortHelper<T>::Compare(const CString &,const CString &)”时
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>        d:\测试程序\testsdi01\testsdi01\listctrlsort.h(116): 参见对正在编译的类 模板 实例化“ListCtrlSortHelper<T>”的引用
    1>        with
    1>        [
    1>            T=ListViewSort
    1>        ]
    1>正在生成代码...
    1>生成日志保存在“file://d:\测试程序\TestSDI01\TestSDI01\Debug\BuildLog.htm”
    1>TestSDI01 - 3 个错误,1 个警告
    ========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
      

  5.   

    VS 2005以上?是的话就在编译设置项的 语言 里,把内建wchar_t类型关闭