MFC视图实时显示鼠标位置实现

xiaoxiao2021-02-28  97

原文链接:http://blog.csdn.net/heiantianshi1/article/details/6553648

主要是OnMove()函数:

eg:

 

void CGDI_testView::OnMouseMove(UINT nFlags, CPoint point) {     // TODO: 在此添加消息处理程序代码和/或调用默认值     int x=point.x;     int y=point.y;     CString str;     str.Format(_T("[%d,%d]   "),x,y);     CDC *pDC=GetDC();     pDC->TextOut(0,0,str);     ReleaseDC (pDC);     CView::OnMouseMove(nFlags, point); }

 

注意,str.Format(_T("[%d,%d]   "),x,y);中引号中空格是消除重叠现象。

转载请注明原文地址: https://www.6miu.com/read-55908.html

最新回复(0)