<TWPRichText>.CallForCurrentParagraphs

    • Offizieller Beitrag

    Hi, the procedure WPRichText1.TextCursor.CallForSelectedText can be used. It is able to report the paragraphs, the characters and the different text attributes:

    Code
    procedure CallForSelectedText(      Sender: TObject; Options: TWPCallForSelectedTextOptions;      ParCallback: TWPParCallback; CharAttCallback: TWPCharAttrCallback;      CharCallBack: TWPCharCallback; TextObjCallback: TWPTextObjectCallback;      spar: TParagraph = nil; epar: TParagraph = nil;      spos: Integer = 0; epos: Integer = 0);


    It expects 4 call-back procedures (or nil).

    Code
    TWPParCallback = procedure(    Sender: TObject;    par: TParagraph;    IsParent: Boolean;    FromChar, ToChar: Integer;    var Abort: Boolean) of object;  TWPCharAttrCallback = procedure(Sender: TObject;    var CharAttrIndex: Cardinal;    par: TParagraph;    posinpar: Integer;    var Abort: Boolean) of object;  TWPCharCallback = procedure(Sender: TObject;    var CharItem: WideChar;    par: TParagraph;    posinpar: Integer;    var Abort: Boolean) of object;  TWPTextObjectCallback = procedure(Sender: TObject;    TxtObj: TWPTextObj;    par: TParagraph;    posinpar: Integer;    var Abort: Boolean) of object;

    'Sender' is the object which will be used for the callbacks.

    The 'Options' will be usually []

    spar, epar are optional. The engine will fill in the current selection pointers if they are missing. Otherwise they are the start and the end position.

    Example: Create a string from the current selection: