DDX and Arrays
-
VS6.0, C++ I have a control I need to 'interact' with, I set it up the usual way with ID = IDC_TINY1 and using ClassWizard to assign a variable CStatic m_Tiny1, as expected this gives me:- DDX_Control(pDX, IDC_TINY1, m_Tiny1); and in the header:- CStatic m_Tiny1; Now though I have 11 more identical controls and instead of having m_Tiny1, m_Tiny2, m_Tiny3 etc I think it would be better to have an array m_Tiny[12] but there seems to be no way to assign each element of the array using ClassWizard. So I decided to edit these entries manually to give me:- DDX_Control(pDX, IDC_TINY1, m_Tiny[0]); DDX_Control(pDX, IDC_TINY2, m_Tiny[1]); DDX_Control(pDX, IDC_TINY3, m_Tiny[2]); . . . DDX_Control(pDX, IDC_TINY12, m_Tiny[11]); and:- CStatic m_Tiny[12]; This appeared to work just fine until I came to edit another control using ClassWizard I then got the error:- Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]" I'm assuming this is VS telling me I have an entry in the DDX that it didn't put there even though it quite happily will compile and run it. So to the problem: Is having array elements in DDX entries a valid thing to do? If yes then how do I do it without the error? Thanks
Apathy Rules - I suppose...
Its not the things you fear that come to get you but all the things that you don't expect
stevepqr wrote:
Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]"
You forgot ");" at the end of the line. That's exactly what VS is telling you also :)
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
VS6.0, C++ I have a control I need to 'interact' with, I set it up the usual way with ID = IDC_TINY1 and using ClassWizard to assign a variable CStatic m_Tiny1, as expected this gives me:- DDX_Control(pDX, IDC_TINY1, m_Tiny1); and in the header:- CStatic m_Tiny1; Now though I have 11 more identical controls and instead of having m_Tiny1, m_Tiny2, m_Tiny3 etc I think it would be better to have an array m_Tiny[12] but there seems to be no way to assign each element of the array using ClassWizard. So I decided to edit these entries manually to give me:- DDX_Control(pDX, IDC_TINY1, m_Tiny[0]); DDX_Control(pDX, IDC_TINY2, m_Tiny[1]); DDX_Control(pDX, IDC_TINY3, m_Tiny[2]); . . . DDX_Control(pDX, IDC_TINY12, m_Tiny[11]); and:- CStatic m_Tiny[12]; This appeared to work just fine until I came to edit another control using ClassWizard I then got the error:- Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]" I'm assuming this is VS telling me I have an entry in the DDX that it didn't put there even though it quite happily will compile and run it. So to the problem: Is having array elements in DDX entries a valid thing to do? If yes then how do I do it without the error? Thanks
Apathy Rules - I suppose...
Its not the things you fear that come to get you but all the things that you don't expect
put the above code after like this //}}AFX_DATA_MAP
//}}AFX_DATA_MAP
stevepqr wrote:
DDX_Control(pDX, IDC_TINY1, m_Tiny[0]);
DDX_Control(pDX, IDC_TINY2, m_Tiny[1]);
DDX_Control(pDX, IDC_TINY3, m_Tiny[2]);
.
.
.
DDX_Control(pDX, IDC_TINY12, m_Tiny[11]);in DoDataExchange Function. It should work.
-
stevepqr wrote:
Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]"
You forgot ");" at the end of the line. That's exactly what VS is telling you also :)
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++cedric, i dont think he has forgotten to add the closing bracket because in the query where he is adding the control variable i can see the bracket being put properly.
-
stevepqr wrote:
Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]"
You forgot ");" at the end of the line. That's exactly what VS is telling you also :)
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
put the above code after like this //}}AFX_DATA_MAP
//}}AFX_DATA_MAP
stevepqr wrote:
DDX_Control(pDX, IDC_TINY1, m_Tiny[0]);
DDX_Control(pDX, IDC_TINY2, m_Tiny[1]);
DDX_Control(pDX, IDC_TINY3, m_Tiny[2]);
.
.
.
DDX_Control(pDX, IDC_TINY12, m_Tiny[11]);in DoDataExchange Function. It should work.
-
Thanks but the code is already included inside the '//}}AFX_DATA_MAP' I didn't change this part just added lines inside the markers.
i had the same problem and this was solved by adding the code outside the markers.
-
VS6.0, C++ I have a control I need to 'interact' with, I set it up the usual way with ID = IDC_TINY1 and using ClassWizard to assign a variable CStatic m_Tiny1, as expected this gives me:- DDX_Control(pDX, IDC_TINY1, m_Tiny1); and in the header:- CStatic m_Tiny1; Now though I have 11 more identical controls and instead of having m_Tiny1, m_Tiny2, m_Tiny3 etc I think it would be better to have an array m_Tiny[12] but there seems to be no way to assign each element of the array using ClassWizard. So I decided to edit these entries manually to give me:- DDX_Control(pDX, IDC_TINY1, m_Tiny[0]); DDX_Control(pDX, IDC_TINY2, m_Tiny[1]); DDX_Control(pDX, IDC_TINY3, m_Tiny[2]); . . . DDX_Control(pDX, IDC_TINY12, m_Tiny[11]); and:- CStatic m_Tiny[12]; This appeared to work just fine until I came to edit another control using ClassWizard I then got the error:- Parsing Error: Expected ")" Input Line:"DDX_Control(pDX,IDC_TINY1,m_Tiny[0]" I'm assuming this is VS telling me I have an entry in the DDX that it didn't put there even though it quite happily will compile and run it. So to the problem: Is having array elements in DDX entries a valid thing to do? If yes then how do I do it without the error? Thanks
Apathy Rules - I suppose...
Its not the things you fear that come to get you but all the things that you don't expect
ClassWizard only parses the lines inside its comments. You should place your custom lines outside the class wizard's special comments. Just below the comment line //}}AFX_DATA_MAP, for example.
CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CYourDialogClassName) // lines added by ClassWizard // DDX_Control(...); // DDX_Text(...); //}}AFX_DATA_MAP // lines added manually DDX_Control(pDX, IDC_TINY1, m_Tiny[0]); DDX_Control(pDX, IDC_TINY2, m_Tiny[1]);
You should also take definitions into account in header file.
// Dialog Data //{{AFX_DATA(CDlgFoo) enum { IDD = IDD_DIALOG1 }; CStatic m_static1; //}}AFX_DATA CStatic m_Tiny[12];
The lines added manually in that way, won't be parsed by ClassWizard.
-
ClassWizard only parses the lines inside its comments. You should place your custom lines outside the class wizard's special comments. Just below the comment line //}}AFX_DATA_MAP, for example.
CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CYourDialogClassName) // lines added by ClassWizard // DDX_Control(...); // DDX_Text(...); //}}AFX_DATA_MAP // lines added manually DDX_Control(pDX, IDC_TINY1, m_Tiny[0]); DDX_Control(pDX, IDC_TINY2, m_Tiny[1]);
You should also take definitions into account in header file.
// Dialog Data //{{AFX_DATA(CDlgFoo) enum { IDD = IDD_DIALOG1 }; CStatic m_static1; //}}AFX_DATA CStatic m_Tiny[12];
The lines added manually in that way, won't be parsed by ClassWizard.
-
I thought of this already - when I try it I get 'Cannot Add New Member' when I try to add a new member but otherwise it works ok. I'm getting round this by commenting out the above lines adding new members and then uncommenting them, PITA!! :)
The problem may be with .clw file. Close project then rename that file. ClassWizard will re-create it. Or you may edit yourself if you know what you do. :)
-
The problem may be with .clw file. Close project then rename that file. ClassWizard will re-create it. Or you may edit yourself if you know what you do. :)
Thanks! Deleting the .clw and regenerating it did the trick - strangely, after recreating it I had to exit VS and restart but now all is good. Thanks to everyone else too for their suggestions. :)
Apathy Rules - I suppose...
Its not the things you fear that come to get you but all the things that you don't expect