C++ Builder 中定时器的应用

来源:互联网 发布:人工智能实际应用 编辑:程序博客网 时间:2024/05/17 04:12

        今天,碰到一函数,一直在被调用,但一直找不到调用它的地方,跟踪了一下,原来该函数是定时器回调函数,示例程序如下(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());}//---------------------------------------------------------------------------

 

 

原创粉丝点击