1 // ResizableMDIFrame.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 "ResizableMDIFrame.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
30 // CResizableMDIFrame
\r
32 IMPLEMENT_DYNCREATE(CResizableMDIFrame, CMDIFrameWnd)
\r
34 CResizableMDIFrame::CResizableMDIFrame()
\r
36 m_bEnableSaveRestore = FALSE;
\r
39 CResizableMDIFrame::~CResizableMDIFrame()
\r
44 BEGIN_MESSAGE_MAP(CResizableMDIFrame, CMDIFrameWnd)
\r
45 //{{AFX_MSG_MAP(CResizableMDIFrame)
\r
46 ON_WM_GETMINMAXINFO()
\r
49 ON_WM_WINDOWPOSCHANGING()
\r
53 /////////////////////////////////////////////////////////////////////////////
\r
54 // CResizableMDIFrame message handlers
\r
56 void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
\r
58 // MDI should call default implementation
\r
59 CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
\r
63 BOOL bMaximized = FALSE;
\r
64 CMDIChildWnd* pChild = MDIGetActive(&bMaximized);
\r
65 if (pChild != NULL && bMaximized)
\r
66 ChainMinMaxInfo(lpMMI, this, pChild);
\r
69 // NOTE: this must be called after setting the layout
\r
70 // to have the view and its controls displayed properly
\r
71 BOOL CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
\r
73 m_sSection = pszSection;
\r
75 m_bEnableSaveRestore = TRUE;
\r
76 m_bRectOnly = bRectOnly;
\r
78 // restore immediately
\r
79 return LoadWindowRect(pszSection, bRectOnly);
\r
82 void CResizableMDIFrame::OnDestroy()
\r
84 if (m_bEnableSaveRestore)
\r
85 SaveWindowRect(m_sSection, m_bRectOnly);
\r
87 CMDIFrameWnd::OnDestroy();
\r
90 BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
\r
92 if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct))
\r
95 MakeResizable(lpCreateStruct);
\r
100 LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
102 if (message != WM_NCCALCSIZE || wParam == 0)
\r
103 return CMDIFrameWnd::WindowProc(message, wParam, lParam);
\r
105 // specifying valid rects needs controls already anchored
\r
106 LRESULT lResult = 0;
\r
107 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
108 lResult = CMDIFrameWnd::WindowProc(message, wParam, lParam);
\r
109 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
113 void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
\r
115 CMDIFrameWnd::OnWindowPosChanging(lpwndpos);
\r
117 // since this window class doesn't have the style CS_HREDRAW|CS_VREDRAW
\r
118 // the client area is not invalidated during a resize operation and
\r
119 // this prevents the system from using WM_NCCALCSIZE to validate rects
\r