AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Tutorials Delphi Tutorial: Splash Screens
Tutorial durchsuchen
Ansicht
Themen-Optionen

Tutorial: Splash Screens

Ein Tutorial von sakura · begonnen am 9. Sep 2003 · letzter Beitrag vom 31. Jan 2009
Antwort Antwort
derula

Registriert seit: 16. Mär 2008
11 Beiträge
 
Delphi 7 Personal
 
#1

Re: Tutorial: Splash Screens

  Alt 26. Sep 2008, 04:25
Hi, keine Ahnung, ob das erwünscht ist, aber ich hätte ne Modifikation des Originaltutorials mit Fade-In /-Out. Und zwar wird dies über einen Thread gesteuert. Funktioniert, und es wird auch wie ich das sehen kann alles wieder ordnungsgemäß freigegeben.

DPR:
Delphi-Quellcode:
begin
  SplashForm := TSplashForm.Create(Application);
  try
    SplashForm.Show;
    SplashForm.Refresh;
    FadeThread := TFadeThread.Create(False);
    Application.Initialize;
    Application.CreateForm(TMainForm, MainForm);
  finally
    SplashForm.InitializationDone := True;
  end;
  Application.Run;
end.
SplashUnit.pas (bei mir):
Delphi-Quellcode:
type
  TSplashForm = class(TTntForm)
    SplashImage: TImage;
    SplashTimer: TTimer;
    CloseBtn: TTntButton;
    procedure SplashTimerTimer(Sender: TObject);
    procedure TntFormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure TntFormClose(Sender: TObject; var Action: TCloseAction);
  private
    FInitializationDone: Boolean;
    { Private declarations }
    procedure SetInitializationDone(const Value: Boolean);
  public
    { Public declarations }
    property InitializationDone: Boolean read FInitializationDone write SetInitializationDone;
  end;

type
  TFadeThread = class(TThread)
  private
    { Private-Deklarationen }
  protected
    procedure Execute; override;
  public
    FadeActive: Boolean;
  end;

var
  SplashForm: TSplashForm;
  FadeThread: TFadeThread;

implementation

{$R *.DFM}

procedure TFadeThread.Execute;
begin
  FadeActive := True;
  while (SplashForm <> nil) and not Terminated do
  begin
    if not SplashForm.InitializationDone or SplashForm.SplashTimer.Enabled then
    begin
      //Fade-In
      if SplashForm.AlphaBlendValue < 255 then
        SplashForm.AlphaBlendValue := SplashForm.AlphaBlendValue + 17
      else
        FadeActive := False;
    end else
    begin
      //Fade-Out
      if SplashForm.AlphaBlendValue > 0 then
        SplashForm.AlphaBlendValue := SplashForm.AlphaBlendValue - 17
      else
      begin
        FadeActive := False;
        Terminate;
        SplashForm.Close;
      end;
    end;
    Sleep(40);
  end;
end;

procedure TSplashForm.SetInitializationDone(const Value: Boolean);
begin
  FInitializationDone := Value;
  Close;
end;

procedure TSplashForm.SplashTimerTimer(Sender: TObject);
begin
  SplashTimer.Enabled := False;
  FadeThread.FadeActive := True;
end;

procedure TSplashForm.TntFormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  CanClose := FadeThread.Terminated;
end;

procedure TSplashForm.TntFormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  FadeThread := nil;
  Action := caFree;
  SplashForm := nil;
end;
Warum 17? Weil 17*15=255. ^^ Das Form muss natürlich vorher mit AlphaBlend := True bestückt werden.

In diesem Sinne: Viel Spaß (und gute Nacht *aufdieuhrseh*)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:24 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz