
03.10.2011, 06:11
|
Прохожий
|
|
Регистрация: 19.08.2011
Сообщения: 28
Репутация: 10
|
|
Чтение файла и ProgressBar
Добрый день.
Файл нормально читается, ProgressBar тоже увеличивается нормально. Но когда ProgressBar полностью заполняется все равно идет считывание файла.
Сама программа:
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
f: File;
i: integer;
Head: array [1..1] of Char;
begin
if openDialog1.Execute then
StatusBar1.SimpleText:= ' Идет обработка файла';
AssignFile(f, Opendialog1.FileName);
Reset(f, 1);
ProgressBar1.position:= 0;
ProgressBar1.max:= round(FileSize(f)*0.019);
i:=1;
while not eof(f) do
begin
BlockRead(f, Head, 1);
inc(i);
ProgressBar1.position:= i;
end;
CloseFile(f);
StatusBar1.SimpleText:= ' Обработка файла закончена';
end;
end.
Последний раз редактировалось royun, 03.10.2011 в 06:45.
|