OSDN Git Service

Add ext and utils
[tortoisegit/TortoiseGitJp.git] / ext / ResizableLib / ResizableMDIFrame.cpp
diff --git a/ext/ResizableLib/ResizableMDIFrame.cpp b/ext/ResizableLib/ResizableMDIFrame.cpp
new file mode 100644 (file)
index 0000000..cf26e7e
--- /dev/null
@@ -0,0 +1,121 @@
+// ResizableMDIFrame.cpp : implementation file\r
+//\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// This file is part of ResizableLib\r
+// http://sourceforge.net/projects/resizablelib\r
+//\r
+// Copyright (C) 2000-2004 by Paolo Messina\r
+// http://www.geocities.com/ppescher - mailto:ppescher@hotmail.com\r
+//\r
+// The contents of this file are subject to the Artistic License (the "License").\r
+// You may not use this file except in compliance with the License. \r
+// You may obtain a copy of the License at:\r
+// http://www.opensource.org/licenses/artistic-license.html\r
+//\r
+// If you find this code useful, credits would be nice!\r
+//\r
+/////////////////////////////////////////////////////////////////////////////\r
+\r
+#include "stdafx.h"\r
+#include "ResizableMDIFrame.h"\r
+\r
+#ifdef _DEBUG\r
+#define new DEBUG_NEW\r
+#undef THIS_FILE\r
+static char THIS_FILE[] = __FILE__;\r
+#endif\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// CResizableMDIFrame\r
+\r
+IMPLEMENT_DYNCREATE(CResizableMDIFrame, CMDIFrameWnd)\r
+\r
+CResizableMDIFrame::CResizableMDIFrame()\r
+{\r
+       m_bEnableSaveRestore = FALSE;\r
+}\r
+\r
+CResizableMDIFrame::~CResizableMDIFrame()\r
+{\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CResizableMDIFrame, CMDIFrameWnd)\r
+       //{{AFX_MSG_MAP(CResizableMDIFrame)\r
+       ON_WM_GETMINMAXINFO()\r
+       ON_WM_DESTROY()\r
+       ON_WM_NCCREATE()\r
+       ON_WM_WINDOWPOSCHANGING()\r
+       //}}AFX_MSG_MAP\r
+END_MESSAGE_MAP()\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+// CResizableMDIFrame message handlers\r
+\r
+void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) \r
+{\r
+       // MDI should call default implementation\r
+       CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);\r
+\r
+       MinMaxInfo(lpMMI);\r
+\r
+       BOOL bMaximized = FALSE;\r
+       CMDIChildWnd* pChild = MDIGetActive(&bMaximized);\r
+       if (pChild != NULL && bMaximized)\r
+               ChainMinMaxInfo(lpMMI, this, pChild);\r
+}\r
+\r
+// NOTE: this must be called after setting the layout\r
+//       to have the view and its controls displayed properly\r
+BOOL CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly)\r
+{\r
+       m_sSection = pszSection;\r
+\r
+       m_bEnableSaveRestore = TRUE;\r
+       m_bRectOnly = bRectOnly;\r
+\r
+       // restore immediately\r
+       return LoadWindowRect(pszSection, bRectOnly);\r
+}\r
+\r
+void CResizableMDIFrame::OnDestroy() \r
+{\r
+       if (m_bEnableSaveRestore)\r
+               SaveWindowRect(m_sSection, m_bRectOnly);\r
+\r
+       CMDIFrameWnd::OnDestroy();\r
+}\r
+\r
+BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct) \r
+{\r
+       if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct))\r
+               return FALSE;\r
+\r
+       MakeResizable(lpCreateStruct);\r
+       \r
+       return TRUE;\r
+}\r
+\r
+LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) \r
+{\r
+       if (message != WM_NCCALCSIZE || wParam == 0)\r
+               return CMDIFrameWnd::WindowProc(message, wParam, lParam);\r
+\r
+       // specifying valid rects needs controls already anchored\r
+       LRESULT lResult = 0;\r
+       HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
+       lResult = CMDIFrameWnd::WindowProc(message, wParam, lParam);\r
+       HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);\r
+       return lResult;\r
+}\r
+\r
+void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) \r
+{\r
+       CMDIFrameWnd::OnWindowPosChanging(lpwndpos);\r
+\r
+       // since this window class doesn't have the style CS_HREDRAW|CS_VREDRAW\r
+       // the client area is not invalidated during a resize operation and\r
+       // this prevents the system from using WM_NCCALCSIZE to validate rects\r
+       Invalidate();\r
+}\r