|
-
February 6th, 2010, 05:54 AM
#9
Re: Difficulty Compiling Resource files (.rc, .h, and .res) in Visual C++
Thank you so much for the replies, guys and girls!
 Originally Posted by Paul McKenzie
First, please use code tags when posting code, as the code you posted becomes unformatted and almost unreadable.
Sorry! I couldn't find the tags needed for it and was in a hurry at the time. I'm familiar with them now, and I will be sure to use them in my post from now on!
A console program must have a main() entry point, and your program does not have one. It has a WinMain(), but not a main() entry point. In other words, when you choose "Windows Console Program", your program has to be a "normal" C++ program. This means it has to have a main() function, just like the C++ examples you find in any book. Inside of this "normal" program, you can make use of the Windows API as much as you want. The WinMain() is the entry point for a Windows GUI program.
After reading this quote, I had one of those life-changing "DUH!!!" moments. I changed from a Win32 Console Application to just a Win32 Application. It worked immediately after this, so that relaxed me a lot. Thank you.
Secondly, Visual C++ 6.0 is very old (over 10 years old), obsolete (pre-standard ANSI C++ compiler), and no longer updated. It should only be used for upkeeping legacy apps that have not (for some reason) migrated themselves to the newer versions of Vis ual C++. Version 6.0 not only compiles broken C++ code as if nothing's wrong, it will also fail to compile legitimate ANSI C++ code.
To be quite frank, I don't really like Visual C++ 6.0 much at all. The only reason I ever switched compilers to begin with was due to the fact that Visual C++ 6.0 supports resource editing, whereas the express edition does not. The book also uses Visual C++ 6.0 as well, as well as the one I intend to use afterwords. For this reason, it may be prudent of me to familiarize myself with this particular compiler, and then when I become more confident and fluent in my programming skills, make the transfer to a more suitable long-term compiler (if "long-term" is indeed the appropriate word of choice here).
 Originally Posted by Igor Vartanov
I looked through the whole thread... You know what? What occured to me first was exactly the same: what's the real problem?
Thank you for taking the time to give me some advice! I will certainly keep it in mind when I ask questions in the future!
I feel my problem has already been broken down into its simplest form. It just so happened that as I was troubleshooting this problem, another problem came along! I think the real issue here is my lack of clarity, which comes from my overall lack and experience in computing. Please allow me one more chance to see if I can succinctly explain the problem:
Problem
I can't load a custom icon into my window, using my own self-created resource files (as opposed to ones that can be used from the tools a given compiler supplies.)
That's it! Nothing more! Now, when I analyze this problem, the first thing I ask myself is: Is the code correct? I know the code is correct, because I'm copying it straight from the book, with only a few of my own personal adjustments. So I know the code cannot be incorrect. Next I ask myself is if the file extensions are correct. They are indeed correct as a .cpp, .rc, and .h file. I've also remembered put an #include "resource.h" tag in the main code.
This leaves only one option left: somehow, I'm not compiling and/or linking the code correctly. Researching google on resources and compilers show that I need an external tool or a compiler that supports resource editing. Well, now I have one! So perhaps I should ask my question as follows:
Given the following files all contained in the "Source Files" directory of Visual C++ 6.0 Standard Edition:
star.ico
resource.h
resource.rc
main.cpp
How do I correctly compile and run this program to create two windows with my custom icon? Also, take note that the previous code I supplied was just to create two windows. The newer code I want to use has an include tag for the header file, and winclass.hIconSm becomes:
Code:
winclass.hIconSm = LoadIcon((hinstance, MAKEINTRESOURCE(id_icon1));
I'd like to thank everyone once again for taking the time to help me and offer their advice. It has not fallen on daft ears!
Edit:
Sorry, I almost forgot. Currently, when I try to run my program, this is the error message I receive:
--------------------Configuration: MenuProgram - Win32 Debug--------------------
Compiling resources...
C:\Documents and Settings\ROESER\Desktop\WindowsProgramming\MenuProgram\resource.h(1) : fatal error RC1004: unexpected end of file found
Error executing rc.exe.
MenuProgram.exe - 1 error(s), 0 warning(s)
Last edited by jroeser; February 6th, 2010 at 06:14 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|