CRectTracker

来源:互联网 发布:java大量线程wait状态 编辑:程序博客网 时间:2024/06/12 01:16

//////////////////范例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);    //限制鼠标移动的位置

0 0