Save all settings not just changed ones
[TortoiseGit.git] / ext / ResizableLib / ResizableMDIFrame.cpp
blobcf26e7e8a8ce9635c010be99fd0a8f6433e82c6d
1 // ResizableMDIFrame.cpp : implementation file
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // This file is part of ResizableLib
6 // http://sourceforge.net/projects/resizablelib
7 //
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 /////////////////////////////////////////////////////////////////////////////
20 #include "stdafx.h"
21 #include "ResizableMDIFrame.h"
23 #ifdef _DEBUG
24 #define new DEBUG_NEW
25 #undef THIS_FILE
26 static char THIS_FILE[] = __FILE__;
27 #endif
29 /////////////////////////////////////////////////////////////////////////////
30 // CResizableMDIFrame
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)
46 ON_WM_GETMINMAXINFO()
47 ON_WM_DESTROY()
48 ON_WM_NCCREATE()
49 ON_WM_WINDOWPOSCHANGING()
50 //}}AFX_MSG_MAP
51 END_MESSAGE_MAP()
53 /////////////////////////////////////////////////////////////////////////////
54 // CResizableMDIFrame message handlers
56 void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
58 // MDI should call default implementation
59 CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
61 MinMaxInfo(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))
93 return FALSE;
95 MakeResizable(lpCreateStruct);
97 return TRUE;
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
106 LRESULT lResult = 0;
107 HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
108 lResult = CMDIFrameWnd::WindowProc(message, wParam, lParam);
109 HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
110 return 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
120 Invalidate();