Change color in palette for 256-color timage

  I wan't to change 1 color in a palette on my 256-color image.
  I doesn't display.
Why ?

  MainForm->ColorDialog->Options << cdFullOpen;
  if (MainForm->ColorDialog->Execute())
    {
    MyPal.lpal.palVersion = 0x0300; // "Magic Number"for Windows LogPalette
    MyPal.lpal.palPalEntry[ColorIndex].peRed =
(Byte)((DWORD)(MainForm->ColorDialog->Color) & 0xff);
    MyPal.lpal.palPalEntry[ColorIndex].peGreen =
(Byte)((DWORD)(MainForm->ColorDialog->Color>>8) & 0xff);
    MyPal.lpal.palPalEntry[ColorIndex].peBlue =
(Byte)((DWORD)(MainForm->ColorDialog->Color>>16) & 0xff);
    MyPal.lpal.palPalEntry[ColorIndex].peFlags = PC_NOCOLLAPSE;
    MyPal.lpal.palNumEntries = TotalColors;
    // Image->Picture->Bitmap->Palette = CreatePalette(&MyPal.lpal);
    // Image->Picture->Bitmap->ReleasePalette();
    HPALETTE Palette = Image->Picture->Bitmap->Palette;
    UnrealizeObject(Palette);
    SetPalet{*word*249}tries(Palette, ColorIndex, 1,
&MyPal.lpal.palPalEntry[ColorIndex]);
    SelectObject(Image->Canvas->Handle, Image->Picture->Bitmap->Palette);
    RealizePalette(Handle);
    RealizePalette(Image->Canvas->Handle);
    Image->Canvas->Refresh();
    MainForm->Invalidate();
    Invalidate();
    }

Thanks,