Insert a Hyperlink?

  • I'm using the WPRichEdit as a basic HTML editor for e-mails, but need to allow insertion of a hyperlink -- how can I go about this? I also need to be able to seperatly specify the text to be the actual hyperlink (preferably by highlighting it in the WPRichEdit), and specify a seperate link..

    Any help gratefully received!

  • I've found a method called CreateHyperlinkFromURL, which converts all the links in the WPRichText.

    Almost what I'm after...

    But I want to be able to specifically insert a single hyperlink with a specific href and target...

    Still hunting...

    • Offizieller Beitrag

    procedure InputHyperlink(link, stamp: string);

    In WPTools V4 implemented as:

    Code
    procedure TWPCustomRtfEdit.InputHyperlink(link, stamp: string);var  a: TAttr;begin  if Changing then  begin    a := Attr;    include(a.Style, afsHyperlink);    exclude(a.Style, afsHidden);    Attr := a;    InputString(link);    exclude(a.Style, afsHyperlink);    include(a.Style, afsHidden);    Attr := a;    InputString(stamp);    exclude(a.Style, afsHidden);    Attr := a;  end;end;

    in WPTools V5 implemented as:

    Code
    function TWPCustomRtfEdit.InputHyperlink(link, URL: string): TWPTextObj; overload;
    begin
      HideSelection;
      Result := InputCode(wpobjHyperlink, '', URL, 
           [wpinpWrapSelectedText, wpinpPlaceCursorAfterStart]);
      InputString(link);
      CPMoveNext;
    end;

    V5 also has:

    function TWPCustomRtfEdit.InputHyperlink(URL: string): TWPTextObj; overload;

    which creates a hyperlink around selected text.

    • Offizieller Beitrag

    >> Am I right in reading the code as the url to load is a block of hidden text?

    In V4 yes, in V5 the link is represented by 2 text objects. The parameters of the first contain the url in 'Source', 'Name' is reserved for "title" - not yet used.

    (To make things quicker all text objects use the same class TWPTextObj instead of using inheritance. The type of the object is stored in TWPTextObj.ObjType so the variables have a different meaning )