-
resource file problem
Hey. Things are going along nicely. Well, they were. Learning menus now.
I'm having problems with the .RC files. The resource files that contain information on what is actually in the menus. Here is the code:
Code:
#include "resource.h"
MYMENU1 MENU DISCARDABLE
BEGIN
POPUP "File"
BEGIN
MENUITEM "Open", ID_FILE_OPEN
MENUITEM "Close", ID_FILE_CLOSE
MENUITEM "Exit", ID_FILE_EXIT
END
POPUP "Help"
BEGIN
MENUITEM "About", ID_HELP_ABOUT
END
END
.
This the resource file for a simple windows program that has menus. One is "file" and one is "help". I can't get this to compile. I'm using MSVC 6.0. This is what it says:
Compiling resources...
C:\Program Files\Microsoft Visual Studio\MyProjects\Basic menu\Prog_2.rc(1) : fatal error RC1015: cannot open include file 'resource.h'.
Error executing rc.exe.
Prog_2.res - 1 error(s), 0 warning(s)
I don't know where or what resource.h is. Is it a generated header file? Any help would be appreciated. I'd like to get this compiled, understand it and move on to better things.
-
>Is it a generated header file?
Yes, you can search your computer for it. Or, you could make your own.
-
on the left side just right click on header files and click on add files/folders. double click on your resource.h. Then your #include "resource.h" will work.
but for a header file that short you should just copy and paste the code into your main cpp file.
-
thanks guys.
I got it!! I can't believe I figured it out but I did. I know it probably seems simple to you guys but its been about 6 years since I had a programming class and really don't remember much of it.
Here is the resource.h file that I needed:
Had to write it myself but being only about 6 lines it was easy. I am trying to follow along in this book but it seems the guy left out the damn resource.h file in the instructional cd.
Code:
// resource.h with menu ids
#define ID_FILE_OPEN 1000
#define ID_FILE_CLOSE 1001
#define ID_FILE_EXIT 1002
#define ID_HELP_ABOUT 2000
bool eof();
Also, I don't know what happened but the guy had another variable misspelled in another header so when it compiled, it worked but didn't have any menus, just a window. Maybe he did it on purpose so I'd have to sort it out.
-
nice. but i thought the problem you had was not being able to find resource.h?
-
being new, I thought maybe the author was refering to a header already in MSVC , but I did search of my MSVC folder and found nothing.
I don't know if I was supposed to write it or what. Is it possible that MSVC will generate a header for you?
That was way more complicated than it needed to be. The author just wants me to learn about resource files and things to make it more organized for when I get into bigger programs I guess.
-
yes, msvc generates a resource.h file for you, provided you use it's import/create new resource feature. once you save it as a .rc, it automatically spits out a resource.h that corresponds with that specific rc(resource file)