Creating a Rich Edit Control

I created the rich edit control used in this sample in response to the WM_CREATE message in the main window procedure. The ES_SAVESEL style specifies that the text selection is saved when the control loses the focus and redisplayed when it regains the focus. (By default, the entire contents of a rich edit control are selected when it is reactivated.)

// Create the rich edit control.
hWndRichEdit = CreateWindowEx (
WS_EX_CLIENTEDGE, // make rich edit control appear "sunken"
"RICHEDIT", // class name of rich edit control
"", // text of rich edit control
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_SUNKEN | ES_SAVESEL |
WS_HSCROLL | WS_VSCROLL, // window styles
0, 0, // initially create 0 size,
0, 0, // main window's WM_SIZE handler will resize
hWnd, // use main parent
(HMENU)ID_RICHED, // ID
hInst, // this app instance owns this window
NULL);