Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-07

the protected property TCompressionStream.OnProgress

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

闫程远

Hi all!
i wanted to compress a file using TCompressionStream, with a progressbar to show the progress.
i wrote the code but they got Compilation Error:

var
  fs,ms:TMemoryStream;
  cs:TCompressionStream;
  size:int64;
begin
  fs:=TMemoryStream.Create;
  fs.LoadFromFile(SourceFile.Text);
  size:=fs.Size;
  ms:=TMemoryStream.Create;
  ms.Write(size,sizeof(size));
  cs:=TCompressionStream.create(clMax,ms);
  pb.Max:=Integer(size div 1024);
  cs.onProgress:=CsOnProgress;
  fs.SaveToStream(cs);
  cs.Free;
  ms.SaveToFile(DestFile.Text);
  ms.Free;
  fs.Free;
end;
the Error Messages are:
UCryptForm.pas(105,6) Error: identifier idents no member "onProgress"
UCryptForm.pas(105,30) Error: Wrong number of parameters specified for call
to "CsOnprogress"
UCryptForm.pas(63,22) Hint: Found declaration:
TCryptForm.CsOnprogress(TObject);
UCryptForm.pas(198) Fatal: There were 2 errors compiling module, stopping

i searched on the web, and found this page:
http://community.freepascal.org:10000/docs-html/fcl/zstream/tcompressionstream.onprogress.html in this page, the OnProgress property was declared as "public", and on my machine, the property is declared as "protected".

Can anybody tell me why?
Thanks in advance.

Regards, Yan Chengyuan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090710/c49f0b10/attachment.html>

Reply by email

Antônio
to 闫程远

Well, you could derive a class and publish the property.

Ant?nio

2009/7/10 ???

Show quoted text 55 lines
Hi all! i wanted to compress a file using TCompressionStream, with a progressbar to show the progress. i wrote the code but they got Compilation Error: var fs,ms:TMemoryStream; cs:TCompressionStream; size:int64; begin fs:=TMemoryStream.Create; fs.LoadFromFile(SourceFile.Text); size:=fs.Size; ms:=TMemoryStream.Create; ms.Write(size,sizeof(size)); cs:=TCompressionStream.create(clMax,ms); pb.Max:=Integer(size div 1024); cs.onProgress:=CsOnProgress; fs.SaveToStream(cs); cs.Free; ms.SaveToFile(DestFile.Text); ms.Free; fs.Free; end; the Error Messages are: UCryptForm.pas(105,6) Error: identifier idents no member "onProgress" UCryptForm.pas(105,30) Error: Wrong number of parameters specified for call to "CsOnprogress" UCryptForm.pas(63,22) Hint: Found declaration: TCryptForm.CsOnprogress(TObject); UCryptForm.pas(198) Fatal: There were 2 errors compiling module, stopping i searched on the web, and found this page: http://community.freepascal.org:10000/docs-html/fcl/zstream/tcompressionstream.onprogress.html in this page, the OnProgress property was declared as "public", and on my machine, the property is declared as "protected". Can anybody tell me why? Thanks in advance. -- Regards, Yan Chengyuan -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090710/a5e3ccdd/attachment.html>

Reply by email

闫程远
to Antônio

well, that worked. thanks.
but there's still a problem:
when i tried to assign a method to the OnProgress property, i got a error message:

UCryptForm.pas(100,37) Error: Wrong number of parameters specified for call
to "CsOnprogress"
UCryptForm.pas(59,22) Hint: Found declaration:
TCryptForm.CsOnprogress(TObject);
UCryptForm.pas(193, stopping

the method was declared and implemented as follow:

  TCryptForm = class(TForm)
    //... other declarations
    procedure CsOnprogress(Sender:TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
procedure TCryptForm.CsOnProgress(Sender:TObject);
begin
  pb.Position:=Integer(TCompressionStream(Sender).Position div 1024);
  Application.ProcessMessages;
end;
and i assigned the method in this way:
cs.onProgress:=Self.CsOnprogress;

why does this get CE?

2009/7/10 Ant?nio

Show quoted text 69 lines
Well, you could derive a class and publish the property. Ant?nio 2009/7/10 ??? > Hi all! > i wanted to compress a file using TCompressionStream, with a progressbar > to show the progress. > i wrote the code but they got Compilation Error: > > var > fs,ms:TMemoryStream; > cs:TCompressionStream; > size:int64; > begin > fs:=TMemoryStream.Create; > fs.LoadFromFile(SourceFile.Text); > size:=fs.Size; > > ms:=TMemoryStream.Create; > ms.Write(size,sizeof(size)); > > cs:=TCompressionStream.create(clMax,ms); > pb.Max:=Integer(size div 1024); > cs.onProgress:=CsOnProgress; > fs.SaveToStream(cs); > cs.Free; > > ms.SaveToFile(DestFile.Text); > ms.Free; > fs.Free; > end; > > > the Error Messages are: > UCryptForm.pas(105,6) Error: identifier idents no member "onProgress" > UCryptForm.pas(105,30) Error: Wrong number of parameters specified for > call to "CsOnprogress" > UCryptForm.pas(63,22) Hint: Found declaration: > TCryptForm.CsOnprogress(TObject); > UCryptForm.pas(198) Fatal: There were 2 errors compiling module, stopping > > i searched on the web, and found this page: > http://community.freepascal.org:10000/docs-html/fcl/zstream/tcompressionstream.onprogress.html > in this page, the OnProgress property was declared as "public", and on my > machine, the property is declared as "protected". > > Can anybody tell me why? > Thanks in advance. > -- > Regards, > Yan Chengyuan > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus > > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Regards, Yan Chengyuan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090710/64523f6a/attachment.html>

Reply by email

Mattias Gaertner
to 闫程远
Show quoted text 33 lines
well, that worked. thanks. but there's still a problem: when i tried to assign a method to the OnProgress property, i got a error message: UCryptForm.pas(100,37) Error: Wrong number of parameters specified for call to "CsOnprogress" UCryptForm.pas(59,22) Hint: Found declaration: TCryptForm.CsOnprogress(TObject); UCryptForm.pas(193, stopping the method was declared and implemented as follow: TCryptForm = class(TForm) //... other declarations procedure CsOnprogress(Sender:TObject); private { Private declarations } public { Public declarations } end; procedure TCryptForm.CsOnProgress(Sender:TObject); begin pb.Position:=Integer(TCompressionStream(Sender).Position div 1024); Application.ProcessMessages; end; and i assigned the method in this way: cs.onProgress:=Self.CsOnprogress; why does this get CE?

I mode objfpc you must assign the address to the procedure:

;
[...lots of old rubbish...]

Mattias

Reply by email

闫程远
to Mattias Gaertner

Thx!

2009/7/10 Mattias Gaertner

Show quoted text 53 lines
On Fri, 10 Jul 2009 12:38:09 +0800 ??? wrote: > well, that worked. thanks. > but there's still a problem: > when i tried to assign a method to the OnProgress property, i got a > error message: > > UCryptForm.pas(100,37) Error: Wrong number of parameters specified > for call to "CsOnprogress" > UCryptForm.pas(59,22) Hint: Found declaration: > TCryptForm.CsOnprogress(TObject); > UCryptForm.pas(193, stopping > > > the method was declared and implemented as follow: > > TCryptForm = class(TForm) > //... other declarations > procedure CsOnprogress(Sender:TObject); > private > { Private declarations } > public > { Public declarations } > end; > > procedure TCryptForm.CsOnProgress(Sender:TObject); > begin > pb.Position:=Integer(TCompressionStream(Sender).Position div 1024); > Application.ProcessMessages; > end; > > and i assigned the method in this way: > cs.onProgress:=Self.CsOnprogress; > > why does this get CE? I mode objfpc you must assign the address to the procedure: ; >[...lots of old rubbish...] Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Regards, Yan Chengyuan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20090710/9d17b1eb/attachment-0001.html>

Reply by email