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: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129:
| unit Stoppuhr;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, XPMan, ExtCtrls, Menus, INIFiles;
resourcestring rsTITLE = 'ServiceClock';
const suSOUND_DELAY = 100; type TStoppuhrForm = class(TForm) Timer: TTimer; ZeitLabel: TLabel; startBB: TBitBtn; stopBB: TBitBtn; resetBB: TBitBtn; XPManifest: TXPManifest; MainMenu: TMainMenu; Info1: TMenuItem; About1: TMenuItem; procedure startBBClick(Sender: TObject); procedure stopBBClick(Sender: TObject); procedure TimerTimer(Sender: TObject); procedure resetBBClick(Sender: TObject); procedure About1Click(Sender: TObject); procedure FormCreate(Sender: TObject); private Limit1 : Integer; Limit2 : Integer; StartTime : TDateTime; procedure ResetTimer; protected public published end;
var StoppuhrForm : TStoppuhrForm; notes : array [0..24] of Integer = (261, 277, 294, 311, 330, 350, 371, 393, 417, 440, 466, 494, 524, 555, 589, 624, 660, 700, 742, 786, 833, 880, 933, 989, 1048);
implementation
uses DateUtils;
{$R *.dfm}
procedure TStoppuhrForm.ResetTimer; begin StartTime := Now; ZeitLabel.Caption := '00:00:00'; end;
procedure TStoppuhrForm.startBBClick(Sender: TObject); begin Timer.Enabled := True; stopBB.Enabled := True; resetBB.Enabled := True; startBB.Enabled := False; end;
procedure TStoppuhrForm.stopBBClick(Sender: TObject); begin Timer.Enabled := False; stopBB.Enabled := False; startBB.Enabled := True; end;
procedure TStoppuhrForm.TimerTimer(Sender: TObject);
var Secs : Integer; TimeDiff : TDateTime; timeSECS, timeMIN, timeHOURS : string; begin Secs := SecondsBetween(Now, StartTime); TimeDiff := Now - StartTime;
timeHOURS := IntToStr(HourOf(TimeDiff)); if StrToInt(timeHOURS) < 10 then timeHOURS := '0' + timeHOURS;
timeMIN := IntToStr(MinuteOf(TimeDiff)); if StrToInt(timeMIN) < 10 then timeMIN := '0' + timeMIN;
timeSECS := IntToStr(SecondOf(TimeDiff)); if StrToInt(timeSECS) < 10 then timeSECS := '0' + timeSECS;
ZeitLabel.Caption := timeHOURS + ':' + timeMIN + ':' + timeSECS; Caption := rsTITLE + ' ' + ZeitLabel.Caption; Application.Title := Caption;
if Secs < Limit1 then ZeitLabel.Font.Color := clBlack else if Secs < Limit2 then ZeitLabel.Font.Color := $00acff else ZeitLabel.Font.Color := clRed; end;
procedure TStoppuhrForm.resetBBClick(Sender: TObject); begin ResetTimer; end; |