You're working too hard...try
the following from Ronen Magid on
www.codeguru.com
1. Create your own CBitmap-derived class (say, CMyBitmap)
2. Add a "load from bitmap" method as listed below
BOOL CMyBitmap::LoadBitmap(LPCTSTR szFilename)
{
ASSERT(szFilename);
DeleteObject();
HBITMAP hBitmap = NULL;
hBitmap = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
return Attach(hBitmap);
}
Then do a CStatic::SetBitmap ( hBitmap ).
I noticed that your example code is all done in C, not C++. The above code assumes using MFC and C++. The LoadImage () call is a WinAPI C-function call that returns an HBITMAP handle.