My custom drawing area's WM_PAINT looks something like this:
// TRUE to clear the background
if (GetUpdateRect(hwnd, &r, TRUE) == 0)
return; // no update rect; do nothing
dc = BeginPaint(hwnd, &ps);
// check return
// paint some RGBA image data with GDI+
EndPaint(hwnd, &ps);
(Disregard the sending a HDC to GDI+ for now.)
I use GetUpdateRect()
here instead of getting the update rect from BeginPaint()
because I always want to draw over a blank canvas, especially since I'm doing alpha-mixed drawing here. Furthermore, the docs for WM_PAINT
say not to call BeginPaint()
if GetUpdateRect()
fails.
However, when my custom drawing area actually does this WM_PAINT, it isn't clearing the drawing area. I can tell because the alpha-enabled image is drawn on top of itself, resulting in darker colors.
In another part of my code, I respond to a keyboard event by calling InvalidateRect()
to force an update of the whole area. If I change the equivalent of
InvalidateRect(hwnd, NULL, FALSE);
to
InvalidateRect(hwnd, NULL, TRUE);
the area does get cleared properly.
So what exactly AM I doing wrong here? Thanks.
(The actual code is this; it's written in Go. This is also why I am working with GDI+ directly. (I have yet to figure out how to do alpha-mixed stuff with regular GDI.))