共用方式為


CEdit::SetRect

使用指定的座標,呼叫這個函式會設定矩形的維度。

void SetRect(
   LPCRECT lpRect 
);

參數

  • lpRect
    為指定格式化矩形的新維度的 RECT 結構或 CRect 物件。

備註

這個成員會由多行編輯控制項只處理。

使用 SetRect 設定多行編輯控制項的格式化矩形。 格式化矩形是文字的條件的矩形,這是控制項視窗的大小無關。 當編輯控制項第一次建立時,格式化矩形與控制項視窗的工作區。 您可以使用 SetRect 成員函式,應用程式小於控制項視窗可以讓格式化矩形大或。

如果編輯控制項沒有捲軸,則文字會裁剪,不會自動換行,則為,如果格式化矩形比 Windows 讓。 如果編輯控制項包含一個框線,格式化矩形中框線的大小縮減。 如果您調整 GetRect 成員函式所傳回的矩形,您必須移除框線的大小,在傳遞至矩形 SetRect之前。

SetRect 呼叫時,編輯控制項的文字或重新格式化並重新顯示。

如需詳細資訊,請參閱 Windows SDK的 EM_SETRECT

範例

// 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);
}

需求

Header: afxwin.h

請參閱

參考

CEdit 類別

階層架構圖

CRect::CRect

CRect::CopyRect

CRect::operator =

CRect::SetRectEmpty

CEdit::GetRect

CEdit::SetRectNP