共用方式為


CWnd::CalcWindowRect

Calculates the window rectangle that can contain the specified client rectangle.

virtual void CalcWindowRect(
   LPRECT lpClientRect,
   UINT nAdjustType = adjustBorder 
);

Parameters

  • [in, out] lpClientRect
    Pointer to a rectangle structure. On input, this structure contains the client rectangle. After the method is finished, this structure contains the window rectangle that can contain the specified client rectangle.

  • [in] nAdjustType
    Use CWnd::adjustBorder to calculate window coordinates without the WS_EX_CLIENTEDGE style; otherwise, use CWnd::adjustOutside.

Remarks

The size of the calculated window rectangle does not include space for a menu bar.

For more usage restrictions, see AdjustWindowRectEx.

Example

// Uses CalcWindowRect to determine size for new CFrameWnd
// based on the size of the current view. The end result is a
// top level frame window of the same size as CMdiView's frame.
void CMdiView::OnMyCreateFrame() 
{
   CFrameWnd* pFrameWnd = new CFrameWnd;
   CRect myRect;
   GetClientRect(myRect);
   pFrameWnd->Create(NULL, _T("My Frame"));
   pFrameWnd->CalcWindowRect(&myRect, CWnd::adjustBorder);
   pFrameWnd->MoveWindow(0, 0, myRect.Width(), myRect.Height());
   pFrameWnd->ShowWindow(SW_SHOW);
}

Requirements

Header: afxwin.h

See Also

Reference

CWnd Class

Hierarchy Chart

AdjustWindowRectEx

Concepts

CWnd Members