I handle the colors for each one of these in the WM_CTLCOLORSTATIC portion of my main window/dialog.
The issue is that I get compiler warnings of multiple or duplicate IDS in my resource file when I use the above #defines for more than one control in each RC file. The code compiles fine (except for the warnings), and the program runs without any problems.
The above will generate a warning of duplicate ID since I use IDC_STATIC_MAROON twice.
If I use a duplicate ID for a checkbox or radio button or whatnot, the program will crash because it doesn't know which control I'm trying to access, but these above #defines are only for CTEXT that I'm using as labels and thus they are never clicked on, so I'm sure that's why the program runs fine.
Anyway, my question is, is this dangerious? Or do I need to simply go ahead and assign a different ID to each CTEXT regardless?
Yes, I've used IDC_STATIC and for whatever reason I never get a duplicate warning on that, which is declared as -1, but for the others I get the duplicate warning. I've tried using the #pragma statement to turn it off, but it's not working, which means I'm not using the #pragma statement properly or not putting it in the right place, or whatever.
I wonder if VS2010 (which is what I'm using), has a built-in #pragma for IDC_STATIC, or if the compiler auto-ignores the duplicates on that, or what? I'd like to get the same thing for the other two ID's I'm using, which are -2 and -3, but if I can't, then I can't.
Either way, like you said, I'm not doing anything with those controls but displaying text and background color, so no harm no foul, I guess.
Thanks for that link. This statement in that article settles it for me --
"If the duplications are all among controls that do not raise notifications and which you do not need to identify programmatically, then you're not going to run into much trouble at all. By convention, the "control ID for controls where I don't care about the ID" is −1, although you can use any number you like; the window manager doesn't care, as long as it doesn't collide with the ID of a control that you do care about."
I'm using the duplicate ID's because I use a lot of dialogs and change the text color in various places and I don't want to have to #define a whole bunch of unique ID"s just to change the text color of a CTEXT entry in my RC file.
I would still like to know how to turn off the warning in VS2010 with the #pragma statement if anyone knows. I've tried using the #pragma warning statement several ways, in several places, like in the RC file, a header file, etc., but it tells I'm doing something wrong, and keeps issuing the warning.