unit MainUnit;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    ColorDialog1: TColorDialog;
    procedure FormPaint(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormPaint(Sender: TObject);
begin
 //Обязательно устанавливаю цвет кисти
 Canvas.Brush.Color:=ColorDialog1.Color;

 //Рисую первый квадрат
 Canvas.Brush.Style:=bsSolid;
 Canvas.Rectangle(10,10,50,50);

 //Рисую второй квадрат
 Canvas.Brush.Style:=bsBDiagonal;
 Canvas.Rectangle(10,110,50,150);

 Canvas.Brush.Style:=bsFDiagonal;
 Canvas.Rectangle(10,160,50,200);

 Canvas.Brush.Style:=bsCross;
 Canvas.Rectangle(110,10,150,50);

 Canvas.Brush.Style:=bsDiagCross;
 Canvas.Rectangle(110,60,150,100);

 Canvas.Brush.Style:=bsHorizontal;
 Canvas.Rectangle(110,110,150,150);

 Canvas.Brush.Style:=bsVertical;
 Canvas.Rectangle(110,160,150,200);

 Canvas.Brush.Style:=bsClear;
 Canvas.Rectangle(10,60,50,100);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if ColorDialog1.Execute then
  Canvas.Brush.Color:=ColorDialog1.Color;
 FormPaint(nil);
end;

end.
