Unable to concatenate defined string and the text

2019-07-21 06:59发布

问题:

I got a problem with setting a path to image within the resource file (.rc).

For some reasone it was not possible to concatenate defined string and the text.

e.g.

File1:  
#define Path "Brand_1"

File2:  
#include File1

Logo BITMAP Path "\Logo.bmp"

Borland resource compiler (5.4) throws error message: 39: Cannot open file: Brand_1

EDIT: My question would be: Is is possible to combine the path for loading image using resource string variable and a string (file name).

Also, project I'm working on relates to a file (Logo.bmp) being present in two locations. I would like to have a switch (.bat file) to generate a different resouce file depending on requirements.

Thanks.

回答1:

BRCC32 accepts -i as search path seperated by semicolon, so you could create a bat file like this

compile_res.bat

brcc32 -ic:\mypath1;c:\mypath2 resource_script

and you define your resource_script as normal, for ex:

resource_script.rc

myImg BITMAP Logo.bmp
myDOC RCDATA mydoc.doc

when you run the compile_res.bat, it will run the brcc32.exe with the search path, and having the bat file saves you from retyping the search path every time.



回答2:

You're not concatenating anything. You're compiling to Logo BITMAP "Brand_1" "\Logo.bmp", and "Brand_1" isn't a valid path to a bitmap file.

#define in the resource compiler acts sort of like find/replace in a text processor - not exactly, but close enough in this case.

You might get by (untested) with removing the quotes and space between them, as long as there are no space characters in either the path or filename; otherwise, you're probably out of luck. (Not sure what you're trying to accomplish, anyway.)