home *** CD-ROM | disk | FTP | other *** search
/ Chip: Shareware for Win 95 / Chip-Shareware-Win95.bin / ostatni / delphi / delphi1 / lmdtoolb.exe / demos / hitimer / unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-09-08  |  3.1 KB  |  138 lines

  1. unit Unit1;
  2.  
  3. {
  4.  Demo-Program for TLMDHiTimer.
  5.  
  6.  This program demonstrates the high resultion capabilities of the TLMDHiTimer-
  7.  component. Here you can get a comparision how often a OnTimer Event is fired.
  8.  By the spinbutton-control you're able to change the number of events which should
  9.  be fired.
  10.  
  11.  This program is freeware. Use it and enjoy!
  12.  If you made any improvements it would be nice to send them to us.
  13.  
  14.  ⌐ 1995 by LMD Innovative
  15.  
  16.  ------------------------------------------------------------------
  17.  History:
  18.  0.01.00 (06.09.95): First Version
  19.  
  20.  Author: RM}
  21.  
  22.  
  23.  
  24.  
  25. interface
  26.  
  27. uses
  28.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  29.   Forms, Dialogs, Lmdappl, lmdtips, Lmddir, Lmdsysin, Lmdabout, StdCtrls,
  30.   Lmdhitim, ExtCtrls, Lmdfile, CtcBase, CtcFBase, CtcFile, Gauges, Spin;
  31.  
  32. type
  33.   TForm1 = class(TForm)
  34.     LMDHiTimer1: TLMDHiTimer;
  35.     Timer1: TTimer;
  36.     Button1: TButton;
  37.     Label1: TLabel;
  38.     Label2: TLabel;
  39.     result1: TLabel;
  40.     result2: TLabel;
  41.     SpinButton1: TSpinButton;
  42.     Label3: TLabel;
  43.     Label4: TLabel;
  44.     procedure LMDHiTimer1Timer(Sender: TObject);
  45.     procedure Timer1Timer(Sender: TObject);
  46.     procedure Button1Click(Sender: TObject);
  47.     procedure FormCreate(Sender: TObject);
  48.     procedure SpinButton1DownClick(Sender: TObject);
  49.     procedure SpinButton1UpClick(Sender: TObject);
  50.   private
  51.     { Private-Deklarationen }
  52.   public
  53.     { Public-Deklarationen }
  54.   end;
  55.  
  56. var
  57.   Form1: TForm1;
  58.   j, k, endvalue:longint;
  59.   start, start2:String;
  60.  
  61. implementation
  62.  
  63. {$R *.DFM}
  64.  
  65. procedure TForm1.LMDHiTimer1Timer(Sender: TObject);
  66. begin
  67.  
  68.   if j=0 then start:=timetostr(now)
  69.   else if j=endvalue then
  70.     begin
  71.       LMDHiTimer1.Enabled:=False;
  72.       result1.caption:='I was hit '+inttostr(j)+' times.'+chr(13)+
  73.                         'starttime: '+start+chr(13)+
  74.                         'endtime:' + timetostr(now);;
  75.     end;
  76.   inc(j);
  77.  
  78. end;
  79.  
  80.  
  81. procedure TForm1.Timer1Timer(Sender: TObject);
  82. begin
  83.  
  84.   if k=0 then start2:=timetostr(now)
  85.   else if k=endvalue then
  86.     begin
  87.       timer1.Enabled:=False;
  88.       result2.caption:='I was hit '+inttostr(k)+' times.'+chr(13)+
  89.                         'starttime: '+start2+chr(13)+
  90.                         'endtime:' + timetostr(now);
  91.       spinbutton1.enabled:=true;
  92.       button1.enabled:=true;
  93.       Screen.cursor:=crDefault;
  94.   end;
  95.   inc(k);
  96.  
  97. end;
  98.  
  99. procedure TForm1.Button1Click(Sender: TObject);
  100. begin
  101.  
  102.   k:=0;j:=0;
  103.   result1.caption:='';
  104.   result2.caption:='';
  105.   button1.enabled:=false;
  106.   spinbutton1.enabled:=false;
  107.   screen.cursor:=crHourglass;
  108.   Timer1.enabled:=true;
  109.   LMDHitimer1.enabled:=true;
  110.  
  111. end;
  112.  
  113. procedure TForm1.FormCreate(Sender: TObject);
  114. begin
  115.  
  116.    endvalue:=100;
  117.    label4.caption:=inttostr(endvalue);
  118.  
  119. end;
  120.  
  121. procedure TForm1.SpinButton1DownClick(Sender: TObject);
  122. begin
  123.  
  124.   if endvalue=10 then exit;
  125.   dec(endvalue,10);
  126.   label4.caption:=inttostr(endvalue);
  127. end;
  128.  
  129. procedure TForm1.SpinButton1UpClick(Sender: TObject);
  130. begin
  131.  
  132.   Inc(endvalue,10);
  133.   label4.caption:=inttostr(endvalue);
  134.  
  135. end;
  136.  
  137. end.
  138.