Page 1 of 1

SRichViewEdit OnPaint

Posted: Mon May 21, 2012 11:21 am
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?

Posted: Tue May 22, 2012 9:01 am
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;

Posted: Tue May 22, 2012 11:42 am
by yf321
in TForm3.AddEditor, add the line

Code: Select all

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