Edit: Can't change thread title...This problem is not really related to PeekMessage.
Nevermind my earlier post, I have a working draw routine, but it leaks GDI resources by the thousands...
Code:
HBITMAP hbmOld;
HDC hdc = GetDC(hwnd);
HDC hdcMem = CreateCompatibleDC(hdc);
hbmTemp = CreateCompatibleBitmap(hdc, 256, 240);
SetDIBits(hdcMem, hbmTemp, 0, 256, bmMainBits, bmiMain, DIB_RGB_COLORS);
hbmOld = SelectObject(hdcMem, hbmTemp);
BitBlt(hdc, 0, 0, 240, 256, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
ReleaseDC(hwnd, hdc);
I clean up the compatible DC with DeleteDC, I clean up the window DC with ReleaseDC and select the default bitmap before I delete the memory DC. I read the MSDN section several times but I still can't see what I'm leaking.