按照第一个 hello world 示例在 VS2010 中出现编译错误
我刚刚开始学习MFC..在这里找到了一个教程 http://bit.ly/j2uhHO ..刚刚尝试了在 VS2010 中也是如此,但在此代码中出现编译错误。
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.TextOut(0, 0, "Hello, world!");
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
}
错误是:
error C2664: 'BOOL CDC::TextOutW(int,int,const CString &)' :无法将参数 3 从 'const char [14]' 转换为 'const CString &
'
任何人都可以解决这个问题并建议一些 mfc 教程..谢谢你..
i just started learning MFC..found a tutorial here http://bit.ly/j2uhHO ..just tried the same thing in VS2010 but getting a compilation error in this code..
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.TextOut(0, 0, "Hello, world!");
// TODO: Add your message handler code here
// Do not call CWnd::OnPaint() for painting messages
}
And the error is:
error C2664: 'BOOL CDC::TextOutW(int,int,const CString &)' : cannot convert parameter 3 from 'const char [14]' to 'const CString &
'
Can anyone solve this and suggest some mfc tutorials please..thank u..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该错误告诉您到底出了什么问题。
TextOutW()
期望const CString &
作为第三个参数,并且您正在传递const char [14]
您需要执行
以下操作 :第三个参数采用函数所需的格式。
要参考 MFC 资源,请参阅此。
The error tells you whats exactly wrong.
TextOutW()
is expectingconst CString &
as the third parameter and you are passingconst char [14]
You need to do:
Which passes the third argument in the format desired by the function.
For MFC resources to refer, you see this.
问题是 Windows 默认使用宽字符
wchar_t
来表示文本。你需要The problem is that Windows by default uses wide characters
wchar_t
for texts. You would need