Margins

General TRichView support forum. Please post your questions here
Post Reply
mbailey
Posts: 14
Joined: Tue Oct 11, 2005 5:55 am
Location: Perth, Western Australia

Margins

Post by mbailey »

Hi,

I know how to dipslay margins in the Previewer with different pen types etc, but, is it possible to achieve the same effect or similar in the Editor.

TIA

Mark Bailey
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry, I missed this question.
Editor has LeftMargin, TopMargin, RightMargin, BottomMargin. They can be shown using OnPaint event.
In addition to them, TRVPrint has LeftMarginMM, TopMarginMM, RightMarginMM, BottomMarginMM (see the sheme in the help topic about TRVPrint). They canot be shown in editor because editor does not have these margins.

Code showing left and right margins in editor:

Code: Select all

procedure TForm1.rvePaint(Sender: TCustomRichView; Canvas: TCanvas;
  Prepaint: Boolean);
var x: Integer;
begin

  Canvas.Pen.Style := psDot;
  Canvas.Pen.Width := 1;
  Canvas.Pen.Color := clBtnShadow;

  x := Sender.LeftMargin-Sender.HScrollPos;

  Canvas.MoveTo(x, 0);
  Canvas.LineTo(x, Sender.Height);

  inc(x,Sender.RVData.TextWidth);

  Canvas.MoveTo(x, 0);
  Canvas.LineTo(x, Sender.Height);

  Canvas.Pen.Color := clBlack;
  Canvas.Pen.Style := psSolid;
  inc(x, Sender.RightMargin);

  Canvas.MoveTo(x, 0);
  Canvas.LineTo(x, Sender.Height);
end;
This code draws 3 vertical lines.
2 gray dotted lines show margins.
Black line shows the right border of the document. It should be visible only if the document width is limited by MaxTextWidth property.
Guest

Post by Guest »

Thanx Sergey,

I will try that out.

Cheers,
Mark
Post Reply