How to get RGB Values

alpires
alpires used Ask the Experts™
on
Hi Experts,

How to get Red, Green, Blue value of TColorDialog component in Delphi 7 ?

Thanks

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
function ColorGetRed(const Cl : TColor) : byte;
begin
  result := Byte(Cl shr 16);
end;

function ColorGetGreen(const Cl : TColor) : byte;
begin
  result := Byte(Cl shr 8);
end;

function ColorGetBlue(const Cl : TColor) : byte;
begin
  result := Byte(Cl);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  Red, Green, Blue: Byte;
begin
  if ColorDialog1.Execute then
  begin
    Red:= ColorGetRed(ColorDialog1.Color);
    Green:= ColorGetGreen(ColorDialog1.Color);
    Blue:= ColorGetBlue(ColorDialog1.Color);
  end;
end;

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial