编程要点 /////坐标转换///////////// CClientDCdc(this);//定义设备对象 OnPrepareDC(&dc);//初始化设备对象 CPointlocal=point;//定义CPoint类实体,并初始化为设备坐标dc.DPtoLP(&local);//将设备坐标转为逻辑坐标//将该段程序放入OnLButtonDown(UINTnFlags,CPointpoint)//和OnMouseMove(UINTnFlags,CPointpoint)中 //////////////////////////显示光标位置 CStringmsg; msg.Format("X=%4d,Y=%4d", local.x,local.y); CMainFrame*pAppFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd; pAppFrame->m_wndStatusBar.SetPaneText(0,msg); pAppFrame->m_wndStatusBar.UpdateWindow();/////改变光标///////////// CSizeScrollSize=GetTotalSize(); CRectScrollRect(0,0,ScrollSize.cx,ScrollSize.cy); if(m_SelectFunction!=13) { if(!ScrollRect.PtInRect(local)) ::SetCursor(m_HCross); else ::SetCursor(m_HArrow);//将该段程序放入OnMouseMove(UINTnFlags,CPointpoint)中,并放在坐标转换的后面//在视图类的头文件的public:后面加上两个光标句柄HCURSORm_HArrow; HCURSORm_HCross;//在视图类的CCP文件的类构造器中加入以下两句 m_HArrow=AfxGetApp()->LoadStandardCursor(IDC_ARROW); m_HCross=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
2025/7/23 5:48:18
1.13MB
内定向
1