I have read the msdn about the CImageList::Create(), but I don't really
get it about the `nGrow' parameter, could anyone explain it to me ?!
its prototype is:
BOOL Create( int cx, int cy, UINT nFlags, int nInitial, int nGrow );
nInitial
Number of images that the image list initially contains.
nGrow
Number of images by which the image list can grow when the system needs
to resize the list to make room for new images. This parameter
represents the number of new images the resized image list can contain.
Say if we want to create a CImageList object with 6 16x15 images:
m_imageList.Create(16, 15, ILC_COLOR, ?, ?);
What should we give in the last 2 parameters ?!
Thanks.
Slash
> I have read the msdn about the CImageList::Create(), but I don't really
> get it about the `nGrow' parameter, could anyone explain it to me ?!
As I understand it (someone correct me if I'm wrong in this case) that
dynamic array objects often have two "size" parameters:
size1 the number of objects which are curently held
size2 the number of objects for which memory is currently allocated.
with size2 greater than or equal to size1.
As you fill it up the spare locations are occupied and size1 grows towards
size2.
When size1 is equal to size2, and you add another element, extra memory is
allocated for "nGrow" objects, leaving nGrow-1 free spaces. The purpose is
to make it possible to have rather few reallocation operations if you know
you're going to add a lot of things to the array, but not to use up lots of
memory if you know you're going to have rather few.
Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm
Tom
"slash" <sl...@ms32.url.com.tw> wrote in message
news:1139899560.3...@o13g2000cwo.googlegroups.com...
Thanks for the wonderful explanation !
Slash