ResizablePage.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // ResizablePage.cpp : implementation file
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. //
  5. // This file is part of ResizableLib
  6. // https://github.com/ppescher/resizablelib
  7. //
  8. // Copyright (C) 2000-2015 by Paolo Messina
  9. // mailto:ppescher@hotmail.com
  10. //
  11. // The contents of this file are subject to the Artistic License 2.0
  12. // http://opensource.org/licenses/Artistic-2.0
  13. //
  14. // If you find this code useful, credits would be nice!
  15. //
  16. /////////////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "ResizablePage.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CResizablePage
  26. IMPLEMENT_DYNCREATE(CResizablePage, CPropertyPage)
  27. CResizablePage::CResizablePage()
  28. {
  29. }
  30. CResizablePage::CResizablePage(UINT nIDTemplate, UINT nIDCaption)
  31. : CPropertyPage(nIDTemplate, nIDCaption)
  32. {
  33. }
  34. CResizablePage::CResizablePage(LPCTSTR lpszTemplateName, UINT nIDCaption)
  35. : CPropertyPage(lpszTemplateName, nIDCaption)
  36. {
  37. }
  38. CResizablePage::~CResizablePage()
  39. {
  40. }
  41. BEGIN_MESSAGE_MAP(CResizablePage, CPropertyPage)
  42. //{{AFX_MSG_MAP(CResizablePage)
  43. ON_WM_SIZE()
  44. ON_WM_ERASEBKGND()
  45. ON_WM_GETMINMAXINFO()
  46. ON_WM_DESTROY()
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CResizablePage message handlers
  51. void CResizablePage::OnSize(UINT nType, int cx, int cy)
  52. {
  53. CWnd::OnSize(nType, cx, cy);
  54. ArrangeLayout();
  55. }
  56. BOOL CResizablePage::OnEraseBkgnd(CDC* pDC)
  57. {
  58. ClipChildren(pDC, FALSE);
  59. BOOL bRet = CPropertyPage::OnEraseBkgnd(pDC);
  60. ClipChildren(pDC, TRUE);
  61. return bRet;
  62. }
  63. void CResizablePage::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
  64. {
  65. MinMaxInfo(lpMMI);
  66. }
  67. BOOL CResizablePage::OnInitDialog()
  68. {
  69. CPropertyPage::OnInitDialog();
  70. // set the initial size as the min track size
  71. CRect rc;
  72. GetWindowRect(&rc);
  73. SetMinTrackSize(rc.Size());
  74. return TRUE; // return TRUE unless you set the focus to a control
  75. // EXCEPTION: OCX Property Pages should return FALSE
  76. }
  77. void CResizablePage::OnDestroy()
  78. {
  79. // remove child windows
  80. RemoveAllAnchors();
  81. ResetAllRects();
  82. CPropertyPage::OnDestroy();
  83. }
  84. LRESULT CResizablePage::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  85. {
  86. if (message != WM_NCCALCSIZE || wParam == 0)
  87. return CPropertyPage::WindowProc(message, wParam, lParam);
  88. LRESULT lResult = 0;
  89. HandleNcCalcSize(FALSE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
  90. lResult = CPropertyPage::WindowProc(message, wParam, lParam);
  91. HandleNcCalcSize(TRUE, (LPNCCALCSIZE_PARAMS)lParam, lResult);
  92. return lResult;
  93. }