473,399 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

Jun 2 '06 #1
5 6195
"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

"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ed Sutton | last post by:
I have been searching for how to get an icon resource and load it into an ImageList. I added an *.ico file to my project and set the files "Build Action" to "Embedded Resource". Is there any easy...
1
by: Ed Sutton | last post by:
How can I load a resource from any namespace in my project? I have all my icons located under the following namespace: ..\resources\images\ For example, I can not figure out how to load them...
2
by: Robert W. | last post by:
I want to create a special DLL that will contain only images. My application will then load these images when it needs them. So I searched MSDN and found this article:...
2
by: Olaf Baeyens | last post by:
I want to convert one bitmap file to another one. For example load as bmp and save as jpg. The loading part is simple I do this: Stream BitmapStream =...
2
by: Michael Murphy | last post by:
At the risk of being publically humiliated, might I ask the following simple question. I have a solution with one project. This project, WindowsApplication1, has one "form" and one "bitmap" (the...
2
by: Alejandro Lapeyre | last post by:
I am using a ImageList with a bitmap that contains all the images. I am currently saving the bitmap in a PictureBox, and load into the ImageList when the form loads. How can I save the bitmap...
4
by: VBTricks.de.vu Webmaster | last post by:
Hello, I have an bitmap in a resources file containing all icons displayed in the toolbar. To display the icons I need to cut them out of the bitmap and add them to an imagelist. The problem is...
1
by: Mythran | last post by:
I am attempting to read all of the resources from a Win32 executable, and load each of them to display them on a screen. So, please help figure out why I can't seem to get it right :) First...
2
by: Yoavo | last post by:
Hi, In my application I need to load a bitmap which exists on an external DLL. How do I do it ? Yoav.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.