博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CRectTracker
阅读量:4298 次
发布时间:2019-05-27

本文共 1338 字,大约阅读时间需要 4 分钟。

//范例1/

声明:

CRect lastRect;

CRectTracker m_rectTracker;

void CUseCRectTrackerDlg::OnLButtonDown(UINT nFlags, CPoint point)

{
CRect clientRect;
GetClientRect(clientRect);
m_rectTracker.m_rect = CRect(point.x - 10,0,point.x,clientRect.Height());
m_rectTracker.m_nStyle = CRectTracker::hatchInside;
CClientDC dc(this);
m_rectTracker.Draw(&dc);
lastRect = m_rectTracker.m_rect;
CDialogEx::OnLButtonDown(nFlags, point);
}

void CUseCRectTrackerDlg::OnMouseMove(UINT nFlags, CPoint point)
{
if (nFlags == MK_LBUTTON )
{
CRect clientRect;
GetClientRect(clientRect);
this->InvalidateRect(lastRect);
UpdateWindow();
m_rectTracker.m_rect = CRect(point.x - 10,0,point.x,clientRect.Height());
m_rectTracker.m_nStyle = CRectTracker::hatchInside;
CClientDC dc(this);
m_rectTracker.Draw(&dc);
lastRect = m_rectTracker.m_rect;
}
CDialogEx::OnMouseMove(nFlags, point);
}

void CUseCRectTrackerDlg::OnLButtonUp(UINT nFlags, CPoint point)

{
this->Invalidate(TRUE);
CDialogEx::OnLButtonUp(nFlags, point);
}

PS:可能需要的辅助函数

this->SetCapture();   ::ReleaseCapture();       //捕获鼠标的输入

ClipCursor(&clipRect);  ClipCursor(NULL);    //限制鼠标移动的位置

PS:可能需要的辅助函数

this->SetCapture();   ::ReleaseCapture();       //捕获鼠标的输入

ClipCursor(&clipRect);  ClipCursor(NULL);    //限制鼠标移动的位置

//范例2/

PS:可能需要的辅助函数

this->SetCapture();   ::ReleaseCapture();       //捕获鼠标的输入

ClipCursor(&clipRect);  ClipCursor(NULL);    //限制鼠标移动的位置

转载地址:http://nlnws.baihongyu.com/

你可能感兴趣的文章
python 有序字典OrderedDict
查看>>
redis 执行filter 过滤
查看>>
centos7 安装 mariadb(mysql的一个分支) 的正确命令
查看>>
简谈python hashlib
查看>>
git的patch(打包)功能
查看>>
django QuerySet对象转换成字典对象
查看>>
入门python(1)
查看>>
入门python-异常(2)
查看>>
hdu-2033-人见人爱A+B
查看>>
hdu-2034-人见人爱A-B
查看>>
hdu-2003-求绝对值
查看>>
hdu-2006-求奇数的乘积
查看>>
hdu-1259-ZJUTACM
查看>>
hdu-1248-寒冰王座
查看>>
hdu-1005-Number Sequence
查看>>
hdu-2021-发工资咯:)
查看>>
hdu-1219-AC Me
查看>>
nyoj-545-Metric Matrice
查看>>
nyoj-630-Problem of IP
查看>>
hdu-1037-Keep on Truckin'
查看>>