[Lazarus] the protected property TCompressionStream.OnProgress
闫程远
yanchengyuan at gmail.com
Fri Jul 10 06:38:09 CEST 2009
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 <antoniog12345 at gmail.com>
> Well, you could derive a class and publish the property.
>
> Antônio
>
> 2009/7/10 闫程远 <yanchengyuan at gmail.com>
>
>> 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
>> Lazarus at lists.lazarus.freepascal.org
>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
--
Regards,
Yan Chengyuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20090710/64523f6a/attachment-0004.html>
More information about the Lazarus
mailing list