Drawing a selection box using CRectTracker
Hello,
I have an MFC SDI CView application and I want to draw an selection box
when the user left clicks and move the mouse. I have found the CRectTracker
class but I can't get it to work
I have this code:
void CSCMLaserView2::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
m_startPt = point;
m_theRectTracker.TrackRubberBand(this,point,TRUE);
}
void CSCMLaserView2::OnLButtonUp(UINT nFlags, CPoint point)
{
//Release the capture on the mouse
ReleaseCapture();
CSCMLaserDoc* pDoc = GetDocument();
ASSERT(pDoc != NULL);
CClientDC dc(this);
OnPrepareDC(&dc);
// Converts screen coordinates into logical ones
dc.DPtoLP(&point);
dc.DPtoLP(&m_startPt);
// Select object
pDoc->SelectObjectByWindow((double)m_startPt.x/m_dViewScale,(double)m_startPt.y/m_dViewScale,(double)point.x/m_dViewScale,(double)point.y/m_dViewScale);
Invalidate();
}
No box will be shown! If I remove the SetCapture/RelaseCapture I will get a
box but then the OnLButtonUp() will never be called...
Please Help!
// Anders
--
English is not my first, or second, language
so anything strange, or insulting, is due to
the translation.
Please correct me so I may improve my English!