Hallo NG,
bin neu hier und versuche mich in der Thread Programmierung. Ich habe da auch einige Beiträge bei Euch gelesen und probiert - leider funzt nix.
Auf meinem Form habe ich ein Panel gemacht - zum Testen.
Mein Hauptprogramm:
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:
| unit Test;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Zeit_Thread; type TMain = class(TForm) procedure FormCreate(Sender: TObject); private Zeit: TStatusBarPanelZeit; public end;
type TForm1 = class(TForm) Panel1: TPanel; private public end;
var Form1: TForm1; Main : TMain;
implementation {$R *.dfm}
procedure TMain.FormCreate(Sender: TObject); begin Zeit := TStatusBarPanelZeit.Create(Panel1.Caption); <-------- hier bekomme ich beim Compilieren den Fehler --- undefinierter Bezeichner Panel1 end;
end. |
Mein Unit:
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:
| unit Zeit_Thread;
interface
uses Classes,ExtCtrls;
type TStatusBarPanelZeit = class(TThread) private Panel1: TPanel; procedure UpdatePanel; virtual; protected procedure Execute; override; public Constructor Create(Panel1:TPanel); end;
implementation
uses SysUtils;
constructor TStatusBarPanelZeit.Create; begin Inherited Create(true); Priority:= tpIdle; Resume; end;
procedure TStatusBarPanelZeit.Execute; begin while not terminated do Synchronize(UpdatePanel);end;
procedure TStatusBarPanelZeit.UpdatePanel; begin Panel1.caption:= TimeToStr(now);end;
end. |
Ziel wäre es, auf dem Panel als Thread die Zeit anzuzeigen - ich habe dieses Beispiel hier im Forum gefunden und versucht abzuwandeln - irgenwas mache ich aber falsch.
Kann mir jemand helfen ???
Gruss
Robert