How I create borders to pages preview or printed?

General TRichView support forum. Please post your questions here
Post Reply
RobertoVG
Posts: 40
Joined: Fri Mar 15, 2013 8:35 pm

How I create borders to pages preview or printed?

Post by RobertoVG »

How I create borders pages?
(I not found an example or property ready for use)

if i use the properties:
SRichViewEdit,ViewProperty.MarginsRectVisible
SRichViewEdit,ViewProperty.MarginsPen
in edit mode, when is set to preview or print the border disappear.

(in other applications in the form of set usually comprises border page left, right, top, bottom separately)
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

The only solution is drawing this border yourself.

In ScaleRichView, you can use TSRichViewEdit.OnPaintPage event.
This event has the full page rectangle as a parameter PageRect. To get margins, use SRichViewEdit.TopMargin100Pix and so on.
For example, the top line Y coordinate is PageRect.Top + SRichViewEdit1.TopMargin100Pix

You can distinguish drawing in TSRichViewEdit and printing using Printing: Boolean parameter of this event.
Another useful parameter – Prepaint: Boolean. This event is called twice: before drawing page content (Prepaint=True) and after (False). Use this parameter to draw only one time, either before or after.
RobertoVG
Posts: 40
Joined: Fri Mar 15, 2013 8:35 pm

border on preview pages to print

Post by RobertoVG »

In EditMode on event onPaint i draw retangle (border) ok.

In preview mode, the onPaint is executed once

But

when i alter to preview, (srvvmPreviewMode) using srvActionsResource.srvActionPreview1 the
event onPaint (SRichViewEdit) is executed but the retangle that drawing in editMode disappears! Why ?

(this contradicts what you said "by default, these drawing will be both on screen and on paper/preview")
RobertoVG
Posts: 40
Joined: Fri Mar 15, 2013 8:35 pm

border pages

Post by RobertoVG »

Please disregard the previous message.Sorry.

I had understood incorrect event (onPaint).

Now I understand that the correct event is onPaintPage as follows and this word.
. . . .

procedure TFormEditor.SRichViewEdit1PaintPage(Sender: TObject;
PageNo: Integer; PageRect, R: TRect; Canvas: TCanvas; Prepaint,
Printing: Boolean);
begin
if Prepaint then
exit;
with Canvas do begin
Brush.Style := bsClear;

pen.Width := 2;//BorderWidth;
pen.Color := clBlack;//BorderColor;

rectangle( PageRect.Left+30,PageRect.Top+30,
PageRect.Right-30, PageRect.Bottom-30);

end


end;
Post Reply