how to insert line?
how to insert line?
hi sergey
how to put this line at the end of the text according to the space remaining to end the page?
how to put this line at the end of the text according to the space remaining to end the page?
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
It is only possible by custom drawing in OnPaintPage event.
The most similar demos are in Demos\CustomDraw\Rectangles folder.
I assume you need to draw it only for the last page.
This event has the page coordinate in parameters: PageRect.
Line coordinates:
Left: PageRect.Left+SRV.LeftMargin100Pix
Right: PageRect.Right - SRV.RightMargin100Pix;
Bottom: PageRect.Bottom - SRV.BottomMargin100Pix;
Top:
Use SRV.GetItemBounds100 to get coordinates of the last item (index = SRV.RichViewEdit.ItemCount-1) relative to the page, and add PageRect.Top, like in the demo mentioned above.
The most similar demos are in Demos\CustomDraw\Rectangles folder.
I assume you need to draw it only for the last page.
This event has the page coordinate in parameters: PageRect.
Line coordinates:
Left: PageRect.Left+SRV.LeftMargin100Pix
Right: PageRect.Right - SRV.RightMargin100Pix;
Bottom: PageRect.Bottom - SRV.BottomMargin100Pix;
Top:
Use SRV.GetItemBounds100 to get coordinates of the last item (index = SRV.RichViewEdit.ItemCount-1) relative to the page, and add PageRect.Top, like in the demo mentioned above.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
The code in OnPaint is:
Unfortunately, there is a problem. When you edit text, the component redraws only changed area. So, if document height is changed while editing, this line is not redrawn, or redrawn only partially.
A solution is calling UpdateBuffer in OnChange:
But it means double redrawing on any change.
Code: Select all
procedure TForm3.SRichViewEdit1PaintPage(Sender: TObject; PageNo: Integer;
PageRect, R: TRect; Canvas: TCanvas; Prepaint, Printing: Boolean);
var srv: TSRichViewEdit;
pt: TPoint;
FirstPageNo, LastPageNo: Integer;
ItemRect: TRect;
begin
srv := Sender as TSRichViewEdit;
if Prepaint or (PageNo<srv.PageCount) then
exit;
pt.X := PageRect.Left + srv.LeftMargin100Pix;
srv.GetItemBounds100(srv.RichViewEdit.RVData, srv.RichViewEdit.ItemCount-1,
ItemRect, FirstPageNo, LastPageNo, -1);
pt.Y := PageRect.Top+ItemRect.Bottom;
Canvas.Pen.Color := clBlack;
Canvas.Pen.Width := 1;
Canvas.Pen.Style := psSolid;
Canvas.MoveTo(pt.X, pt.Y);
pt.X := PageRect.Right - srv.RightMargin100Pix;
pt.Y := PageRect.Bottom - srv.BottomMargin100Pix;
Canvas.LineTo(pt.X, pt.Y);
end;
A solution is calling UpdateBuffer in OnChange:
Code: Select all
procedure TForm3.SRichViewEdit1Change(Sender: TObject);
begin
SRichViewEdit1.UpdateBuffer;
end;
Last edited by Sergey Tkachenko on Sun Nov 02, 2014 11:36 am, edited 1 time in total.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: