1 // ResizableMDIChild.cpp : implementation file
\r
3 /////////////////////////////////////////////////////////////////////////////
\r
5 // This file is part of ResizableLib
\r
6 // http://sourceforge.net/projects/resizablelib
\r
8 // Copyright (C) 2000-2004 by Paolo Messina
\r
9 // http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com
\r
11 // The contents of this file are subject to the Artistic License (the "License").
\r
12 // You may not use this file except in compliance with the License.
\r
13 // You may obtain a copy of the License at:
\r
14 // http://www.opensource.org/licenses/artistic-license.html
\r
16 // If you find this code useful, credits would be nice!
\r
18 /////////////////////////////////////////////////////////////////////////////
\r
21 #include "ResizableMDIChild.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
30 // CResizableMDIChild
\r
32 IMPLEMENT_DYNCREATE(CResizableMDIChild, CMDIChildWnd)
\r
34 CResizableMDIChild::CResizableMDIChild()
\r
36 m_bEnableSaveRestore = FALSE;
\r
39 CResizableMDIChild::~CResizableMDIChild()
\r
44 BEGIN_MESSAGE_MAP(CResizableMDIChild, CMDIChildWnd)
\r
45 //{{AFX_MSG_MAP(CResizableMDIChild)
\r
46 ON_WM_GETMINMAXINFO()
\r
53 /////////////////////////////////////////////////////////////////////////////
\r
54 // CResizableMDIChild message handlers
\r
56 void CResizableMDIChild::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
\r
58 // MDI should call default implementation
\r
59 CMDIChildWnd::OnGetMinMaxInfo(lpMMI);
\r
63 CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST);//GetActiveView();
\r
65 ChainMinMaxInfo(lpMMI, this, pView);
\r
68 void CResizableMDIChild::OnSize(UINT nType, int cx, int cy)
\r
70 CMDIChildWnd::OnSize(nType, cx, cy);
\r
72 /* Why was this necessary???
\r
74 // make sure the MDI parent frame doesn't clip
\r
75 // this child window when it is maximized
\r
76 if (nType == SIZE_MAXIMIZED)
\r
78 CMDIFrameWnd* pFrame = GetMDIFrame();
\r
81 pFrame->GetWindowRect(rect);
\r
82 pFrame->MoveWindow(rect);
\r
87 // NOTE: this must be called after setting the layout
\r
88 // to have the view and its controls displayed properly
\r
89 BOOL CResizableMDIChild::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
\r
91 m_sSection = pszSection;
\r
93 m_bEnableSaveRestore = TRUE;
\r
94 m_bRectOnly = bRectOnly;
\r
96 // restore immediately
\r
97 return LoadWindowRect(pszSection, bRectOnly);
\r
100 void CResizableMDIChild::OnDestroy()
\r
102 if (m_bEnableSaveRestore)
\r
103 SaveWindowRect(m_sSection, m_bRectOnly);
\r
105 CMDIChildWnd::OnDestroy();
\r
109 LRESULT CResizableMDIChild::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
111 if (message != WM_NCCALCSIZE || wParam == 0)
\r
112 return CMDIChildWnd::WindowProc(message, wParam, lParam);
\r
114 // specifying valid rects needs controls already anchored
\r
115 LRESULT lResult = 0;
\r
116 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
117 lResult = CMDIChildWnd::WindowProc(message, wParam, lParam);
\r
118 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
122 BOOL CResizableMDIChild::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
\r
124 if (!CMDIChildWnd::OnNcCreate(lpCreateStruct))
\r
126 ModifyStyle(0, WS_CLIPCHILDREN);
\r