Page 1 of 1

RTF via TDBRichView

Posted: Tue Apr 17, 2007 4:34 pm
by felisca
Hey,
I have used TRichView->LoadRTF(with path to RTF).
Now I want to use TDBRichView and to get path that stored as string in TClientDataSet .
DataField in TDBRichView throws error if I set string field.

What can I do?
What type is DataField in TDBRichView?

Thanks

P.S. I need it to be autoedit.

Posted: Tue Apr 17, 2007 6:23 pm
by Sergey Tkachenko
I do not understand the question completely, but as for data type for TDBRichView/TDBRichViewEdit, it must be able to contain data of any size.
(Table.FieldByName(...) is TBLOBField) must be True for this field.

If field contains RTF document, it may be a memo field.
But by default, TDBRichViewEdit stores documents in RVF, not RTF (you can change this by modifying FieldFormat property). For RVF documents, the field must be able to store arbitrary binary data.

Posted: Wed Apr 18, 2007 11:36 am
by felisca
I will clarify the question.

I have field that is String type and contains path to RTF file.
Can I load it to TDBRichView without changing String type field to Memo type?

Posted: Wed Apr 18, 2007 3:24 pm
by Sergey Tkachenko
No, TDBRichView assumes that it is linked to TBlobField.
After conversion to memo, you can use LoadCustomFormat event to display RTF files linked from this field:

Code: Select all

procedure TForm1.DBRichView1LoadCustomFormat(Sender: TCustomRichView;
  Stream: TStream; var DoDefault: Boolean);
var s: String;
begin
  Stream.Position := 0;
  SetLength(s, Stream.Size);
  Stream.ReadBuffer(PChar(s)^, Length(s));
  Sender.LoadRTF(s);
  DoDefault := False;
end;

Posted: Wed Apr 18, 2007 5:41 pm
by felisca
And how can I convert RVF to Binary?

Posted: Thu Apr 19, 2007 4:55 am
by Sergey Tkachenko
Sorry, what do you mean?