CWnd::CalcWindowRect
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
);
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
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 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