gauge regressivo?

08/03/2006

0

olá pessoal estou com fonte de copia de arquivo vinculado a um gauge

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

Crcam

Responder

Posts

08/03/2006

Adriano Santos

Não testei, mas acredito que basta você fazer um esquema semelhante a isto:

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;



Responder

08/03/2006

Paullsoftware

você pode usar a mesma regra que usa para chegar no final do Gauge, mais ao invés de fazer:

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:


Responder

08/03/2006

Crcam

Adriano Santos valeu mas infelizmente não deu resultado o gauge fica 0¬ no click...

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


Responder

08/03/2006

Massuda

Não testei mas isso deve funcionar...
totLido := totLido + Numread; 

Gauge1.Progress := Gauge1.maxvalue - 
  trunc(totLido * Gauge1.maxvalue /  filesize(f1));



Responder

08/03/2006

Crcam

Massuda valeu mesmo cara vc resolver o dilema

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;


Responder

08/03/2006

Crcam

vou por o código de backup e restore mas esse esquema so deixa a desejar em uma coisa ele so copia um arquivo somente eu tentei fazer ele copiar usando *.* mas bug o sistema
====================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;


Responder

08/03/2006

Adriano Santos

Pow velho, vlw.
Vou dar uma olhada na rotina com mais calma depois.

[]s


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar