简体   繁体   English

在MBCS类型项目中使用UNICODE支持编辑控件

[英]Edit Control with UNICODE support in MBCS type project

I have old MFC application which support MBCS(Multi Byte Character Set). 我有支持MBCS(多字节字符集)的旧MFC应用程序。 I have a Edit Control and CString related to this Control.Now I want that only this control should support UNICODE(UTF-16) character set. 我有一个与该控件相关的Edit控件和CString。现在,我希望仅此控件应支持UNICODE(UTF-16)字符集。

EDIT: 编辑:

In header file : 在头文件中:

CString m_SerialNO;

In cpp file : 在cpp文件中:

DDX_Text(pDX, IDC_EDIT_SERIAL_NO, m_SerialNO);

I can not change the project's character set property from Use Multi-Byte Character Set to Use Unicode Character Set 我无法将项目的字符集属性从“ Use Multi-Byte Character Set更改为“ Use Unicode Character Set

只要使用CreateWindowA创建了Edit控件,所有消息都将通过当前代码页进行过滤和转换...即使您使用SetWindowTextW或WM_SETTEXTW也会进行转换。

It is actually quite easy: 实际上很简单:

// macro to get buffer size in declare character type
#define _countof(array) (sizeof(array)/sizeof(array[0]))

// text buffer must be in unicode
WCHAR szBufferW[1024];

// retrieve unicode text in MCBS build dialog
::GetDlgItemTextW(this->m_hWnd, IDC_EDIT1, szBufferW, _countof(szBufferW));

// display unicode text in in MCBS build dialog
::SetDlgItemTextW(this->m_hWnd, IDC_EDIT2, szBufferW);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在MBCS项目中使用unicode dll,反之亦然 - using unicode dlls in MBCS projects or vice versa 在VS 2013中弃用MBCS对MFC的支持的副作用 - Side-effect of deprecation of MBCS support for MFC in VS 2013 检查Visual C ++ 6.0项目是否支持unicode? - Check whether a Visual C++ 6.0 project did support unicode or not? 无法获取Visual C ++ 6.0对话框编辑控件以接受Unicode /无法获取EDITTEXT资源以接受Unicode - Can't Get Visual C++ 6.0 Dialog Edit Control to Accept Unicode / Can't Get EDITTEXT Resource to Accept Unicode 如何读取文本文件并将其显示在win 32 unicode字符集中的编辑控件上? - how to read text file and show it on edit control in win 32 unicode character set? 每次我构建一个虚幻引擎项目时,vs都会发出这样的警告:无法获取MBCS字符串 - Everytime I build a unreal engine project, vs keeps warning like this: unable to get MBCS string C ++项目类型:Unicode与多字节; 利弊 - C++ project type: unicode vs multi-byte; pros and cons 如何在添加到MFC Doc / Frame项目的对话框中为“编辑控件框”设置默认值 - How to set a default value for “Edit control box” in a Dialog that is added to MFC Doc/Frame project 如何向CRichEditCtrl添加Unicode支持? - How do I add Unicode support to a CRichEditCtrl? MBCS文件菜单生成???? 人物 - MBCS File Menus generate ???? Characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM