2010年6月28日 星期一

MFC: show current cusor poistion

void CChildView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此加入您的訊息處理常式程式碼和 (或) 呼叫預設值

//CWnd::OnMouseMove(nFlags, point);
CClientDC dc(this); // device context for painting
COLORREF fgcol = dc.GetTextColor();
static CPoint opoint(0,0);
CString a;

dc.SetTextColor(dc.GetBkColor());
a.Format("(%3d, %3d)", opoint.x, opoint.y);
dc.TextOutA(opoint.x-15, opoint.y-15, a);
dc.SetTextColor(fgcol);
a.Format("(%3d, %3d)", point.x, point.y);
dc.TextOutA(point.x-15,point.y-15, a);
opoint = point;

}

沒有留言: