//** Added function
LRESULT CTrackView::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
// Draw last rect, but no new one (erase old rect)
CClientDC dc(this);
dc.DrawDragRect(CRect(0,0,0,0), CSize(0,0), m_rectLast, CSize(2,2));
m_rectLast = CRect(0,0,0,0);
// WM_MOUSEMOVE + !m_bMouseTracking becomes the equivalent of
// WM_MOUSEENTER of which there is no such thing.
if (!m_bMouseTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = this->m_hWnd;
if (::_TrackMouseEvent(&tme))
{
m_bMouseTracking = TRUE;
// Draw new rect, but no last rect as we are starting anew
dc.DrawDragRect(rectNew, CSize(2,2), NULL, CSize(0,0));
}
}
else
{
// Draw new rect and erase old rect
dc.DrawDragRect(rectNew, CSize(2,2), m_rectLast, CSize(2,2));
}
// Remember where we drew this rectangle
m_rectLast = rectNew;