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)
How I create borders to pages preview or printed?
-
- Site Admin
- Posts: 17557
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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.
border on preview pages to print
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")
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")
border pages
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;
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;