June 2nd, 2013, 04:56 PM
[RESOLVED] Cannot load bitmap resource onto button, but can do so if I load the filesystem file
So I'm trying to load a bitmap onto a button, which I can do if I get the bitmap handle like this:
LoadImage(NULL, _T("C:\\Users\\Luis\\Documents\\Visual Studio 2012\\Projects\\dlltest\\Debug\\status1.bmp"), IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
However, when I attempt to load this same image from a resource as follows it doesn't work:
LoadImage(hInstance, MAKEINTRESOURCE(IDB_STATUS1), IMAGE_BITMAP, NULL, NULL, LR_CREATEDIBSECTION);
I had also tried LoadBitmap without success:
None of these lines produces a NULL result, so they seem to succeed, but only the first will actually load a bitmap onto a button on my dialog:
Is it possible that either or both of these last two calls cannot locate the actual requested bitmap and so they returned a valid handle to like, a blank bitmap? Or would a NULL result failure be the only expected alternative to complete success? I do load the dialog from the same resource and it works just fine.
Having to load these bitmaps from external files makes deployment a little less friendly. Any clues what might be the problem?
June 2nd, 2013, 05:25 PM
Re: Cannot load bitmap resource onto button, but can do so if I load the filesystem f
Okay, I figured it out. It was because I was destroying the bitmaps after I loaded them to my buttons:
Not doing this causes it to all look right, but I'll have to check to figure out if I have any cleanup responsibility, which I had just assumed I do.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!