将MFC应用程序分段转换为Unicode / MBCS [英] Piecewise conversion of an MFC app to Unicode/MBCS

查看:168
本文介绍了将MFC应用程序分段转换为Unicode / MBCS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的MFC应用程序,我扩展允许多语言输入。目前我需要允许用户在单个对话框中的编辑框中输入Unicode数据。



有一种方法可以不打开UNICODE或MBCS整个应用程序?我只需要转换应用程序的一小部分。




澄清:如果是这样,我可以使用:: GetWindowTextW()获取Unicode信息出窗口。我想弄清楚如何允许用户在窗口中输入Unicode文本。目前,Windows-1252代码页外的字符用户类型显示为?。是否有解决方法?

解决方案

允许 CEdit 显示Unicode字符,您应该使用 CreateWindowW 函数创建它。我已经在ANSI MFC程序中测试了它。

  //允许Unicode字符
CreateWindowW(LEDIT ,L,WS_CHILD | WS_VISIBLE,10,10,50,20,GetSafeHwnd(),0,0,0);

//显示Unicode字符?
CreateWindow(EDIT,,WS_CHILD | WS_VISIBLE,10,10,50,20,GetSafeHwnd(),0,0,0);

您可以在 OnInitDialog 对话框的功能。然后将其子类化为具有Unicode支持的自定义CMyEdit类。


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.

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?


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?

解决方案

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 );

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆