XTPSkinObjectMDI.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPSkinObjectMDI.cpp: implementation of the CXTPSkinObjectMDI class.
  2. //
  3. // This file is a part of the XTREME SKINFRAMEWORK MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Common/XTPDrawHelpers.h"
  22. #include "XTPSkinObjectMDI.h"
  23. #include "XTPSkinManager.h"
  24. #define MM_CALCSCROLL            0x003F
  25. #ifdef _DEBUG
  26. #undef THIS_FILE
  27. static char THIS_FILE[]=__FILE__;
  28. #define new DEBUG_NEW
  29. #endif
  30. //////////////////////////////////////////////////////////////////////
  31. // Construction/Destruction
  32. //////////////////////////////////////////////////////////////////////
  33. IMPLEMENT_DYNCREATE(CXTPSkinObjectMDIClient, CXTPSkinObjectFrame)
  34. CXTPSkinObjectMDIClient::CXTPSkinObjectMDIClient()
  35. {
  36. m_bMDIClient = TRUE;
  37. m_bArrange = FALSE;
  38. m_pMDIParent = NULL;
  39. }
  40. CXTPSkinObjectMDIClient::~CXTPSkinObjectMDIClient()
  41. {
  42. }
  43. BEGIN_MESSAGE_MAP(CXTPSkinObjectMDIClient, CXTPSkinObjectFrame)
  44. //{{AFX_MSG_MAP(CXTPSkinObjectButton)
  45. ON_WM_VSCROLL()
  46. ON_WM_HSCROLL()
  47. ON_MESSAGE(MM_CALCSCROLL, OnCalcScroll)
  48. ON_WM_NCACTIVATE()
  49. ON_WM_SIZE()
  50. ON_MESSAGE_VOID(WM_MDIICONARRANGE, OnMDIArrange)
  51. ON_MESSAGE_VOID(WM_MDICASCADE, OnMDIArrange)
  52. ON_MESSAGE_VOID(WM_MDITILE, OnMDIArrange)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. void CXTPSkinObjectMDIClient::OnHookAttached(LPCREATESTRUCT lpcs, BOOL bAuto)
  56. {
  57. CXTPSkinObjectFrame* pParent = (CXTPSkinObjectFrame*)GetSkinManager()->Lookup(lpcs->hwndParent);
  58. if (pParent)
  59. {
  60. m_pMDIParent = pParent;
  61. m_pMDIParent->m_pMDIClient = this;
  62. m_pMDIParent->InternalAddRef();
  63. }
  64. CXTPSkinObjectFrame::OnHookAttached(lpcs, bAuto);
  65. }
  66. void CXTPSkinObjectMDIClient::OnHookDetached(BOOL bAuto)
  67. {
  68. if (m_pMDIParent)
  69. {
  70. m_pMDIParent->m_pMDIClient = NULL;
  71. m_pMDIParent->InternalRelease();
  72. m_pMDIParent = NULL;
  73. }
  74. CXTPSkinObjectFrame::OnHookDetached(bAuto);
  75. }
  76. BOOL CXTPSkinObjectMDIClient::IsDefWindowProcAvail(int nMessage) const
  77. {
  78. return (UINT)nMessage == m_nMsgQuerySkinState;
  79. }
  80. void CXTPSkinObjectMDIClient::OnHScroll(UINT /*nSBCode*/, UINT /*nPos*/, CScrollBar* /*pScrollBar*/)
  81. {
  82. Default();
  83. RedrawScrollBar(SB_HORZ);
  84. }
  85. void CXTPSkinObjectMDIClient::OnVScroll(UINT /*nSBCode*/, UINT /*nPos*/, CScrollBar* /*pScrollBar*/)
  86. {
  87. Default();
  88. RedrawScrollBar(SB_VERT);
  89. }
  90. LRESULT CXTPSkinObjectMDIClient::OnCalcScroll(WPARAM, LPARAM)
  91. {
  92. LRESULT lResult = Default();
  93. RedrawScrollBar(SB_VERT);
  94. RedrawScrollBar(SB_HORZ);
  95. return lResult;
  96. }
  97. BOOL CXTPSkinObjectMDIClient::OnNcActivate(BOOL bActive)
  98. {
  99. BOOL bResult = CXTPSkinObjectFrame::OnNcActivate(bActive);
  100. RedrawScrollBar(SB_VERT);
  101. RedrawScrollBar(SB_HORZ);
  102. return bResult;
  103. }
  104. void CXTPSkinObjectMDIClient::OnSize(UINT nType, int cx, int cy)
  105. {
  106. if ((m_pManager->GetApplyOptions() & xtpSkinApplyMetrics))
  107. {
  108. HWND hwndActive = (HWND)SendMessage(WM_MDIGETACTIVE);
  109. if (hwndActive && ::GetWindowLongPtr(hwndActive, GWL_STYLE) & WS_MAXIMIZE)
  110. {
  111. CXTPSkinObjectFrame* pFrame = (CXTPSkinObjectFrame*)m_pManager->Lookup(hwndActive);
  112. if (pFrame && pFrame->IsSkinEnabled())
  113. {
  114. CRect rcBorders = pFrame->GetBorders();
  115. RECT rc;
  116. rc.left = -rcBorders.left;
  117. rc.top = -rcBorders.top;
  118. rc.right = cx + rcBorders.right;
  119. rc.bottom = cy + rcBorders.bottom;
  120. ::MoveWindow(hwndActive, rc.left, rc.top,
  121. rc.right - rc.left, rc.bottom - rc.top, TRUE);
  122. return;
  123. }
  124. }
  125. }
  126. CXTPSkinObjectFrame::OnSize(nType, cx, cy);
  127. }
  128. void CXTPSkinObjectMDIClient::OnMDIArrange()
  129. {
  130. if (m_bArrange)
  131. {
  132. Default();
  133. return;
  134. }
  135. else
  136. {
  137. m_bArrange = TRUE;
  138. HWND hWnd = ::GetWindow(m_hWnd, GW_CHILD);
  139. while (hWnd)
  140. {
  141. CXTPSkinObjectFrame* pFrame = (CXTPSkinObjectFrame*)m_pManager->Lookup(hWnd);
  142. if (pFrame)
  143. {
  144. RECT rc = CXTPWindowRect(hWnd);
  145. pFrame->m_bLockFrameDraw += 1;
  146. pFrame->SendMessage(WM_NCCALCSIZE, FALSE, (LPARAM)&rc);
  147. pFrame->m_bLockFrameDraw -= 1;
  148. pFrame->SetTimer(XTP_TID_REFRESHFRAME, 1000, NULL);
  149. }
  150. hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
  151. }
  152. Default();
  153. m_bArrange = FALSE;
  154. hWnd = ::GetWindow(m_hWnd, GW_CHILD);
  155. while (hWnd)
  156. {
  157. CXTPSkinObjectFrame* pFrame = (CXTPSkinObjectFrame*)m_pManager->Lookup(hWnd);
  158. if (pFrame)
  159. {
  160. pFrame->RedrawFrame();
  161. }
  162. hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
  163. }
  164. }
  165. }