Menutup Form Dgn Animasi

unit Unit1;

interface

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

type
TForm1 = class(TForm)
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
// sumber :  http://www.swissdelphicenter.ch/en/showcode.php?id=672

var
tutup: Boolean;
i: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
tutup := True;
timer1.Enabled := False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
reg1, reg2: hrgn;
begin
if tutup = True then
begin
i := i + 10;
reg1 := CreateRoundRectRgn(0 + i, 0 + i, Width – i, Height – i, 20, 20);
SetWindowRgn(Handle, reg1, True);
end;

if i >= Width then
begin
tutup := False;
i := 1;
end;

if tutup = False then
begin
i := i + 10;
reg1 := CreateRectRgn(0, 0, (Width div 2) – i, Height);
reg2 := CreateRectRgn((Width div 2) + i, 0, Width, Height);
CombineRgn(reg1, reg1, reg2, rgn_or);
SetWindowRgn(Handle, reg1, True);
if i >= Width div 2 then
begin
tutup := True;
i := 1;
end;
end;

end;

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
reg1: hrgn;
begin
i := 1;
timer1.Enabled := True;
if MessageDlg(‘Anda Yakin Akan Keluar ?’,
mtConfirmation, [mbYes, mbNo], 0) = mrYes then
CanClose := True
else
begin
CanClose := False;
timer1.Enabled := False;
reg1 := CreateRoundRectRgn(0, 0, Width, Height, 0, 0);
SetWindowRgn(Handle, reg1, True);
end;

end;

end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: