www.pudn.com > Producer&cusuom.rar > UnitStreadProduct.cpp
//--------------------------------------------------------------------------- #include#include "unit1.h" #pragma hdrstop #include "UnitStreadProduct.h" #pragma package(smart_init) //--------------------------------------------------------------------------- // Important: Methods and properties of objects in VCL can only be // used in a method called using Synchronize, for example: // // Synchronize(UpdateCaption); // // where UpdateCaption could look like: // // void __fastcall Unit2::UpdateCaption() // { // Form1->Caption = "Updated in a thread"; // } //--------------------------------------------------------------------------- __fastcall TStreamProduct::TStreamProduct(bool CreateSuspended) : TThread(CreateSuspended) { FreeOnTerminate=true; Count=0; TPB=NULL; TB=NULL; TE=NULL; } //--------------------------------------------------------------------------- void __fastcall TStreamProduct::Execute() { if(!Terminated) { DoWork(); //Synchronize(DoWork); //TQ->Acquire(); TB->Caption="¹ÒÆð"; TB->Enabled=false; TE->Text=IntToStr(StrToInt(TE->Text)+1); //TQ->Release(); } } //--------------------------------------------------------------------------- void __fastcall TStreamProduct::InitStread(TProgressBar *Proces,TButton *But,TEdit *edit) { TPB=Proces; TB=But; TE=edit; Count=0; } void __fastcall TStreamProduct::DoWork() { for(Count=0;Count<700;Count++) { Sleep(1); if(TPB->Position Max) { TPB->StepIt(); } } TPB->Position=0; }