Autor Beitrag
Gabberman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mi 25.10.06 21:54 
Hy Leutz ;)

isch mal wieder :roll:
ich wollte mal mit nem Timer arbeiten, hab aber irgendwie keinen blassen Schimmer davon. Also hab ich in der Delphi Hilfe nachgeschaut und ein irgendwie sinnloses Beispiel bekommen.... Das sagt mir gar nichts. Also hier mein Anwendungsbeispiel. Beim Speichervorgang meines Programms möchte ich das er anzeigt wie weit das Speichern ist mit einem Progressbar. Wenn er fertig ist, soll er ca. 1 Sec warten und dann diesen Progressbar löschen. Hier ist mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
Timer1.Interval := 1000000000;
if ActiveControl <> nil then
    Fortschritt.Position:=0;


Nur irgendwie seh ich trotzdem keinen Progressbar (wird zu schnell gelöscht!!!) :evil:
Kann mir da jemand helfen!!!!


Danke
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 25.10.06 21:56 
So stand das sicherlich nicht in der Hilfe drin!

_________________
Markus Kinzler.
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Mi 25.10.06 21:58 
versuchs mal mit sleep(1000). war das in millisekunden??


Gruß

Bäär
soisseteben
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111

Win XP
D7
BeitragVerfasst: Mi 25.10.06 22:04 
du kannst im Ereignis "OnTimer"-Ereignis des Timers etwas ausführen. Das Ereignis tritt ein, wenn die Zeit des Timers ran ist. Danach noch den Timer1.Enable = FALSE und fertsch is (sonst zählt er erneut und löst das Ereignis neu aus).

have fun

_________________
„Wer nur nach dem Zweck der Dinge fragt, wird ihre Schönheit nie entdecken.“ - (Halldór Laxness)
Gabberman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mi 25.10.06 23:50 
user profile iconmkinzler hat folgendes geschrieben:
So stand das sicherlich nicht in der Hilfe drin!


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Interval := 100;
  if ActiveControl <> nil then
    ActiveControl.Left := ActiveControl.Left + 1;
end;


Also so stands in der Delphi Hilfe unter OnTimer-Ereignis...

@ soisseteben!!! DAS VERSTEH ICH NICH!!! KANNST DU MIR DA MAL BITTE EIN BEISPIEL GEBEN!!!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 26.10.06 00:07 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
var
  Form1: TForm1;
  i:Integer;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  i:=0// Zurücksetzen
  Timer1.Enabled:=True; //Timer anstellen
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Timer1.Interval:=1000//Führe alle sec. etwas aus
  Inc(i); //Hochzählen
  Caption:=IntToStr(i);
  if i =10 then Timer1.Enabled:=False; // Timer ausschalten
end;
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 26.10.06 01:26 
user profile iconGabberman hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
Timer1.Interval := 1000000000;
if ActiveControl <> nil then
    Fortschritt.Position:=0;


Nur irgendwie seh ich trotzdem keinen Progressbar (wird zu schnell gelöscht!!!) :evil:

Wie sollte auch, ich meine dein Timer wird ja erst nach 1000000000 Millisekunden, d.h. 1000000 Sekunden, d.h. 11,5 Tagen das erste Mal aktiv... (Und danach wieder nach derselben Zeit, wenn er nicht deaktiviert wird.)

Ach so: Das ist schon außerhalb des Maximalwerts fürs Intervall, insofern weiß ich nicht, was der Code tatsächlich macht.