Monday, September 8, 2008

Loading a bitmaps from a MFC DLL resource

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);

}

No comments: