rvico TRichView Reference | TRichViewEdit


Top  Previous  Next

Allows to define size and position for custom caret.


  TRVMeasureCustomCaretEvent = procedure (Sender: TCustomRichViewEdit;

    var Rect: TRect) of object;

property OnMeasureCustomCaret: TRVMeasureCustomCaretEvent;

(introduced in version 10)

Custom caret is drawn if CustomCaretInterval>0.

This event is called before each call to OnDrawCustomCaret. It allows to set your own size and position for the caret. The default size and position are the same as of the default system caret. The editor stores background under the Rect, it will be restored after the call to OnDrawCustomCaret.


This example defines the custom caret width. For non-text items, or at the end of item, it sets the caret width = default width + 10.For text items, it sets the caret width equal to width of character to the right of the caret.

This example uses TMyForm.Canvas to calculate character width.

procedure TMyForm.MyRichViewEditMeasureCustomCaret(Sender: TCustomRichViewEdit;

  var Rect: TRect);

var s: String;


  Sender := Sender.TopLevelEditor;

  if Sender.CurItemStyle<0 then begin

    inc(Rect.Right, 10);



  if Sender.OffsetInCurItem>=Sender.GetOffsAfterItem(Sender.CurItemNothen


    inc(Rect.Right, 10);



  s := Sender.GetItemText(Sender.CurItemNo);


  Rect.Right := Rect.Right+Canvas.TextWidth(s[Sender.OffsetInCurItem]);


TRichView © trichview.com