AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

SplashScreen Problem

Ein Thema von Störtebeker · begonnen am 18. Okt 2008 · letzter Beitrag vom 19. Okt 2008
Antwort Antwort
Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#1

SplashScreen Problem

  Alt 18. Okt 2008, 23:28
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:
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.
Codeausschnitt für eines der weiteren Formulare:
Delphi-Quellcode:
.
.
.
procedure TForm2.FormCreate(Sender: TObject);
begin
sleep(2500);
Form2.DoubleBuffered := true;
Form3.Label8.Caption:='System will be analyzed...';
Form3.Refresh;
end;
.
.
.
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?
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat
Benutzerbild von Die Muhkuh
Die Muhkuh

Registriert seit: 21. Aug 2003
7.332 Beiträge
 
Delphi 2009 Professional
 
#2

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:38
Du musst die ProgressBar auch noch neu zeichnen.
  Mit Zitat antworten Zitat
Benutzerbild von blawen
blawen

Registriert seit: 30. Nov 2003
Ort: Luterbach (CH)
654 Beiträge
 
Delphi 12 Athens
 
#3

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:41
Hast Du es schon mal mit Application.ProcessMessages versucht?
Roland
  Mit Zitat antworten Zitat
Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#4

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:46


@Die Muhkuh:
Delphi-Quellcode:
Application.Initialize;
  ProgressBar1.Max:=100;
  Show;
  Update;
ich dachte, dass in diesem Fall "Show" und "Update" dafür verantwortlich sind.

@blawen: Bei "Application.ProcessMessages" würde ich ehrlichgesagt Neuland betreten.
Sprich, hätte nicht die geringste Ahnung der Verwendung.
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat
Benutzerbild von Die Muhkuh
Die Muhkuh

Registriert seit: 21. Aug 2003
7.332 Beiträge
 
Delphi 2009 Professional
 
#5

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:46
Warum überhaupt das Sleep mit 2,5 Sekunden?
  Mit Zitat antworten Zitat
Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#6

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:48
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.
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat
Benutzerbild von Die Muhkuh
Die Muhkuh

Registriert seit: 21. Aug 2003
7.332 Beiträge
 
Delphi 2009 Professional
 
#7

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:50
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.
  Mit Zitat antworten Zitat
Benutzerbild von Störtebeker
Störtebeker

Registriert seit: 9. Jul 2007
398 Beiträge
 
#8

Re: SplashScreen Problem

  Alt 18. Okt 2008, 23:55
Du meinst so:

Delphi-Quellcode:
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.
bringt leider auch nichts.
"And he piled upon the whale´s white hump - a sum of all the rage and hate felt by his whole race.
If his chest had been a cannon, he would have shot his heart upon it."
  Mit Zitat antworten Zitat
Benutzerbild von blawen
blawen

Registriert seit: 30. Nov 2003
Ort: Luterbach (CH)
654 Beiträge
 
Delphi 12 Athens
 
#9

Re: SplashScreen Problem

  Alt 19. Okt 2008, 00:29
Eine kleine Erklärung zu Processmessages findest Du z.B. hier:

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.
Roland
  Mit Zitat antworten Zitat
Benutzerbild von Garfield
Garfield

Registriert seit: 9. Jul 2004
Ort: Aken (Anhalt-Bitterfeld)
1.334 Beiträge
 
Delphi XE5 Professional
 
#10

Re: SplashScreen Problem

  Alt 19. Okt 2008, 09:45
Zitat von Störtebeker:
bringt leider auch nichts.
Ich würde das Refresh nicht auf die ProgressBar sondern die Form3 anwenden.
Gruss Garfield
Ubuntu 22.04: Laz2.2.2/FPC3.2.2 - VirtBox6.1+W10: D7PE, DXE5Prof
  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 04:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz