////////////////////////////////////////////////////////////////////////////// // MFC Tip #7 -- Vision X Software -- http://www.visionx.com/mfcpro // Sizing an MDI Child Window // // This source code is provided for instructional purposes, and is released // to the public domain. No claim of ownership is made. Use it at your own // risk. No warranties are expressed or implied. The resulting program may // not be fully functional. No animals were used to test this code. ////////////////////////////////////////////////////////////////////////////// // Get the parent frame window. This CWnd function searches up the // parent chain until a CFrameWnd (or derived class) object is found. CFrameWnd *pFrame = GetParentFrame(); // Get the size of the client portion of the window. CRect cRect; pFrame->GetClientRect( &cRect ); // Get the size of the entire window. CRect wRect; pFrame->GetWindowRect( &wRect ); // Calculate the new window size by subtracting out the client // size, and adding 100 (we want the *client* area to be 100). wRect.right = wRect.right - cRect.Width() + 100; wRect.bottom = wRect.bottom - cRect.Height() + 100; // Now resize the window. Ta-da! pFrame->SetWindowPos( NULL, 0, 0, Rect.Width(), wRect.Height(), SWP_NOZORDER | SWP_NOMOVE);