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()
36 m_bEnableSaveRestore
= FALSE
;
39 CResizableMDIChild::~CResizableMDIChild()
44 BEGIN_MESSAGE_MAP(CResizableMDIChild
, CMDIChildWnd
)
45 //{{AFX_MSG_MAP(CResizableMDIChild)
53 /////////////////////////////////////////////////////////////////////////////
54 // CResizableMDIChild message handlers
56 void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR
* lpMMI
)
58 // MDI should call default implementation
59 CMDIChildWnd::OnGetMinMaxInfo(lpMMI
);
63 CWnd
* pView
= GetDlgItem(AFX_IDW_PANE_FIRST
);//GetActiveView();
65 ChainMinMaxInfo(lpMMI
, this, pView
);
68 void CResizableMDIChild::OnSize(UINT nType
, int cx
, int cy
)
70 CMDIChildWnd::OnSize(nType
, cx
, cy
);
72 /* Why was this necessary???
74 // make sure the MDI parent frame doesn't clip
75 // this child window when it is maximized
76 if (nType == SIZE_MAXIMIZED)
78 CMDIFrameWnd* pFrame = GetMDIFrame();
81 pFrame->GetWindowRect(rect);
82 pFrame->MoveWindow(rect);
87 // NOTE: this must be called after setting the layout
88 // to have the view and its controls displayed properly
89 BOOL CResizableMDIChild::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
91 m_sSection = pszSection;
93 m_bEnableSaveRestore = TRUE;
94 m_bRectOnly = bRectOnly;
96 // restore immediately
97 return LoadWindowRect(pszSection, bRectOnly);
100 void CResizableMDIChild::OnDestroy()
102 if (m_bEnableSaveRestore)
103 SaveWindowRect(m_sSection, m_bRectOnly);
105 CMDIChildWnd::OnDestroy();
109 LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
111 if (message != WM_NCCALCSIZE || wParam == 0)
112 return CMDIChildWnd::WindowProc(message, wParam, lParam);
114 // specifying valid rects needs controls already anchored
116 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
117 lResult = CMDIChildWnd::WindowProc(message, wParam, lParam);
118 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
122 BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
124 if (!CMDIChildWnd::OnNcCreate(lpCreateStruct))
126 ModifyStyle(0, WS_CLIPCHILDREN);