Sign in to follow this  
Slyfox

.rc files - including icons

Recommended Posts

i've written an .rc file and it should load some icons, the .rc file itself looks like this: #include "Resource.h" //------------------------------------------------------------------------------ // Icons //------------------------------------------------------------------------------ IDI_BLIZZARD ICON "Res\\Blizzard.ico" IDI_BLIZZARD_SM ICON "Res\\Blizzard_sm.ico" The part I am stuck with is the part in quotes e.g. the location of the files, the files are located in a file called Res in the same folder as the rest of the code now i've tried fiddling with this part of the code and including the full location of the files e.g "C:\Dev-Cpp\Res\Blizzard.ico" But the program still seems to fail to load the icons have I got the code right and it's a problem else where, or have i entered it wrong? any help would be much appreciated thanks!

Share this post


Link to post
Share on other sites
IDI_ICON1 ICON "exeicon.ico"

This is what I have, just put the icon in the same folder of your project,... or write the path relative to your project. Usually you would use Visual Studio resource generator instead of messing with this file...

Share this post


Link to post
Share on other sites
The problem is that I'm not using visual studio, I'm using dev-C++ so I don't have that option, and I have tried using the icons in the same location as the rest of the files, but that doesn't seem to work either?!

Share this post


Link to post
Share on other sites
A relative path is typically prefixed with a dot. For example:

".\\res\\icon.ico"


To quote from that link:

Quote:

Two dots ("..") are used for moving up in the hierarchy, to indicate the parent directory; one dot (".") represents the directory itself. Both can be components of a complex relative path (e.g., "../mark/./bobapples"), where "." alone or as the first component of such a relative path represents the working directory.

Share this post


Link to post
Share on other sites
I assume you are defining the resource ID in Resource.h, correct?

Make sure you use the right 'slashes' as well.

Also, you might try including DISCARDABLE after ICON in your .rc file.

Resource.h file
#define IDI_BLIZZARD 24000

.rc file
IDI_BLIZZARD ICON DISCARDABLE "Res\\Blizzard.ico"

This code works for me in VS 2005.

EDIT: Also make sure that your icon is in a correct format. According to MSDN:

48x48, 256 color
32x32, 16 color
16x16 pixels, 16 color

About Icons From MSDN

[Edited by - shadowcomplex on October 8, 2006 7:20:34 PM]

Share this post


Link to post
Share on other sites
Thanks for the help, but I've tried all your suggestions but still can't get it to load the icons. There is an accompanying Resource.h file, which looks like this:

//-----------------------------------------------------------------
// Blizzard Resource Identifiers
// C++ Header - Resource.h
//-----------------------------------------------------------------

#ifndef RESOURCE_H
#define RESOURCE_H

//-----------------------------------------------------------------
// Icons Range : 1000 - 1999
//-----------------------------------------------------------------
#define IDI_BLIZZARD 1000
#define IDI_BLIZZARD_SM 1001

#endif

The odd thing is that I have made this program following a book, I have looked at the example on the cd that came with the book and the program works fine, but as soon as i copy the files to my desktop it compiles but fails to load the icons. Therefore the icons are in the correct format and I tried adding DISCARDABLE but that didn't work either. Any futher assistance would be much appreciated thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this