Q
Jetzt hab ichs gecheckt. Für alle dies interessiert, hier der Code:
void OnPaint(HWND hwnd) {
HDC hBitmapdc, hWindowdc;
HBITMAP hOld;
PAINTSTRUCT ps;
RECT rc;
// If the bitmap is present, draw it
if (hDesktopBitmap_) {
// Get window dc and start paint
hWindowdc = BeginPaint(hwnd, &ps);
hWindowdc = GetDC(hwnd);
// Create compatible dc
hBitmapdc = CreateCompatibleDC(hWindowdc);
// Select the bitmap into the dc
hOld = SelectBitmap(hBitmapdc, hDesktopBitmap_);
SelectObject(hWindowdc, hOld);
// Get width and height of this window
GetClientRect(hwnd, &rc);
// Draw the bitmap to the window leaving a border of 20 pixels
BitBlt(hWindowdc, 0, 0, rc.right, rc.bottom,
hBitmapdc, 0, 0, SRCCOPY);
// draw a rectangle
RECT rectangle;
HBRUSH hBrush;
rectangle.left = 100;
rectangle.top = 100;
rectangle.bottom = 300;
rectangle.right = 600;
hBrush = CreateSolidBrush(RGB(255,0,0)) ;
FillRect (hWindowdc, &rectangle, hBrush) ;
// Delete bitmap dc
DeleteDC(hBitmapdc);
DeleteObject(hBrush);
// Tell windows that you've updated the window
EndPaint(hwnd, &ps);
}
}
Danke für den Tip!