Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

control array Borland C++ Builder Visual Basic

Posted on 2001-07-30
5
Medium Priority
?
721 Views
Last Modified: 2013-11-25
Using Borland C++ Builder, how does one create a control array?

In Visual Basic it is very simple, just highlight the control in design view and paste it, VB asks if you want to create a control array.  In Builder however, the subject of control arrays is not even mentioned in the help files.  It's amazing in such a faithful reproduction of each others products, that this very helpful and simple interface was skipped over.

I would like to create 256 Panels on a Form during run time, and treat them as an array for iteration purposes.

Example source code is desirable.

Thanks in Advance:)
0
Comment
Question by:lirtua
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 180 total points
ID: 6336675
You must to make simething as (example for TButton):
TButton * buttons[200];
for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); ++i)
{
buttons[i] = new TButton(whatever);
}
After that you must add events (example for OnClick:)
void __fastcall TMyForm::MyClick(TObject* Sender)
{
}

for (int i = 0; i < sizeof(buttons) / sizeof(*buttons); ++i)
{
buttons[i]->OnClick = MyClick;
}

See full discussion in
http://www.mers.com/MERLIST/BORLAND/PUBLIC/CPPBUILDER/LANGUAGE/37757.HTML
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6375437
I hope, my info helps you. Alex
0
 

Author Comment

by:lirtua
ID: 6520561
Sorry, the controls are not showing up on my form.  Here is my source code:

   for(int i = 0; i < NUM_IMG; ++i)
   {
      image[i] = new TImage(ScrollBox1);
      image[i]->Picture = Image1->Picture;
      image[i]->Top = i * 10;
      image[i]->Left = 10;
      image[i]->AutoSize = true;
      image[i]->Visible = true;
      image[i]->Invalidate();
   }

On the form is a scrollbox containing an image that has a bitmap loaded at design time.  The control array should be located in the scrollbox and have the same pictures as the design time image.
0
 

Author Comment

by:lirtua
ID: 6520611
Oh - forgot to mention this also in source code:

#define NUM_IMG 10
TImage * image[NUM_IMG];
0
 

Author Comment

by:lirtua
ID: 6520673
Your code is very close.  There is one thing missing though.  For some reason the constructor does not set the Parent property.  So we have to do this explicitly as follows:

      image[i] = new TImage(sbPictureScrollBox);
      image[i]->Parent = sbPictureScrollBox;

With this addition, the code above works.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question