Then use ID_TWO as a resource ID in a resource file.
If the ID can be interpreted as either string or numeric, it'll parsed and processed but not evaluated and used as a string resource.
If the ID can be interpreted as numeric only, it'll be parsed, processed and evaluated numerically.
What this means:
Any "loadable" resource (icon, bitmap, dialog, html, manifest, ....) will be added as a string resource.
So for ID_TWO you will get a loadable resource named "1+1" rather than having numeric ID 2.
Any item which is an (numerically) identifiable part of a resource (resource string, an ID of a control on a dialog) will be evaluated to having the value 2.
Then use ID_TWO as a resource ID in a resource file.
If the ID can be interpreted as either string or numeric, it'll parsed and processed but not evaluated and used as a string resource.
If the ID can be interpreted as numeric only, it'll be parsed, processed and evaluated numerically.
What this means:
Any "loadable" resource (icon, bitmap, dialog, html, manifest, ....) will be added as a string resource.
So for ID_TWO you will get a loadable resource named "1+1" rather than having numeric ID 2.
Any item which is an (numerically) identifiable part of a resource (resource string, an ID of a control on a dialog) will be evaluated to having the value 2.
I agree, I think you're right.
But what can I do to get my icon ID dependent of buttons ID values (that was my first aim)
Here is a sample project
in the dialog box, you will see only 2 icons
But if you look at the test1.rc source code, you should expect 3 icons
Note that the rc editor give an error (on IDI_MYICON1), because it is unable to interpret it
1. You resource file compiles (I used VS2010) with the warning
Code:
warning RC2182: duplicate dialog control ID 2
2. If I comment out the line
Code:
// ICON IDI_MYICON1,IDR_MAINFRAME3,238,55,20,20
in your .rc file then the resource view becomes available and what you could see is the ID of the icon "..\test1\res\cancel2.ico" is "(1999+2)"
So it looks like the compiler is expecting a string or a numeric expression and therefore the expression is not evaluated.
1. You resource file compiles (I used VS2010) with the warning
Code:
warning RC2182: duplicate dialog control ID 2
2. If I comment out the line
Code:
// ICON IDI_MYICON1,IDR_MAINFRAME3,238,55,20,20
in your .rc file then the resource view becomes available and what you could see is the ID of the icon "..\test1\res\cancel2.ico" is "(1999+2)"
So it looks like the compiler is expecting a string or a numeric expression and therefore the expression is not evaluated.
I've added an ICON to this, and in this case the expression is not evaluated, even when using rc from the command line (I have VS2008 installed)
From the MSDN note, it looks like this might work with older versions of the resource compiler, e.g. from VS .NET (2003)
Alan
I agree with you. That don't work for loadables resources.
However, Igor Vartanov test is interesting showing it is possible to order (IDC1= IDC0+1, IDC2=IDC0+2 ...) a serie of controls which may be useful in some cases (loop treatments relying on controls ID).
there is a solution, even a dynamic one, but you'll need extra tools since the regular resource compiler won't work.
* Have a .h witht he button id's
* have a .h with the icon id's. You create/update it as part of your build, it needs to have regular '#define ID value' lines not '#define ID expression'.
* include both H's in the resource symbols
* make the .rc compilation dependant on the .h (may not be needed in 2010, explicit dependant is needed in VS2008).
While unusual, .h and .cpp files in your project can be the result of a tool generating those files. prior to the compiler picking them up for compilation. You sort of make your own "precompiler" in a way.
there is a solution, even a dynamic one, but you'll need extra tools since the regular resource compiler won't work.
* Have a .h witht he button id's
* have a .h with the icon id's. You create/update it as part of your build, it needs to have regular '#define ID value' lines not '#define ID expression'.
* include both H's in the resource symbols
* make the .rc compilation dependant on the .h (may not be needed in 2010, explicit dependant is needed in VS2008).
While unusual, .h and .cpp files in your project can be the result of a tool generating those files. prior to the compiler picking them up for compilation. You sort of make your own "precompiler" in a way.
Thanks. This seem a bit complicated but I'll think about it
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.