SRichViewEdit OnPaint

General TRichView support forum. Please post your questions here
Post Reply
yf321
Posts: 2
Joined: Wed Apr 11, 2012 6:55 am

SRichViewEdit OnPaint

Post by yf321 »

in SRV demo's ActionTestTabs, open two or more rvf file, on SRVTabSet click someone tabitem, I try to get current tabitem's CurItemNo with CaretPos, and draw a line, use code by SRichViewEdit1.OnPaint event:

procedure TForm3.ActiveEditorPaint(Sender: TSRichViewEdit; Canvas: TCanvas; Prepaint: Boolean; PaintRect: TRect);
var y: Integer;
begin
if not vdrawline then exit;
y:= ActiveEditor.CaretPos.Y;
Canvas.Pen.Color := clRed;
Canvas.Pen.Width := 1;
Canvas.Pen.Style:= psdot;
Canvas.MoveTo(0,y);
Canvas.LineTo(ClientWidth,y);
edit1.Text:= inttostr(ActiveEditor.ActiveEditor.CurItemNo);
end;

it act only in tabitem1,how can i do it with ActiveEditorPaint in other tabitems?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This demo works in the following way.
Initially, only one editor is available, SRichViewEdit1.
Next, the user can create new editors. Properties and events of new editors are assigned in TForm3.AddEditor procedure.
(Next, the user can close some tabs and thus destroy some editors, including SRichViewEdit1)

What you need to do.
1) At design time, assign SRichViewEdit1.OnPaint
2) in TForm3.AddEditor, add the line

Code: Select all

srve.OnPaint := ActiveEditorPaint;
yf321
Posts: 2
Joined: Wed Apr 11, 2012 6:55 am

Post by yf321 »

in TForm3.AddEditor, add the line

Code: Select all

srve.OnPaint := ActiveEditorPaint;
it is OK,i got it,think you!
Post Reply