User forums > Help
is there a way to make control arrays in wxSmith?
(1/1)
ouch:
I could really use them for my project but I can't seem to be able to find a way to do it. anytime I enter a non standard character for the control's variable wxsmith strips it out.
to better describe what I'm talking about see below:
--- Code: ---wxTextCtrl TextCtrl[2];
TextCtrl[0] = new wxTextCtrl(Panel2, ID_TEXTCTRL0, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL0"));
TextCtrl[1] = new wxTextCtrl(Panel2, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
TextCtrl[2] = new wxTextCtrl(Panel2, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
//Then later on:
for (i=0;i<2;i++)
{
TextCtrl[i]->ChangeValue("written by an array!");
}
--- End code ---
you can also do something simular (but less elegant) with wxArrays. But wxSmith doesn't let you use that method either.
I'm pretty much stuck on my project till I can solve this.
MortenMacFly:
--- Quote from: ouch on April 21, 2008, 09:06:10 pm ---
--- Code: ---wxTextCtrl TextCtrl[2];
[...]
TextCtrl[2] = new wxTextCtrl(Panel2, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(100,-1), 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
--- End code ---
--- End quote ---
As you didn't describe what exactly happens: In case your app crashes: You are creating a vector of size 2 and write on position 3. This should definitely result in a crash. Probably this already solves your problem. ;-)
In additon: You are creating an array of objects but fill with pointers... probably you should start reading a book on C++?!
ouch:
the problem is that I can't make the brackets on the variable in the first place. ;) wxSmith strips them out when you try to add them in the variable for the control.
if you try to do it outside of wxSmith of course it overwrites everything you do if you touch your GUI with it again.
that was just some example code to show what I would like wxSmith (or some other method) to do.
Navigation
[0] Message Index
Go to full version