Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do you erase the CRectTracker and its styles?

Posted on 2004-09-13
6
424 Views
Last Modified: 2013-11-20
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::resizeOutside;

// try invalidating its rect
CRect rectTrue;
tracker->GetTrueRect(&rectTrue);
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!
0
Comment
Question by:mromeo
  • 3
  • 3
6 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12051708
I don't see what function you are actually using (Draw, TrackRubberBand..) to draw it in the first place.

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(&rectTrue);
InvalidateRect(rectTrue, TRUE);

You may have a mis-match of screen and client co-ordinates
0
 

Author Comment

by:mromeo
ID: 12054176
I use Draw to draw the tracker.
0
 

Author Comment

by:mromeo
ID: 12054243
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.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 44

Accepted Solution

by:
AndyAinscow earned 200 total points
ID: 12054375
give this a try


CRect rectTrue;
tracker->GetTrueRect(&rectTrue);

rectTrue.InflateRect(1, 1);   //make the rect a little bit larger
InvalidateRect(&rectTrue, TRUE);   //note the & - it wants a pointer to a rect

UpdateWindow();
0
 

Author Comment

by:mromeo
ID: 12054509
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.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12054590
Yr welcome.  (I'd not seen it either at first glance!)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
My project did see openJDK that I installed. What could be the problem 7 150
Sed question 2 100
Problem to event 3 102
how to split multiple lines delimiter : 8 109
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question