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
;
40 CResizableFrame::~CResizableFrame()
45 BEGIN_MESSAGE_MAP(CResizableFrame
, CFrameWnd
)
46 //{{AFX_MSG_MAP(CResizableFrame)
50 ON_WM_WINDOWPOSCHANGING()
54 /////////////////////////////////////////////////////////////////////////////
55 // CResizableFrame message handlers
57 void CResizableFrame::OnGetMinMaxInfo(MINMAXINFO FAR
* lpMMI
)
61 CView
* pView
= GetActiveView();
65 ChainMinMaxInfo(lpMMI
, this, pView
);
68 // NOTE: this must be called after setting the layout
69 // to have the view and its controls displayed properly
70 BOOL
CResizableFrame::EnableSaveRestore(LPCTSTR pszSection
, BOOL bRectOnly
)
72 m_sSection
= pszSection
;
74 m_bEnableSaveRestore
= TRUE
;
75 m_bRectOnly
= bRectOnly
;
77 // restore immediately
78 return LoadWindowRect(pszSection
, bRectOnly
);
81 void CResizableFrame::OnDestroy()
83 if (m_bEnableSaveRestore
)
84 SaveWindowRect(m_sSection
, m_bRectOnly
);
86 CFrameWnd::OnDestroy();
89 BOOL
CResizableFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct
)
91 if (!CFrameWnd::OnNcCreate(lpCreateStruct
))
94 MakeResizable(lpCreateStruct
);
99 LRESULT
CResizableFrame::WindowProc(UINT message
, WPARAM wParam
, LPARAM lParam
)
101 if (message
!= WM_NCCALCSIZE
|| wParam
== 0)
102 return CFrameWnd::WindowProc(message
, wParam
, lParam
);
104 // specifying valid rects needs controls already anchored
106 HandleNcCalcSize(FALSE
, (LPNCCALCSIZE_PARAMS
)lParam
, lResult
);
107 lResult
= CFrameWnd::WindowProc(message
, wParam
, lParam
);
108 HandleNcCalcSize(TRUE
, (LPNCCALCSIZE_PARAMS
)lParam
, lResult
);
112 // TODO: implement this in CResizableMinMax
113 // We definitely need pluggable message handlers ala WTL!
114 void CResizableFrame::OnWindowPosChanging(WINDOWPOS FAR
* lpwndpos
)
116 if ((lpwndpos
->flags
& (SWP_NOSIZE
|SWP_NOMOVE
)) != (SWP_NOSIZE
|SWP_NOMOVE
))
117 CFrameWnd::OnWindowPosChanging(lpwndpos
);