1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| //---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Timer1 = new TTimer(NULL);
Timer1->OnTimer = Timer1Timer;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
static int i = 0;
// juste pour que quelchose bouge
Caption = IntToStr(i);
// après dix secondes, on détruit le timer
if(10 == ++i) {
// C'est la ligne suivante qui me fait peur : a t on le droit
// de détruire le timer dans son propre gestionnaire d'evt ?
delete Timer1;
Timer1 = NULL;
}
}
//--------------------------------------------------------------------------- |
Partager