Hi didan
Post by didanI need to create a variable amount of buttons at runtime. I don't know what's the best way to do it. I'm thinking about to create an array of controls so that I can create them by loop the array. I even don't know if there is a way to create a control array at design time.
Can you help? Thanks in advance
typedef std::vector<TButton*> ButtenVector;
ButtenVector ButtenVec;
void __fastcall createButtons(int Count, TWinControl* Parent, int Left, int Top,
int Width, int Height, int Space, bool Vertical, TNotifyEvent Event)
{
for(int i = 0; i < Count; ++i)
{
TButton* NewButton = new TButton(Parent);
if(Vertical)
NewButton->SetBounds(Left, Top + i * (Space + Height), Width, Height);
else
NewButton->SetBounds(Left + i * (Space + Width), Top, Width, Height);
NewButton->Parent = Parent;
NewButton->Caption = "Button" + String(i);
NewButton->OnClick = Event;
ButtenVec.push_back(NewButton);
}
}
void __fastcall hideButtons()
{
int C = ButtenVec.size();
for(int i = 0; i < C; ++i)
ButtenVec[i]->Hide();
}
p.s. Please break Your text lines.
Kind regards
Asger