void SetRect( LPCRECT lpRect );
Parameters
lpRect
Points to the RECT structure or CRect object that specifies the new dimensions of the formatting rectangle.
Remarks
Call this function to set the dimensions of a rectangle using the specified coordinates. 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 Win32 documentation.
Example
// The pointer to my edit.
extern CEdit* pmyEdit;
// Flag indicating whether to redraw the edit control.
extern bool fRedraw;
CRect r;
pmyEdit->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)
pmyEdit->SetRect(&r);
else
pmyEdit->SetRectNP(&r);
}
CEdit Overview | Class Members | Hierarchy Chart
See Also CRect::CRect, CRect::CopyRect, CRect::operator =, CRect::SetRectEmpty, CEdit::GetRect, CEdit::SetRectNP