A Journey 2 Eternity

Loading a bitmaps from a MFC DLL resource

Posted on: September 8, 2008

HMODULE hPrevInst = AfxGetResourceHandle();
HMODULE hDLLInstance = ::LoadLibrary( _T(“ESIMFCControls”));
if (hDLLInstance != NULL) {
	AfxSetResourceHandle(hDLLInstance);

	CBitmap bmp;
	if ( bmp.LoadBitmap(MAKEINTRESOURCE(IDB_FILTER_BITMAP)) ) {
		CDC dcMemory;
		BITMAP bm;
		dcMemory.CreateCompatibleDC(pDC);
		dcMemory.SelectObject(&bmp);

		// Get the height and width of the bitmap
		bmp.GetBitmap(&bm);
		pDC->BitBlt(rcFilter.left, rcFilter.top, bm.bmWidth, bm.bmHeight, &dcMemory, 0, 0, SRCCOPY);
	}

	// Restore previous resource handle
	AfxSetResourceHandle(hPrevInst);
}
Advertisements
Tags:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Pages

Categories

September 2008
M T W T F S S
« Aug   Dec »
1234567
891011121314
15161718192021
22232425262728
2930  

Blog Stats

  • 27,176 hits
%d bloggers like this: