GuiCapOutBar.cpp
上传用户:zhanglf88
上传日期:2013-11-19
资源大小:6036k
文件大小:5k
源码类别:

金融证券系统

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------//
  2. // This is a part of the GuiLib MFC Extention.  //
  3. // Autor  :  Francisco Campos  //
  4. // (C) 2002 Francisco Campos <www.beyondata.com> All rights reserved     //
  5. // This code is provided "as is", with absolutely no warranty expressed  //
  6. // or implied. Any use is at your own risk.  //
  7. // You must obtain the author's consent before you can include this code //
  8. // in a software library.  //
  9. // If the source code in  this file is used in any application  //
  10. // then acknowledgement must be made to the author of this program  //
  11. // fcampos@tutopia.com  //
  12. //-----------------------------------------------------------------------//
  13. #include "stdafx.h"
  14. #include "GuiCapOutBar.h"
  15. #include "resource.h"
  16. #include "GuiDrawLayer.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. //////////////////////////////////////////////////////////////////////
  23. // Construction/Destruction
  24. //////////////////////////////////////////////////////////////////////
  25. BEGIN_MESSAGE_MAP(GuiCapOutBar, CControlBar)
  26. //{{AFX_MSG_MAP(GuiCapOutBar)
  27. // NOTE - the ClassWizard will add and remove mapping macros here.
  28. //    DO NOT EDIT what you see in these blocks of generated code !
  29. ON_WM_CREATE()
  30. ON_WM_PAINT()
  31. ON_WM_ERASEBKGND()
  32. ON_WM_SIZE()
  33. ON_WM_SYSCOLORCHANGE()
  34. ON_WM_NCCALCSIZE()
  35. ON_WM_NCPAINT()
  36. ON_WM_LBUTTONDOWN()
  37. ON_WM_LBUTTONUP()
  38. ON_WM_TIMER()
  39. ON_WM_SETCURSOR()
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. GuiCapOutBar::GuiCapOutBar()
  43. {
  44. m_iBorder=4;
  45. m_MiniTool=NULL;
  46. m_miniSplitter=NULL;
  47. }
  48. GuiCapOutBar::~GuiCapOutBar()
  49. {
  50. }
  51. BOOL GuiCapOutBar::Create (DWORD dwStyle, CWnd* pParentWnd, UINT uID,int iMaxi)
  52. {
  53. SetBarStyle (CBRS_ALIGN_TOP);
  54. m_uID=uID;
  55. m_iHigh=iMaxi;
  56. return CControlBar::Create(0,0,dwStyle,CRect(0,0,0,0),pParentWnd,uID);
  57. }
  58. void GuiCapOutBar::SetStyleFlag(BOOL m_bFlag)
  59. {
  60. m_bIsFlag=m_bFlag;  //si quiere que se comporte como un boton
  61. }
  62. void GuiCapOutBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
  63. {
  64. }
  65. CSize GuiCapOutBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
  66. {
  67. return CSize(32767,m_iHigh);
  68. }
  69. int GuiCapOutBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
  70. {
  71. if (CControlBar::OnCreate(lpCreateStruct)==-1)
  72. return -1;
  73. return 0;
  74. }
  75. void GuiCapOutBar::OnPaint()
  76. {
  77. CPaintDC dc(this);
  78. CRect rcClient;
  79. GetClientRect(&rcClient);
  80. CBrush cb;
  81. cb.CreateSysColorBrush(GuiDrawLayer::GetRGBColorShadow());
  82. dc.FillRect(rcClient,&cb);
  83. }
  84. void GuiCapOutBar::RecalLayout()
  85. {
  86. if (!GetSafeHwnd()) return;
  87. CRect m_rc;
  88. GetClientRect(m_rc);
  89. if (m_MiniTool != NULL  && m_miniSplitter != NULL) 
  90. {
  91. CRect m_rctemp=m_rc;
  92. m_rctemp.right=m_rc.Width()/2;
  93. m_MiniTool->MoveWindow(m_rctemp);
  94. m_rctemp=m_rc;
  95. m_rctemp.left=(m_rc.Width()/2)+1;
  96. m_miniSplitter->MoveWindow(m_rctemp);
  97. }
  98. else if( m_MiniTool != NULL)
  99. m_MiniTool->MoveWindow(m_rc);
  100. else if (m_miniSplitter != NULL)
  101. m_miniSplitter->MoveWindow(m_rc);
  102. }
  103. BOOL  GuiCapOutBar::SetSplitter(CGuiMiniSplitter* m_sppliter)
  104. {
  105. if (!m_sppliter->Create(this))
  106. return FALSE;
  107. m_miniSplitter=m_sppliter;
  108. RecalLayout();
  109. return TRUE;
  110. }
  111. BOOL GuiCapOutBar::SetMiniTool(CGuiMiniTool* m_sppliter)
  112. {
  113. if (!m_sppliter->Create(_T(""),WS_VISIBLE | WS_CHILD |SS_OWNERDRAW, 
  114. CRect(0,0,0,0), this))
  115. return FALSE;
  116. m_MiniTool=m_sppliter;
  117. RecalLayout();
  118. return TRUE;
  119. }
  120. BOOL GuiCapOutBar::OnEraseBkgnd(CDC* pDC)
  121. {
  122. CBrush cbr;
  123. cbr.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
  124. CRect m_rect;
  125. GetClientRect(m_rect);
  126. pDC->FillRect(m_rect,&cbr);
  127. return TRUE;
  128. }
  129. void GuiCapOutBar::OnSize(UINT nType, int cx, int cy)
  130. {
  131. CControlBar::OnSize(nType,cx,cy);
  132. RecalLayout();
  133. }
  134. void GuiCapOutBar::OnSysColorChange()
  135. {
  136. CControlBar::OnSysColorChange();
  137. }
  138. void GuiCapOutBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp)
  139. {
  140. lpncsp->rgrc[0].bottom -= m_iBorder;
  141. lpncsp->rgrc[0].top  += m_iBorder+3;
  142. lpncsp->rgrc[0].left += m_iBorder;
  143. lpncsp->rgrc[0].right-=m_iBorder;
  144. }
  145. void GuiCapOutBar::OnNcPaint()
  146. {
  147. CRect rcWindow;
  148. CRect rcClient;
  149. CWindowDC dc(this);
  150. GetWindowRect(&rcWindow);
  151. GetClientRect(&rcClient);
  152. CBrush cbr;
  153. cbr.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace());
  154. rcClient.OffsetRect(-rcWindow.TopLeft());
  155.     rcWindow.OffsetRect(-rcWindow.TopLeft());
  156.     ScreenToClient(rcWindow);
  157. rcClient.OffsetRect(-rcWindow.left,-rcWindow.top);
  158. dc.ExcludeClipRect(rcClient);   
  159. rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top);
  160. int ibotton=rcWindow.bottom;
  161. rcWindow.top=rcWindow.bottom-m_iBorder;
  162. dc.FillRect(rcWindow,&cbr); 
  163. rcWindow.top=0;
  164. rcWindow.bottom+=3;
  165. dc.FillRect(rcWindow,&cbr); 
  166. dc.FillSolidRect(0,rcWindow.top+1,rcWindow.right+1,1,GuiDrawLayer::GetRGBColorBTNHigh()); 
  167. }