Sign in to follow this  
phil05

Help making blank resource files in VC++ 6.0

Recommended Posts

phil05    100
I'm trying to make a blank dialog without the stupid visuals they let you paint on. How do I go about this and do I need to put any #includes in the file? Please give me some simple steps because this is extremely annoying. I don't know if I did this right, but I went to 'new' and clicked on header file, and typed in resource.h. I throw this in here...
#include <windows.h>
#include <afxres.h>


IDD_ABOUT DIALOG DISCARDABLE  0, 0, 239, 66
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My About Box"
FONT 8, "MS Sans Serif"
BEGIN
    DEFPUSHBUTTON   "&OK",IDOK,174,18,50,14
    PUSHBUTTON      "&Cancel",IDCANCEL,174,35,50,14
    GROUPBOX        "About this program...",IDC_STATIC,7,7,225,52
    CTEXT           "An example program showing how to use Dialog Boxes\r\n\r\nby theForger",
                    IDC_STATIC,16,18,144,33
END

And this shows up...
c:\program files\microsoft visual studio\myprojects\win32 api practice\resource.h(5) : error C2146: syntax error : missing ';' before identifier 'DIALOG'
c:\program files\microsoft visual studio\myprojects\win32 api practice\resource.h(5) : error C2501: 'IDD_ABOUT' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\myprojects\win32 api practice\resource.h(5) : fatal error C1004: unexpected end of file found

...?

Share this post


Link to post
Share on other sites
Instruo    373
impatience isn't going to get you answers, for one, and for another thing it's the middle of the night where most people that use this forum are, so perhaps you should wait until at least morning before expecting an answer. I'd try google.

Share this post


Link to post
Share on other sites
Endurion    5411
Don't name it .h, name it .rc. Then the resource compiler will take care of it.

Also you might change windows.h to resource.h. And resource.h ought to hold the defines for the IDs of the components. You can't put them in one file together, as your code will need access to the IDs only. The compiler doesn't know what to do with the resource script, hence the separation.

Share this post


Link to post
Share on other sites
Ryuu-do    136
"resource.h" is just header where there's a series of #defines which define symbols used in the resource script. So everything that should be put into this file is the line "#define IDD_ABOUT 101" or any other number. Everything other you tried to put there should be in some "*.rc" file and one of the first lines in that file have to be inclusion of your resource.h header.

Share this post


Link to post
Share on other sites
phil05    100
I tried the .rc file but I don't understand what good it is to me because all I can do in it is call visual dialogs when I want to write it in pure code.

Share this post


Link to post
Share on other sites
Endurion    5411
That's a feature of the VS IDE. .rc-Files are recognized as resource scripts and thus opened in the resource editor. You can always open them in another text editor besides and edit manually.

Share this post


Link to post
Share on other sites
Empirical    190
Perhaps you cound unload it. Load it into notetpad and stick an error in it.

When you load it /compile it it should say "Error in script" with a button maked "Edit code" once you have clicked this save your projects. As long as you dont close that window you can edit to your hearts contect.

I know this because my copy of VC6 always halts at its OWN code!
So i cant use the flashly editor thing.

Share this post


Link to post
Share on other sites
phil05    100
Ok, I opened the .rc file in notepad and I'm now able to stick my own resource code into it. It seems to be comiling fine since the .rc file in vC++ has a file of a dialog box now after writing it in in notepad. Is ths all I need to do then? There's no way of editing the .rc file in VC++ but outside of it?

Share this post


Link to post
Share on other sites
Endurion    5411
I just found a possibility.
In the solution explorer (workspace dialog) right-click the .rc-File in the project tree, choose "open with" and there choose "code-editor" (or similar).

Downside: You'll have to do that everytime you want to open it anew.

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