Export (0) Print
Expand All
Expand Minimize


Call this member function to compute the required size of the window rectangle based on the desired client-rectangle size.

virtual void CalcWindowRect(
   LPRECT lpClientRect,
   UINT nAdjustType = adjustBorder 


Points to a RECT structure or CRect object that contains the resultant value of the window rectangle.
An enumerated type used for in-place editing. It can have the following values: CWnd::adjustBorder = 0, which means that scroll-bar sizes are ignored in calculation; and CWnd::adjustOutside = 1, which means that they are added into the final measurements of the rectangle.


The resulting window rectangle (contained in lpClientRect) can then be passed to the Create member function to create a window whose client area is the desired size.

Called by the framework to size windows prior to creation.

A client rectangle is the smallest rectangle that completely encloses a client area. A window rectangle is the smallest rectangle that completely encloses the window.


// 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 CMyView's frame.
void CMyView::OnMyCreateframe() 
   CFrameWnd* pFrameWnd = new CFrameWnd;
   CRect myRect;
   pFrameWnd->Create(NULL, "My Frame");
   pFrameWnd->CalcWindowRect(&myRect, CWnd::adjustBorder);
   pFrameWnd->MoveWindow(0, 0, myRect.Width(), myRect.Height());

See Also

CWnd Overview | Class Members | Hierarchy Chart | AdjustWindowRectEx

© 2015 Microsoft