unit uBlendForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TBlendForm =
class(TForm)
private
{ Private-Deklarationen }
FBlendValue: Byte;
FFirstShow: Boolean;
FBlendTimer: TTimer;
FBlendOut: Boolean;
procedure TimerProc(Sender: TObject);
procedure SetBlendOut(
const Value: Boolean);
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent);
override;
procedure DoClose(
var Action: TCloseAction);
override;
procedure DoShow;
override;
published
property BlendOut: Boolean
read FBlendOut
write SetBlendOut;
end;
var
BlendForm: TBlendForm;
implementation
{$R *.dfm}
constructor TBlendForm.Create(AOwner: TComponent);
begin
inherited;
FBlendOut := false;
FBlendValue := 0;
FFirstShow := true;
FBlendTimer:= TTimer.Create(Self);
FBlendTimer.Enabled := false;
FBlendTimer.Interval := 1;
FBlendTimer.OnTimer := TimerProc;
end;
procedure TBlendForm.DoClose(
var Action: TCloseAction);
var
i: integer;
begin
inherited;
if FBlendOut
then begin
for i := 255
downto 0
do begin
AlphaBlendValue := i;
Sleep(1);
Application.ProcessMessages;
end;
end;
end;
procedure TBlendForm.DoShow;
begin
inherited;
if FFirstShow
then begin
FBlendTimer.Enabled := true;
end;
end;
procedure TBlendForm.SetBlendOut(
const Value: Boolean);
begin
FBlendOut := Value;
end;
procedure TBlendForm.TimerProc(Sender: TObject);
begin
if FBlendValue < 255
then begin
inc(FBlendValue);
if FBlendValue = 255
then begin
FBlendTimer.Enabled := false;
end;
AlphaBlendValue := FBlendValue;
end;
end;
// oder das Ganze in FormActivate
//
//procedure TBlendForm.FormActivate(Sender: TObject);
//var
// i: integer;
//begin
// for i := 0 to 255 do begin
// AlphaBlendValue := i;
// Sleep(1);
// Application.ProcessMessages;
// end;
//end;
end.