The rectangle is not redrawn, even if the application is revealed after being covered by another application. The repaint procedure would be responsible for maintaining the appearance of the selected region if, for example, it were to be redrawn or displayed in a different color. The following images Rubber 1 Rubber 2 depict two different views of the application, although there is not much to see. Two views are shown each with a different rectangle. The cursor is not shown in these figures.
Swap operation is used to draw and erase the rectangle.
The swap operation ensures that original pixels on the path are restored when the path is erased. To implement rubber banding four things are done in the mouse method. Set a flag to indicate that the rubber banding has begun. Start a new rubber banding path. Save the cursor position.