Sign in to follow this  

Putting a Bitmap on a Dialog directly from the harddrive

This topic is 3870 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So far this is what I have:
        case WM_INITDIALOG:
		{
			HBITMAP hBitmap = (HBITMAP)LoadImage(   NULL,
					(LPCWSTR)"page2.bmp",
					IMAGE_BITMAP,
					0, 0, 
					LR_LOADFROMFILE | LR_CREATEDIBSECTION |
                                       LR_DEFAULTSIZE);
		

		} break;
I'm not sure what to do after this. Help? I'd like some help with actual code please; not just reference to a link.

Share this post


Link to post
Share on other sites
do you know how to use WM_ERASEBKGND or WM_PAINT yet? are you familiar with GDI objects and device contexts? what i would do is (this is off the top of my head and my contain bugs):


static HBITMAP hBitmap;
static int dx, dy;

case WM_INITDIALOG:
{
hBitmap = (HBITMAP)LoadImage( NULL,
(LPCWSTR)"page2.bmp",
IMAGE_BITMAP,
0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION |
LR_DEFAULTSIZE);

// doing off top of my head, params may be out of order
BITMAP bm;
GetObject(hBitmap, &bm, sizeof(bm));
dx = bm.bmWidth; // might be misnamed, don't remember
dy = bm.bmHeight;

} break;

case WM_ERASEBKGND: {
HDC hDC = (HDC)wParam;
HDC hMemDC = CreateCompatibleDC(hDC); // or GetCompatibleDC... i forget!
HANDLE hOldBitmap = SelectObject(hMemDC, hBitmap);
BitBlt(hDC, 0, 0, dx, dy, hMemDC, 0, 0, SRCCOPY);
SelectObject(hMemDC, hOldBitmap);
DeleteDC(hMemDC);
return TRUE;
}


Share this post


Link to post
Share on other sites
Sign in to follow this