C++Builder Tips


アプリケーション・IDLE時のイベント


アプリケーションのアイドル時のイベント(OnIde)を処理するときのサンプルです。
//-------------------------------------------------------------------
//  Unit1.h
//-------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE 管理のコンポーネント
  TLabel *Label1;
  void __fastcall FormCreate(TObject *Sender);
private: // ユーザー宣言
public: // ユーザー宣言
  __fastcall TForm1(TComponent* Owner);
  
void __fastcall OnIdle(TObject *Sender,bool &Done);
};

//-------------------------------------------------------------------
//  Unit1.cpp
//-------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  
Application->OnIdle = &OnIdle;
}
//-------------------------------------------------------------------
void __fastcall TForm1::OnIdle(TObject *Sender,bool &Done)
{
  Label1->Caption = Now();
}



DownLoad bcbtips004.lzh 3KB(BCB5)