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
;
40 CResizableMDIFrame::~CResizableMDIFrame()
45 BEGIN_MESSAGE_MAP(CResizableMDIFrame
, CMDIFrameWnd
)
46 //{{AFX_MSG_MAP(CResizableMDIFrame)
50 ON_WM_WINDOWPOSCHANGING()
54 /////////////////////////////////////////////////////////////////////////////
55 // CResizableMDIFrame message handlers
57 void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR
* lpMMI
)
59 // MDI should call default implementation
60 CMDIFrameWnd::OnGetMinMaxInfo(lpMMI
);
64 BOOL bMaximized
= FALSE
;
65 CMDIChildWnd
* pChild
= MDIGetActive(&bMaximized
);
66 if (pChild
!= NULL
&& bMaximized
)
67 ChainMinMaxInfo(lpMMI
, this, pChild
);
70 // NOTE: this must be called after setting the layout
71 // to have the view and its controls displayed properly
72 BOOL
CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection
, BOOL bRectOnly
)
74 m_sSection
= pszSection
;
76 m_bEnableSaveRestore
= TRUE
;
77 m_bRectOnly
= bRectOnly
;
79 // restore immediately
80 return LoadWindowRect(pszSection
, bRectOnly
);
83 void CResizableMDIFrame::OnDestroy()
85 if (m_bEnableSaveRestore
)
86 SaveWindowRect(m_sSection
, m_bRectOnly
);
88 CMDIFrameWnd::OnDestroy();
91 BOOL
CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct
)
93 if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct
))
96 MakeResizable(lpCreateStruct
);
101 LRESULT
CResizableMDIFrame::WindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
103 if (message
!= WM_NCCALCSIZE
|| wParam
== 0)
104 return CMDIFrameWnd::WindowProc(message
, wParam
, lParam
);
106 // specifying valid rects needs controls already anchored
108 HandleNcCalcSize(FALSE
, (LPNCCALCSIZE_PARAMS
)lParam
, lResult
);
109 lResult
= CMDIFrameWnd::WindowProc(message
, wParam
, lParam
);
110 HandleNcCalcSize(TRUE
, (LPNCCALCSIZE_PARAMS
)lParam
, lResult
);
114 void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR
* lpwndpos
)
116 CMDIFrameWnd::OnWindowPosChanging(lpwndpos
);
118 // since this window class doesn't have the style CS_HREDRAW|CS_VREDRAW
119 // the client area is not invalidated during a resize operation and
120 // this prevents the system from using WM_NCCALCSIZE to validate rects