Solved

Label changing part 2

Posted on 1998-03-14
5
160 Views
Last Modified: 2010-04-06
Will you give me an EXAMPLE please,  on displaying a new text on a label  every 24 hrs with the aid of a TTimer.
In particular, give an example of a written  OnTImer eventhandler that updates the label caption every 24hrs.

p.s.  Isn't this really easier than 50 points?
0
Comment
Question by:jjhj
  • 2
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
rene100 earned 50 total points
ID: 1360503
try this (I haven't tested this for 24 hours, just for 1 minute)



unit Unit1;

interface

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

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

var
  Form1: TForm1;
  PassedTime: Cardinal;
implementation

{$R *.DFM}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(PassedTime); //every minute
if PassedTime=1440 then //after 24 hours (60 * 24);
   begin
   MessageDlg('24 hours passed',mtInformation,[mbok],0);
   label1.caption:='24 hours passed';
   //Here, you can restart this with
   //TimePassed:=0;
end;

procedure TForm1.btStartClick(Sender: TObject);
begin
timer1.interval:=60000; //Sets interval of timer1 to 60000 ms
                        //=1 minute
end;

end.
0
 
LVL 1

Expert Comment

by:pjdb
ID: 1360504
If it is in a 32bits program, i think you can give a timer interval of 86400000 (24*60*60*1000) and have your timer working once a day. However, in 16 bits (delphi 1) it will give an overflow.

JDB
0
 

Author Comment

by:jjhj
ID: 1360505
rene 100

you did a great job!  
if i had extra points to spare i would give em,   however...

thanks bunches, loads , tons, greatly,immensly,weightily,
countlessly,,hugely,                 and frankly    alot.

jjhj
0
 

Author Comment

by:jjhj
ID: 1360506
rene 100

you did a great job!  
if i had extra points to spare i would give em,   however...

thanks bunches, loads , tons, greatly,immensly,weightily,
countlessly,,hugely,                 and frankly    alot.

jjhj
0
 
LVL 2

Expert Comment

by:rene100
ID: 1360507
thanks for the nice comment!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question