RAD Studio VCL Reference
|
Determines the amount of time, in milliseconds, that passes before the timer component initiates another OnTimer event.
property Interval: Cardinal;
__property unsigned Interval;
Interval determines how frequently the OnTimer event occurs. Each time the specified interval passes, the OnTimer event occurs.
Use Interval to specify any cardinal value as the interval between OnTimer events. The default value is 1000 (one second).
C++ Examples:
/* Place a TTimer object in the form and enter Timer1Timer in the OnTimer event. Place other controls in the form and change the active control at runtime. The following event handler responds to timer events by moving the active control one pixel to the right every 100 miliseconds: */ void __fastcall TForm1::Timer1Timer(TObject *Sender) { Timer1->Interval = 100; if (ActiveControl) ActiveControl->Left = ActiveControl->Left + 1; }
/* This code uses a button, a timer and a maskedit on a form. When the user clicks the button, the form disappears for the period of time specified in the Interval property of the timer control, then the form reappears: */ void __fastcall TForm1::Button1Click(TObject *Sender) { Timer1->Interval = StrToInt(MaskEdit1->Text); Timer1->Enabled = true; Hide(); } void __fastcall TForm1::Timer1Timer(TObject *Sender) { Visible = true; Timer1->Enabled = false; }
/* This example uses a timer on a form. When the application runs and the user minimizes the application, the timer starts and the application returns to its normal size when an OnTimer event occurs. The timer then shuts down until the next time the form is minimized. Be sure to declare the AppStartTimer method as a public method of TForm1. Place a TTimer object in the form and enter Timer1Timer in the OnTimer event. */ void __fastcall TForm1::FormCreate(TObject *Sender) { Application->OnMinimize = AppStartTimer; Timer1->Interval = 1000; } void __fastcall TForm1::AppStartTimer(TObject *Sender) { Timer1->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { Application->Restore(); Timer1->Enabled = false; }
Delphi Examples:
{ Place a TTimer object in the form and enter Timer1Timer in the OnTimer event. Place other controls in the form and change the active control at runtime. The following event handler responds to timer events by moving the active control one pixel to the right every 100 miliseconds: } procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.Interval := 100; if ActiveControl <> nil then ActiveControl.Left := ActiveControl.Left + 1; end;
{ This code uses a button, a timer and a maskedit on a form. When the user clicks the button, the form disappears for the period of time specified in the Interval property of the timer control, then the form reappears: } procedure TForm1.Button1Click(Sender: TObject); begin Timer1.Interval := StrtoInt(MaskEdit1.Text); Timer1.Enabled := True; Hide; end; procedure TForm1.Timer1Timer(Sender: TObject); begin Visible := True; Timer1.Enabled := False; end;
{ This example uses a timer on a form. When the application runs and the user minimizes the application, the timer starts and the application returns to its normal size when an OnTimer event occurs. The timer then shuts down until the next time the form is minimized. Be sure to declare the AppStartTimer method as a public method of TForm1. Place a TTimer object in the form and enter Timer1Timer in the OnTimer event. } procedure TForm1.FormCreate(Sender: TObject); begin Application.OnMinimize := AppStartTimer; end; procedure TForm1.AppStartTimer(Sender: TObject); begin Timer1.Enabled := True; end; procedure TForm1.Timer1Timer(Sender: TObject); begin Application.Restore; Timer1.Enabled := False; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|