Wednesday, February 11, 2009

Tampilkan Waktu di Delphi

Beberapa waktu lalu aku sempat mikir bisa gak ya kLo misal pacarku yang bernama "Compaq Presario C700... :) " tidur (baca:ShutDown) secara otomatis kLo aku udah tidur berdasarkan waktu yang aku set dulu, beberapa saat berpikir (ciee...) aku simpulkan kLo aku mesti cari dulu gimana script buat tampilkan waktu dulu, yang akhirnya setelah beberapa saat berpusing ria akhirnya dapat juga tuch script,,, gini nih scriptnya :

unit Ujam;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons;

type
TForm1 = class(TForm)
Timer1: TTimer;
lTime: TLabel;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}


{------start of fungsi tampilkan waktu------}

procedure TForm1.Timer1Timer(Sender: TObject);
var
DateTime : TDateTime;
str : string;
begin
DateTime := Time; // store the current date and time
str := TimeToStr(DateTime); // convert the time into a string
{ Note This could have been done with the following line of code:
Caption := TimeToStr(Time); }
lTime.Caption := str; //display time to label
end;

{------end of fungsi tampilkan waktu------}




end.

di Form ini aku gunakan satu buah komponen Timer dan satu buah komponen label yang aku beri nama lTime.
Tapi sayangnya aku belum ketemu script buat shutdown,,,,
kLo mungkin temen2 ada yang punya bisa sharing doNk,,, contact emailQ di ardi_nix@yahoo.co.id

2 comments:

Ahmad Helmy said...

Weh IT bgt skarang TUS!

Te eN Te said...

gak gitu Dhe,,masalah'e isone yo mung iku tok,,, juga pengen sharing knowledge yg cuma dikit ini...