InfoFrame.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // InfoFrame.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "InfoFrame.h"
  16. #ifdef _DEBUG
  17. #undef new
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CInfoFrame
  24. IMPLEMENT_DYNCREATE(CInfoFrame, CMiniFrameWnd)
  25. CInfoFrame::CInfoFrame()
  26. {
  27. m_pInfoSheet = NULL;
  28. }
  29. CInfoFrame::~CInfoFrame()
  30. {
  31. // there is no need to destroy or delete sheet object m_pInfoSheet because
  32. // it is created as child window and will be automatically deleted trough its
  33. // PostNcDestroy() and DestroyWindow() member functions. (second one will be called
  34. // by its parent and will end with "delete this;"
  35. }
  36. BEGIN_MESSAGE_MAP(CInfoFrame, CMiniFrameWnd)
  37. //{{AFX_MSG_MAP(CInfoFrame)
  38. ON_WM_CREATE()
  39. ON_WM_CLOSE()
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CInfoFrame message handlers
  44. int CInfoFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  45. {
  46. if (CMiniFrameWnd::OnCreate(lpCreateStruct) == -1)
  47. return -1;
  48. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  49. // create sheet object to hold numerous pages
  50. m_pInfoSheet = new CInfoSheet(this);
  51. // if creation fails, delete allocated object
  52. if (!m_pInfoSheet->Create(this, WS_CHILD | WS_VISIBLE, 0))
  53. {
  54. delete m_pInfoSheet;
  55. m_pInfoSheet = NULL;
  56. return -1;
  57. }
  58. // resize the mini frame so that it fits around the child property sheet
  59. CRect rectClient, rectWindow;
  60. // property sheet's window rectangle
  61. m_pInfoSheet->GetWindowRect(rectClient);
  62. // becomes mini frame's client rectangle
  63. rectWindow = rectClient;
  64. // add the width and height needed from the mini frame's borders
  65. CalcWindowRect(rectWindow);
  66. // get screen size
  67. int iScreenWidth = ::GetSystemMetrics(SM_CXSCREEN);
  68. int iScreenHeight = ::GetSystemMetrics(SM_CYSCREEN);
  69. // rectangle to hold status bar size
  70. CRect rectStatusBar;
  71. // get status bar rectangle
  72. pMainFrame->m_wndStatusBar.GetWindowRect( rectStatusBar);
  73. // rectangle to hold mainframe height
  74. CRect rectMainFrame;
  75. // get main frame rectangle
  76. pMainFrame->GetWindowRect( rectMainFrame);
  77. PIX pixStatusHeight = rectStatusBar.Height();
  78. PIX pixInfoHeight = rectWindow.Height();
  79. PIX pixMainFrameHeight = rectMainFrame.Height();
  80. // offset mini frame window coordinates so it fits in lower left part of the screen
  81. //rectWindow.OffsetRect( 3, iScreenHeight - pixInfoHeight - pixStatusHeight - 3);
  82. rectWindow.OffsetRect( 0, pixMainFrameHeight - pixInfoHeight - pixStatusHeight - 9);
  83. // move frame window to new position
  84. SetWindowPos( NULL, rectWindow.left, rectWindow.top, rectWindow.Width(), rectWindow.Height(),
  85. SWP_NOZORDER | SWP_NOACTIVATE);
  86. // set property sheet position and type
  87. m_pInfoSheet->SetWindowPos( NULL, 0, 0, rectClient.Width(), rectClient.Height(),
  88. SWP_NOZORDER | SWP_NOACTIVATE);
  89. return 0;
  90. }
  91. void CInfoFrame::OnClose()
  92. {
  93. // Instead of closing the modeless property sheet, just hide it.
  94. CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
  95. pMainFrame->m_pInfoFrame->ShowWindow(SW_HIDE);
  96. }