mromeo
asked on
How do you erase the CRectTracker and its styles?
Hi. I have a view which contains multiple static fields. When the user clicks on a static field, I add a CRectTracker over the static field. If there is another mouse click outside of the control with the CRectTracker, I want to delete the rect tracker and erase all remnants of it. I have tried simply deleting the rect tracker, redrawing the window, invalidating its rect, etc. Here is what I've tried:
// try clearing it's style
tracker->m_nStyle &= ~CRectTracker::hatchInside ;
tracker->m_nStyle &= ~CRectTracker::dottedLine;
tracker->m_nStyle &= ~CRectTracker::resizeOutsi de;
// try invalidating its rect
CRect rectTrue;
tracker->GetTrueRect(&rect True);
InvalidateRect(rectTrue, TRUE);
// try redrawing the window it was used for
CWnd *trackingWnd = tracker->GetTrackingWnd();
trackingWnd->RedrawWindow( );
// now just try deleting it.
delete tracker;
tracker = NULL;
Unfortunatley, with all of this, I still end up with the outline of the tracker on the screen. I don't want to redraw the entire view because there is too much screen flicker. Anybody have any ideas?
Thanks!
// try clearing it's style
tracker->m_nStyle &= ~CRectTracker::hatchInside
tracker->m_nStyle &= ~CRectTracker::dottedLine;
tracker->m_nStyle &= ~CRectTracker::resizeOutsi
// try invalidating its rect
CRect rectTrue;
tracker->GetTrueRect(&rect
InvalidateRect(rectTrue, TRUE);
// try redrawing the window it was used for
CWnd *trackingWnd = tracker->GetTrackingWnd();
trackingWnd->RedrawWindow(
// now just try deleting it.
delete tracker;
tracker = NULL;
Unfortunatley, with all of this, I still end up with the outline of the tracker on the screen. I don't want to redraw the entire view because there is too much screen flicker. Anybody have any ideas?
Thanks!
ASKER
I use Draw to draw the tracker.
ASKER
Tried your TRACE suggestion. The coordiantes are exactly the same. The only thing that seems to get the tracker to erase is a call to RedrawWindow, which redraws the entire CView.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YESSSS!! All it was was the rect param. I failed to pass a pointer to the rect. Sometimes the simplest things can make you crazy...Thanks for your help.
Yr welcome. (I'd not seen it either at first glance!)
One thing you could try is to use a TRACE to find out the co-ordinates when you start the track and when you use this code
tracker->GetTrueRect(&rect
InvalidateRect(rectTrue, TRUE);
You may have a mis-match of screen and client co-ordinates