EM_SETRECT

2.x

EM_SETRECT
wParam = 0;                           /* not used, must be zero */
lParam = (LPARAM) (const RECT FAR*) lprc; /* address of RECT    */

An application sends an EM_SETRECT message to set the formatting rectangle of a multiline edit control. The formatting rectangle is the limiting rectangle of the text. The limiting rectangle is independent of the size of the edit-control window. When the edit control is first created, the formatting rectangle is the same as the client area of the edit-control window. By using the EM_SETRECT message, an application can make the formatting rectangle larger or smaller than the edit-control window.

This message is processed only by multiline edit controls.

Parameters

lprc

Value of lParam. Points to a RECT structure that specifies the new dimensions of the rectangle. The RECT structure has the following form:

typedef struct tagRECT {    /* rc */
   int left;
   int top;
   int right;
   int bottom;
} RECT;

Return Value

This message does not return a value.

Comments

The EM_SETRECT message causes the text of the edit control to be redrawn. To change the size of the formatting rectangle without redrawing the text, use the EM_SETRECTNP message.

If the edit control does not have a horizontal scroll bar, and the formatting rectangle is set to be larger than the edit-control window, lines of text exceeding the width of the edit-control window (but smaller than the width of the formatting rectangle) are clipped instead of wrapped.

If the edit control contains a border, the formatting rectangle is reduced by the size of the border. If you are adjusting the rectangle returned by an EM_GETRECT message, you must remove the size of the border before using the rectangle with the EM_SETRECT message.

Example

This example retrieves the current formatting rectangle for a multiline edit control, removes the border width dimensions, and sets the right border to 32767 so that all text sent to the edit control is clipped rather than wrapped if it exceeds the width of the edit-control window. The example then sends an EM_SETRECT message to set the new formatting rectangle.

RECT rect;

SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    EM_GETRECT, 0, (LPARAM) (RECT FAR*) &rect);
rect.left = 0;            /* remove border width  */
rect.right = 32767;       /* clip all lines       */
rect.bottom += rect.top;  /* remove border height */
rect.top = 0;             /* remove border height */
SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    EM_SETRECT, 0, (LPARAM) (RECT FAR*) &rect);

See Also

EM_GETRECT, EM_SETRECTNP, MoveWindow