# RichEdit::LimitText

## Description

Limits the amount of text a user can enter into the RichEdit control.

## Syntax

void LimitText( long nChars = 0 )


## Parameters

nChars
Specifies the length (in bytes) of the text that the user can enter.
If this parameter is 0, the text length is set to UINT_MAX bytes. This is the default behavior.
Remarks
Call this function to limit the length of the text that the user can enter into an edit control.
Changing the text limit restricts only the text the user can enter. It has no effect on any
text already in the edit control, nor does it affect the length of the text copied to the edit
control by the Text member function in Window. If an application uses the Text
function to place more text into an edit control than is specified in the call to LimitText,
the user can delete any of the text within the edit control. However, the text limit will
prevent the user from replacing the existing text with new text, unless deleting the
current selection causes the text to fall below the text limit.

None.

## Examples

EX1

#include <..\OriginLab\DialogEx.h>
#define IDC_RICHEDIT1 1001
#define TEXT_LIMITS 4096

void RichEdit_LimitText(Dialog& EditBoxes)
{
RichEdit richEdit = EditBoxes.GetItem(IDC_RICHEDIT1);
int nChars = TEXT_LIMITS;
richEdit.LimitText(nChars);
int nLimits = richEdit.GetLimitText();
ASSERT(TEXT_LIMITS == nLimits);
}


Control.h