unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Timer1: TTimer;
    MonthCalendar1: TMonthCalendar;
    procedure FormShow(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  procedure WMNCHITTEST(var Mes:Tmessage); Message WM_NCHITTEST;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormShow(Sender: TObject);
var FullRgn, EllRgn, Rgn: HRGN;
    w, h: integer;
begin
  FullRgn := CreateRectRgn(0,0,Width,Height);
  Rgn := CreateRectRgn(0,0,Width,Height);
  w := 25; h := 25;
  EllRgn := CreateEllipticRgn(w,h,Width - w,Height - h);
  CombineRgn(Rgn,Rgn,EllRgn,RGN_DIFF);
  CombineRgn(FullRgn,FullRgn,Rgn,RGN_DIFF);
  SetWindowRgn(Handle,FullRgn,True);
end;

procedure TForm1.WMNCHITTEST(var Mes:Tmessage);
begin
  Mes.Result := HTCAPTION;
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  MonthCalendar1.Date := Date;
  MonthCalendar1.EndDate := Date;
  Application.Title := 'Календарь';
end;

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

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Label1.Caption := FormatDateTime('c',Now);
end;

end.
