unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    procedure FormActivate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  poz :integer;
  procedure WMNCHITTEST(var Mes:Tmessage); Message WM_NCHITTEST;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormActivate(Sender: TObject);
var rgn, rgn2 :HRGN;
begin
  rgn := CreateRectRgn(0, 0, 41, 41);
  rgn2 := CreateEllipticRgn(5, 5, 37, 37);
  CombineRgn(rgn2, rgn, rgn2, RGN_DIFF);
  CombineRgn(rgn, rgn, rgn2, RGN_DIFF);
  SetWindowRgn(BitBtn1.handle, rgn, true);

  rgn := CreateRectRgn(0, 0, 41, 41);
  rgn2 := CreateEllipticRgn(5, 5, 37, 37);
  CombineRgn(rgn2, rgn, rgn2, RGN_DIFF);
  CombineRgn(rgn, rgn, rgn2, RGN_DIFF);
  SetWindowRgn(BitBtn2.handle, rgn, true);

  rgn := CreateRectRgn(0, 0, 41, 41);
  rgn2 := CreateEllipticRgn(5, 5, 37, 37);
  CombineRgn(rgn2, rgn, rgn2, RGN_DIFF);
  CombineRgn(rgn, rgn, rgn2, RGN_DIFF);
  SetWindowRgn(BitBtn3.handle, rgn, true);
end;


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

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  Application.Minimize;
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
  if poz = 0 then
    begin
     ShowWindow(Application.Handle, SW_HIDE);
     poz := 1;
     BitBtn2.Enabled := False;
    end
     else
      begin
        ShowWindow(Application.Handle, SW_SHOW);
        poz := 0;
        BitBtn2.Enabled := True;
      end;
end;

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

end.
