Er det noget i stil med dette du er ude efter:
void OnDraw(HWND hwnd)
{
PAINTSTRUCT PaintStruct;
BeginPaint(hwnd, &PaintStruct);
HFONT Font = CreateFont(16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Arial");
HDC dc = PaintStruct.hdc; // The screen Device Context
HDC MemDc = CreateCompatibleDC(dc); // And a memory DC compatible with the screen DC
SelectObject(MemDc, Font); // Tell windows that we want to use the font when drawing on the DC
HBITMAP Bitmap = CreateCompatibleBitmap(dc, 200, 100); // Now create a Ditmap
HGDIOBJ OldBitmap = SelectObject(MemDc, Bitmap); // Use the Bitmap with the memory DC
HBRUSH Brush = CreateSolidBrush(RGB(255, 128, 128)); // Create a light red brush
RECT Rect = {0, 0, 200, 100};
FillRect(MemDc, &Rect, Brush); // Fill the background of the bitmap with brush
SetBkMode(MemDc, TRANSPARENT); // Don't draw background while drawing text.
TextOut(MemDc, 5, 5, "Whatever", 8); // Put some text
HPEN Pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255)); // Create a blue pen
HGDIOBJ OldPen = SelectObject(MemDc, Pen); // Tell windows to use the pen with this DC
MoveToEx(MemDc, 0, 0, 0); // Move to upper left corner
LineTo(MemDc, 199, 0); // Draw some lines
LineTo(MemDc, 199, 99);
LineTo(MemDc, 0, 99);
LineTo(MemDc, 0, 0);
BitBlt(dc, 10, 10, 200, 100, MemDc, 0, 0, SRCCOPY); // Copy everything to the screen
SelectObject(MemDc, OldBitmap); // Cleanup
SelectObject(MemDc, OldPen); // Cleanup
EndPaint(hwnd, &PaintStruct);
DeleteDC(MemDc);
DeleteObject(Font);
DeleteObject(Brush);
DeleteObject(Bitmap);
DeleteObject(OldPen);
}
Der er en hel applikation der bruger det her:
http://home20.inet.tele.dk/midgaard/bitmapwin.htmlHvis du bruger MFC vil du nok bruge nogle class'er, så som CDC, CBitmap, CPen etc. men fremgangsmåden er den samme.