Help Center

CTextRange2.GetTextmethod

Gets the text in this range according to the specified conversion flags.

Windowsmethoddocumented

Syntax

FUNCTION GetText (BYVAL Flags AS LONG = tomUseCRLF) AS DWSTRING

Parameters

NameDescription
FlagsThe flags controlling how the text is retrieved. The flags can include a combination of the values in the table below.

Return value

The text in the range in unicode.

Description

Gets the text in this range according to the specified conversion flags.

Remarks

This method uses the GetText2 method of the ITextRange2 interface to retrieve the text because it allows to use the conversion flags. Passing 0 in the Flags parameter is the same that using the GetText method of the ITextRange interface, which does not return correct results when dealing with files that use CR (MacIntosh) or LF (Linux), instead of CRLF (Windows).

This method includes the special flag tomLanguageTag to get the BCP-47 language tag for the range. This is an industry standard language tag which may be preferable to the language code identifier (LCID) obtained by calling the GetLanguageID method of the ITextFont interface.

To use with the dotted syntax. To use with the pointer syntax.

Examples

SCOPE ' // Get the number of characters of the text in the Rich Edit control DIM numChars AS LONG = pRichEdit.TextLength ' // Get the 0-based range of all the text DIM pRange2 AS CTextRange2 = pRichEdit.Range2(0, numChars) ' // Get the text DIM dwsText AS DWSTRING = pRange2.GetText(tomUseCRLF) ' // The CTextRange2 class will be destroyed when the scope ends END SCOPE

' // Get the number of characters of the text in the Rich Edit control DIM numChars AS LONG = pRichEdit->TextLength ' // Get the 0-based range of all the text DIM pRange2 AS CTextRange2 PTR = NEW CTextRange2(pRichEdit->Range2(0, numChars)) ' // Get the text DIM dwsText AS DWSTRING = pRange2->GetText(tomUseCRLF) ' // Delete the range Delete pRange2

Reference

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