unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    RedEdit: TEdit;
    GreenEdit: TEdit;
    BlueEdit: TEdit;
    Button1: TButton;
    ColorDialog1: TColorDialog;
    procedure Button1Click(Sender: TObject);
    procedure FormPaint(Sender: TObject);
    procedure RedEditChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 c:LongInt;
begin
 if not ColorDialog1.Execute then exit;

 C:=ColorToRGB(ColorDialog1.Color);
 RedEdit.Text:=IntToStr(GetRValue(C));
 GreenEdit.Text:=IntToStr(GetGValue(C));
 BlueEdit.Text:=IntToStr(GetBValue(C));

 Repaint;
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
 Canvas.Brush.Color:=RGB(StrToIntDef(RedEdit.Text, 0), 
                 StrToIntDef(GreenEdit.Text, 0), StrToIntDef(BlueEdit.Text,0));
 Canvas.Rectangle(10,10, 250, 150);
end;

procedure TForm1.RedEditChange(Sender: TObject);
begin
 Repaint;
end;

end.
