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