unit Unit1;
interface
uses
Windows, Messages, Variants, Classes, Graphics, Controls, Forms, StdCtrls;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TFadeForm =
class(TForm)
private
pFadeIn, pFadeOut : Boolean;
protected
procedure DoShow;
override;
procedure DoHide;
override;
published
property FadeIn : Boolean
read pFadeIn
write pFadeIn;
property FadeOut : Boolean
read pFadeOut
write pFadeOut;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TFadeForm.DoShow;
begin
// AlphaBlend runtersetzen
if pFadeIn
then
AlphaBlendValue := 0;
// Show "ausführen" // <-
inherited Show;
// <-
ShowWindow(Self.Handle, SW_SHOW);
// ein Show erzwingen!
// Einblenden
if pFadeIn
then
while AlphaBlendValue < 255
do begin
AlphaBlendValue := AlphaBlendValue + 5;
Application.ProcessMessages;
// Messages Verarbeiten !
Sleep(10);
end;
end;
procedure TFadeForm.DoHide;
begin
// Ausblenden
if pFadeOut
then begin
AlphaBlendValue := 255;
while AlphaBlendValue > 5
do begin
AlphaBlendValue := AlphaBlendValue - 10;
Application.ProcessMessages;
// Messages Verarbeiten !
Sleep(10);
end;
end;
// Close "ausführen"
inherited Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
lFadeForm: TFadeForm;
begin
lFadeForm := TFadeForm.CreateNew(
nil);
lFadeForm.Left := (Screen.Width
div 2) - ((lFadeForm.Width)
div 2 );
lFadeForm.Top := (Screen.Height
div 2) - ((lFadeForm.Height)
div 2);
lFadeForm.AlphaBlend := true;
lFadeForm.FadeIn := true;
lFadeForm.FadeOut := true;
lFadeForm.Show;
sleep(2000);
lFadeForm.Hide;
lFadeForm.Free;
sleep(500);
end;
end.