![]() |
SplashScreen Problem
Hallo,
kleine Nebenbemerkung: Ich arbeite in Lazarus: ich verwende für mein Programm einen Splash und wollte nun etwas kombinieren, von dem meine vorherige Programme jeweils nur eines besaßen. Kombination: ProgressBar und Label Code der Programm-Unit
Delphi-Quellcode:
Codeausschnitt für eines der weiteren Formulare:
program Project;
{$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms { you can add units after this }, main, robots, splash; {$IFDEF WINDOWS}{$R manifest.rc}{$ENDIF} begin Application.Initialize; Form3 :=TForm3.Create(Application); with TForm3.Create(nil) do try Form3.show; Form3.Update; Application.Initialize; ProgressBar1.Max:=100; Show; Update; Application.Title:= 'Project'; Application.CreateForm(TForm1, Form1); ProgressBar1.StepBy(30); Application.CreateForm(TForm2, Form2); ProgressBar1.StepBy(80); Finally free; Form3.visible :=false; end; Application.Run; end.
Delphi-Quellcode:
Also, der Splash erscheint, die Progressbar lädt. Gleichzeitig soll ein Label anzeigen, was das Programm gerade macht. Ohne ProgressBar funzt es. Aber nicht mit der ProgressBar. Was muss ich machen, damit die Kombination funktioniert?
.
. . procedure TForm2.FormCreate(Sender: TObject); begin sleep(2500); Form2.DoubleBuffered := true; Form3.Label8.Caption:='System will be analyzed...'; Form3.Refresh; end; . . . |
Re: SplashScreen Problem
Du musst die ProgressBar auch noch neu zeichnen.
|
Re: SplashScreen Problem
Hast Du es schon mal mit Application.ProcessMessages versucht?
|
Re: SplashScreen Problem
:wiejetzt:
@Die Muhkuh:
Delphi-Quellcode:
ich dachte, dass in diesem Fall "Show" und "Update" dafür verantwortlich sind.
Application.Initialize;
ProgressBar1.Max:=100; Show; Update; @blawen: Bei "Application.ProcessMessages" würde ich ehrlichgesagt Neuland betreten. Sprich, hätte nicht die geringste Ahnung der Verwendung. |
Re: SplashScreen Problem
Warum überhaupt das Sleep mit 2,5 Sekunden?
|
Re: SplashScreen Problem
Das sleep verwende ich, damit der SplashScreen auch seine Wirkung hat und nicht nach ner Sekunde wieder weg ist. Habe ich bis jetzt immer so gemacht.
|
Re: SplashScreen Problem
Ist aber nicht Sinn und Zweck davon, einfach mal so 2,5 Sekunden zu warten, nur damit man das Ding sieht.
Du musst noch jedem Ändern des Wertes der ProgressBar ein .Refresh aufrufen, sonst geht das nicht. |
Re: SplashScreen Problem
Du meinst so:
Delphi-Quellcode:
bringt leider auch nichts.
program Project;
{$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Forms { you can add units after this }, main, robots, splash; {$IFDEF WINDOWS}{$R manifest.rc}{$ENDIF} begin Application.Initialize; Form3 :=TForm3.Create(Application); with TForm3.Create(nil) do try Form3.show; Form3.Update; Application.Initialize; ProgressBar1.Max:=100; Show; Update; Application.Title:= 'Project'; Application.CreateForm(TForm1, Form1); ProgressBar1.StepBy(30); ProgressBar1.Refresh; Application.CreateForm(TForm2, Form2); ProgressBar1.StepBy(80); ProgressBar1.Refresh; Finally free; Form3.visible :=false; end; Application.Run; end. |
Re: SplashScreen Problem
Eine kleine Erklärung zu Processmessages findest Du z.B.
![]() In meinem (gekürzten) Bsp. rufe ich ein Intro-Fenster auf und aktualisiere darin die Progressbar. (In diesem Bsp. arbeite ich ohne Processmessages)
Delphi-Quellcode:
var
Intro : TSplashScreen; begin Application.Title := 'XY'; Application.CreateForm(TFMainform, FMainform); Application.Initialize; Intro:=TSplashScreen.Create(Application); Try Intro.Show; Intro.UpDate; sleep(1000); Intro.Hide; Application.CreateForm(TFLogin, FLogin); Finally Intro.Free; End; . . { Passwortabfrage wird nach dem Intro ausgeführt } FLogin.ShowModal; . . { Passwortabfrage erfolgreich } { Intro-Fenster wird wieder eingeblendet und die Progressbar sichtbar gemacht } TRY Intro:=TSplashScreen.Create(Application); Intro.ProgressBar1.Visible := True; Intro.Show; Intro.UpDate; Intro.ProgressBar1.Position := 5; Application.CreateForm(TFMD, FMD); Intro.ProgressBar1.Position :=10; Application.CreateForm(TFPLZ_Ort_Ausw, FPLZ_Ort_Ausw); . . . Intro.ProgressBar1.Position := 90; Application.CreateForm(TFImportExport, FImportExport); Intro.Hide; Intro.Free; Application.Run; Except ShowMessage('Initialisierungsfehler'); Application.Terminate; Application.Free; end; end. |
Re: SplashScreen Problem
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:54 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-2025 by Thomas Breitkreuz