BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Image gallery (StringGrid)?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students)
View previous topic :: View next topic  
Author Message
Alexandre Paulino
Guest





PostPosted: Wed Mar 14, 2007 12:16 am    Post subject: Image gallery (StringGrid)? Reply with quote



Hi!
I want to do an image gallery like a product list in the web sites.
Is the best way using the StringGrid? How can I load each image to the each
cell?
Thank you.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Mar 14, 2007 1:28 am    Post subject: Re: Image gallery (StringGrid)? Reply with quote



"Alexandre Paulino" <alexandre (AT) belatriz (DOT) com.br> wrote in message
news:45f6f87f (AT) newsgroups (DOT) borland.com...

Quote:
Is the best way using the StringGrid?

No. A TDrawGrid would be better. Or a TListView in vsIcon mode.

Quote:
How can I load each image to the each cell?

If you use a TStringGrid or a TDrawGrid, then have to use the
OnDrawCell event to manually draw each cell. Which means you have to
store the actual images somewhere else that you can reach when needed.


Gambit
Back to top
JD
Guest





PostPosted: Wed Mar 14, 2007 7:40 pm    Post subject: Re: Image gallery (StringGrid)? Reply with quote



"Alexandre Paulino" <alexandre (AT) belatriz (DOT) com.br> wrote:
Quote:

[...] Is the best way using the StringGrid?

As Gambit noted, a TDrawGrid is a better choice because a
TStringGrid has overhead that you don't need - except that
it does have the Objects property implemented and that can
be used to associate the TBitmap with each cell.

Quote:
How can I load each image to the each cell?

You can not. The best that you can do is setup some way
for you to be able to determine which image to draw at
what moment. To know when an image needs drawing, set the
grid's DefaultDrawing property to false and add an OnDrawCell
event which will be called for each cell seperately when ever
that cell needs to be painted and the paramater list for the
event contains all of the information that you need to know
for drawing that cell.

If you were to setup a 2D array of the images that correspond
with the grids Cols and Rows count, you can use the ACol and
ARow parameters as an index into the array to get the image
for that cell. Then you can use the ARect parameter with
TCanvas::CopyRect to paint the image.

The problems that I see with this approach is image sizes
and cell sizes. Unless all of the images are exactly the
same, some images will be clipped *or* you're going to have
to tinker away at setting each individual cell's size and
that may not always be sufficient.

If your goal is to mimic the web pages that I've seen, I
would go for using a TPaintBox where you add an OnPaint
event to it and do all of the drawing in there. Again, if
you use TCanvas::CopyRect, you'll get great performance and
you'll also be able to tweek the appearance by adding what
ever you like without the restrictions imposed by using a
grid (or any other control for that matter). In addition,
if the page needs to be scrolled, just add the TPaintBox
to a TScrollBox.

~ JD
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Mar 14, 2007 11:08 pm    Post subject: Re: Image gallery (StringGrid)? Reply with quote

"JD" <nospam (AT) nospam (DOT) com> wrote in message
news:45f7fb32$1 (AT) newsgroups (DOT) borland.com...

Quote:
As Gambit noted, a TDrawGrid is a better choice because
a TStringGrid has overhead that you don't need - except
that it does have the Objects property implemented and
that can be used to associate the TBitmap with each cell.

If you use a TDrawGrid, then you can simply allocate your own array
for that. It doesn't matter where the images are stored, as long as
you have a way to associate each image with a specific cell, and can
find the image when needed.

Quote:
The problems that I see with this approach is image sizes
and cell sizes. Unless all of the images are exactly the
same, some images will be clipped *or* you're going to have
to tinker away at setting each individual cell's size and
that may not always be sufficient.

Or, you could simply stretch each image to the same size in the grid.
Then it won't matter the size of the original images. You could then
provide a separate viewer form to display the image in its original
size if the user wants a closer look.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Students) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.