定义一个对象:
CRectTracker m_rectTracker
在LButtonDown消息处理函数里:
int nIn; //定义一个鼠标的点击值;
nIn=m_rectTracker.HitTest(point); //看看点到了哪了
if(nIn<0) //不在四边形区域内;
{ //非选中的时候,画橡皮筋
CRectTracker temp;
temp.TrackRubberBand(this,point,TRUE);
temp.m_rect.NormalizeRect();
}
else
{ //选中,调整选区
CClientDC dc(this);
m_rectTracker.Draw(&dc);
m_rectTracker.Track(this,point,TRUE);
// Track()是CRectTracker中最富魅力的函数。它时时的改变调用者的m_rect;
Invalidate();
}