用c++编写一个跟踪鼠标并获取其坐标的程序,哪位高手赐教
1个回答
展开全部
void CFindingView::OnLButtonUp(UINT nFlags, CPoint point)
{
CRect r;
GetClientRect(&r);
char * s;
if (point.x>r.right/2)
if(point.y>r.bottom/2) s="1";
else
s="2";
else
if(point.y>r.bottom/2)
s="3";
else
s="4";
MessageBox(s,"弇离枑尨",MB_OK|MB_ICONEXCLAMATION);
CView::OnLButtonUp(nFlags, point);
}
void CFindingView::OnMouseMove(UINT nFlags, CPoint point)
{
CFindingDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Text=IntToCString(point.x)+","+IntToCString(point.y); mPoint.x=point.x+20;
mPoint.y=point.y;
Invalidate();
CView::OnMouseMove(nFlags, point);
}
CString CFindingView::IntToCString(int Num)
{int i;
CString strnum="";
char c;
while(Num>0)
{
i=Num%10;
c='0';
c=c+i;
strnum+=(char)c;
Num=Num/10;
}
strnum.MakeReverse();
return strnum;
}
{
CRect r;
GetClientRect(&r);
char * s;
if (point.x>r.right/2)
if(point.y>r.bottom/2) s="1";
else
s="2";
else
if(point.y>r.bottom/2)
s="3";
else
s="4";
MessageBox(s,"弇离枑尨",MB_OK|MB_ICONEXCLAMATION);
CView::OnLButtonUp(nFlags, point);
}
void CFindingView::OnMouseMove(UINT nFlags, CPoint point)
{
CFindingDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Text=IntToCString(point.x)+","+IntToCString(point.y); mPoint.x=point.x+20;
mPoint.y=point.y;
Invalidate();
CView::OnMouseMove(nFlags, point);
}
CString CFindingView::IntToCString(int Num)
{int i;
CString strnum="";
char c;
while(Num>0)
{
i=Num%10;
c='0';
c=c+i;
strnum+=(char)c;
Num=Num/10;
}
strnum.MakeReverse();
return strnum;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询