Hi,
Thanks for your help orwell! You're right: I output a bitmap at each repaint. How could I save the content of the drawing and then paint over it? Below is how the WM_PAINT message is handled.
[CODE]
static HDC hdcBack;
static RECT windowRect;
static HBITMAP backBuffer;
...
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
hdcBack = CreateCompatibleDC(hdc);
GetClientRect(hWnd, &windowRect);
backBuffer = CreateCompatibleBitmap(hdc, windowRect.right, windowRect.bottom);
SelectObject(hdcBack, backBuffer);
FloodFill(hdcBack, 0, 0, RGB(255, 255, 255));
hBrush = CreateSolidBrush(color);
SelectObject (hdcBack, hBrush);
Rectangle (hdcBack, x1, y1, x2, y2);
BitBlt(hdc, 0, 0, windowRect.right, windowRect.bottom, hdcBack, 0, 0, SRCCOPY);
DeleteObject(hBrush);
DeleteDC(hdcBack);
DeleteObject(backBuffer);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
x1 = LOWORD(lParam);
y1 = HIWORD(lParam);
break;
case WM_MOUSEMOVE:
if(wParam & MK_LBUTTON) {
x2 = LOWORD(lParam);
y2 = HIWORD(lParam);
InvalidateRect(hWnd, NULL, FALSE);
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}