Autor Beitrag
dr. rom4o
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 59


TMT-Pascal, D3 Prof, C++Builder
BeitragVerfasst: Fr 16.09.05 20:29 
Hallo Leute, ich wollte in meinem Programm
die Systemuhrzeit anzeigen lassen hat auch prima geklapt,
doch wenn ich die Maus nicht bewege wird die Zeit nicht
aktuallisiert.
Wie kann man das machen?????????????????
Ich habst schon mit 'Application.ProcessMessages;' probiert geht trotzdem nicht.
hier mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.FormCreate(Sender: TObject);
begin
     Label2.Caption := TimeToStr(Time);

     Application.ProcessMessages;
     canvas.pen.color:=clNavy;
     canvas.brush.color:=clWhite;

     Canvas.Rectangle(10,50,ClientWidth-10,ClientHeight-10);

     //Canvas->MoveTo (0,ClientHeight/2);
     //Canvas->LineTo (ClientWidth,ClientHeight/2);
end;

Ich hoffe es einer ne Lösung. :-(

Moderiert von user profile iconKlabautermann: Code- durch Delphi-Tags ersetzt.

_________________
Sei frei!!! ...doch eigentlich bist du es nie...denn Alles ist determiniert
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Fr 16.09.05 20:35 
Also dafür müsstest Du schon einen Timer verwenden, der dann sagen wir mal pro Sek. die Anzeigeroutine durchläuft. Hast Du schon mal was von der RX Libary gehört, da ist auch eine Uhrzeitkompnente drin.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 16.09.05 23:02 
Was glaubst du, wie oft FormCreate ausgeführt wird? Bonus Frage: Wann wird es ausgefüht? ;)

Millionen-Frage: Wie oft und wann wird also die Uhrzeit in deinem Label aktualisiert?
Raffo
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 300



BeitragVerfasst: Fr 16.09.05 23:12 
Du musst natürlich zuvor eine eigene Proc schreiben und vom Timer dorthin verweisen.
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 17.09.05 01:09 
Luckie hat natürlich recht (FormCreate)...wird nur einmal aufgerufen, danach musst du natürlich die Zeit aktualisieren mit zb. einem Timer.


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 Timer1.Enabled:=true;
 Timer1.Interval:=50;
 Caption := TimeToStr(Time);
end;
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Sa 17.09.05 02:34 
Da könntest du dich jetzt mit objektorientierter Programmierung und mit Threads beschäftigen.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
type
  TTimeSync = class(TThread)
  private
    FLabel: TLabel;
    procedure UpdateVCL;
  public
    procedure Execute; override;
    property TimeLabel: TLabel read FLabel write FLabel;
  end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TTimeSync.Execute;
begin
  while not Terminated do
  begin
    Synchronize(UpdateVCL);
    Sleep(1000);
  end;
end;

procedure TTimeSync.UpdateVCL;
begin
  if Assigned(FLabel) then
    FLabel.Caption := TimeToStr(Now);
end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.FormCreate(Sender: TObject);
begin
  with TTimeSync.Create(True) do
  begin
    FreeOnTerminate := True;
    Priority := tpHigher;
    TimeLabel := Label1;
    Resume;
  end;
end;

_________________
Ciao, Sprint.
dr. rom4o Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 59


TMT-Pascal, D3 Prof, C++Builder
BeitragVerfasst: Sa 17.09.05 09:43 
Titel: ja wunderbar
Hi Leute ich danke euch vielmals.
Ich glaube mit diesen zahlreichen Tips werde ich es schnell schaffen.

Bis zum nächsten Topic. :-)

dr. rom4o

_________________
Sei frei!!! ...doch eigentlich bist du es nie...denn Alles ist determiniert