Q
q.yuhen
Unregistered / Unconfirmed
GUEST, unregistred user!
我使用了NMStrmServ作为文件流的接收方。同时
使用一个ProgressBar显示进度。由于NMStrmServ
没有直接提供OnPacketRecvd事件,我使用了下面的
方法,却不起作用,请高手指教。
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String; strm: TStream);
var Stream2:TFileStream;
F:String;
begin
F:='D:/temp/demo.zip';
IF FileExists(F) then DeleteFile(F);
Stream2:=TFileStream.Create(F,fmCreate);
Stream2.CopyFrom(strm, strm.size);
Stream2.Free;
end;
procedure TForm1.PacketRecvd(Sender: TObject);
Begin
ProgressBar1.Max:=NMStrmServ1.BytesTotal;
ProgressBar1.Position:=NMStrmServ1.BytesRecvd;
End;
procedure TForm1.FormCreate(Sender: TObject);
begin
NMStrmServ1.OnPacketRecvd:=PacketRecvd;
end;
使用一个ProgressBar显示进度。由于NMStrmServ
没有直接提供OnPacketRecvd事件,我使用了下面的
方法,却不起作用,请高手指教。
procedure TForm1.NMStrmServ1MSG(Sender: TComponent; const sFrom: String; strm: TStream);
var Stream2:TFileStream;
F:String;
begin
F:='D:/temp/demo.zip';
IF FileExists(F) then DeleteFile(F);
Stream2:=TFileStream.Create(F,fmCreate);
Stream2.CopyFrom(strm, strm.size);
Stream2.Free;
end;
procedure TForm1.PacketRecvd(Sender: TObject);
Begin
ProgressBar1.Max:=NMStrmServ1.BytesTotal;
ProgressBar1.Position:=NMStrmServ1.BytesRecvd;
End;
procedure TForm1.FormCreate(Sender: TObject);
begin
NMStrmServ1.OnPacketRecvd:=PacketRecvd;
end;