MSDN Home >  MSDN Library >  User Interface Design and Development >  Windows Shell >  Windows Controls >  Individual Control Information >  Rich Edit Controls > 

EM_SETTEXTMODE Message


An application sends an EM_SETTEXTMODE message to set the text mode or undo level of a rich edit control. The message fails if the control contains any text.

Syntax

To send this message, call the SendMessage function as follows.
lResult = SendMessage(     // returns LRESULT in lResult
   (HWND) hWndControl,     // handle to destination control
   (UINT) EM_SETTEXTMODE,     // message ID
   (WPARAM) wParam,     // = (WPARAM) () wParam;
   (LPARAM) lParam     // = (LPARAM) () lParam;
);

Parameters

wParam
One or more values from the TEXTMODE enumeration type. The values specify the new settings for the control's text mode and undo level parameters.

Specify one of the following values to set the text mode parameter. If you don't specify a text mode value, the text mode remains at its current setting.
ValueMeaning
TM_PLAINTEXTIndicates plain text mode, in which the control is similar to a standard edit control. For more information about plain text mode, see the following Remarks section.
TM_RICHTEXTIndicates rich text mode, in which the control has standard rich edit functionality. Rich text mode is the default setting.

Specify one of the following values to set the undo level parameter. If you don't specify an undo level value, the undo level remains at its current setting.
ValueMeaning
TM_SINGLELEVELUNDOThe control allows the user to undo only the last action that can be undone.
TM_MULTILEVELUNDOThe control supports multiple undo operations. This is the default setting. Use the EM_SETUNDOLIMIT message to set the maximum number of undo actions.

Specify one of the following values to set the code page parameter. If you don't specify an code page value, the code page remains at its current setting.
ValueMeaning
TM_SINGLECODEPAGEThe control only allows the English keyboard and a keyboard corresponding to the default charset. For example, you could have Greek and English. Note that this prevents Unicode text from entering the control. For example, use this value if a Microsoft Rich Edit control must be restricted to ANSI text.
TM_MULTICODEPAGEThe control allows multiple code pages and Unicode text into the control. This is the default setting.

lParam
This parameter is not used; it must be zero.

Return Value

If the message succeeds, the return value is zero.

If the message fails, the return value is a nonzero value.


Remarks

In rich text mode, a rich edit control has standard rich edit functionality. However, in plain text mode, the control is similar to a standard edit control:

  • The text in a plain text control can have only one format (such as Bold, 10pt Arial).
  • The user cannot paste rich text formats, such as Rich Text Format (RTF) or embedded objects into a plain text control.
  • Rich text mode controls always have a default end-of-document marker or carriage return, to format paragraphs. Plain text controls, on the other hand, do not need the default, end-of-document marker, so it is omitted.

The control must contain no text when it receives the EM_SETTEXTMODE message. To ensure there is no text, send a WM_SETTEXT message with an empty string ("").

Message Information

HeaderDeclared in Richedit.h
Minimum operating systems Windows 95 with Rich Edit 2.0, Windows 98, Windows NT 4.0

See Also

Rich Edit Controls, EM_GETTEXTMODE, EM_SETUNDOLIMIT, TEXTMODE, WM_SETTEXT
 Contact Us   |  E-Mail this Page   |  MSDN Flash Newsletter
 © 2003 Microsoft Corporation. All rights reserved.   Terms of Use  Privacy Statement   Accessibility