timesetevent应用例子
- 格式:doc
- 大小:26.50 KB
- 文档页数:2
.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
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