vc 显示鼠标位置(新手上路)

来源:百度知道 编辑:UC知道 时间:2024/05/16 00:12:59
大家好,我想把鼠标的位置显示在状态栏上,当我只增添以下代码:
void CDdView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("x=%d,y=%d",point.x,point.y);
((CMainFrame*)GetParent())->m_wndStatusBar.SetWindowText(str);

CView::OnMouseMove(nFlags, point);
}
经过编译:
出现下面错误:
F:\学习vc\1026\显示鼠标位置\ShowXY1\dd\ddView.cpp(110) : error C2059: syntax error : ')'

之后,翻书”为了能够访问这个变量,我们修改这个变量的定义,将其访问权限设置为Public,即在CMainFrame类的头文件中,把这个变量的定义修改为:public:CStatusBar m_wndStatusBar;
然而这时候,跳出一个提示框
---------------------------
Microsoft Visual C++
---------------------------
Cannot compile the file 'F:\学习vc\1026\显示鼠标位置\ShowXY1\dd\MainFrm.h'; no compile tool is associated with the file extension.
---------------------------
确定
请问这是怎么回事啊。我的要求并不高,只是想把鼠标的位置显示在statusbar上。敬请大牛大虾

很简单哦

void CDdView::OnMouseMove(UINT nFlags, CPoint point)
{
CString str;
str.Format("x=%d,y=%d",point.x,point.y);
((CFrameWnd*)GetParent())->SetMessageText(str);

CView::OnMouseMove(nFlags, point);
}

---------------------------
Microsoft Visual C++
---------------------------
Cannot compile the file 'F:\学习vc\1026\显示鼠标位置\ShowXY1\dd\MainFrm.h'; no compile tool is associated with the file extension.
---------------------------
确定
======
你不能编头文件啊,你直接Ctrl+F5啊

你可以在CFrameWnd类中 响应你的MouseMove消息