Search code examples
mfcerase

MFC: how to erase a just drawn rectangle


Could somebody tell me how to erase a rectangle that has just been drawn on an image?

In the application, I have an image displayed on a document (MDI application). The user can select a portion of the image. I implemented this feature as letting the user start the selection with a CRectTrackerColor (derived from CRectTracker) object. The selection works fine: a user is able select a rectangle using the mouse. A rubber band rectangle is shown as a feedback. After the user releases the left mouse, the rectangle is colored based on my pen color. Then I present a dialog for OK/Cancel. Upon Cancel, I would like the rectangle to disappear. How should I go about doing that?

Thanks.


Solution

  • Just invalidate that rectangle so it'll get redrawn normally.