richview学习之 stream load/save 流保存,读取。

 

 

代码
1 function SaveRVFToField(rv: TCustomRichView; tbl: TTable;
2 const FieldName: String): Boolean;
3  var Stream: TStream;
4  begin
5 Stream := TMemoryStream.Create;
6 try
7 Result := rv.SaveRVFToStream(Stream, False);
8 Stream.Position := 0;
9 TBlobField(tbl.FieldByName(FieldName)).LoadFromStream(Stream);
10 finally
11 Stream.Free;
12 end;
13  end;
14
15 function LoadRVFFromField(rv: TCustomRichView; tbl: TTable;
16 const FieldName: String): Boolean;
17 var Stream: TStream;
18 begin
19 Stream := TMemoryStream.Create;
20 try
21 TBlobField(tbl.FieldByName(FieldName)).SaveToStream(Stream);
22 Stream.Position := 0;
23 Result := rv.LoadRVFFromStream(Stream);
24 finally
25 Stream.Free;
26 end;
27 rv.Format;
28 end;

 

 

 

posted on 2010-03-14 22:22  yxh  阅读(586)  评论(0编辑  收藏  举报