| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Im trying to create an array of image/picture boxes using C++ Builder 6.0 forms (if possible?),
instead of intialising each individual Image component. My Current program loads each separate image block: <code> AnsiString WallBlock = "Images\\Wall.jpg"; //Image to load, picture of a wall //Load in 1 row of wall blocks (p0 is the name of the image box) p0->Picture->LoadFromFile(WallBlock); p1->Picture->LoadFromFile(WallBlock); p2->Picture->LoadFromFile(WallBlock); p3->Picture->LoadFromFile(WallBlock); p4->Picture->LoadFromFile(WallBlock); p5->Picture->LoadFromFile(WallBlock); p6->Picture->LoadFromFile(WallBlock); p7->Picture->LoadFromFile(WallBlock); p8->Picture->LoadFromFile(WallBlock); p9->Picture->LoadFromFile(WallBlock); p10->Picture->LoadFromFile(WallBlock); p11->Picture->LoadFromFile(WallBlock); </code> I've attempted trying to create an array of boxes but i am unsure how to do it: <code> //use loop to create 1 row of wall blocks for(int i=0; i < 12; i++) { p(i)->Picture->LoadFromFile(WallBlock); } </code> Is it possible to set the names of the image boxes to act like a control array such as: p(0) p(1) p(2) p(3) etc. I've seen like an array created in Visual Basic but how can you create in C++ Builder ?Alternatively, if there is a better way of doing it, let me know, thanks very much. ![]() Andy |
|
#2
|
|||
|
|||
|
Array of Picture boxes
Is that possible to create an array of TImages?
Image(0)->Picture->LoadFromFile(WallBlock); Image(1)->Picture->LoadFromFile(WallBlock); Image(2)->Picture->LoadFromFile(WallBlock); Image(3)->Picture->LoadFromFile(WallBlock); Image(4)->Picture->LoadFromFile(WallBlock); |
|
#3
|
|||
|
|||
|
Can someone please give me an idea on how to load in a row of images using picture boxes?
There must be a easier a way than intialising each image box to load a picture Could I use a pointer? Im really stuck, Im trying to create a 2D grid of images which is for a RPG Game (Final Year Project at Preston UCLAN). So for example where there is just a row of wall blocks, I want to able to put it in a loop instead intialising each picture box. (1 to 10 (top of grid) pictures boxes will load in the wall block image). Andy |
|
#4
|
|||
|
|||
|
to access elements in arrays in c++, you need to use array[element], not array(element)
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Array of Image/Picture boxes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|