Article View: borland.public.delphi.language.objectpascal
Article #32492Re: How to use a TProgressBar showing real data?
From: Dan Rhea
Date: Fri, 22 Nov 2002 15:01
Date: Fri, 22 Nov 2002 15:01
51 lines
2524 bytes
2524 bytes
"Rodrigo Pimenta Carvalho" <pimenta@inatel.br> wrote in message
news:3DDCE658.AF38831E@inatel.br...
> Hi.
<snip>
> But, how can I add percent's information (%) to my progress bar, if I
> don't know how many directories exist in the machine?? For example, if
> the machine has just 2 directories, to each one found I would like to
> add 50% to the progress bar. But, I don't know how many directories
> there are.
<snip>
> Rodrigo Pimenta.
>
Hi Rodrigo,
Here's how I handle this... Rather than trying to guess or prescan, I
readjust the max pointer of the progress bar on the fly. It tends to get a
bit more accurate the longer it runs. The important thing it shows the user
is that progress in indeed being made. Pardon the sloppy math below... it's
on my todo list <grin>.
---
prgBar.Max := 100;
prgBar.Position := 0;
{.. findfirst find next loop or recursion}
BlindProgress(prgBar);
{End of loop}
prgBar.Position := prgBar.Max;
---
{Maintain an open ended progress bar}
procedure BlindProgress(Progress: TProgressBar);
var
iPercent:
integer;
begin
iPercent := Trunc((Float(Progress.Position) / Float(Progress.Max)) *
Float(100));
if iPercent >= 95 then
Progress.Max := Progress.Position * 2;
Progress.StepIt;
end;
{Integer to float function}
function Float(iValue: integer): extended;
begin
Result := StrToFloat(IntToStr(iValue));
end;
__________________________
Dan Rhea
Windows Programmer
SIRS Publishing, Inc.
Technical Details
Message-ID:
<3dde46b0@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!208.184.7.66.MISMATCH!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mailReferences:
<3DDCE658.AF38831E@inatel.br>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d30,2cde5f40ba106d6b X-Google-Attributes: gid109d30,public X-Google-ArrivalTime: 2002-11-22 07:16:07 PST From: "Dan Rhea" <danr@sirs.com> Newsgroups: borland.public.delphi.language.objectpascal References: <3DDCE658.AF38831E@inatel.br> Subject: Re: How to use a TProgressBar showing real data? Date: Fri, 22 Nov 2002 10:01:04 -0500 Lines: 54 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 205.162.172.34 Message-ID: <3dde46b0@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1037977264 205.162.172.34 (22 Nov 2002 07:01:04 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!208.184.7.66.MISMATCH!newsfeed1.cidera.com!Cidera!news.uni-x.net!newsgroups.borland.com!not-for-mail