It removes the #include <windows.h> everytime I save

All announcements, questions and issues related to the Resource Builder
Post Reply
dit6a9
Posts: 4
Joined: Sun Aug 01, 2004 9:49 pm

It removes the #include <windows.h> everytime I save

Post by dit6a9 »

I'm working on the following resource:

Code: Select all

#include <windows.h>

/*********************************************
File: C:\MIS C\20040807\SETUP01\DIALOGBOXES.RC
Generated by Resource Builder 2.0.
*********************************************/
// Below are important 3 lines, don't change them!
/*
OutputExt=res
*/
DIALOG_0 DIALOG 0, 0, 421, 188
STYLE DS_SETFONT |WS_CHILD 
FONT 8, "Tahoma"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "Button0",0,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,250,165,149,17
  CONTROL "",1,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,20,7,380,151
END
Everything goes fine. Resource Builder reads it perfectly (At last I get it! I had problems with the windows.h file as I wrote before. It seems I had to add the _MSC_VER compiler definition in the compiler options). But when I save the .rc file, it removes the #include <windows.h>. This is a problem as long as that include is needed later so that my proyect compiles with no errors.

Is it normal? Can't I use any include directive in the .rc files? I don't know, maybe I shouldn't use the #include <windows.h> in the .rc file but if I don't do it, I can't compile the proyect. Maybe the mistake lies in the other part, I mean in the way I compile the whole application.

I would be very grateful if someone could help me. Thanks in advance.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Resource Builder's compiler removes all <#include> directives after parsing so the file saved by Resource Builder won't have them. But in order to be able to compile the project that uses this RC file you may do the following:
1. Create new RC file using text editor with the following content:

Code: Select all

#include <windows.h>
#include <YOUR_RC_FILE_FROM_RESOURCE_BUILDER.RC>
2. Use this file in your project instead of actual RC file and use actual RC file in Resource Builder.

This way you will be able to handle the situation.
Hope this helps.
dit6a9
Posts: 4
Joined: Sun Aug 01, 2004 9:49 pm

Post by dit6a9 »

You're right. That way it all works out well. Many thanks.

But I've got another probem/question.

I'd like to use names instead of numbers in order to indetify the different controls. Something like this:

Code: Select all

/*********************************************
#include "resorces.h"
 
File: C:\MIS C\20040807\SETUP01\DIALOGBOXES.RC
Generated by Resource Builder 2.0.
*********************************************/
// Below are important 3 lines, don't change them!
/*
OutputExt=res
*/
DIALOG_0 DIALOG 0, 0, 421, 188
STYLE DS_SETFONT |WS_CHILD
FONT 8, "Tahoma"
LANGUAGE LANG_NEUTRAL, 0
BEGIN
  CONTROL "Button0",BUTTON_STARTDOWNLOADING,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,250,165,149,17
  CONTROL "",1,"EDIT",ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,20,7,380,151
END 
where resources.h is:

Code: Select all

#define BUTTON_STARTDOWNLOADING 0
This is just an example. Can't I do this with Resource Builder? Probably the first time I try to open this .rc no errors will happen, but if the resource.h is removed, next time it won't work.

Is there any workaround to solve this?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Unfortunately, this is not possible. Resource Builder will replace all named (literal) constants with their values on first reading and on later saving will save RC file with only integer IDs. There is no workaround for this (or at least I don't know it ;))
Post Reply