用c++编写一个跟踪鼠标并获取其坐标的程序,哪位高手赐教

2024-12-03 01:37:05
推荐回答(1个)
回答(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;
}