gauge regressivo?
08/03/2006
0
so que eu tenho de fazer o gauge regredir de 100¬ para 0¬ vou postar o código se alguem tiver alguma ideia ficarei grato
procedure TForm1.btn_restauraClick(Sender: TObject);
begin
totlido := 0;
//verifico a
Destino:= (ExtractFileDir(Application.ExeName)+´\destino\teste.rar´);
Origem:= (ExtractFileDir(Application.ExeName)+´\origem\teste.rar´);
assignfile(f1,Origem);
filemode := 0;
reset(f1,1);
assignfile(f2,Destino);
filemode := 1;
rewrite(f2,1);
Gauge1.maxvalue := 100;
Gauge1.Progress := 100;
Gauge1.MinValue := 0;
repeat
BlockRead(f1, Buf, SizeOf(Buf), NumRead);
BlockWrite(f2, Buf, NumRead, NumWritten);
totLido := totLido + Numread;
Gauge1.Progress :=trunc(filesize(f2) * 100 / filesize(f1));
totlidoint := trunc(totlido);
// eventos
if Gauge1.Progress = 10 then Label1.Visible:= true;;
if Gauge1.Progress = 30 then Label1.Caption:= ´já se foram 30¬´;
if Gauge1.Progress = 50 then Label1.Caption:= ´Metade já foi´;
if Gauge1.Progress = 100 then Label1.Caption:= ´Terminou´;
// fim eventos
Application.ProcessMessages;
until (NumRead = 0) or (NumWritten <> NumRead) ;
closefile(f1);
closefile(f2);
end;
Crcam
Posts
08/03/2006
Adriano Santos
Gauge1.Progress := Gauge1.Progress - (trunc(filesize(f2) * 100 / filesize(f1)));
Posso estar falando besteira.
Vc pode também usar um For..donwto..
for I := 100 downto 0 do begin //comandos necessários end;
08/03/2006
Paullsoftware
Query.Open; Query.Last; Gauge1.Max := Query.RecordCount; Gauge1.Progress := Query.RecordCount; While Not Query.Bof do begin Gauge1.Progress := Gauge1.Progress - 1; Query.Prior; end;
acho que assim também funciona! :wink:
08/03/2006
Crcam
PaullSoftware legal o esquema vou tentar usar em outros projetos mas nesse em questão não estou usando query a copia do arquivo é de pasta p/ pasta
08/03/2006
Massuda
totLido := totLido + Numread; Gauge1.Progress := Gauge1.maxvalue - trunc(totLido * Gauge1.maxvalue / filesize(f1));
08/03/2006
Crcam
fica aqui o codigo corrigido para os irmãozinhos que tiverem as mesma dúvida
procedure TForm1.btn_restauraClick(Sender: TObject);
begin
totlido := 0;
//verifico a
Origem:= (ExtractFileDir(Application.ExeName)+´\destino\gostosa.rar´);
Destino:= (ExtractFileDir(Application.ExeName)+´\origem\gostosa.rar´);
assignfile(f1,Origem);
filemode := 0;
reset(f1,1);
assignfile(f2,Destino);
filemode := 1;
rewrite(f2,1);
Gauge1.maxvalue := 100;
Gauge1.Progress := 100;
repeat
BlockRead(f1, Buf, SizeOf(Buf), NumRead);
BlockWrite(f2, Buf, NumRead, NumWritten);
totLido := totLido + Numread;
Gauge1.Progress := Gauge1.maxvalue - trunc(totLido * Gauge1.maxvalue / filesize(f1));
totlidoint := trunc(totlido);
// eventos
if Gauge1.Progress = 90 then Label1.Visible:= true;;
if Gauge1.Progress = 70 then Label1.Caption:= ´já se foram 30¬´;
if Gauge1.Progress = 50 then Label1.Caption:= ´Metade já foi´;
if Gauge1.Progress = 10 then Label1.Caption:= ´Só Fata 10¬´;
if Gauge1.Progress = 100 then Label1.Caption:= ´Terminou´;
// fim eventos
Application.ProcessMessages;
until (NumRead = 0) or (NumWritten <> NumRead) ;
closefile(f1);
closefile(f2);
end;
08/03/2006
Crcam
====================FONTE=======================
var
Form1: TForm1;
// -------------------
totlido,buf,NumRead,NumWritten,position,totlidoint: integer;
Origem,Destino: string;
F1, F2 : file;
//--------------------
implementation
{$R *.dfm}
//BACKUP--------------------
procedure TForm1.btn_bkpClick(Sender: TObject);
begin
totlido := 0;
//verifico a
Origem:= (ExtractFileDir(Application.ExeName)+´\origem\gostosa.rar´);
Destino:= (ExtractFileDir(Application.ExeName)+´\destino\gostosa.rar´);
assignfile(f1,Origem);
filemode := 0;
reset(f1,1);
assignfile(f2,Destino);
filemode := 1;
rewrite(f2,1);
Gauge1.maxvalue := 100;
Gauge1.Progress := 0;
repeat
BlockRead(f1, Buf, SizeOf(Buf), NumRead);
BlockWrite(f2, Buf, NumRead, NumWritten);
totLido := totLido + Numread;
Gauge1.Progress := trunc(filesize(f2) * 100 / filesize(f1));
totlidoint := trunc(totlido);
// eventos
if Gauge1.Progress = 10 then Label1.Visible:= true;;
if Gauge1.Progress = 30 then Label1.Caption:= ´já se foram 30¬´;
if Gauge1.Progress = 50 then Label1.Caption:= ´Metade já foi´;
if Gauge1.Progress = 100 then Label1.Caption:= ´Terminou´;
// fim eventos
Application.ProcessMessages;
until (NumRead = 0) or (NumWritten <> NumRead) ;
closefile(f1);
closefile(f2);
end;
//RESTORE-------------------------------------------------------
procedure TForm1.btn_restauraClick(Sender: TObject);
begin
totlido := 0;
//verifico a
Origem:= (ExtractFileDir(Application.ExeName)+´\destino\gostosa.rar´);
Destino:= (ExtractFileDir(Application.ExeName)+´\origem\gostosa.rar´);
assignfile(f1,Origem);
filemode := 0;
reset(f1,1);
assignfile(f2,Destino);
filemode := 1;
rewrite(f2,1);
Gauge1.maxvalue := 100;
Gauge1.Progress := 100;
repeat
BlockRead(f1, Buf, SizeOf(Buf), NumRead);
BlockWrite(f2, Buf, NumRead, NumWritten);
totLido := totLido + Numread;
Gauge1.Progress := Gauge1.maxvalue - trunc(totLido * Gauge1.maxvalue / filesize(f1));
totlidoint := trunc(totlido);
// eventos
if Gauge1.Progress = 90 then Label1.Visible:= true;;
if Gauge1.Progress = 70 then Label1.Caption:= ´já se foram 30¬´;
if Gauge1.Progress = 50 then Label1.Caption:= ´Metade já foi´;
if Gauge1.Progress = 10 then Label1.Caption:= ´Só Fata 10¬´;
if Gauge1.Progress = 100 then Label1.Caption:= ´Terminou´;
// fim eventos
Application.ProcessMessages;
until (NumRead = 0) or (NumWritten <> NumRead) ;
closefile(f1);
closefile(f2);
end;
08/03/2006
Adriano Santos
Vou dar uma olhada na rotina com mais calma depois.
[]s
Clique aqui para fazer login e interagir na Comunidade :)