实现多国语言,都常用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
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 |
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.