|
When I am designing a dialog box with static text boxes to display numbers can I initialize control variables as arrays through the wizard?
As an example, say I am collecting information in 8 channels and would like to display this information in a 8 separate text boxes. I want to store the information in the variable int m_chan[8] but I don't see the array option in the 'Add Variable...' in VS2010.
|
|
|
|
|
The answer is "No you cannot". But you can apply various method to achieve that simpley
You can remind in your two variable your first id and last id, if they are incremental. on various occasion we have to create more than one static object, dynamically.
I wish I could believe there is an after life.
|
|
|
|
|
The Add Variable wizard does not support what you want to do.
However, you can add the variables manually to get at what you're trying to do.
For the first text box, right click and select Add Variable .
Then select the datatype as int and enter the name of the variable as m_chan .
After this, open the dialog header file and change the member variable from int m_chan; to int m_chan[8]; .
Now open the dialog source file and make the following changes -
At the dialog constructor remove the line , m_chan(0) .
In the DoDataExchange function, remove the line DDX_Text(pDX, IDC_EDIT1, m_chan); and add the following lines -
DDX_Text(pDX, IDC_EDIT1, m_chan[0]);
DDX_Text(pDX, IDC_EDIT2, m_chan[1]);
DDX_Text(pDX, IDC_EDIT3, m_chan[2]);
DDX_Text(pDX, IDC_EDIT4, m_chan[3]);
DDX_Text(pDX, IDC_EDIT5, m_chan[4]);
DDX_Text(pDX, IDC_EDIT6, m_chan[5]);
DDX_Text(pDX, IDC_EDIT7, m_chan[6]);
DDX_Text(pDX, IDC_EDIT8, m_chan[7]);
Here, replace the IDs of the edit boxes to the appropriate IDs.
|
|
|
|
|
The wizard is limited; you should get used to skip the wizard. Many times it's even faster to add something to your code, than using the wizard. What you want is possible (as shown already), but not with the wizard.
|
|
|
|