The trick to add animation effects alphablend current form onShow and OnClose.
Form design:
Add TTimer two components (with the given name of each: TimerOnShow, TimerOnClose). Change the second interval timer to 1 and set Enabled: = False.
private
intShow, intClose: Byte;
CloseIt: Boolean;
...
TForm1.FormCreate procedure (Sender: TObject);
begin
intShow: = 0;
Alphablend: = True;
AlphablendValue: = 0;
CloseIt: = False;
intClose: = 255;
end;
TForm1.FormShow procedure (Sender: TObject);
begin
TimerOnShow.Enabled: = True;
end;
TForm1.FormCloseQuery procedure (Sender: TObject; var CanClose: Boolean);
begin
Alphablend: = True;
TimerOnClose.Enabled: = True;
CanClose: = CloseIt;
end;
TForm1.TimerOnShowTimer procedure (Sender: TObject);
begin
intShow: = intShow + 5;
AlphablendValue: = intShow;
if intShow> = 255 then
begin
TimerOnShow.Enabled: = False;
Alphablend: = False;
end;
end;
TForm1.TimerOnCloseTimer procedure (Sender: TObject);
begin
intClose: = IntClose - 5;
AlphablendValue: = intClose;
if intClose <= 5 then
begin
CloseIt: = True;
TimerOnClose.Enabled: = False;
Close;
end;
end;
No comments:
Post a Comment