Displaying Two BitMaps
I want to display two bitmap files one on top of the other. The ball then the dot on top but not mixed with ball. I want to move the dot over the ball. Prog is in c.
The problem is that it will only display one bitmap and not the dot bitmap. What did I miss or overlook? Each structor is defined loaded resourced and
HBITMAP g_hbmBall = NULL; //hbm ball defined as hbitmap check
HBITMAP g_hbmDot = NULL; //hbm dot defined as hbitmap check
// more code
g_hbmBall = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BALL));
g_hbmDot = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(I DB_DOT));
// ball and dot loadedbitmap check
HDC hdc = BeginPaint(hwnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = SelectObject(hdcMem, g_hbmBall);
HDC hdc2 = BeginPaint(hwnd, &ps2);
HDC hdcMem2 = CreateCompatibleDC(hdc2);
HBITMAP hbmOld2 = SelectObject(hdcMem2, g_hbmDot);
// hdc and dc and mem both created check
GetObject(g_hbmBall, sizeof(bm), &bm);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
/* insert dot */
/* BITMAP bm2; */
/* PAINTSTRUCT ps2; */
/* HDC hdc2 = BeginPaint(hwnd, &ps2); */
/* HDC hdcMem2 = CreateCompatibleDC(hdc2); */
/* HBITMAP hbmOld2 = SelectObject(hdcMem2, g_hbmDot); */
/* bm2 and ps2 moved up because of compile error declaration is not allowed here in function windproc */
GetObject(g_hbmDot, sizeof(bm2), &bm2);
/* bm2 */
BitBlt(hdc2,524, 224, bm2.bmWidth, bm2.bmHeight, hdcMem2, 0, 0, SRCCOPY);
// dot moved to side of ball to see if it was over painting
Last edited by kryptkat on 12-23-2002 at 05:04 PM
I spent all morning yesterday with this to see if I could get it to work with no results. It compiles with no errors but only displays one bitmap. Then I spent the rest of the day reading everything I could find on BitBlt. It seems no one ever tryed this before lol.
I did find one function that lets you or two bitmaps but that is not what I want. Yet anyway. Thank You in advance.
Do not call BeginPaint two times. Instead make 2 compatible DC's and store one bitmap in each. Then just blt from the compatible DC to the main DC and you should be fine.