> I want to make up a component similar to the faulty Timagelist.
> Eg
> bitmap:array[0..99] of tbitmap;
> 
> Say currently we have 20 items in the array and item number 5 is to be
> deleted. What is needed is that now we have 19 items used in the array
> and item 6 drops into item 5, item 7 into 6 and so on. It seems messy,
> but I bet there is a fast and efficient way to do it. Yea, anyone know how?

It's easy enough to implement a wrapper around a dynamic array of TBitmap
and use move(Source,Destination,BytestoMove) to shift items

TBAWrapper = class(Tobject)
private
    FBitmaps :array of TBitmap;
public
    procedure Add(BM :TBitmap);
        // Setlength(FBitmaps,Length(FBitmaps)+1); FBitmaps[High(FBitmaps)] := BM;
  procedure Remove(Index :Integer);
        // FBitmaps[Index].Free;
        // if (Index>0) and (Index<High(FBitmaps)) then
        //    
move(FBitmaps[Index+1],FBitmaps[Index],SizeOf(TBitmap)*(High(FBitmaps)-Index));
        // SetLength(FBitmaps,High(FBItmaps));
end;

Or something like that... Don't forget that you'll want a destructor as well to 
cleanup...

Also it is bad to constantly resize the array... you might want to use an FCount field
and resize the array in jumps of something like 1/8th or 1/16th of the current size so
that memory doesn't keep getting reallocated.  Remember that empty array slots
are only as big as the Handle to the Tbitmap (4bytes) not the size of the bitmap 
itself.

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to