From: marten.larsson@gdpc.se (Marten Larsson)
Subject: Re: Delphi: Palette question
Date: Tue, 30 May 95 15:40:53 GMT

bludrake@nexus.interealm.com (Gilbert Roper) wrote:
>Can someone explain the palpalentry? I don't understand what the
>array[0..0] does and how to use it.

Yes, you can use this for indicating the number of colours your palette is
to contain. You should allocate memory for the palette dynamically,
this way you can decide how much memory you want to put aside for the
palette, i.e.

VAR LogPal  : PLogPalette;
    Palette : HPalette;
    PalSize : LongInt;
BEGIN
  ...
  PalSize:=2*SizeOf(Word)+n_Colors*SizeOf(TPaletteEntry));
   { 2 * SizeOf(Word) to get space for palVersion and palNumEntries }
   { n_Colors is (of course) the number of colors in the palette    }
  GetMem(LogPal,PalSize);
  LogPal^.palVersion:=$0300;
  LogPal^.palNumEntries:=n_Colors;
  LogPal^.palPalEntry[0]:= {Some colour};
  LogPal^.palPalEntry[1]:= {Some other colour};

  etc.
 ...
  FreeMem(LogPal,PalSize);
 ...

END;

This has to be compiled with $R- (no range checking), otherwise you will
get an error when you try using palPalEntry with an index higher than
0.

/Marten
