• Breaking News

    Panduan dan Tutorial Lengkap serta Materi Pelajaran di Mulyono Blog. Konten Terlengkap dan Terpercaya

    Selasa, 20 September 2011

    Menampilkan jam pada title Bar

    unit Unit1;

    interface

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

    type
      TForm1 = class(TForm)
        Timer1: TTimer;
        Label1: TLabel;
        Button1: TButton;
        procedure Timer1Timer(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;

    var
      Form1: TForm1;
      dc: hDC;

    implementation

    {$R *.dfm}

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      TheTime: array[0..80] of char;
    begin
      StrPCopy(TheTime, TimeToStr(time));
      TextOut(dc, width DIV 2, 5, TheTime, StrLen(TheTime));
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      dc := GetWindowDC(handle);
    end;

    procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      ReleaseDC(handle, dc);
    end;

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    close;
    end;

    end.