Page 1 of 1

DefaultTabWidth

Posted: Wed Oct 18, 2006 3:46 am
by mphilbrick
Greetings,

Is there any way to set the "DefaultTabWidth" in a TRichView or TppRichView component without using TRuler?

I am loading RTF text into a TppRichView component. If there are tab characters in the document I want it to honor whatever the current default tab setting is in the RTF text (which I can easily obtain).

I did try TRuler with a TRichViewEdit component and set the DefaultTabWidth to 2 inches in code, called Format, and the tab stops were still about 0.5 inches.

Note that custom tab settings come across fine. It is only the default tabs that are the problem.

Michael Philbrick

Posted: Wed Oct 18, 2006 6:57 am
by Sergey Tkachenko
TRVStyle.DefTabWidth

Posted: Thu Oct 19, 2006 11:33 pm
by mphilbrick
Sergey,

Problem partially solved. When I load the RTF into TRichView and set the Style.DefTabWidth the tabs are correct.

However, I then transfer the data from the TRichView component to the TppRichView component and I lose the new default tab settings when the report prints:

procedure TdlgPrintPreview.CopyCustomRVFText(src, dst: TCustomRichView);
var
Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
src.SaveRVFToStream(Stream, False);
Stream.Position := 0;
dst.LoadRVFFromStream(Stream);
Stream.Free;
end;

I attached the same style to the TppRichView instance, attached a new style to the TppRichView instance and set (and verified) the DefTabWidth setting, called TppRichView.Format and nothing seems to help.

What is the solution?

Posted: Fri Oct 20, 2006 4:56 pm
by Sergey Tkachenko
ppRichView uses its own TRVStyle, accessible as ppRichView.RichView.Style.
DefTabWidth is not stored in RVF. So the only option is reassigning ppRichView.RichView.Style.DefTabWidth. Unfortunately, this value will not be stored with ppRichView (you can store it yourself, using ppRichView.RichView.DocProperties)