Problem with Copying several RV together

General TRichView support forum. Please post your questions here
Post Reply
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Problem with Copying several RV together

Post by dc3_dcfl »

I am attempting to concatenate the contents of several DBRichViewEdits into one RichView and saving the output in RTF.

Each document is correctly formatted in the DBRichViewEdit, but at the end of the process of copying each one, the 1st document copied (in the RV) is incorrectly formatted (most everything is bold and font sizes range throughout the document), 2nd and subsequent documents copied are correctly formatted.

Can you tell me what I should set the Options and RVOptions to for both the DBRichViewEdit and the RichView.

Also, here my code:

Code: Select all

procedure TForm1.Button1Click(Sender:  TObject);

function RVCopy (RVSource, RVDest:  TCustomRichView):  Boolean;
var
  MyStream:  TMemoryStream;
begin
  try
     try
         RVSource.SaveRVFToStream(MyStream, False);
         MyStream.Position := 0;
         Result := RVDest.InsertRVFFromStream(MyStream, RVDest.ItemCount);
         RVDest.FormatTail;
     except
         result := False;
     end;
   finally
      MyStream.Free;   
end;


Query1.First;
while not Query1.EOF do
begin
  if not RVCopy(DBRichViewEdit1, RichView1) then
     messagedlg ('Error', mtError, [mbok], 0)
   Query1.Next;
end;
RichView1.Format;
if SaveDialog1.Execute then
   Richview1.SaveRTF(SaveDialog1.Filename, False)
end;
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Make sure that
1) DBRichView1 and RichView1 are linked with different RVStyle components.
2) Right click DBRichView1 in Delphi, choose "Settings" in the context menu. Make sure that "Allow adding styles dynamically" is selected.
3) The same for RichView1.

PS: Add the line

Code: Select all

result := True
at the beginning of RVCopy. Otherwise, it returns undefined (random) value on success.
dc3_dcfl
Posts: 33
Joined: Sat Jan 30, 2010 12:45 am

Post by dc3_dcfl »

That did it. Thank you again!!!
Post Reply