我可以本地化AFX_IDP_ASK_TO_SAVE吗?
Can I localize AFX_IDP_ASK_TO_SAVE?
在我的应用程序中,我有一个"是否要保存更改?"消息框。我正在从 MFC 获取要显示的文本:
CString prompt;
AfxFormatString1(prompt, AFX_IDP_ASK_TO_SAVE, strFileName);
UINT nResult = AfxMessageBox(prompt, MB_YESNOCANCEL, AFX_IDP_ASK_TO_SAVE)
现在,我将应用程序本地化为日语。我猜像这样的标准文本已经被翻译成大多数主要语言。但是我不知道如何将MFC设置为使用这些标准文本的资源标识符的日语版本。可以这样做吗?
事实证明,我需要更改 .rc 文件中的一些包含文件:
#include "afxres.rc" // Standard components
#include "afxprint.rc" // printing/print preview resources
#include "afxribbon.rc" // MFC ribbon and control bar resources
需要成为:
#include "l.jpn/afxres.rc" // Standard components
#include "l.jpn/afxprint.rc" // printing/print preview resources
#include "l.jpn/afxribbon.rc" // MFC ribbon and control bar resources
在VS2008 AFX_IDP_ASK_TO_SAVE和其他AFX_...字符串保存在 MFC 本地化 DLL 中:MFC90CHS.dll、MFC90JPN.dll MFC90KOR.dll等。要在 Windows Vista 及更高版本上使用它们,您应该调用:
SetThreadUILanguage (MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
或
SetThreadUILanguage (MAKELANGID(LANG_JAPANESE,SUBLANG_JAPANESE_JAPAN));
在 Windows XP 调用中:
SetThreadLocale(lcid)
对于常量,请参阅 https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693%28v=vs.85%29.aspx
使用 GetSystemDefaultLangID 检索正确的语言环境,即在中文操作系统上。
重要提示:不要使用 GetUserDefaultLangID() 或 GetSystemDefaultUILanguage(),它们返回不同的东西,即如果你有英语操作系统,选择了中文语言环境。
lcid = MAKELCID(GetSystemDefaultLangID(), SORT_DEFAULT);//With Chinese locale, returns 0x804, zh-CN
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- C++ Singleton - Prevent ::instance() to variable
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- Python str to C++ to Python str
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- System.InvalidCastException - SQL to C++ - safe_cast<float>
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- "no matching function for call to 'Vector::Vector'"错误
- vector<vector<double>> to mxArray using memcpy
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- 当覆盖存在时调用基本虚拟"binded to object"函数
- OpenGL VBO Indexing ( How to compute Index Array)
- 为什么我会" void value not ignored as it ought to be"?
- 以编程方式调用"Save to PDF..."表