我无法使用AfxMessageBox,我在找书做一个练习,技术响应键盘(输入0显示0),
void CKeyMouseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
switch(nChar)
{
case 0x30:
AfxMessageBox("数字0被按下");
break;
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}void CKeyMouseView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
AfxMessageBox("鼠标左键被单击");
CView::OnLButtonDown(nFlags, point);
}可是提示错误:
e:\程序\test\keymouse\keymouse\keymouseview.cpp(111) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5025): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5027): or 'int AfxMessageBox(UINT,UINT,UINT)'
1> while trying to match the argument list '(const char [12])'
1>e:\程序\test\keymouse\keymouse\keymouseview.cpp(123) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5025): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5027): or 'int AfxMessageBox(UINT,UINT,UINT)'
1> while trying to match the argument list '(const char [15])'
1>生成日志保存在“file://e:\程序\test\KeyMouse\KeyMouse\Debug\BuildLog.htm”
1>KeyMouse - 2 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========
为什么请高人指点.
void CKeyMouseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
switch(nChar)
{
case 0x30:
AfxMessageBox("数字0被按下");
break;
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}void CKeyMouseView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
AfxMessageBox("鼠标左键被单击");
CView::OnLButtonDown(nFlags, point);
}可是提示错误:
e:\程序\test\keymouse\keymouse\keymouseview.cpp(111) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5025): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5027): or 'int AfxMessageBox(UINT,UINT,UINT)'
1> while trying to match the argument list '(const char [12])'
1>e:\程序\test\keymouse\keymouse\keymouseview.cpp(123) : error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5025): could be 'int AfxMessageBox(LPCTSTR,UINT,UINT)'
1> d:\microsoft visual studio 8\vc\atlmfc\include\afxwin.h(5027): or 'int AfxMessageBox(UINT,UINT,UINT)'
1> while trying to match the argument list '(const char [15])'
1>生成日志保存在“file://e:\程序\test\KeyMouse\KeyMouse\Debug\BuildLog.htm”
1>KeyMouse - 2 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========
为什么请高人指点.
VS2005编译器的检查更严格了,在vc6和vc7种可以编译通过的语句:AfxMessageBox(“test”);
VS2005编译器只能写成AfxMessageBox(_T(“test”));才能使用,否则编译器会告诉你有两个AfxMessageBox函数,但编译器不知道使用哪一个。错误提示如上。