Function TWPCustomRtfEdit.GetSelPosLen(Pos:Integer; len:Integer) : Boolean

Unit: WPCTRMemo
Class: WPCTRMemo.TWPCustomRtfEdit

Parameters

  • Pos:Integer
  • len:Integer

Returns

The type of the result value is Boolean.

Description

Retrieves the start position and the length of the selection. Returns TRUE if text is actually selected. if WPRichText1.GetSelPosLen(i,l) then begin WPRichText1.HideSelection; WPRichText1.CPPosition := i+l; WPRichText1.InputString(''); WPRichText1.CPPosition := i; WPRichText1.InputString(''); end; You can also work with TParagraph references. This code is more effective: spar := WPRichText1.TextCursor.GetBlockStart(i); epar := WPRichText1.TextCursor.GetBlockEnd(l); if (spar<>nil) and (epar<>nil) then begin epar.Insert(l, '',0); spar.Insert(i, '',0); WPRichText1.TextCursor.SelectFromHere(spar,i); WPRichText1.TextCursor.SelectToHere(epar,l + Length('')); WPRichText1.ReformatAll(false,true); end;