C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 9th, 2004, 01:42 PM
AMAshcroft AMAshcroft is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 AMAshcroft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Array of Image/Picture boxes using C++ Builder???

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

Reply With Quote
  #2  
Old November 11th, 2004, 06:31 AM
AMAshcroft AMAshcroft is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 AMAshcroft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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);

Reply With Quote
  #3  
Old November 13th, 2004, 08:44 AM
AMAshcroft AMAshcroft is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 3 AMAshcroft User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy I really need help!!!!

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

Reply With Quote
  #4  
Old November 18th, 2004, 08:39 PM
code_geek code_geek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 9 code_geek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
to access elements in arrays in c++, you need to use array[element], not array(element)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Array of Image/Picture boxes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway