Palette problem in 253 color mode with delphi 2.0

my problem is the following:
I have a from with two TImage components.
They both contain a bitmap picture. The palette of bitmap A is
different from de palette of bitmap B. I would like to see
alternatively Bitmap A and bitmap B with their respective palette.
I put two buttons on my form. One to select the palette for bitmap A
and a second to select the palette for bitmap B.
The first time I press button1 the palette of bitmap B (that is shown
corectly at the beginning of the program) is deselected and the
palette of bitmap A is selected so that I can see perfectly bitmap A.
Then if I clic on button 2 the palette of bitmap A is deselected and
the palette of bitmap B is selected so that I see again bitmap B with
the right colors.
BUT .....

That's all after that buttons are not working anymore.
I'v tried to work with the result of the selectpalette function
without succes. RealizePalette does not change anything.

What do I have to do?

Here is my code:

procedure TForm1.Button1Click(Sender: TObject);
begin
SelectPalette(Image1.Picture.Bitmap.Canvas.Handle,
Image1.Picture.Bitmap.Palette, True);
Image1.Refresh;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
SelectPalette(Image2.Picture.Bitmap.Canvas.Handle,
Image2.Picture.Bitmap.Palette, True);
Image2.Refresh;
end;