Board index » cppbuilder » Percent Label for a ProgressBar...
Oren Halvani
![]() CBuilder Developer |
Percent Label for a ProgressBar...2004-10-12 01:34:54 AM cppbuilder0 hi dear builders, i would like to show a Label near my ProgressBar that shows how many percent of the work has left since the function began.. so i tried the following: Percent = frmMainUnit->Progress->Max * (pos / 100); frmMainUnit->Caption = IntToStr(Percent) + " % finshed.."; but the value i get ist endlesssssssss :-) what do i do wrong..? here's the full code: /************************************************************/ void __fastcall ReplaceStrings(const String &a, const String &b, TRichEdit *re) { frmMainUnit->Progress->Position = 0; frmMainUnit->Progress->Max = re->GetTextLen(); int Percent; TSearchTypes options; re->Lines->BeginUpdate(); Screen->Cursor = crHourGlass; try { int pos = re->FindText(a, 0, re->GetTextLen(), options); while(pos != -1) { re->SelStart = pos; re->SelLength = a.Length(); re->SelText = b; frmMainUnit->Progress->Position = pos; frmMainUnit->Progress->Update(); Percent = frmMainUnit->Progress->Max * (frmMainUnit->Progress->Position / 100); frmMainUnit->Caption = IntToStr(Percent) + " % finshed.."; Application->ProcessMessages(); pos += b.Length(); pos = re->FindText(a, pos, re->GetTextLen()-pos, options); } } __finally { re->Lines->EndUpdate(); frmMainUnit->Progress->Position = 0; Screen->Cursor = crDefault; } } void __fastcall TfrmMainUnit::Button1Click(TObject *Sender) { ReplaceStrings("a", "-----", re); } /************************************************************/ thanks for any hints on this.. Oren Halvani |