unit Unit5;

interface

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

type
  TfrmHole = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmHole: TfrmHole;

implementation
{$R *.dfm}

procedure TfrmHole.FormCreate(Sender: TObject);
var
  rgn1, rgn2: HRGN; //"Регионы-дырки" в форме
  formRgn: HRGN;
begin
  //Создание "дырок" в регионе формы
  formRgn := CreateRectRgn(0, 0, Width - 1, Height - 1);
  rgn1 := CreateEllipticRgn(10, 10, 100, 50);
  rgn2 := CreateRoundRectRgn(10, 60, 200, 90, 10, 10);

  CombineRgn(formRgn, formRgn, rgn1, RGN_XOR);
  CombineRgn(formRgn, formRgn, rgn2, RGN_XOR);

  SetWindowRgn(Handle, formRgn, TRUE);

  //Регионы для "дырок" больше не нужны
  DeleteObject(rgn1);
  DeleteObject(rgn2);
end;

procedure TfrmHole.Button1Click(Sender: TObject);
begin
  Close;
end;

end.
