DrawerCtrl.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /************************************************************************/
  2. /* Copyright (C), 2016-2020, [IT], 保留所有权利;
  3. /* 模 块 名:;
  4. /* 描 述:;
  5. /*
  6. /* 版 本:[V];
  7. /* 作 者:[IT];
  8. /* 日 期:[8/19/2016];
  9. /*
  10. /*
  11. /* 注 意:;
  12. /*
  13. /* 修改记录:[IT];
  14. /* 修改日期:;
  15. /* 修改版本:;
  16. /* 修改内容:;
  17. /************************************************************************/
  18. #ifndef __DRAWERCTRL__
  19. #define __DRAWERCTRL__
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif // _MSC_VER >= 1000
  23. #include <afxcoll.h>
  24. #include "EnBitmap.h"
  25. #include "ChildFrameList.h"
  26. class CDrawerCtrl : public CWnd
  27. {
  28. // Construction
  29. DECLARE_DYNCREATE(CDrawerCtrl)
  30. public:
  31. CDrawerCtrl();
  32. // Attributes
  33. public:
  34. // 正常时的抽屉图片;
  35. CEnBitmap m_bmpNormalFolder;
  36. // 鼠标在上面的抽屉图片;
  37. CEnBitmap m_bmpHoverFolder;
  38. COLORREF m_crBackground;
  39. // 图片高度;
  40. UINT m_nFolderHeight;
  41. // 鼠标位置;
  42. CPoint m_curpoint;
  43. COLORREF m_crText;
  44. CFont* m_pFont;
  45. HCURSOR hHandCursor;
  46. int iLastFolderHighlighted;
  47. int iHoverFolder;
  48. // 当前选中的项;
  49. int m_nCurSelFolder;
  50. HICON iSelcon;
  51. CPtrArray m_arFolder;
  52. class CBm_arFolder
  53. {
  54. public:
  55. CBm_arFolder(const char* name, DWORD exData);
  56. virtual ~CBm_arFolder();
  57. char* cName;
  58. DWORD dwData;
  59. CWnd* pChild;
  60. };
  61. // Operations
  62. public:
  63. enum { htNothing = -1, htFolder, htFind };
  64. // Implementation
  65. public:
  66. void SetAutoFolder(IN const DWORD& dwTime = 800);
  67. DWORD GetFolderData(int iFolder = -1);
  68. CWnd* GetFolderChild(int iFolder = -1);
  69. int AddFolderBar(const char* pFolder, CWnd* pSon, const DWORD exData = 0);
  70. void HighlightFolder(const int index);
  71. void SetFolderText(const int index, const char* text);
  72. void SetFolderImage(LPCTSTR lpszPath);
  73. void SetSelIcon(LPCTSTR lpszIconPath);
  74. void RemoveFolder(const int index);
  75. int GetSelFolder() const;
  76. int GetFolderCount() const;
  77. void SetSelFolder(const int index);
  78. int HitTestEx(const CPoint& point, int& index);
  79. void GetInsideRect(CRect& rect) const;
  80. int AddFolder(const char* cFolderName, const DWORD exData);
  81. bool GetFolderRect(const int iIndex, CRect& rect) const;
  82. bool PtInFolderHeadRect(CPoint pt) const;
  83. BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  84. void SetFolderHeight(UINT nHeight) { m_nFolderHeight = nHeight; };
  85. virtual ~CDrawerCtrl();
  86. // Generated message map functions
  87. protected:
  88. void DrawFolder(CDC* pDC, const int iIdx, CRect rect);
  89. //{{AFX_MSG(CDrawerCtrl)
  90. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  91. afx_msg void OnPaint();
  92. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  93. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  94. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  95. afx_msg void OnTimer(UINT_PTR nIDEvent);
  96. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  97. afx_msg void OnSize(UINT nType, int cx, int cy);
  98. //}}AFX_MSG
  99. DECLARE_MESSAGE_MAP()
  100. public:
  101. CWnd* GetFolderWnd(const char* pszName);
  102. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  103. afx_msg void OnNMClickNavQuarter(NMHDR* pNMHDR, LRESULT* pResult);
  104. afx_msg void OnNMClickNavOthers(NMHDR* pNMHDR, LRESULT* pResult);
  105. };
  106. #endif