RTF via TDBRichView

General TRichView support forum. Please post your questions here
Post Reply
felisca
Posts: 3
Joined: Mon Apr 16, 2007 3:20 pm

RTF via TDBRichView

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
felisca
Posts: 3
Joined: Mon Apr 16, 2007 3:20 pm

Post 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?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
felisca
Posts: 3
Joined: Mon Apr 16, 2007 3:20 pm

Post by felisca »

And how can I convert RVF to Binary?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, what do you mean?
Post Reply