Help Center

CTextRange2.SetURLmethod

Sets the text in this range to that of the specified URL.

Windowsmethoddocumented

Syntax

FUNCTION SetURL (BYREF wszUrl AS WSTRING) AS HRESULT

Parameters

NameDescription
cbsThe text to use as a URL for the selected friendly name.

Description

Sets the text in this range to that of the specified URL.

Remarks

The URL string is not validated. The text it contains must be enclosed in quotes, optionally preceded by the sentinel character 0xFDDF. For example: "http://www.msn.com" or 0xFDDF"http://www.msn.com". The range must be nondegenerate.

The following actions are possible:

  • If part of a link's friendly name is selected, the URL part is replaced with bstr.
  • If part of a regular URL is selected, it becomes the link's friendly name, with bstr as the URL.
  • If nonlink text is selected:
  • If the text immediately follows a link's friendly name and bstr matches the URL, the text is appended to the friendly name.
  • Otherwise, the text becomes the friendly name of a link, with bstr as the URL.

The text range be adjusted to different character positions after calling SetURL.

Reference

  • Defined in AfxNova/CTextRange2.inc:941
  • Documented in Windows/WIndows Controls/RichEdit/CTextRange2 Class.md
  • Topic: CTextRange2 Class