1 // ResizableMDIChild.cpp : implementation file
3 /////////////////////////////////////////////////////////////////////////////
5 // This file is part of ResizableLib
6 // http://sourceforge.net/projects/resizablelib
8 // Copyright (C) 2000-2004 by Paolo Messina
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
11 // The contents of this file are subject to the Artistic License (the "License").
12 // You may not use this file except in compliance with the License.
13 // You may obtain a copy of the License at:
14 // http://www.opensource.org/licenses/artistic-license.html
16 // If you find this code useful, credits would be nice!
18 /////////////////////////////////////////////////////////////////////////////
21 #include "ResizableMDIChild.h"
26 static char THIS_FILE
[] = __FILE__
;
29 /////////////////////////////////////////////////////////////////////////////
32 IMPLEMENT_DYNCREATE(CResizableMDIChild
, CMDIChildWnd
)
34 CResizableMDIChild::CResizableMDIChild()
38 CResizableMDIChild::~CResizableMDIChild()
43 BEGIN_MESSAGE_MAP(CResizableMDIChild
, CMDIChildWnd
)
44 //{{AFX_MSG_MAP(CResizableMDIChild)
52 /////////////////////////////////////////////////////////////////////////////
53 // CResizableMDIChild message handlers
55 void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR
* lpMMI
)
57 // MDI should call default implementation
58 CMDIChildWnd::OnGetMinMaxInfo(lpMMI
);
62 CWnd
* pView
= GetDlgItem(AFX_IDW_PANE_FIRST
);//GetActiveView();
64 ChainMinMaxInfo(lpMMI
, this, pView
);
67 void CResizableMDIChild::OnSize(UINT nType
, int cx
, int cy
)
69 CMDIChildWnd::OnSize(nType
, cx
, cy
);
71 /* Why was this necessary???
73 // make sure the MDI parent frame doesn't clip
74 // this child window when it is maximized
75 if (nType == SIZE_MAXIMIZED)
77 CMDIFrameWnd* pFrame = GetMDIFrame();
80 pFrame->GetWindowRect(rect);
81 pFrame->MoveWindow(rect);
86 // NOTE: this must be called after setting the layout
87 // to have the view and its controls displayed properly
88 BOOL CResizableMDIChild::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bHorzResize, BOOL bVertResize)
90 m_sSection = pszSection;
92 m_bEnableSaveRestore = TRUE;
93 m_bRectOnly = bRectOnly;
95 // restore immediately
96 return LoadWindowRect(pszSection, bRectOnly, bHorzResize, bVertResize);
99 void CResizableMDIChild::OnDestroy()
101 if (m_bEnableSaveRestore)
102 SaveWindowRect(m_sSection, m_bRectOnly);
104 CMDIChildWnd::OnDestroy();
108 LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
110 if (message != WM_NCCALCSIZE || wParam == 0)
111 return CMDIChildWnd::WindowProc(message, wParam, lParam);
113 // specifying valid rects needs controls already anchored
115 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
116 lResult = CMDIChildWnd::WindowProc(message, wParam, lParam);
117 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
121 BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
123 if (!CMDIChildWnd::OnNcCreate(lpCreateStruct))
125 ModifyStyle(0, WS_CLIPCHILDREN);