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

How do i add image to VC++ program?

P: 6
Hey there, well firstly i'm a college student studying a diploma in software development. In my assignment i am asked to write a program that is like an IQ test. My program is finished, but i decided to add a high scores section to it at the end, to try gain extra marks. I used the bitmap creation tool on Microsoft Visual C++ 6.0 to create a picture of a trophy with the number 1 on it. I would create two more bitmaps with 2 and 3 on them for the purpose of the high score.

On to my problem:

I dont know how to add an image to a C++ program and i cant find the help i need anywhere on the internet. Could someone possibly talk me through adding an image to a program step by step?

I am by no means asking you to do the assignment for me, i just would like to know how to actually put in the image.

If its relevant to you helping me, the image is called "Cup1.bmp" and is in the same folder as the program is.


Thanks in advance, Ian.
May 25 '07 #1
Share this Question
Share on Google+
6 Replies


100+
P: 110
First of all u need to create a resource file.. A resource file has .rc xtension.. then u need to add the resource file into u r project.. after that go to view-->resource view in Visual studio.. then xpand the resource file there u can c bitmaps folder.. after that right click on the bitmap then insert bitmap..
May b this helps u..
Xoinki
May 25 '07 #2

P: 6
Hi there, i tried to do what you said. It managed to create an .rc file, but i am unclear what to do now with it. The code inside the resource file is exactly this:

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Bitmap.rc
//
#define IDB_BITMAP1 101

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif


It uses a file called "bitmap1" that i created temporarily to see if it would work.


How i did all this was:

1. In Visual C++ 6.0, i went to insert>resource
2. I highlighted bitmap then clicked import and selected my bitmap
3. I then went to view>resource includes
4. It brought up a small screen with the following information

Symbol header file:
resource.h

Read-only symbol directives:
#include "afxres.h"

Compile time directives:
[ nothing was written here ]

5. I then pressed ok, and that is where i am up to.
6. I did compile the program to see what it would do after entering the #include "afxres.h" where the libraries usually go at the top of the page.


Can you tell me what to do from now, or any mistakes i have made so far.

Thanks again for your help, Ian.
May 27 '07 #3

P: 6
Can anyone help me?

I've been thinking, would i have to create a whole new project for it to work? Because all the code so far is in a single .cpp file

I'm relatively new to C++ and only been reading up on classes today, but i think i've got the hang of them.

As long as you can explain it in simple terms i will be able to do what you tell me, or research on how to do it.

Thanks again, Ian.
May 28 '07 #4

P: 6
How come everyone else seems to get help, except me :(

Do i smell funny or something?? I just washed 5 days ago, surely not time for another one yet??

Just kiddin' please help :D
May 30 '07 #5

P: 6
bump
bump
bump
bump
May 31 '07 #6

P: 6
bump
bump
bump
bump
Jun 1 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.