Hier ein kleines Beispiel, welches im einem Panel der Mainform die Uhrzeit und das Datum anzeigt. Benutzt die frei verfügbaren Orpheus-Komponenten (o32sBar), kann aber auch mit jeder anderen kombiniert werden:
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:
| unit sbpZeit;
interface
uses Classes,o32sbar;
type TStatusBarPanelZeit = class(TThread) private Panel: TO32StatusPanel; procedure UpdatePanel; virtual; protected procedure Execute; override; public Constructor Create(aPanel:TO32StatusPanel); end;
TStatusBarPanelDatum = Class(TStatusbarPanelZeit) private procedure UpdatePanel; override; end;
implementation
uses SysUtils;
constructor TStatusBarPanelZeit.Create; begin Inherited Create(true); Panel:=aPanel; Priority:= tpIdle; Resume; end;
procedure TStatusBarPanelZeit.Execute; begin while not terminated do Synchronize(UpdatePanel);end;
procedure TStatusBarPanelZeit.UpdatePanel; begin Panel.Text:= TimeToStr(now);end;
procedure TStatusBarPanelDatum.UpdatePanel; begin Panel.Text:= DateToStr(now);end;
end. |
In deinem Hauptprogramm reicht der Code:
Delphi-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:
| unit Main;
interface type TMain = class(TForm) procedure FormCreate(Sender: TObject); private Zeit: TStatusBarPanelZeit; Datum: TStatusBarPanelDatum; public end;
var Main: TMain;
implementation
procedure TMain.FormCreate(Sender: TObject); begin Zeit := TStatusBarPanelZeit.Create(Statusbar.Panels[2]); Datum:= TStatusBarPanelDatum.Create(Statusbar.Panels[3]); end; |
grez
msch