简体   繁体   中英

Edit Control with UNICODE support in MBCS type project

I have old MFC application which support MBCS(Multi Byte Character Set). 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:

In header file :

CString m_SerialNO;

In cpp file :

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

只要使用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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM