Help Center

CRichEdit.GetTextLengthmethod

Retrieves the length of all text in a rich edit control.

Windowsmethoddocumented

Syntax

FUNCTION GetTextLength (BYVAL hRichEdit AS HWND) AS LONG

Parameters

NameDescription
hRichEditThe handle of the rich edit control.

Return value

The return value is the length of the text in characters, not including the terminating null character.

Description

Retrieves the length of all text in a rich edit control.

Remarks

When the WM_GETTEXTLENGTH message is sent, the DefWindowProc function returns the length, in characters, of the text. Under certain conditions, the DefWindowProc function returns a value that is larger than the actual length of the text. This occurs with certain mixtures of ANSI and Unicode, and is due to the system allowing for the possible existence of double-byte character set (DBCS) characters within the text. The return value, however, will always be at least as large as the actual length of the text; you can thus always use it to guide buffer allocation. This behavior can occur when an application uses both ANSI functions and common dialogs, which use Unicode.

To retrieve the text, you can also use the AfxGetWindowText function, the WM_GETTEXT message, or the Windows API GetWindowTextW function.

Reference

  • Defined in AfxNova/CRichEdit.inc:692
  • Documented in Windows/WIndows Controls/CRichEdit Class.md
  • Topic: CRichEdit Class