错误C2664:'CWnd :: SetWindowTextW':无法将参数1从'const char [6]'转换为'LPCTSTR' [英] error C2664: 'CWnd::SetWindowTextW' : cannot convert parameter 1 from 'const char [6]' to 'LPCTSTR'
本文介绍了错误C2664:'CWnd :: SetWindowTextW':无法将参数1从'const char [6]'转换为'LPCTSTR'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码是
CString mytext = 你好跨度>;
((CEdit *)GetDlgItem(IDC_EDITTITLE7)) - > SetWindowText(mytext);
解决方案
字符串Hello 是一个ANSI字符串。对于Unicode构建,必须使用字符串前缀L
来使用宽字符串。要独立于Unicode设置,您可以使用_T()
宏,如果需要,将设置前缀:
CString mytext = _T(Hello);
强制性链接: C ++字符串完整指南,第一部分 - Win32字符编码 [ ^ ]。
The code is
CString mytext = "Hello";
((CEdit *) GetDlgItem(IDC_EDITTITLE7))->SetWindowText(mytext);
解决方案
The string "Hello" is an ANSI string. With Unicode builds, you must use a wide string by prefixing the string with the letterL
. To be independant of the the Unicode setting, you can use the_T()
macros which will set the prefix if necessary:
CString mytext = _T("Hello");
Obligatory link: The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^].
这篇关于错误C2664:'CWnd :: SetWindowTextW':无法将参数1从'const char [6]'转换为'LPCTSTR'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文