FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   Help function ProgressPercent (https://fileforums.com/showthread.php?t=98076)

buttignol 09-08-2016 21:49

Help function ProgressPercent
 
Help function ProgressPercent

I'm trying to use function ProgressPercent

But it works only > LabelPct.Caption: = IntToStr (ProgressPercent) + '%';

I wanted to add + chr (48 + OveralPct mod 10) + '%' '.';

failing to add is not correct (Example: stay like 45.4%)

Can anyone help

Quote:

function ProgressPercent:Integer;
var
pr,i1,i2: Extended;
begin
if (ISDoneProgressBar.Position>ISDoneProgressBar.Min) then begin
i1:=ISDoneProgressBar.Position-ISDoneProgressBar.Min;
i2:=ISDoneProgressBar.Max-ISDoneProgressBar.Min;
pr:=i1*100/i2;
Result:=Round(100*pr/100);;
end;
end;

function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAn siChar): longword;
begin
if OveralPct<=ISDoneProgressBar.Max then
ISDoneProgressBar.Position := OveralPct;

LabelPct.Caption := IntToStr(ProgressPercent)+'.'+chr(48 + OveralPct mod 10)+'%';
LabelCurrFileName.Caption := MinimizePathName(ExpandConstant('{app}\')+CurrentF ile, LabelCurrFileName.Font, LabelCurrFileName.Width);
LabelTime1.Caption := ExpandConstant('{cm:ElapsedTime} ')+TimeStr2;
LabelTime2.Caption := ExpandConstant('{cm:RemainingTime} ')+TimeStr1;
LabelTime3.Caption := ExpandConstant('{cm:AllElapsedTime}')+TimeStr3;
Result := ISDoneCancel;
end;
Thank you

Razor12911 10-08-2016 14:38

Use this

Function FloatToStrDeci(Float: Extended; DeciCount: Integer): String;
Begin
Result:= Format('%.'+IntToStr(DeciCount)+'n', [Float]);
StringChange(Result, ',', ',');
while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = ',')) and (Pos(',', Result) > 0) do
SetLength(Result, Length(Result)-1);
End;

FloatToStrDeci(Float value,The number of decimals you want)

buttignol 10-08-2016 15:54

I can not add

LabelPct.Caption :=

Razor12911 10-08-2016 16:46

Well you have to declare and create one if you can't use the object.


All times are GMT -7. The time now is 23:14.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com