首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

为什么Timer在Form中的OnCreate中设置Enabled为true,OnTimer事件里面的代码不起作用,该怎么处理

2012-03-24 
为什么Timer在Form中的OnCreate中设置Enabled为true,OnTimer事件里面的代码不起作用我在Form的OnCreate事

为什么Timer在Form中的OnCreate中设置Enabled为true,OnTimer事件里面的代码不起作用
我在Form的OnCreate事件中设置Timer的Enabled为true,发现OnTimer事件里面的代码不起作用,而如果在窗体显示之后点击按钮设置Timer的Enabled为true,OnTimer事件里面的代码就起作用,这是为什么?

[解决办法]
void __fastcall TForm3::FormCreate(TObject *Sender)
{
Timer1-> Enabled = true;
}
//---------------------------------------
void __fastcall TForm3::Timer1Timer(TObject *Sender)
{
Caption = Now().DateTimeString();
}
//---------------------------------------

这样的代码并没有问题,没有出现你说的错误

热点排行