MFC创建简单的窗口 [英] MFC creation of simple windows
本文介绍了MFC创建简单的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MFC_Tutorial_Window() { Create(NULL,"MFC Tutorial Part 1 CoderSource Window"); }
在我的项目中,第二个参数产生问题,我得到的错误就像
in my project the second argument create problem and i am getting error like
cannot convert parameter 2 from 'const char [39]' to 'LPCTSTR'
< b>我尝试了什么:
i没有任何想法,但如果我将Create()的第二个参数更改为null,则可以正常工作。但我需要窗口的标题。
What I have tried:
i dont have any idea to do but if i change the second argument of Create() to null it works. but i need title of the window.
推荐答案
您已将项目设置为构建Unicode应用程序(这是默认设置)。
对于这样的所有字符串文字必须是Unicode(宽字符)字符串,需要在前面加上L
:
You have set your project to build a Unicode application (which is the default).
For such all string literals have to be Unicode (wide char) strings which requires prefixing them with anL
:
MFC_Tutorial_Window() { Create(NULL, L"MFC Tutorial Part 1 CoderSource Window"); }
如果你也想支持非Unicode版本,你可以使用 _T()
宏来表示这些字符串然后根据项目设置解决:
If you want to support non Unicode builds too, you can use the _T()
macro for such strings which is then resolved according to the project settings:
MFC_Tutorial_Window() { Create(NULL, _T("MFC Tutorial Part 1 CoderSource Window")); }
欢迎来到 Macrosoft 梦魇。
看看在这个CodeProect
的文章中:什么是TCHAR,WCHAR,LPSTR,LPWSTR,LPCTSTR(等)? [ ^ ]
Welcome to the Macrosoft Nightmare.
Have a look at thisCodeProect
's article: What are TCHAR, WCHAR, LPSTR, LPWSTR, LPCTSTR (etc.)?[^]
这篇关于MFC创建简单的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文