1 控件System 中的TTimer
打开定时器: Timer1->Enabled = true;
关闭定时器: Timer1 ->Enabled = false;
TTimer的InterVal属性设置定时器的时间
eg:实现字幕滚动
void __fastcall TForm2::FormPaint(TObject *Sender) { Label1->Canvas->TextOut(i, j, "Hello from the canvas"); /*TRect rect; rect.Left = 100; rect.right = 20; rect.Bottom = 500; rect.top = 30; DrawText(Form2->Canvas->Handle,"hello world",12,&rect,1); */ }
void __fastcall TForm2::Label1MouseEnter(TObject *Sender) { //Form2-> Canvas->TextOutA(0,0,"hello world"); Timer1 ->Enabled = false; } //--------------------------------------------------------------------------- void __fastcall TForm2::Label1MouseLeave(TObject *Sender) { //Form2-> Canvas->TextOutA(0,0,""); // MessageBox(Application->Handle,"bb","aa",MB_OK); //Invalidate(); Timer1->Enabled = true; } //--------------------------------------------------------------------------- void __fastcall TForm2::Timer1Timer(TObject *Sender) { i=i+10; //if(i>50) //i = 0; Invalidate(); //SetBkMode(Canvas->Handle,TRANSPARENT); }