unit UForms;

interface

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

type
  TForm1 = class(TForm)
    RadioGroup1: TRadioGroup;
    RadioGroup2: TRadioGroup;
    Panel1: TPanel;
    procedure RadioGroup1Click(Sender: TObject);
    procedure RadioGroup2Click(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.RadioGroup1Click(Sender: TObject);
var MyRegion, MyRegion2: HRGN;
    P: array[0..7] of TPoint;
    NP: array[0..1] of integer;
begin
 case RadioGroup1.ItemIndex of
  0: MyRegion := CreateRectRgn(0, 0, Width, Height);
  1: MyRegion := CreateRectRgnIndirect(Rect(0, 0, Width, Height));
  2: MyRegion := CreateRoundRectRgn(0, 0, Width, Height, 50, 50);
  3: MyRegion := CreateEllipticRgn(0, 0, Width, Height);
  4: MyRegion := CreateEllipticRgnIndirect(Rect(0, 0, Width, Height));
  5: begin
      P[0] := Point(0, Height div 2);
      P[1] := Point(Width div 2, 0);
      P[2] := Point(Width, Height div 2);
      P[3] := Point(Width div 2, Height);
      MyRegion := CreatePolygonRgn(P, 4, ALTERNATE);
     end;
  6: begin
      P[0] := Point(0, Height div 2);
      P[1] := Point(Width div 4, 0);
      P[2] := Point(Width div 2, Height div 2);
      P[3] := Point(Width div 4, Height);
      P[4] := Point(Width div 2, Height div 2);
      P[5] := Point(3 * Width div 4, 0);
      P[6] := Point(Width, Height div 2);
      P[7] := Point(3 * Width div 4, Height);
      NP[0] := 4;
      NP[1] := 4;
      MyRegion := CreatePolyPolygonRgn(P, NP, 2, ALTERNATE);
     end;
  7: begin
      MyRegion := CreateEllipticRgn(Width div 4, 0, 3 * Width div 4, Height);
      MyRegion2 := CreateEllipticRgn(0, Height div 4, Width, 3 * Height div 4);
      CombineRgn(MyRegion, MyRegion, MyRegion2, RGN_XOR);
     end;
 end;
 SetWindowRgn(Handle, MyRegion, true);
end;

procedure TForm1.RadioGroup2Click(Sender: TObject);
var MyRegion, MyRegion2: HRGN;
    P: array[0..7] of TPoint;
    NP: array[0..1] of integer;
begin
 with Panel1 do
 case RadioGroup2.ItemIndex of
  0: MyRegion := CreateRectRgn(0, 0, Width, Height);
  1: MyRegion := CreateRectRgnIndirect(Rect(0, 0, Width, Height));
  2: MyRegion := CreateRoundRectRgn(0, 0, Width, Height, 50, 50);
  3: MyRegion := CreateEllipticRgn(0, 0, Width, Height);
  4: MyRegion := CreateEllipticRgnIndirect(Rect(0, 0, Width, Height));
  5: begin
      P[0] := Point(0, Height div 2);
      P[1] := Point(Width div 2, 0);
      P[2] := Point(Width, Height div 2);
      P[3] := Point(Width div 2, Height);
      MyRegion := CreatePolygonRgn(P, 4, ALTERNATE);
     end;
  6: begin
      P[0] := Point(0, Height div 2);
      P[1] := Point(Width div 4, 0);
      P[2] := Point(Width div 2, Height div 2);
      P[3] := Point(Width div 4, Height);
      P[4] := Point(Width div 2, Height div 2);
      P[5] := Point(3 * Width div 4, 0);
      P[6] := Point(Width, Height div 2);
      P[7] := Point(3 * Width div 4, Height);
      NP[0] := 4;
      NP[1] := 4;
      MyRegion := CreatePolyPolygonRgn(P, NP, 2, ALTERNATE);
     end;
  7: begin
      MyRegion := CreateEllipticRgn(Width div 4, 0, 3 * Width div 4, Height);
      MyRegion2 := CreateEllipticRgn(0, Height div 4, Width, 3 * Height div 4);
      CombineRgn(MyRegion, MyRegion, MyRegion2, RGN_OR);
     end;
 end;
 SetWindowRgn(Panel1.Handle, MyRegion, true);
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 ReleaseCapture();
 Perform(WM_SYSCOMMAND, $F012, 0);
end;

end.
