473,789 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_STAT E(AfxGetStaticM oduleState());
HINSTANCE hInst = GetModuleHandle ("ThisLibrary.d ll");
HBITMAP hBitmap = ::LoadBitmap(hI nst, 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)LoadIm age(GetModuleHa ndle(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 6222
"dotnetchic " <do********@gma il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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******** ******@TK2MSFTN GP05.phx.gbl...
"dotnetchic " <do********@gma il.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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********@gma il.com> wrote in message
news:11******** **************@ h76g2000cwa.goo glegroups.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
49020
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 way to do this? This was easy to do in the old MFC. I can not find the answer in C#. I also need to embed an XML file into the resource and load it at run time. I am hoping once I figure out how to load an icon resource then loading an XML...
1
2200
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 from the following namespace: ..\ui\views\navcontroller\
2
8997
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskEmbeddingImageResourcesInProject.asp I followed the example but could not get it to work. Specifically, here's my code: Assembly myAssembly = Assembly.GetExecutingAssembly(); Stream...
2
4104
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 = File.Open(sSrcFile,FileMode.Open,FileAccess.Read,FileShare.None); Bitmap imgPhoto=new Bitmap(BitmapStream); iPixelsX=imgPhoto.Width; iPixelsY=imgPhoto.Height; BitmapStream.Close();
2
2641
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 bitmap created by right clicking on the project, selecting add new item, then add bitmap file). The project explorer says my bitmap is called "Bitmap1.bmp". If I have a function in my project declared as
2
8752
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 into a Resource and load it from there later? Thanks. Alejandro Lapeyre
4
3363
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 the cutting out. I wrote the following function: Public Shared Function CutOutIcon(ByRef vBitmap As Image, _ ByVal iIndex As Integer) As Image
1
4709
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 off, I have my API declarations (will post that at bottom). I make a call to LoadLibraryEx. Then, if the result is not zero, I make a call to EnumResourceNames. EnumResourceNamesDelegate (delegate for EnumResourceNames) is called for every found...
2
6216
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
9665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.