LoadString失败

实现多国语言,都常用dll方式来加载资源(dll).

 

加载要设置一下: 如

      m_hLangDLL = ::LoadLibrary("TCHINESE.dll");
       if(m_hLangDLL)
     {
      AfxSetResourceHandle(m_hLangDLL);
      break;
     }

 

可今天遇到,英,简都成功,繁体就是不成功,为什么呢?

于是试着解决这个问题:

1>心想,其它都成功,应该是这个繁体的问题。逐 将TCHINESE.dll目录下文件删除掉,重新编译 Rebuild All. 测试。发现问题依旧 Fail

 

2>难道是StringTable 的ID号问题?于是把简中繁全部手动改编一下:


#define IDS_INCEPT_TIME                 61825--->#define IDS_INCEPT_TIME                 71825

...

测试结果,发现依然LoadString失败

 

3>这时想到,记得有本书上写过,StringTable是有范围的。于是查了查范围。。

Prefix          Resource type             Valid range
IDR_            multiple                  1 -> 0x6FFF
IDD_            dialog templates          1 -> 0x6FFF
IDC_,IDI_,IDB_  cursors, icons, bitmaps   1 -> 0x6FFF
IDS_, IDP_      general strings           1 -> 0x7FFF
ID_             commands                  0x8000 -> 0xDFFF
IDC_            controls                  8 -> 0xDFFF

#define IDS_INCEPT_TIME                 61825--->#define IDS_INCEPT_TIME                 51825

 

经测试,问题解决了。LoadString成功。

小结:根据MSDN: 7FFF=32767 我的ID定义都明显超过了啊,但很多都成功了。

经测试发现:65535 范围内都OK。

 

参考资料:

TN020: ID Naming and Numbering Conventions

 

PrefixResource TypeValid Range
IDR_multiple1 -> 0x6FFF
IDD_dialog templates1 -> 0x6FFF
IDC_,IDI_,IDB_cursors, icons, bitmaps1 -> 0x6FFF
IDS_, IDP_general strings1 -> 0x7FFF
ID_commands0x8000 -> 0xDFFF
IDC_controls8 -> 0xDFFF

Reasons for these range limits:

  • By convention, the ID value of 0 is not used.

  • Windows implementation limitations restrict true resource IDs to be less than or equal to 0x7FFF.

  • MFC's internal framework implementations reserve several ranges: 0xE000->0xEFFF and 0x7000->0x7FFF.

  • Several Windows system commands use the range of 0xF000 -> 0xFFFF.

  • Control IDs of 1->7 are reserved by IDOK, IDCANCEL, and so on.

  • The range of 0x8000->0xFFFF for strings is reserved for menu prompts for commands.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值