CRichEditCtx.TextLengthExmethod
Calculates text length in various ways. It is usually called before creating a buffer to receive the text from the control.
Syntax
FUNCTION TextLengthEx (BYREF gtex AS .GETTEXTLENGTHEX) AS LONG
FUNCTION TextLengthEx (BYVAL dwFlags AS DWORD = GTL_DEFAULT) AS LONG
Parameters
| Name | Description | |
|---|---|---|
gtex | A GETTEXTLENGTHEX structure that receives the text length information. | |
dwFlags | Value specifying the method to be used in determining the text length. This member can be one or more of the following values (some values are mutually exclusive). |
Return value
First overloaded method: The method returns the number of characters in the edit control, depending on the setting of the flags in the GETTEXTLENGTHEX structure. If incompatible flags were set in the flags member, the message returns E_INVALIDARG.
Second overloaded method: The method returns the number of characters in the edit control, depending on the setting of the flags in the dwFlags parameter. If incompatible flags were set in the flags member, the message returns E_INVALIDARG.
Description
Calculates text length in various ways. It is usually called before creating a buffer to receive the text from the control. Since this CRichEditCtx class uses unicode, it is easier to use the simplified second overloaded function.
Remarks
This message is a fast and easy way to determine the number of characters in the Unicode version of the rich edit control. However, for a non-Unicode target code page you will potentially be converting to a combination of single-byte and double-byte characters.
Examples
--- First overloaded method: DIM gtex AS GETTEXTLENGTHEX = TYPE<GETTEXTLENGTHEX>(GTL_NUMCHARS, 1200) DIM Result AS LONG = pRichEdit.GetTextLEngthEx(gtex) DIM cbLen AS LONG IF Result <> E_INVALIDARG THEN cbLen = Result
--- Second overloaded method: DIM Result AS LONG = pRichEdit.GetTextLEngthEx ' // Uses the GTL_DEFAULT flag DIM Result AS LONG = pRichEdit.GetTextLEngthEx(GTL_NUMCHARS) ' // Uses the GTL_NUMCHARS flag DIM cbLen AS LONG IF Result <> E_INVALIDARG THEN cbLen = Result
Reference
- Defined in AfxNova/CRichEditCtx.inc:3091
- Documented in Windows/WIndows Controls/RichEdit/CRichEditCtx Class.md
- Topic: CRichEditCtx Class