G
RECT rect = {0, 0, width, height};
HBITMAP bitmap;
HBRUSH hBgBrush;
HDC hdc = GetDC(hWndMain);
HDC temp_hdc = CreateCompatibleDC(hdc);
// Bitmap erzeugen und in temp_hdc selektieren:
bitmap = CreateCompatibleBitmap(hdc, width, height);
HGDIOBJ previousBitmap=SelectObject(hdc, bitmap);
// Brush erzeugen und auf temp_hdc anwenden (wo die Bitmap drin liegt)
hBgBrush = CreateSolidBrush(RGB(255,0,0));
FillRect(temp_hdc, &rect, hBgBrush);
DeleteObject(hBgBrush);
// Inhalt von temp_hdc nach hdc kopieren an Stelle xDst/yDst:
BitBlt(hdc,xDst,yDst,16,16,temp_hdc,0,0,SRCCOPY);
// Aufräumen:
SelectObject(temp_hdc,previousBitmap);
DeleteDC(temp_hdc);
ReleaseDC(hWndMain,hdc);