Page 1 of 1

Margins

Posted: Thu Nov 17, 2005 9:42 pm
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

Posted: Sat Dec 03, 2005 11:05 am
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.

Posted: Sat Dec 03, 2005 11:28 am
by Guest
Thanx Sergey,

I will try that out.

Cheers,
Mark