Тема: Delphi. TTimer
Показать сообщение отдельно
  #3  
Старый 16.04.2012, 13:04
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Цитата:
TTimer
TTimer encapsulates the Windows API timer functions.
Unit
ExtCtrls
Description
TTimer is used to simplify calling the Windows API timer functions SetTimer and KillTimer, and to simplify processing the WM_TIMER messages. Use one timer component for each timer in the application.
The execution of the timer occurs through its OnTimer event. TTimer has an Interval property that determines how often the timer’s OnTimer event occurs. Interval corresponds to the parameter for the Windows API SetTimer function.
Caution: Limitations on the total number of timers system-wide are system dependent.

Purpose
Use the Timer component to trigger an event, either one time or repeatedly, after a measured interval. Write the code that you want to occur at the specified time inside the timer component's OnTimer event.
Tasks
-To specify the amount of elapsed time before the timer event is triggered, use the Interval property.
-To discontinue a timed event, set the timer component's Enabled property to false.
-Displaying a SplashScreen

Displaying a SplashScreen
The following two event handlers display and close a form called SplashScreen before the application's main form opens. The constant Startup is declared in Form1's interface part. The first event handler calls the Show method of SplashScreen from Form1's OnActivate event.

Delphi example

procedure TForm1.FormActivate(Sender: TObject);
begin
if Startup then
begin
Startup := False;
SplashScreen.Show;
end;
end;

SplashScreen contains a Timer component whose Interval property is set to 3000, so the form is displayed for three seconds and then closes. The form's Close method is attached to the timer component's OnTimer event.

Delphi example

procedure TForm2.Timer1Timer(Sender: TObject);

begin
Close;
end;
--------->
__________________
Пишу программы за еду.
__________________
Ответить с цитированием