- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 根据颜色值获取颜色常量名: ColorToIdent
本例效果图:

代码文件:
--------------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ColorDialog1: TColorDialog;
procedure Button1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
c: Integer;
s: string;
begin
if ColorDialog1.Execute then c := ColorDialog1.Color;
ColorToIdent(c, s);
if s = '' then s := ColorToString(c);
Color := c;
Text := s;
end;
end.