Page 1 of 1

Problem with Copying several RV together

Posted: Thu Feb 04, 2010 4:06 pm
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;

Posted: Thu Feb 04, 2010 4:43 pm
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.

Posted: Thu Feb 04, 2010 5:04 pm
by dc3_dcfl
That did it. Thank you again!!!