//调用线程的窗体头文件
class TForm1 : public TForm
{
__published: // IDE-managed Components
TButton *Button1;
TTimer *Timer1;
void __fastcall Button1Click(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
TProThead *Pt;
TModelThread *Tmod;
};
//实现
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled = true ;
Tmod = new TModelThread(false);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(Tmod)
Tmod->Terminate() ;
Action = caFree ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
if(ProgressBar1->Position < ProgressBar1->Max)
{
ProgressBar1->StepIt();
}
else
{
Timer1->Enabled = false ;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ProgressBar1->Position = 0 ;
ProgressBar1->Step = 10 ;
Timer1->Interval = 3000;
}
//---------------------------------------------------------------------------