ShowCustomizePaletteDlg example for Delphi

procedure TForm1.ShowCustomizePaletteDlg1Click(Sender: TObject); 
var
   i: L_INT; 
   nRet: L_INT; 
begin
   LEADDlgColor1.UserPaletteColorsCount:= 0; 

   LEADDlgColor1.DlgFlags:= DLG_CUSTOMIZEPALETTE_SHOW_SORT                 Or
                            DLG_CUSTOMIZEPALETTE_SHOW_FINDCLOSEST          Or
                            DLG_CUSTOMIZEPALETTE_SHOW_ADDOPTION            Or
                            DLG_CUSTOMIZEPALETTE_SHOW_REMOVEOPTION         Or
                            DLG_CUSTOMIZEPALETTE_SHOW_COLORMODEL           Or
                            DLG_CUSTOMIZEPALETTE_SHOW_RGBLEFTPAN           Or
                            DLG_CUSTOMIZEPALETTE_SHOW_HTMLLEFTPAN          Or
                            DLG_CUSTOMIZEPALETTE_SHOW_INDEXLEFTPAN         Or
                            DLG_CUSTOMIZEPALETTE_SHOW_RGBRIGHTPAN          Or
                            DLG_CUSTOMIZEPALETTE_SHOW_HTMLRIGHTPAN         Or
                            DLG_CUSTOMIZEPALETTE_SHOW_INDEXRIGHTPAN        Or
                            DLG_CUSTOMIZEPALETTE_SHOW_NEW                  Or
                            DLG_CUSTOMIZEPALETTE_SHOW_OPEN                 Or
                            DLG_CUSTOMIZEPALETTE_SHOW_SAVE                 Or
                            DLG_CUSTOMIZEPALETTE_SHOW_SAVEAS               Or
                            DLG_CUSTOMIZEPALETTE_GENERATE_PALETTE; 

   LEADDlgColor1.LEADImage:= LEADImage1; 
   LEADDlgColor1.LEADDlgService:= LEADDlgService1; 
   nRet:= LEADDlgColor1.ShowCustomizePaletteDlg ( Self ); 
   if ( nRet = SUCCESS_DLG_OK ) then
   begin
      if ( LEADDlgColor1.ApplyPaletteWhenExit ) then
         Edit1.Text:= 'True'
      else
         Edit1.Text:= 'False'; 

      for i:= 0 to LEADDlgColor1.GeneratedPaletteColorsCount -1 do
      begin
         LEADImage1.UserPaletteColors [i]:= LEADDlgColor1.GeneratedPaletteColors [i]; 
      end; 
   end; 
end;