I need to judge that a rvf's stream contains the special tag which I set.So, I create a dynamic richview object and create a instance to do it.But, there are errors in my program.
function PipisheUtil.judgeRVSTREAMIsNull(rvStream: TStream): Boolean;
var
tempRV: TRichView;
tempStream:TStream;
begin
try
tempRV := TRichView.Create(nil);
tempStream:=TMemoryStream.Create;
tempStream.CopyFrom(rvStream,0);
tempStream.Position:=0; //add this ,the IDE show error
tempRV.LoadRVFFromStream(tempStream);
tempRV.Format;
if (tempStream.Size<1) or (judgeRVIsNull(tempRV)) then
begin
Result := True;
end
else
begin
Result := False;
end;
finally
tempRV.Free;
tempStream.Free;
end;
end;
First, tempRV.Style must be assigned. You can create TRVStyle component in the same procedure.
Next, if you call Format or save RTF, you need to assign tempRV.Parent. Assign some form to it. If you do not want to show tempRV, set tempRV.Visible := False. If you do not have forms in your application, create a form without showing it in the same procedure.