So I have close to 300 variables (just right now), and I have numerically ordered their IDs in Resource.h so it’s:
#define IDC_BOX1 1
#define IDC_BOX2 2
#define IDC_BOX3 3
#define IDC_BOX4 4
etc. My question involves the DoDataExchange that I’m performing for each different dialog that I have that contains all of these variables. I REALLY don’t want to go through doing the following for each variable:
DDX_CText(pDX, IDC_BOX1, m_nBox1);
DDX_CText(pDX, IDC_BOX2, m_nBox2);
DDX_CText(pDX, IDC_BOX3, m_nBox3);
DDX_CText(pDX, IDC_BOX4, m_nBox4);
because that’s just ridiculous.
How can I do something along the same lines as this:
for(int i = 0; i < **totalVariables**; i++)
DDX_CText(pDX, **nameByIdInResourceFile(i)**, **indexOfVariableNameInArray**;
I’m sure this is possible, I just don’t know what the function might be that pulls the IDC_… variable names by their ID number. Any thoughts?
@Mark Ransom’s answer is great. I do exactly what he suggests, but I have one other thing I do as well. During my app’s startup (guarded by an #ifdef DEBUG), I have some code that verifies that all of my IDs are in consecutive numerical order. That way, I can be sure that someone (likely me in the future) doesn’t come along and add an out-of-numerical-sequence ID.