简体   繁体   English

使用GetWindowTextW从编辑控件获取希伯来语文本

[英]Using GetWindowTextW to get Hebrew text from edit control

I have a VisualStudio project set to "Use Multi-Byte Character Set. It's an older codebase and generally I've been able to get around ok using the "W" version of various functions. However I'm running into a problem trying to get a Hebrew string out of an edit control. No matter what I try I get question marks. 我有一个VisualStudio项目设置为“使用多字节字符集。这是一个较旧的代码库,通常我可以使用各种功能的“ W”版本来解决问题。但是,在尝试执行以下操作时遇到了问题从编辑控件中获取一个希伯来语字符串。无论我尝试什么,都会出现问号。

Eg 例如

int textLen = GetWindowTextLengthW(chatBoxHwnd);
wchar_t* buffw = new wchar_t[textLen + 1];  
GetWindowTextW(chatBoxHwnd, buffw, textLen + 1);

But when I try to use buffw (such as displaying it with MessageBoxW) I still get question marks. 但是当我尝试使用buffw(例如与MessageBoxW一起显示)时,我仍然会收到问号。

So the solution was to also use the Unicode version for creating the edit control itself ( CreateWindowExW vs CreateWindowEX) as well as the ancillary functions around that (SendMessageW, SetWindowLongPtrW, etc...) After that I was able to successfully use the above code to pull Hebrew (and other languages) from the edit box. 因此解决方案是还使用Unicode版本来创建编辑控件本身(CreateWindowExW与CreateWindowEX)以及围绕该控件的辅助功能(SendMessageW,SetWindowLongPtrW等)。之后,我能够成功使用上述代码从编辑框中拉希伯来语(和其他语言)。

Special thanks to this post How to create a unicode window in a non-unicode application 特别感谢这篇文章如何在非Unicode应用程序中创建Unicode窗口

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

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