My app requires me to change logos and icons every time it is compiled for each customer. Doing this by hand is, naturally, time consuming and error prone, so I have written the .Net form to load its images and icons from a .rc file, but I’m trying to work some preprocessor magic in the resources file.
My goal is to have it automatically load only one image and icon from a directory that has the customer’s id. This will prevent the .rc file from linking unneeded images and files, and make setup for each customer as simple as a single prepcessor command.
I have a token called “CUSTOMER_ID” that is the folder name of their resources. So, their files would be in “../files/images/customer1/” where CUSTOMER_ID = customer1.
I want to get the preprocessor to concatenate the constant of “..files/images/” with CUSTOMER_ID, followed by “icon.ico” or “logo.bmp” so that I can define the resource. This is what I have currently:
//in resources.rc
#include "airline.h"
#define CONCAT(dir, cid, filetype) dir ## cid ## filetype
IDI_ICON1 ICON CONCAT("../files/images/",CUSTOMER_ID,"icon.ico")
However, the results always end up off. Advice?
For RC files preprocessor directives are very limited, see: http://msdn.microsoft.com/en-us/library/windows/desktop/aa381033(v=vs.85).aspx
And
#defineis of simple form: (after http://msdn.microsoft.com/en-us/library/windows/desktop/aa381061(v=vs.85).aspx):There is solution – according to this answer prepare your ICON/BITMAPS paths as environment variables, you can build them from costumer name – but it must be done in your batchFile or makefile:
From the already mentioned answer:
This answer was for C++ files:
For your example:
You should use such macro:
This is because this macro expansion is:
"../files/images/" "customer1" "icon.ico". And the C++ compiler will concatenate adjacent string literals.This example:
will produce output:
Possible you should add
/beforeicon.ico…