unit Unit4;

interface

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

type
  TfrmRoundRect = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmRoundRect: TfrmRoundRect;

implementation
{$R *.dfm}

procedure TfrmRoundRect.Button3Click(Sender: TObject);
begin
  Close;
end;

procedure TfrmRoundRect.FormCreate(Sender: TObject);
var
  formRgn, but1Rgn, but2Rgn, but3Rgn: HRGN;
begin
  //Создаем регионы для окна и кнопок
  but1Rgn := CreateRoundRectRgn(0, 0, Button1.Width-1, Button1.Height-1,
                                Button1.Width div 5, Button1.Height div 5);
  SetWindowRgn(Button1.Handle, but1Rgn, FALSE);

  but2Rgn := CreateRoundRectRgn(0, 0, Button2.Width-1, Button2.Height-1,
                                Button2.Width div 5, Button2.Height div 5);
  SetWindowRgn(Button2.Handle, but2Rgn, FALSE);

  but3Rgn := CreateRoundRectRgn(0, 0, Button3.Width-1, Button3.Height-1,
                                Button3.Width div 5, Button3.Height div 5);
  SetWindowRgn(Button3.Handle, but3Rgn, FALSE);

  formRgn := CreateRoundRectRgn(0, 0, Width-1, Height-1,
                                Width div 5, Height div 5);
  SetWindowRgn(Handle, formRgn, FALSE);
end;

end.
