mfc >> Loading bitmap resource to HBITMAP structure

by ArtuS » Sun, 23 Nov 2003 23:43:15 GMT

How can I load Bitmap resource (IDB_BITMAP) to HBITMAP structure (named
m_hBitmap)?



Thank you for your help

ArtuS




mfc >> Loading bitmap resource to HBITMAP structure

by Jeff Partch [MVP] » Mon, 24 Nov 2003 00:24:03 GMT






See if either the LoadBitmap or LoadImage APIs are what you're after.
--
Jeff Partch [VC++ MVP]





mfc >> Loading bitmap resource to HBITMAP structure

by ArtuS » Mon, 24 Nov 2003 01:07:00 GMT

> See if either the LoadBitmap or LoadImage APIs are what you're after.

I tried
m_hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), "IDB_BITMAP",
IMAGE_BITMAP, 0, 0, 0);
but it is wrong. I can load bitmap from file but I need load bitmap from
resource....

ArtuS




Loading bitmap resource to HBITMAP structure

by Jeff Partch [MVP] » Mon, 24 Nov 2003 01:40:29 GMT





Try it again, but replacing your "IDB_BITMAP" with
MAKEINTRESOURCE(IDB_BITMAP).

--
Jeff Partch [VC++ MVP]




Loading bitmap resource to HBITMAP structure

by ArtuS » Mon, 24 Nov 2003 05:32:39 GMT

> Try it again, but replacing your "IDB_BITMAP" with

It OK now. Thank You!

ArtuS




Similar Threads

1. Loading Bitmap From resource - CSharp/C#

2. load bitmap from resource

(Sorry about cross-post to MFC...got no reply so I'm reposting here)

Porting my code over from VC++6 to MC++, loading bitmaps from resources
broke.  This code is in a lib file (previously, it was a dll)...don't
know how that affects it.  Here's what we had  previously that worked:

        AFX_MANAGE_STATE(AfxGetStaticModuleState());
        HINSTANCE hInst = GetModuleHandle("ThisLibrary.dll");
        HBITMAP hBitmap = ::LoadBitmap(hInst, MAKEINTRESOURCE(ID));

(1) I tried to load the dll as above, which didn't work.  (2) I tried
getting the module handle from ThisLibrary.lib (which is how it is
currently compiled), which did not work.  (3) I tried compiling as
native and repeating 1 & 2 above, which did not work.  (4) Also tried
load image which didn't work:
        HBITMAP hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),
                                        MAKEINTRESOURCE(IDB_LOOPC01),
                                        IMAGE_BITMAP,
                                        0, 0, 0);

Can someone tell me how to resolve this?  Is there a better way to load
resources at runtime?  

TIA,
Sharon