Archived

This topic is now archived and is closed to further replies.

breakscience

Bitmap Resource

Recommended Posts

I have made a member function to load a resource bitmap. It gives me error 87: Invalid parameter. What am I doing wrong: //////////////////////////////////////////////////////////// void CGDIBitmap::LoadResource(HDC hdcCompatible,int ResID) { // if we''ve already got a bitmap loaded, UnInit it so we can load a new // one. if(m_hdcBitmap) UnInit(); // create the memory dc m_hdcBitmap = CreateCompatibleDC(hdcCompatible); // load the BMP file m_hBitmap = (HBITMAP)LoadImage( NULL, MAKEINTRESOURCE(ResID),IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); // if the load failed, throw an error. if (m_hBitmap == NULL) { CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "LoadResource failed: error code %u\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK); } // select our new bitmap into the dc m_hOldBitmap = static_cast(SelectObject(m_hdcBitmap,m_hBitmap)); // query the bitmap''s properties BITMAP bmp; GetObject(m_hBitmap,sizeof(BITMAP),(LPVOID)&bmp); // assign height and width from those properties m_iWidth=bmp.bmWidth; m_iHeight=bmp.bmHeight; } //////////////////////////////////////////////////// please help Break;

Share this post


Link to post
Share on other sites