1 // ResizableFrame.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 "ResizableFrame.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
29 /////////////////////////////////////////////////////////////////////////////
\r
32 IMPLEMENT_DYNCREATE(CResizableFrame, CFrameWnd)
\r
34 CResizableFrame::CResizableFrame()
\r
36 m_bEnableSaveRestore = FALSE;
\r
39 CResizableFrame::~CResizableFrame()
\r
44 BEGIN_MESSAGE_MAP(CResizableFrame, CFrameWnd)
\r
45 //{{AFX_MSG_MAP(CResizableFrame)
\r
46 ON_WM_GETMINMAXINFO()
\r
49 ON_WM_WINDOWPOSCHANGING()
\r
53 /////////////////////////////////////////////////////////////////////////////
\r
54 // CResizableFrame message handlers
\r
56 void CResizableFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
\r
60 CView* pView = GetActiveView();
\r
64 ChainMinMaxInfo(lpMMI, this, pView);
\r
67 // NOTE: this must be called after setting the layout
\r
68 // to have the view and its controls displayed properly
\r
69 BOOL CResizableFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)
\r
71 m_sSection = pszSection;
\r
73 m_bEnableSaveRestore = TRUE;
\r
74 m_bRectOnly = bRectOnly;
\r
76 // restore immediately
\r
77 return LoadWindowRect(pszSection, bRectOnly);
\r
80 void CResizableFrame::OnDestroy()
\r
82 if (m_bEnableSaveRestore)
\r
83 SaveWindowRect(m_sSection, m_bRectOnly);
\r
85 CFrameWnd::OnDestroy();
\r
88 BOOL CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
\r
90 if (!CFrameWnd::OnNcCreate(lpCreateStruct))
\r
93 MakeResizable(lpCreateStruct);
\r
98 LRESULT CResizableFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
\r
100 if (message != WM_NCCALCSIZE || wParam == 0)
\r
101 return CFrameWnd::WindowProc(message, wParam, lParam);
\r
103 // specifying valid rects needs controls already anchored
\r
104 LRESULT lResult = 0;
\r
105 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
106 lResult = CFrameWnd::WindowProc(message, wParam, lParam);
\r
107 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
\r
111 // TODO: implement this in CResizableMinMax
\r
112 // We definitely need pluggable message handlers ala WTL!
\r
113 void CResizableFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
\r
115 if ((lpwndpos->flags & (SWP_NOSIZE|SWP_NOMOVE)) != (SWP_NOSIZE|SWP_NOMOVE))
\r
116 CFrameWnd::OnWindowPosChanging(lpwndpos);
\r