Solved

Trigger events

Posted on 1999-01-24
3
159 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 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

10 Experts available now in Live!

Get 1:1 Help Now