Форум по Delphi программированию

Delphi Sources



Вернуться   Форум по Delphi программированию > Все о Delphi > [ "Начинающим" ]
Ник
Пароль
Регистрация <<         Правила форума         >> FAQ Пользователи Календарь Поиск Сообщения за сегодня Все разделы прочитаны

Ответ
 
Опции темы Поиск в этой теме Опции просмотра
  #1  
Старый 16.04.2012, 12:00
allod26 allod26 вне форума
Прохожий
 
Регистрация: 14.04.2012
Сообщения: 3
Репутация: 10
По умолчанию Delphi. TTimer

Расскажите, как работать с таймером в Delphi.

Если я в интервале задам 50. И вот так запишу:


Код:
Timer1.Enabled:=True;

.........................................
PaintBox1.Canvas.Rectangle...
PaintBox1.Canvas.MoveTo...
PaintBox1.Canvas.LineTo...
......................................
// и т.д.

Timer1.Enabled:=False;


оно ведь не сработает?

нужно, что бы картинки выводились с задержкой
Ответить с цитированием
  #2  
Старый 16.04.2012, 12:38
Pyro Pyro вне форума
Так проходящий
 
Регистрация: 18.07.2011
Сообщения: 805
Версия Delphi: 7Lite
Репутация: 6063
По умолчанию

Код:
PaintBox1.Canvas.Rectangle...
sleep(1000);
PaintBox1.Canvas.MoveTo...
sleep(1000);
PaintBox1.Canvas.LineTo.
Ответить с цитированием
  #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;
--------->
__________________
Пишу программы за еду.
__________________
Ответить с цитированием
  #4  
Старый 16.04.2012, 15:49
icWasya icWasya вне форума
Местный
 
Регистрация: 09.11.2010
Сообщения: 499
Репутация: 10
По умолчанию

Код:
procedure Form1.Button1Click(Sender:TObject);
begin
  Timer1.Enabled:=True;
end;

procedure Form1.Button2Click(Sender:TObject);
begin
  Timer1.Enabled:=false;
end;

procedure Form1.Timer1OnTimer(Sender:TObject);
begin
  PaintBox1.Invalidate;
end;

procedure Form1.PaintBox1OnPaint(Sender:TObject);
begin
.........................................
PaintBox1.Canvas.Rectangle...
PaintBox1.Canvas.MoveTo...
PaintBox1.Canvas.LineTo...
......................................
// и т.д.
end;
А если надо что бы картинки менялись, то внутри PaintBox1OnPaint нужно выбирать, какую картинку и где рисовать, а внутри Timer1OnTimer увеличивать номер картинки
Ответить с цитированием
Ответ


Delphi Sources

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB-коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход


Часовой пояс GMT +3, время: 06:47.


 

Сайт

Форум

FAQ

Соглашения

Прочее

 

Copyright © Форум "Delphi Sources" by BrokenByte Software, 2004-2025