procedure TForm1.Button1Click(Sender: TObject);
var TheRgbValue : TColorRef;
begin
if ColorDialog1.Execute then
begin
TheRgbValue := ColorToRGB(ColorDialog1.Color);
Label1.Caption := Format('#%.2x%.2x%.2x',
[GetRValue(TheRGBValue),
GetGValue(TheRGBValue),
GetBValue(TheRGBValue)]);
end;
end;