FloorPageObject.cpp
上传用户:zhout2004
上传日期:2007-01-02
资源大小:218k
文件大小:5k
源码类别:

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. /************************************
  2.   REVISION LOG ENTRY
  3.   Revision By: Mihai Filimon
  4.   Revised on 9/12/98 2:22:50 PM
  5.   Comments: FloorPageObject.cpp: implementation of the CFloorPageObject class.
  6.  ************************************/
  7. #include "stdafx.h"
  8. #include "XFloorWnd.h"
  9. #include "FloorPageObject.h"
  10. #include "XFloorWndCtl.h"
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[]=__FILE__;
  14. #define new DEBUG_NEW
  15. #endif
  16. //////////////////////////////////////////////////////////////////////
  17. // Construction/Destruction
  18. //////////////////////////////////////////////////////////////////////
  19. IMPLEMENT_DYNAMIC(CFloorPageObject, CFloorObject)
  20. // Function name : CFloorPageObject::CFloorPageObject
  21. // Description     : default Contructor
  22. // Return type : 
  23. CFloorPageObject::CFloorPageObject(CXFloorWndCtrl* pWnd, LPCTSTR lpszPageName):CFloorObject(pWnd, lpszPageName)
  24. {
  25. m_pWndClient = NULL;
  26. m_pOldParent = NULL;
  27. }
  28. BOOL CFloorPageObject::m_bAutoDetach = TRUE;
  29. // Function name : CFloorPageObject::~CFloorPageObject
  30. // Description     : virtual destructor
  31. // Return type : 
  32. CFloorPageObject::~CFloorPageObject()
  33. {
  34. if (m_bAutoDetach)
  35. Detach();
  36. }
  37. // Function name : CFloorPageObject::OnDraw
  38. // Description     : Call this function by m_pParentWnd->OnDraw function to draw itself
  39. // Return type : void 
  40. // Argument         : CDC* pDC
  41. // Argument         : BOOL bEraseBkGnd
  42. void CFloorPageObject::OnDraw(CDC* pDC, BOOL bEraseBkGnd)
  43. {
  44. if (GetHeight())
  45. {
  46. if (bEraseBkGnd)
  47. {
  48. // Put dargray if thsi is m_pActivePage
  49. CBrush* pBrush = pDC->SelectObject(m_pParentWnd->GetActivePage() != this ? &m_brBkGnd : &CBrush(RGB(128,128,128)));
  50. pDC->PatBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), PATCOPY);
  51. pDC->SelectObject(pBrush);
  52. }
  53. pDC->SetBkMode(TRANSPARENT);
  54. CRect rDraw(m_rect);
  55. pDC->FrameRect(rDraw, &CBrush(RGB(0,0,0)));
  56. rDraw.InflateRect(-1,-1);
  57. pDC->FrameRect(rDraw, &CBrush(RGB(255,255,255)));
  58. rDraw.InflateRect(-1,-1);
  59. CBrush* pBrush = pDC->SelectObject(&m_brBkGnd);
  60. // CFont* pFont = pDC->SelectObject((CFont*)m_pParentWnd->GetPagesFont());
  61. CFont* pFont = m_pParentWnd->SelectStockFont(pDC);
  62. pDC->DrawText(m_sName, rDraw, m_nFormatDrawText);
  63. pDC->SelectObject(pFont);
  64. pDC->SelectObject(pBrush);
  65. }
  66. }
  67. // Function name : CFloorPageObject::OnFocus
  68. // Description     : Called to draw a arrow in this 
  69. // Return type : void 
  70. void CFloorPageObject::OnFocus()
  71. {
  72. if (m_pParentWnd)
  73. if (::IsWindow(m_pParentWnd->m_hWnd))
  74. if (m_pParentWnd->m_bSign)
  75. {
  76. CDC* pDC = m_pParentWnd->GetDC();
  77. pDC->DrawIcon(m_rect.right - 32, (m_rect.top + m_rect.bottom) / 2 - 16, AfxGetApp()->LoadIcon(IsPullUp() ? IDI_ICON_DOWN : IDI_ICON_UP));
  78. m_pParentWnd->ReleaseDC(pDC);
  79. }
  80. }
  81. // Function name : CFloorPageObject::SetRectClient
  82. // Description     : 
  83. // Return type : void 
  84. // Argument         : CRect rect
  85. void CFloorPageObject::SetRectClient(CRect rect)
  86. {
  87. if (m_pWndClient)
  88. m_pWndClient->MoveWindow(rect.left, rect.top, rect.Width(), rect.Height());
  89. }
  90. // Function name : CFloorPageObject::OnDeactivateObject
  91. // Description     : Called before deactivate the object
  92. // Return type : void 
  93. void CFloorPageObject::OnDeactivateObject()
  94. {
  95. if (m_pWndClient)
  96. m_pWndClient->ShowWindow(SW_HIDE);
  97. }
  98. // Function name : CFloorPageObject::OnActivateObject
  99. // Description     : Called after that object was activated
  100. // Return type : void 
  101. void CFloorPageObject::OnActivateObject()
  102. {
  103. if (m_pWndClient)
  104. m_pWndClient->ShowWindow(SW_SHOW);
  105. }
  106. // Function name : CFloorPageObject::Attach
  107. // Description     : Attach a window to this page
  108. // Return type : void 
  109. // Argument         : CWnd * pWnd
  110. void CFloorPageObject::Attach(CWnd * pWnd)
  111. {
  112. ASSERT (m_pParentWnd && ::IsWindow(m_pParentWnd->m_hWnd));
  113. ASSERT (pWnd && ::IsWindow(pWnd->m_hWnd));
  114. m_pOldParent = pWnd->GetParent();
  115. m_pParentWnd->ModifyStyle(0, WS_CLIPCHILDREN);
  116. m_pWndClient = pWnd;
  117. m_pWndClient->SetParent(m_pParentWnd);
  118. OnDeactivateObject();
  119. CFloorPageObject* pPage = m_pParentWnd->GetActivePage();
  120. if (pPage)
  121. {
  122. pPage->SetRectClient(m_pParentWnd->GetRectClient());
  123. pPage->OnActivateObject();
  124. }
  125. }
  126. // Function name : CFloorPageObject::Detach
  127. // Description     : Dettach the window.
  128. // Return type : void 
  129. void CFloorPageObject::Detach()
  130. {
  131. if (m_pOldParent)
  132. if (::IsWindow(m_pOldParent->m_hWnd))
  133. m_pWndClient->SetParent(m_pOldParent);
  134. m_pOldParent = NULL;
  135. m_pWndClient = NULL;
  136. if (m_pParentWnd)
  137. if (::IsWindow(m_pParentWnd->m_hWnd))
  138. m_pParentWnd->Invalidate();
  139. }
  140. // Function name : CFloorPageObject::GetWindow
  141. // Description     : 
  142. // Return type : CWnd* 
  143. CWnd* CFloorPageObject::GetWindow()
  144. {
  145. return m_pWndClient;
  146. }
  147. void CFloorPageObject::PrepareToScroll()
  148. {
  149. }
  150. void CFloorPageObject::EndScroll()
  151. {
  152. }