Original Post
Hia!
I have just started out with Win32 Programming. Ok, I'm stuck on loading bitmaps with GDI. This is how the function for drawing bitmaps looks:
-------------------------------------------------------------
int DrawBitmapResource(HDC hDestDC, int xDest, int yDest, int nResID)
{
HBITMAP hBitmap;
HDC hSrcDC;
BITMAP bmp;
int nWidth, nHeight;
if((hBitmap = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(nResID), IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION)) == NULL)
return(FALSE);
if((hSrcDC = CreateCompatibleDC(NULL)) == NULL)
return(FALSE);
if(SelectObject(hSrcDC, hBitmap) == NULL)
return(FALSE);
if(GetObject(hBitmap, sizeof(BITMAP), &bmp))
return(FALSE);
nWidth = bmp.bmWidth;
nHeight = bmp.bmHeight;
if(BitBlt(hDestDC, xDest, yDest, nWidth, nHeight, hSrcDC, 0, 0, SRCCOPY) == NULL)
return(FALSE);
DeleteDC(hSrcDC);
return(TRUE);
}
-------------------------------------------------------------
and this is how I call for the function:
-------------------------------------------------------------
DrawBitmapResource(hMainDC, 0, 0, 1002);
-------------------------------------------------------------
hMainDC //a Device Context for the main window
hInstance //handle to the main window
1002 //resource id for my bmp picture
the problem is that when I try this, no errors occure... but the bitmap isn't shown either! (black screen is shown)
Could someone tell me what I have made wrong?
THX!
[edited by - FxMazter on December 19, 2002 12:42:58 PM]