Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC VC++
To load a bitmap from resource you normally use one of the below function:
 
BOOL LoadBitmap(UINT nIDResource);
BOOL LoadBitmap(LPCTSTR lpszResourceName);
 
To do so, I have folowed the example in this page:
http://www.functionx.com/visualc/bitmaps/DisplayFromResource.htm[^]
 
I did it using VC 6.0. It has compiled like a charm even when moving the progect to onther computer with VC 6.0 installed, because the Imported .bmp file (resource) becomes part of the project (VC 6.0 made a copy to the res folder of the project).
 
But, doing the same thing with VS 2012, the project will compile only on the computer where it has been created in (VS 2012 will not make a copy of the .bmp file (resource) in the res folder of the project).
 
I think that this is a bug., if not so whats wrong with VS 2012 !?
 
--------------------------------------------------------------------------------
EDIT:
 
You should take a look at this demo to understand what I mean.
 
.SWF: http://www.mediafire.com/?pkb2bfokps287ax[^]
--------------------------------------------------------------------------------
 
Thank you for your understanding.
Posted 29-Dec-12 18:46pm
tomay30001.2K
Edited 2-Jan-13 16:57pm
v10
Comments
Sergey Alexandrovich Kryukov at 30-Dec-12 1:16am
   
Not clear. You did not describe your actions.
—SA
tomay3000 at 2-Jan-13 0:45am
   
Re updated my question, you should take a look
 
Thank you for your understanding.
Sergey Alexandrovich Kryukov at 2-Jan-13 0:51am
   
Doesn't my answer addresses your problem? Look thoroughly.
—SA
tomay3000 at 2-Jan-13 0:55am
   
Sorry, I am talking about resources by importing them, not "Adding Existing Files" to the project
 
You should take a look at this demo I uploaded to understand what I mean.
Sergey Alexandrovich Kryukov at 2-Jan-13 1:21am
   
No, I should not, sorry.
What do you think is the difference between importing and adding is? :-)
Just think about it.
—SA
Sergey Alexandrovich Kryukov at 2-Jan-13 1:45am
   
Here is the thing: such post using the executable file is a serious abuse, because this is very unsafe practice. Sorry, I reported this post for abuse here:
 
http://www.codeproject.com/Messages/4462911/Danger-An-inquirer-posts-a-reference-to-executable.aspx
 
If you want, you can respond to this post. I indicated that I don't think you should be banned for this offense, but... don't you really understand such basic safety problems? And please don't tell us that the file is not infected or something: you really cannot know this yourself.
 
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Warning! OP posted the file which is supposed to contain OP's project. I downloaded the file to see what it is. The files is named as *.EXE and contains the PE executable signature. This is an executable file. Please don't try to run it and, better, don't even download it.
 
OP is warned about using of unsafe practice of sharing the code. Using an executable file is never needed and is prohibitively unsafe. It's always possible to store file in .ZIP or another archive. Also, most CodeProject members never download inquirers files, for good reasons.
 
An inquirer is supposed to be able to explain the problem using just the text of the question. Asking questions, as any other activity, also requires certain qualification and has its prerequisites.
 
Sorry that this is not an answer. I've placed this post just in case, to reduce the possibility of damage in some less experienced members. Running of the file from not a trusted source can easily lead to system infection or infiltration of other malicious software. This is extremely dangerous.

Thank you,
—SA
  Permalink  
v2
Comments
jibesh at 2-Jan-13 1:40am
   
Thanks Sergey for the Alert!!!
Sergey Alexandrovich Kryukov at 2-Jan-13 1:47am
   
My pleasure (and my disgust) :-)
See also the report to abuse watch forum, referenced in my comment to the question above.
—SA
Nelek at 2-Jan-13 8:02am
   
I think you should edit your very first comment, so the warning and the information you provide is placed near the link at the bottom of the question
tomay3000 at 2-Jan-13 8:24am
   
Don't judge people on their religion, their country or even their SKULL avatar
I have spent many time creating this demo illustration to make you understand my issue, because I am not good in english with just text.
 
I have created this demo using Instant Demo which gives you the ability to export your demo in many different format including .EXE, so I have choosed the .EXE format with Adobe Flash Player included.Here is its website: http://www.instant-demo.com
 
Any one who suspect an .EXE file to be malicious may try it inside the SandBox first, and not a quick judgement from the first time.
 
I have uploaded another file; a .ZIP file that contains the demo in the .SWF format which can be viewed in your web browser by clicking the .HTM file.
 
So please delete your abuse report about this question.
 
Thank you for your understanding.
Sergey Alexandrovich Kryukov at 2-Jan-13 9:27am
   
Look what are you asking about: someone should install a virtual sandbox machine to test something that only you are interested in. Instead of something which you could do very fast. Very nice.
 
Not only you still don't understand safety practice, but you virtually accused me in something like racism, on totally baseless "arguments".
 
This is clearly anti-social behavior; and your ignorance about safety practice would make you a potentially dangerous member, sorry to say that.
 
I'll update my abuse report post.
 
—SA
tomay3000 at 2-Jan-13 10:49am
   
I am very sorry for my antisocial behavior, that's not what I meant, I didn't knew how to make an idea clear.
 
Actually I am using Google translator to correct my text paragraphs.
 
And about my ignorance about safety practice, that's true, I have learned that today in this post, and I will be more carefull next time.
 
Thank you.
Sergey Alexandrovich Kryukov at 2-Jan-13 11:59am
   
Very good. It's very decent to use criticism for fixing yourself, learning on your mistakes and openly admitting it. I really appreciate it.
I'll indicate your constructive approach in my report and I'm pretty much sure that community won't vote for banning you or something (this is always decided by community).
 
Please remove the EXE link, to stay on safe side, and then I can remove the warning.
 
And we can further discuss your problem. First, you can use ZIP file instead of EXE. Most members avoid downloading them, but sometimes I do. More importantly, add some explanations.
 
I started to think that you are talking about getting resources from some EXE file and putting then into a new project. If this is what you need, you do the following:
Open an EXE file as in in Visual Studio, using [Main Menu] File -- open -- file. Visual Studio will create a windows where you can browse resources. Save those you need. Add to the resource of your new project the way I already explained. Does it makes sense?
 
If this is something else, try to explain.
 
Good luck,
—SA
tomay3000 at 2-Jan-13 14:07pm
   
.EXE link removed.
 
About getting resources from some .EXE file I use PE Explorer as my default resource viewer & editor (and this is not my problem).
 
I have completely reformed my question.
Sergey Alexandrovich Kryukov at 2-Jan-13 14:40pm
   
Thank you. Now the question looks clear to me, but the problem looks weird. I suspect that the resource was not correctly created in your original VC6 project. If you had original .RC source file with a separate .BMP files (for example) referenced in the .RC file by name, I think the migrated to 2012 project would work. Is it possible that you only have compiled resource .RES? It could be a problem. To resolve it, I would suggest you retrofit your legacy project: take out the resources using PE Explorer or VS 2012 and write .RC file from scratch...
—SA
tomay3000 at 2-Jan-13 15:25pm
   
I have opened the .RC file created by the VC 6.0 by a text editor & I found this line: IDB_BITMAP1 BITMAP "res\\ANEM.bmp" (VC 6.0 imports resources & links their path relatively to the project directory)
 
And opened the .RC file created by the VS 2012 by a text editor & I found this line: IDB_BITMAP1 BITMAP "D:\\My Pictures\\ANEM.bmp" (VS 2012 imports resources & links their path absolutely to their original location)
 
This way created projects with VS 2012 that contains imported resources should not be moved to other computers to be compiled, because they wont compile successfully.
Sergey Alexandrovich Kryukov at 2-Jan-13 15:30pm
   
OK, probably that's correct. And does this .RC works correctly under 2012?
—SA
tomay3000 at 2-Jan-13 15:38pm
   
If you migrate you project from VC 6.0 to VS 2012 it will work perfectly.
The path of the resources imported by VC 6.0 before migration will stay relative to the project directory ("res\\...") <-- This is good.
But, If you import new resources to the project after migration using VS 2012, so its path in the .RC file will be absolute ("X:\\someFolder\\...") <-- This is bad.
Sergey Alexandrovich Kryukov at 2-Jan-13 15:53pm
   
Probably you should say "migration", "migrate", not "immigration".
You are absolutely right if you use the first way. An absolute path should never ever be used, this is merely a bug, and the first variant is the way to go.
—SA
tomay3000 at 2-Jan-13 16:06pm
   
Sorry for my English, corrected immigration to migration.
 
About the issue, it seems to me like bug too.
Sergey Alexandrovich Kryukov at 2-Jan-13 16:08pm
   
Please, no need to apologize for that. I just tried to help you with English just a little bit. I understand you well, as it is not my native too, as you could guess...
—SA
tomay3000 at 2-Jan-13 16:15pm
   
I guess you are russian from your name
Sergey Alexandrovich Kryukov at 2-Jan-13 17:20pm
   
Sure. :-)
—SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question. We don't know what exactly you did, but something is wrong here.
 
First of all, there is no such thing as "res folder of the project". Actually, you can create any folder in your project, and then the sub-directory in the file system will be added. You can copy your external file(s) with your resources there and create a resource file there. If then you add the copy to the resource, there won't be a need in copy of the file; it will remain in the same place. I also don't know what did you mean by "export", but the best way to add some resource (such as image file, for example) is using "Add Existing File". This way, the file will remain a separate file, so you will be able to edit it with any tool. (For example, in particular, as to the image files, Visual Studio is quite a bad editor for them.) Besides, such approach will allow you to add any files of any formats to the resources.
 
—SA
  Permalink  
Comments
Espen Harlinn at 30-Dec-12 8:15am
   
5'ed!
Sergey Alexandrovich Kryukov at 30-Dec-12 11:51am
   
Thank you, Espen.
—SA
Albert Holguin at 31-Dec-12 13:28pm
   
+5... completely right about VS not always being the right tool for the job.
Sergey Alexandrovich Kryukov at 31-Dec-12 13:38pm
   
Thank you, Albert.
 
That's right, but this is not the main point. It's more important to leave a space for maneuver and avoid the vendor lock-in.
 
The formats of project files and even solutions are not really proprietary. You don't need VS or even any other IDE to build the projects. After all, the project and other source files can be manipulated manually. And the formats are pretty well documented. At the same time, embedding one file of resource (such as image) into another is an extra hassle, referencing it is not.
 
Happy New Year!
 
—SA
Albert Holguin at 31-Dec-12 14:01pm
   
Very true... Happy New Year! :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

It is a bug, confirmed by Visual Studio Product Team
 
Take a look at here: http://connect.microsoft.com/VisualStudio/Feedback/details/775713[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 269
1 OriginalGriff 180
2 DamithSL 180
3 Peter Leow 125
4 Kornfeld Eliyahu Peter 95
0 OriginalGriff 7,355
1 DamithSL 5,254
2 Sergey Alexandrovich Kryukov 4,942
3 Maciej Los 4,906
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 9 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100