timesetevent应用例子

  • 格式:doc
  • 大小:26.50 KB
  • 文档页数:2

下载文档原格式

  / 6
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

.cpp

//$$---- Form CPP ----

//---------------------------------------------------------------------------

#include

#include

#pragma hdrstop

#include "u_TimeEvent.h "

//---------------------------------------------------------------------------

#pragma package(s mart_init)

#pragma resource "*.d fm "

TForm1 *Form1;

int Ti meID;

int Ti meAccuracy;

int num = 0;

void __stdcall Ti meCallProc(UINT Ti merID,UINT msg,DWORD dwUser,DWORD a,DWORD b){ TForm1 *eventForm = dynamic_cast (Form1);

String Str;

Str = "Lines ";

Str += "----------------- ";

Str += IntT oStr(++ num);

eventForm-> Log-> Lines-> Add(Str);

}

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TCo mponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::StartClick(TObject *Sender)

{

int Ti meInterval = 1;

TimeID= timeSetEvent(TimeInterval,TimeAccuracy,&TimeCallProc,1,TIME_PERIODIC);

}

//---------------------------------------------------------------------------

void __fastcall TForm1::StopClick(TObject *Sender)

{

timeKillEvent(TimeID);

}

//---------------------------------------------------------------------------

.h

//$$---- Form HDR ----

//---------------------------------------------------------------------------

#ifndef u_TimeEventH

#define u_TimeEventH

//---------------------------------------------------------------------------#include

#include

#include

#include

//---------------------------------------------------------------------------class TForm1 : public TForm

{

__published: // IDE-managed Co mponents

TButton *Start;

TButton *Stop;

TMemo*Log;

void __fastcall StartClick(TObject *Sender);

void __fastcall StopClick(TObject *Sender); private: // User declarations

public: // User declarations

__fastcall TForm1(TCo mponent* Owner);

};

//---------------------------------------------------------------------------extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------#endif

相关主题