编程要点
/////坐标转换/////////////
CClientDC dc(this); //定义设备对象
OnPrepareDC(&dc); //初始化设备对象
CPoint local=point; //定义CPoint类实体,并初始化为设备坐标
dc.DPtoLP(&local); //将设备坐标转为逻辑坐标
//将该段程序放入OnLButtonDown(UINT nFlags, CPoint point)
//和OnMouseMove(UINT nFlags, CPoint point)中
//////////////////////////显示光标位置
CString msg;
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();
/////改变光标/////////////
CSize ScrollSize=GetTotalSize();
CRect ScrollRect(0,0,ScrollSize.cx,ScrollSize.cy);
if(m_SelectFunction!=13)
{
if(!ScrollRect.PtInRect(local))
::SetCursor(m_HCross);
else
::SetCursor(m_HArrow);
//将该段程序放入OnMouseMove(UINT nFlags, CPoint point)中,并放在坐标转换的后面
//在视图类的头文件的public:后面加上两个光标句柄
HCURSOR m_HArrow;
HCURSOR m_HCross;
//在视图类的CCP文件的类构造器中加入以下两句
m_HArrow=AfxGetApp()->LoadStandardCursor(IDC_ARROW);
m_HCross=AfxGetApp()->LoadStandardCursor(IDC_CROSS);
2019-12-21 19:32:00
1.13MB
内定向
1