Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macros within .rc file

Tags:

macros

mfc

I want to switch the GUID I use for an activex control based on if its a 32 bit control or a 64 bit. I would rather not have two .rc files to do this. However resource compiler ignores my pre-processor definitions inside BEGIN - END blocks and always defaults to the Control in the #else section. Please let me know if there is a better way to do this other than having two different resource(.rc) file.

BEGIN
#ifdef _Win64
CONTROL         "",IDC_TCHART1,"{FCB4B50A-E3F1-4174-BD18-54C3B3287258}",WS_TABSTOP,0,15,445,199
#else
CONTROL         "",IDC_TCHART1,"{FAB9B41C-87D6-474D-AB7E-F07D78F2422E}",WS_TABSTOP,0,15,445,199
#endif
END
like image 757
coolshashi Avatar asked Dec 06 '22 02:12

coolshashi


1 Answers

I think it doesn't recognise pre-processor symbols defined in project properties for the compiler options, you would need to add this to the Resources properties too. Also, you can #include a file that contains a #define'ed symbol instead.

So as MSDN says :

To define symbols for your resource identifiers, use the #define directive to define them in a header file. Include this header both in the resource script and your application source code. Similarly, you define the values for resource attributes and styles by including Windows.h in the resource script.

RC treats files with the .c and .h extensions in a special manner. It assumes that a file with one of these extensions does not contain resources. If a file has the .c or .h file name extension, RC ignores all lines in the file except the preprocessor directives. Therefore, to include a file that contains resources in another resource script, give the file to be included an extension other than .c or .h.

Having said that, it's highly likely that as soon as you modify this with the Visual Studio resource editor, you'll lose your changes.

like image 123
Roger Rowland Avatar answered Dec 31 '22 01:12

Roger Rowland