Page 1 of 1

how to create a dynamic richview object?

Posted: Fri Jan 18, 2008 6:21 am
by li_nummereins
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.

Code: Select all

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;

Posted: Fri Jan 18, 2008 5:40 pm
by Sergey Tkachenko
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.

Thank you very muck

Posted: Sat Jan 19, 2008 10:26 pm
by li_nummereins
I have bean solven it.