Değişik Bir Saat Uygulaması

Paket programlarınızın tanıtımını bu forumda yapabilirsiniz. Bu foruma soru sormayın!
Cevapla
ercanskose
Üye
Mesajlar: 62
Kayıt: 18 Eyl 2011 02:31

Değişik Bir Saat Uygulaması

Mesaj gönderen ercanskose »

Arkadaşlar can sıkıntısından değişik bir saat uygulaması yaptım. kaynak dosyalarınıda gönderiyorum işine yarayan olursa geliştirebilir. Devexpress component yüklü olması gerekir.

Resim
Dosya ekleri
digi_saat.rar
(46.25 KiB) 166 kere indirildi
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4740
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: Değişik Bir Saat Uygulaması

Mesaj gönderen mrmarman »

Güzel bir çalışma..

Sadece matematiksel fonksiyonlar ile daha kısa kod yükü ile halledilebilir olduğuna bir örnek ile destek vereyim.

Yukarıdan aşağıya Label'lar
Resim

Resim

Kod: Tümünü seç

Uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
Var
  i : Integer;
begin
  // 01..03 Saat   Onlar  Hanesi
  // 04..13 Saat   Birler Hanesi
  // 14..23 Dakika Onlar  Hanesi
  // 24..33 Dakika Birler Hanesi
  // 34..39 Saniye Onlar  Hanesi
  // 40..49 Saniye Birler Hanesi
  for i := 1 to 49 do
    case i of
    01..03: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-01);
    04..13: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-04);
    14..23: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-14);
    24..33: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-24);
    34..39: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-34);
    40..49: TLabel(Self.FindComponent('label' + IntToStr(i))).Caption := IntToStr(i-40);
    end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
Var
  i : Integer;
  s : TTime;
begin
  // 01..03 Saat   Onlar  Hanesi
  // 04..13 Saat   Birler Hanesi
  // 14..23 Dakika Onlar  Hanesi
  // 24..33 Dakika Birler Hanesi
  // 34..39 Saniye Onlar  Hanesi
  // 40..49 Saniye Birler Hanesi
  for i := 1 to 49
    do TLabel(Self.FindComponent('label' + IntToStr(i))).Font.Style := [];
  s := Time();
  Caption := TimeToStr(s);
  // Örneğin 22:01:15
  i := HourOf(s) div 10; // 2
  TLabel(Self.FindComponent('label' + IntToStr(i+01))).Font.Style := [fsBold];
  i := HourOf(s) - ( (HourOf(s) div 10)*10 ); // 2
  TLabel(Self.FindComponent('label' + IntToStr(i+04))).Font.Style := [fsBold];

  i := MinuteOf(s) div 10; //0
  TLabel(Self.FindComponent('label' + IntToStr(i+14))).Font.Style := [fsBold];
  i := MinuteOf(s) - ( (MinuteOf(s) div 10)*10 ); // 1
  TLabel(Self.FindComponent('label' + IntToStr(i+24))).Font.Style := [fsBold];

  i := SecondOf(s) div 10; //1
  TLabel(Self.FindComponent('label' + IntToStr(i+34))).Font.Style := [fsBold];
  i := SecondOf(s) - ( (SecondOf(s) div 10)*10 ); // 5
  TLabel(Self.FindComponent('label' + IntToStr(i+40))).Font.Style := [fsBold];
end;
veya Matematikle işim olmaz derseniz, String operasyonlar ile olan hali..

Kod: Tümünü seç

procedure TForm1.Timer1Timer(Sender: TObject);
Var
  i : Integer;
  s : TTime;
begin
  // 01..03 Saat   Onlar  Hanesi
  // 04..13 Saat   Birler Hanesi
  // 14..23 Dakika Onlar  Hanesi
  // 24..33 Dakika Birler Hanesi
  // 34..39 Saniye Onlar  Hanesi
  // 40..49 Saniye Birler Hanesi
  for i := 1 to 49
    do TLabel(Self.FindComponent('label' + IntToStr(i))).Font.Style := [];
  s := Time();
  Caption := TimeToStr(s);
  // Örneğin 22:01:15
  i := StrToInt(Copy(Caption, 1, 1)); // 2
  TLabel(Self.FindComponent('label' + IntToStr(i+01))).Font.Style := [fsBold];
  i := StrToInt(Copy(Caption, 2, 1)); // 2
  TLabel(Self.FindComponent('label' + IntToStr(i+04))).Font.Style := [fsBold];

  i := StrToInt(Copy(Caption, 4, 1)); //0
  TLabel(Self.FindComponent('label' + IntToStr(i+14))).Font.Style := [fsBold];
  i := StrToInt(Copy(Caption, 5, 1));; // 1
  TLabel(Self.FindComponent('label' + IntToStr(i+24))).Font.Style := [fsBold];

  i := StrToInt(Copy(Caption, 7, 1));; //1
  TLabel(Self.FindComponent('label' + IntToStr(i+34))).Font.Style := [fsBold];
  i := StrToInt(Copy(Caption, 8, 1));; // 5
  TLabel(Self.FindComponent('label' + IntToStr(i+40))).Font.Style := [fsBold];
end;
Resim
Resim ....Resim
ercanskose
Üye
Mesajlar: 62
Kayıt: 18 Eyl 2011 02:31

Re: Değişik Bir Saat Uygulaması

Mesaj gönderen ercanskose »

Güzel yöntem tşk arkadaşım
Cevapla