Autor Beitrag
DiamondDog
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Mi 11.02.09 12:33 
Hallo Leute,
ich hab da ein kleines Problem ich wollte gerne mit einer Progressbar anzeigen wie weit die Saeite geladen ist. So wie es jeder kennt. Mein problem dabei ist das die Progressbar erst ganznormal läuft aber dann wieder zurück springt und ich nicht ganz verstehe wieso.
Hier mal mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.WebBrowserProgressChange(Sender: TObject; Progress,
  ProgressMax: Integer);
var
  Position: Integer;
begin
   try
    if ProgressMax <> 0 then
    begin
      Position := (Progress * 100div ProgressMax;
      WBProgressBar.Position := Position;
    end;
  except
  end;
end;
Danke schon mal fürs Helfen.

Mfg Dog
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 11.02.09 14:38 
Der Try-Except Block sollte eigentlich unnötig sein, da dürften keine Exceptions auftreten, es sei denn, du erzeugst deine ProgressBar dynamisch.
Zum Problem: Lass dir doch mal in einem geeigneten Element (Memo vielleicht) ausgeben, wie sich die Werte von Progress und ProgressMax ändern, vielleicht einfach mal ein Memo1.Lines.Add(IntToStr(Progress) + 'progress, max:' + IntToStr(ProgressMax)); reinschreiben, vielleicht lassen sich damit die Ergebnisse erklären. Auch könntest du noch zusätzlich das Ergebnis deiner Rechnung dazu schreiben, wenn da mal was rauskommt was größer ist als ProgressBar.Max dann dürfte das eine Erklärung sein.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Mi 11.02.09 15:31 
Das kriege ich dann in Memo1 angezeigt:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
100progress, max:10000
150progress, max:10000
200progress, max:10000
250progress, max:10000
300progress, max:10000
350progress, max:10000
400progress, max:10000
450progress, max:10000
500progress, max:10000
550progress, max:10000
600progress, max:10000
650progress, max:10000
700progress, max:10000
750progress, max:10000
800progress, max:10000
850progress, max:10000
900progress, max:10000
950progress, max:10000
1000progress, max:10000
1000progress, max:10000
1050progress, max:10000
1100progress, max:10000
1150progress, max:10000
1200progress, max:10000
1250progress, max:10000
1300progress, max:10000
1350progress, max:10000
1400progress, max:10000
1450progress, max:10000
1500progress, max:10000
1550progress, max:10000
1600progress, max:10000
1650progress, max:10000
1700progress, max:10000
1750progress, max:10000
1800progress, max:10000
1850progress, max:10000
1900progress, max:10000
1950progress, max:10000
2000progress, max:10000
2050progress, max:10000
2100progress, max:10000
2150progress, max:10000
2200progress, max:10000
2250progress, max:10000
2300progress, max:10000
2350progress, max:10000
2400progress, max:10000
2450progress, max:10000
2500progress, max:10000
2525progress, max:10000
2550progress, max:10000
2575progress, max:10000
2600progress, max:10000
2625progress, max:10000
2625progress, max:10000
10000progress, max:10000
-1progress, max:10000
27500progress, max:1000000
27500progress, max:10000
27550progress, max:10000
10000progress, max:10000
-1progress, max:10000
-1progress, max:10000
10000progress, max:10000
-1progress, max:10000
Progressbar Max steht auf 10000
Min auf 0 und
Steps 50

ProgressChangesieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  if ProgressMax <> 0 then
    begin
      WBProgressBar.Position := Progress;
      if WBProgressBar.Position = 10000 then WBProgressBar.Position := 10000;
      Memo1.Lines.Add(IntToStr(Progress) + 'progress, max:' + IntToStr(ProgressMax));
    end;
das -1progress versteh ich nicht so ganz.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mi 11.02.09 15:42 
:shock: die letzten paar Werte sind ja total abstrakt!
if WBProgressBar.Position = 10000 then WBProgressBar.Position := 10000; Dass die Zeile überflüssig ist und keine Wirkung hat, ist dir aber klar, oder? ;)
Spontan sieht das für mich wie ein Fehler im WebBrowser aus, aber keine Ahnung :nixweiss:
Mein nächster Schritt wäre, damit musst du leben und diese dämlichen Werte abfangen: Wenn Progress > MaxProgress oder Progress < 0 ist, einfach garnix machen... bzw wenn Progress < 0 dann Progressbar.Progress auf 0 setzen... :?!?:

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
DiamondDog Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 460



BeitragVerfasst: Mi 11.02.09 15:56 
Ok habs nun so gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
  if ProgressMax <> 0 then
    begin
      if Progress < 0 then
        begin

        end else
        begin
          WBProgressBar.Position := Progress;
        end;
    end;