Solved

Trigger events

Posted on 1999-01-24
3
160 Views
Last Modified: 2010-04-06
Hi All,

What's the best way to trigger one event at any 30 minutes
(7:00,7:30,...12:00,12:30 and so on) using TTimer.
Any code or another one component will be welcome.

Regards
Paulo
0
Comment
Question by:sergio_2001
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 1363110
Hi,
i ask this last week :-)
Set your Timer to 1800000
then it will fire every 30 minutes
Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 1363111
here is a prog i did to get a screencapture every 30 minutes:
set timer to 1800000

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  y:Integer;
  x:String;
  implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:=True;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
VAR
DC:HDC;
Bmp:TBitmap ;
begin
Image1.Picture.Free;
Inc(y);
x:=IntToStr(y);
Timer1.Enabled:=False;
DC:=getDC(GetDeskTopWindow);
Bmp:=TBitmap.Create;
Bmp.Width:=Screen.Width;
Bmp.Height:=Screen.Height;
BitBlt(Bmp.Canvas.Handle,0,0,Screen.Width,Screen.Height,DC,0,0,SRCCOPY);
Image1.Picture.Bitmap:=Bmp;
ReleaseDC(DC,DC);
Bmp.Free;
Image1.Picture.SaveToFile('C:\DCSC'+x+'.BMP');
Sleep(5000);
Timer1.Enabled:=True;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
y:=1;
end;

end.
0
 
LVL 1

Expert Comment

by:Oli2
ID: 1363112
Instead of setting the TTimer component's interval to 1800000, you could also set it to
1000 ( one second ) and check the current time.
store the starttime in a var, then check, if the current time is more than 30 minutes past the starttime. if so, do your thing and reinitialize the starttime with the current time, so it will get fired again 30 minutes later.

Greetings, Oli
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now