CWnd::CalcWindowRect
virtualvoidCalcWindowRect(LPRECTlpClientRect, UINTnAdjustType = adjustBorder);
Parameters
lpClientRect
Points to a RECT structure or CRect object that contains the resultant value of the window rectangle.
nAdjustType
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.
Remarks
Call this member function to compute the required size of the window rectangle based on the desired client-rectangle size. 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.
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 CMyView's frame.
void CMyView::OnMyCreateframe()
{
CFrameWnd* pFrameWnd = new CFrameWnd;
CRect myRect;
GetClientRect(myRect);
pFrameWnd->Create(NULL, "My Frame");
pFrameWnd->CalcWindowRect(&myRect, CWnd::adjustBorder);
pFrameWnd->MoveWindow(0, 0, myRect.Width(), myRect.Height());
pFrameWnd->ShowWindow(SW_SHOW);
}