Piecewise conversion of an MFC app to Unicode/MBCS(MFC 应用程序到 Unicode/MBCS 的分段转换)
问题描述
我有一个大型 MFC 应用程序,我正在扩展它以支持多语言输入.目前我需要允许用户在单个对话框的编辑框中输入 Unicode 数据.
I have a large MFC application that I am extending to allow for multi-lingual input. At the moment I need to allow the user to enter Unicode data in edit boxes on a single dialog.
有没有办法在不为整个应用程序打开 UNICODE 或 MBCS 的情况下做到这一点?我现在只需要转换应用程序的一小部分.是否可以分段进行,如果可以,怎么做?
Is there a way to do this without turning UNICODE or MBCS on for the entire application? I only need a small part of the application converted at the moment. Is it possible to do this piecewise, and if so, how?
澄清:我可以使用 ::GetWindowTextW() 从窗口中获取 Unicode 信息.我试图弄清楚如何允许用户在窗口中输入 Unicode 文本.目前,用户键入的字符在 windows-1252 代码页之外显示为?".有没有办法解决这个问题?
Clarification: I could use ::GetWindowTextW() to get Unicode information out of the window. I am trying to figure out how to allow the user to enter Unicode text in the window. Currently, characters the user types outside of the windows-1252 codepage show up as '?'. Is there a way to fix this?
推荐答案
要允许 CEdit 显示 Unicode 字符,您应该使用 CreateWindowW 函数创建它.我刚刚在 ANSI MFC 程序中测试过.
To allow CEdit to show Unicode characters you should create it with CreateWindowW function. I've just tested it in ANSI MFC program.
// allows Unicode characters
CreateWindowW( L"EDIT", L"", WS_CHILD|WS_VISIBLE, 10, 10, 50, 20, GetSafeHwnd(), 0, 0, 0 );
// shows Unicode characters as ?
CreateWindow( "EDIT", "", WS_CHILD|WS_VISIBLE, 10, 10, 50, 20, GetSafeHwnd(), 0, 0, 0 );
您可以在对话框的OnInitDialog 函数中手动创建所有编辑框.然后将它们子类化为支持 Unicode 的自定义 CMyEdit 类.
You could create all edit boxes manually in OnInitDialog function of dialog box. And later subclass them to custom CMyEdit class with Unicode support.
这篇关于MFC 应用程序到 Unicode/MBCS 的分段转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:MFC 应用程序到 Unicode/MBCS 的分段转换
基础教程推荐
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- c++ STL设置差异 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
- 提升 ASIO 流缓冲 2021-01-01
