Monitoring Events

Certain events within a rich edit control, such as mouse and keyboard events and drag-and-drop operations, can be monitored by the control's parent window. An application uses an event-notification mask (by sending the EM_SETEVENTMASK message) to specify which events it wants to monitor. The control will then send the appropriate notification each time one of the specified events occurs. All the notifications that are listed in Table 5-1 are sent through the WM_NOTIFY message.

Event-Notification Mask Description
ENM_CHANGE Sends an EN_CHANGE notification when the user changes the text in a rich edit control.
ENM_DROPFILES Sends EN_DROPFILES notifications. The application can allow the user to drop files in a rich edit control by processing the EN_DROPFILES notification. The specified ENDROPFILES structure contains information about the files being dropped.
ENM_KEYEVENTS Sends EN_MSGFILTER notifications for keyboard events. The parent window can prevent the keyboard message from being processed or can change the message by modifying the specified MSGFILTER structure.
ENM_MOUSEEVENTS Sends EN_MSGFILTER notifications for mouse events. The parent window can prevent the mouse message from being processed or can change the message by modifying the specified MSGFILTER structure.
ENM_PROTECTED Sends EN_PROTECTED notifications, which are used to detect when the user attempts to modify protected text.
ENM_REQUESTRESIZE Sends EN_REQUESTRESIZE notifications. This lets an application resize a rich edit control as needed so that the control is always the same size as its contents. A rich edit control supports this “bottomless” functionality by sending its parent window an EN_REQUESTRESIZE notification whenever the size of its contents changes. In response, the application uses the SetWindowPos function to resize the control to the dimensions in the specified REQRESIZE structure.
ENM_SCROLL Sends an EN_HSCROLL notification when the user clicks the horizontal scroll bar of a rich edit control.
ENM_SELCHANGE Sends EN_SELCHANGE notifications. This informs the parent window that the current selection has changed.
ENM_UPDATE Sends an EN_UPDATE notification when a rich edit control is about to display altered text.
ENM_NONE No notifications are sent to the parent window (the default).

Table 5-1. Rich edit control event-notification masks.