473,221 Members | 2,362 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,221 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 6190
"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.
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.