.RC Problem

This is a discussion on .RC Problem within the C++ Programming forums, part of the General Programming Boards category; I have posted this thread before, but now i can't find it. So here is my .RC file. Code: MY_ICON ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    151

    Question .RC Problem

    I have posted this thread before, but now i can't find it. So here is my .RC file.
    Code:
    MY_ICON ICON "c:/users/bijan/pictures/program icons/notepad.ico"
    Here is my error
    Code:
    |1|error: `MY_ICON' does not name a type|
    in the other topic someone said something about MY_ICON being in a header file, but I don't know what they're talking about.

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    First off, this is a Windows-specific question. But I'll be nice and answer it anyway .

    When you write your .RC file, you're basically telling Windows to include files in your executable and give them an ID number. (This may not sound very basic but that's as basic as it gets.)

    When you type
    Code:
    MY_ICON ICON "c:/users/bijan/pictures/program icons/notepad.ico"
    you're saying, "Windows! You listening? When I say the magic word, MY_ICON, I want you to load an ICON file with the data at "c:/users/bijan/pictures/program icons/notepad.ico"." (If it sounds like I'm talking down to you I honestly apologize. It's just that I find metaphors very useful.) So, MY_ICON is nothing more than a magic word, or in this case, a number.

    You could technically write it like this:
    Code:
    101 ICON "c:/users/bijan/pictures/program icons/notepad.ico"
    and the code would work, as long as you use 101 instead of MY_ICON in your code. But people find it easier to work with words, so they cleverly use #defines in a common file "resource.h".

    resource.h:
    Code:
    #define MY_ICON 101
    That's all it is. Now you can include "resource.h" in your .rc file as well as your .cpp file, and instead of referring to the data as '101', you refer to it as MY_ICON.

    Hope this helps.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    151
    Thank you sooo much, you're the best!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lamest .rc problem
    By balazsbotond in forum Windows Programming
    Replies: 6
    Last Post: 12-04-2007, 04:12 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21