TColorのHtml形式への変換













var

bgc:String;//背景色



implementation





procedure TMainForm1.Button1Click(Sender: TObject);

 var

 irot,iros:String;

begin

    if ColorDialog.Execute then

   begin

   iros:= ColorToString(ColorDialog.Color);

   irot:= ChangeColorF(iros);

    bgc:= irot;

   end;

end;



function TMainForm1.ChangeColorF(iro:String):String;

var

  Acol,Bcol,Ccol:String;

begin

  if Copy(iro,1,2) = 'cl'   then

   begin

   	if iro='clAqua' then

   	   iro := 'Aqua';

	if iro='clBlack' then

 	   iro := 'Black';

	if iro='clBlue' then

   	   iro := 'Blue';

	if iro='clDkGray' then

  	   iro := 'Darkslategray';

	if iro='clFuchsia' then

 	   iro := 'Fuchsia';

	if iro='clGray' then

  	   iro := 'Gray';

	if iro='clGreen' then

 	   iro := 'Green';

	if iro='clLime' then

  	   iro := 'Lime';

	if iro='clLtGray' then

 	   iro := ' Lightgrey';

	if iro='clMaroon' then

   	   iro := 'Maroon';

	if iro='clNavy' then

	   iro := 'Navy';

	if iro='clOlive' then

	   iro := 'Olive';

	if iro='clPurple' then

	   iro := 'Purple';

	if iro='clRed' then

	   iro := 'Red';

	if iro='clSilver' then

	   iro := 'Silver';

	if iro='clTeal' then

	   iro := 'Teal';

	if iro='clWhite' then

	   iro := 'White';

	if iro='clYellow' then

	   iro := 'Yellow';

     end

     else

     begin

     if Copy(iro,1,2) = 'cl'   then

        iro := 'White'

      else

      begin

      Acol:= Copy(iro,4,2) ;

      Bcol:= Copy(iro,6,2) ;

      Ccol:= Copy(iro,8,2) ;

      iro:= '#'+Ccol+Bcol+Acol;

      end;

      end;

     

     Result :=iro;

end;










Back