读书人

新手有关问题

发布时间: 2012-04-03 12:38:19 作者: rapoo

新手问题
大家好想请教下,我想实现个当程序一分钟内没有人点Form就跳个新的Form,如果有人点击过就不触发新的Form;

C/C++ code
void __fastcall TForm1::tmr1Timer(TObject *Sender){ TForm2 *form2=new  TForm2(this); form2->ShowModal(); delete  form2;}//---------------------------------------void __fastcall TForm1::FormCreate(TObject *Sender){     tmr1->Interval=60000;     tmr1->Enabled=true;}//---------------------------------------void __fastcall TForm1::FormClick(TObject *Sender){                tmr1->Enabled=false;}

大侠们帮我看看怎么改啊

[解决办法]
C/C++ code
void __fastcall TForm1::tmr1Timer(TObject *Sender){tmr1->Enabled=false; TForm2 *form2=new  TForm2(this); form2->ShowModal(); delete  form2;tmr1->Enabled=true;}
[解决办法]
测试了可以实现
C/C++ code
//---------------------------------------#include <vcl.h>#pragma hdrstop#include "Unit1.h"//---------------------------------------#pragma package(smart_init)#pragma resource "*.dfm"TForm1 *Form1;TDateTime dt;//---------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)        : TForm(Owner){}//---------------------------------------void __fastcall TForm1::Timer1Timer(TObject *Sender){ if((double)(Now()-dt)>=1.0/(24*60))   {    TForm *f=new TForm(this);    f->Show() ;    }}//---------------------------------------void __fastcall TForm1::FormCreate(TObject *Sender){  Timer1->Interval=1000;  dt=Now();}//---------------------------------------void __fastcall TForm1::FormClick(TObject *Sender){  dt=Now();}//--------------------------------------- 

读书人网 >C++ Builder

热点推荐