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