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
;
40 CResizableMDIChild::~CResizableMDIChild()
45 BEGIN_MESSAGE_MAP(CResizableMDIChild
, CMDIChildWnd
)
46 //{{AFX_MSG_MAP(CResizableMDIChild)
54 /////////////////////////////////////////////////////////////////////////////
55 // CResizableMDIChild message handlers
57 void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR
* lpMMI
)
59 // MDI should call default implementation
60 CMDIChildWnd::OnGetMinMaxInfo(lpMMI
);
64 CWnd
* pView
= GetDlgItem(AFX_IDW_PANE_FIRST
);//GetActiveView();
66 ChainMinMaxInfo(lpMMI
, this, pView
);
69 void CResizableMDIChild::OnSize(UINT nType
, int cx
, int cy
)
71 CMDIChildWnd::OnSize(nType
, cx
, cy
);
73 /* Why was this necessary???
75 // make sure the MDI parent frame doesn't clip
76 // this child window when it is maximized
77 if (nType == SIZE_MAXIMIZED)
79 CMDIFrameWnd* pFrame = GetMDIFrame();
82 pFrame->GetWindowRect(rect);
83 pFrame->MoveWindow(rect);
88 // NOTE: this must be called after setting the layout
89 // to have the view and its controls displayed properly
90 BOOL CResizableMDIChild::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
92 m_sSection = pszSection;
94 m_bEnableSaveRestore = TRUE;
95 m_bRectOnly = bRectOnly;
97 // restore immediately
98 return LoadWindowRect(pszSection, bRectOnly);
101 void CResizableMDIChild::OnDestroy()
103 if (m_bEnableSaveRestore)
104 SaveWindowRect(m_sSection, m_bRectOnly);
106 CMDIChildWnd::OnDestroy();
110 LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
112 if (message != WM_NCCALCSIZE || wParam == 0)
113 return CMDIChildWnd::WindowProc(message, wParam, lParam);
115 // specifying valid rects needs controls already anchored
117 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
118 lResult = CMDIChildWnd::WindowProc(message, wParam, lParam);
119 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
123 BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
125 if (!CMDIChildWnd::OnNcCreate(lpCreateStruct))
127 ModifyStyle(0, WS_CLIPCHILDREN);