By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,241 Members | 2,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,241 IT Pros & Developers. It's quick & easy.

load bitmap from resource

P: n/a
(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

Jun 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
(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:


At first blush I'd say your failure probably stems from the fact that static
libraries do not contain resources.
--
Jeff Partch [VC++ MVP]
Jun 2 '06 #2

P: n/a

"Jeff Partch [MVP]" <je***@mvps.org> wrote in message
news:uc**************@TK2MSFTNGP05.phx.gbl...
"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
(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:

At first blush I'd say your failure probably stems from the fact that
static libraries do not contain resources.


Additionally, if you are porting to the Managed environment, realize that
the managed resource editor is totally incompatible with Win32 resources,
and there is a ResourceManager class in the BCL for dealing with managed
resources.

..resx, .resources => managed resources (.NET ResourceManager)
..rc, .res => Win32 resources (win32 api LoadResource, etc.)
--
Jeff Partch [VC++ MVP]

Jun 5 '06 #3

P: n/a
Jeff Partch [MVP] wrote:
At first blush I'd say your failure probably stems from the fact that static
libraries do not contain resources.


Then why would IS_INTRESOURCE return true for the resource?

Jun 5 '06 #4

P: n/a
Ben Voigt wrote:
Additionally, if you are porting to the Managed environment, realize that
the managed resource editor is totally incompatible with Win32 resources,
and there is a ResourceManager class in the BCL for dealing with managed
resources.


Right. But all I'm trying to do is load a bitmap from a resource. So
to accomplish this, I should (1) recompile the library containing the
bitmaps as dynamic and (2) load the the bitmaps from a section within
the main app compiled as native? Would this work?

Thanks,
Sharon

Jun 5 '06 #5

P: n/a
"dotnetchic" <do********@gmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
Jeff Partch [MVP] wrote:
At first blush I'd say your failure probably stems from the fact that
static
libraries do not contain resources.


Then why would IS_INTRESOURCE return true for the resource?


It only tests bits. It says nothing about whether the passed in value
identifies a valid resource.

--
Jeff Partch [VC++ MVP]
Jun 5 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.