今天,碰到一函数,一直在被调用,但一直找不到调用它的地方,跟踪了一下,原来该函数是定时器回调函数,示例程序如下(Timer1Timer是定时器回调函数):
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
int __fastcall TForm1::MyFun()
{
static int i = 0;
return ++i;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Label1->Caption = IntToStr(MyFun());
}
//---------------------------------------------------------------------------