/ext/ResizableLib/ResizableMDIFrame.cpp

https://gitlab.com/hussinhassan80/tortoisegit · C++ · 122 lines · 66 code · 24 blank · 32 comment · 9 complexity · 1204d9ab5f86237f8d6d59a236dd334f MD5 · raw file

  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
  10. //
  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
  15. //
  16. // If you find this code useful, credits would be nice!
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "ResizableMDIFrame.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CResizableMDIFrame
  28. IMPLEMENT_DYNCREATE(CResizableMDIFrame, CMDIFrameWnd)
  29. CResizableMDIFrame::CResizableMDIFrame()
  30. {
  31. m_bEnableSaveRestore = FALSE;
  32. m_bRectOnly = FALSE;
  33. }
  34. CResizableMDIFrame::~CResizableMDIFrame()
  35. {
  36. }
  37. BEGIN_MESSAGE_MAP(CResizableMDIFrame, CMDIFrameWnd)
  38. //{{AFX_MSG_MAP(CResizableMDIFrame)
  39. ON_WM_GETMINMAXINFO()
  40. ON_WM_DESTROY()
  41. ON_WM_NCCREATE()
  42. ON_WM_WINDOWPOSCHANGING()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CResizableMDIFrame message handlers
  47. void CResizableMDIFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
  48. {
  49. // MDI should call default implementation
  50. CMDIFrameWnd::OnGetMinMaxInfo(lpMMI);
  51. MinMaxInfo(lpMMI);
  52. BOOL bMaximized = FALSE;
  53. CMDIChildWnd* pChild = MDIGetActive(&bMaximized);
  54. if (pChild != NULL && bMaximized)
  55. ChainMinMaxInfo(lpMMI, this, pChild);
  56. }
  57. // NOTE: this must be called after setting the layout
  58. // to have the view and its controls displayed properly
  59. BOOL CResizableMDIFrame::EnableSaveRestore(LPCTSTR pszSection, BOOL bRectOnly, BOOL bHorzResize, BOOL bVertResize)
  60. {
  61. m_sSection = pszSection;
  62. m_bEnableSaveRestore = TRUE;
  63. m_bRectOnly = bRectOnly;
  64. // restore immediately
  65. return LoadWindowRect(pszSection, bRectOnly, bHorzResize, bVertResize);
  66. }
  67. void CResizableMDIFrame::OnDestroy()
  68. {
  69. if (m_bEnableSaveRestore)
  70. SaveWindowRect(m_sSection, m_bRectOnly);
  71. CMDIFrameWnd::OnDestroy();
  72. }
  73. BOOL CResizableMDIFrame::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
  74. {
  75. if (!CMDIFrameWnd::OnNcCreate(lpCreateStruct))
  76. return FALSE;
  77. MakeResizable(lpCreateStruct);
  78. return TRUE;
  79. }
  80. LRESULT CResizableMDIFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  81. {
  82. if (message != WM_NCCALCSIZE || wParam == 0)
  83. return CMDIFrameWnd::WindowProc(message, wParam, lParam);
  84. // specifying valid rects needs controls already anchored
  85. LRESULT lResult = 0;
  86. HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
  87. lResult = CMDIFrameWnd::WindowProc(message, wParam, lParam);
  88. HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
  89. return lResult;
  90. }
  91. void CResizableMDIFrame::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
  92. {
  93. CMDIFrameWnd::OnWindowPosChanging(lpwndpos);
  94. // since this window class doesn't have the style CS_HREDRAW|CS_VREDRAW
  95. // the client area is not invalidated during a resize operation and
  96. // this prevents the system from using WM_NCCALCSIZE to validate rects
  97. Invalidate();
  98. }