Condividi tramite


CEdit::SetRect

Call this function to set the dimensions of a rectangle using the specified coordinates.

void SetRect(
   LPCRECT lpRect 
);

Parameters

  • lpRect
    Points to the RECT structure or CRect object that specifies the new dimensions of the formatting rectangle.

Remarks

This member is processed only by multiple-line edit controls.

Use SetRect to set the formatting rectangle of a multiple-line edit control. The formatting rectangle is the limiting rectangle of the text, which 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 SetRect member function, an application can make the formatting rectangle larger or smaller than the edit-control window.

If the edit control has no scroll bar, text will be clipped, not wrapped, if the formatting rectangle is made larger than the window. If the edit control contains a border, the formatting rectangle is reduced by the size of the border. If you adjust the rectangle returned by the GetRect member function, you must remove the size of the border before you pass the rectangle to SetRect.

When SetRect is called, the edit control's text is also reformatted and redisplayed.

For more information, see EM_SETRECT in the Windows SDK.

Example

// Flag indicating whether to redraw the edit control.
bool fRedraw = TRUE;

CRect r;

m_myEdit.GetRect(&r);

// Reduce the formatting rect of the edit control by
// 10 pixels on each side.
if ((r.Width() > 20) && (r.Height() > 20))
{
   r.DeflateRect(10, 10);

   if (fRedraw)
      m_myEdit.SetRect(&r);
   else
      m_myEdit.SetRectNP(&r);
}

Requirements

Header: afxwin.h

See Also

Reference

CEdit Class

Hierarchy Chart

CRect::CRect

CRect::CopyRect

CRect::operator =

CRect::SetRectEmpty

CEdit::GetRect

CEdit::SetRectNP

Other Resources

CEdit Members