🔒 Locked
Including Bitmap files
Advertisement
Original Post
How do I include a bitmap file in my .EXE ?
I have defined it as a resource(.rc and .h) and I have included it in my resource directory but it is only accessed by my proggy as long as I don't move the .EXE elsewhere.
Therefore I am assuming the .BMP code is not contained within the .EXE. This is very odd as I have it working for .ICO
I'm using VC++ 6.0 and a Bitmap loading routing and accessing
the .BMP file using a string definition (e.g. "name.bmp").
Any ideas ?
Edited by - [HBB]Raven on 7/3/00 6:55:41 AM
> I''m using VC++ 6.0 and a Bitmap loading routing and accessing
> the .BMP file using a string definition (e.g. "name.bmp").
There''s your problem. You are loading the bitmap by name at runtime, so if the corresponding file can''t be found (relative to the current dir), it won''t work. Instead load it by resource id, something like:
LoadBitmap(MAKEINTRESOURCE(IDB_MYBITMAP));
Hopefully that will do the trick.
> the .BMP file using a string definition (e.g. "name.bmp").
There''s your problem. You are loading the bitmap by name at runtime, so if the corresponding file can''t be found (relative to the current dir), it won''t work. Instead load it by resource id, something like:
LoadBitmap(MAKEINTRESOURCE(IDB_MYBITMAP));
Hopefully that will do the trick.
I''ve tried using MAKEINTRESOURCE(ID_BITMAP1) but it tells me that
ID_BITMAP1 isn''t defined
Even so, I have the RES tab and it contains ID_BITMAP1 and the
details for ID_BITMAP1 contain a filename of "image_name.bmp"
Help !
ID_BITMAP1 isn''t defined
Even so, I have the RES tab and it contains ID_BITMAP1 and the
details for ID_BITMAP1 contain a filename of "image_name.bmp"
Help !
//\_/\\
//\(v)/\\
// X^X \\
/_\
Have you #includ:ed your resource.h in the file that's using MAKEINTRESOURCE(ID_BITMAP1)?
- Muzzafarath
Mad House Software
The Field Marshals
Edited by - Muzzafarath on July 3, 2000 9:51:55 AM
- Muzzafarath
Mad House Software
The Field Marshals
Edited by - Muzzafarath on July 3, 2000 9:51:55 AM
I have only included the resource.h in the resource.rc file.
Does it also need to go into my_prog.cpp ?
Thanks for the speedy replies BTW - much appreciated :D
Does it also need to go into my_prog.cpp ?
Thanks for the speedy replies BTW - much appreciated :D
No you need to add the .rc file to your project.
Click on the workspace button on the tool bar, to bring up your workspace, if it is not showing already.
Select the File View Tab.
Right click on the project name (in the tree view). Select 'Add Files to Project...).
Now add you .rc file.
--------------------------
Carpe Diem
Edited by - DeltaVee on July 3, 2000 10:38:31 AM
Click on the workspace button on the tool bar, to bring up your workspace, if it is not showing already.
Select the File View Tab.
Right click on the project name (in the tree view). Select 'Add Files to Project...).
Now add you .rc file.
--------------------------
Carpe Diem
Edited by - DeltaVee on July 3, 2000 10:38:31 AM
resource.h needs to be included in my_prog.cpp (to use the filename you used). If you are using Visual C++, then if you choose to create a new .rc file from Visual C++ w/ my_prog project open (are you following me?), then the .rc and resource.h files will already have been included in the PROJECT (that is, they will be linked into the final .exe, I believe). All you need to do, then, is #include "resource.h"
P h a n t a s m
"I'd feel safer if the helicopter had an ejection seat."
P h a n t a s m
"I'd feel safer if the helicopter had an ejection seat."
Mucho thanks people - problem solved.


To load a bitmap from a file, look at this article.
- Muzzafarath
Mad House Software
The Field Marshals
- Muzzafarath
Mad House Software
The Field Marshals
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement