If you want your line to be drawn in plain color, then you shouldn't use
SetROP2
with
R2_XORPEN. Just use the normal mode to draw your line.
To "erase" the line, just invalidate the corresponding area with one of the
Invalidate
functions. For example:
HWND hDesktopWnd = GetDesktopWindow();
InvalidateRect(hDesktopWnd, &rect, TRUE);
InvalidateRgn(hDesktopWnd, rgn, TRUE);