Solved

Trigger events

Posted on 1999-01-24
3
161 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

776 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