HoverButton.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #if !defined(AFX_HOVERBUTTON_H__1155737E_628E_11D2_81B5_0020AFC24C58__INCLUDED_)
  2. #define AFX_HOVERBUTTON_H__1155737E_628E_11D2_81B5_0020AFC24C58__INCLUDED_
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. // HoverButton.h : header file
  7. //
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CHoverButton window
  10. enum BUTTON_STATE{ BUTTON_OFF, BUTTON_ON, BUTTON_OVER, BUTTON_GREYED};
  11. class CHoverButton : public CBitmapButton
  12. {
  13. // Construction
  14. public:
  15. // Constructor: default is to use buttons defined in our resources
  16. CHoverButton();
  17. // Attributes
  18. public:
  19. // The only way of accessing data from outside this class is to call these 2 functions
  20. BUTTON_STATE GetButtonState(void) { return(m_ButtonState);};
  21. BUTTON_STATE SetButtonState(BUTTON_STATE nState);
  22. void SetTabButton( bool bTabButton)
  23. {
  24. m_bTabButton = bTabButton;
  25. };
  26. bool GetTabButton( bool bTabButton )
  27. {
  28. return m_bTabButton;
  29. };
  30. private:
  31. bool m_bTabButton;
  32. bool m_bTabState;
  33. BOOL m_bMouseTracking;
  34. BUTTON_STATE m_ButtonState;
  35. CBitmap m_bmpButtonDown;
  36. CBitmap m_bmpButtonFocussed;
  37. CBitmap m_bmpButtonUp;
  38. CBitmap m_bmpButtonDisabled;
  39. HWND m_hWndOld;
  40. //此为了防止光标从右边的工具条直接移动到按钮上造成右边的工具条不隐藏
  41. //CLeftToolbar* m_pLeftToolbar;
  42. // Operations
  43. public:
  44. // Overrides
  45. // ClassWizard generated virtual function overrides
  46. //{{AFX_VIRTUAL(CHoverButton)
  47. public:
  48. virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  49. //}}AFX_VIRTUAL
  50. public:
  51. // Called by OnMouseMove() when entering/leaving the button
  52. void OnMouseLeave(void);
  53. void OnMouseEnter(void);
  54. void SetTabState( bool bTabState );
  55. bool GetTabState();
  56. // Implementation
  57. public:
  58. virtual ~CHoverButton();
  59. BOOL LoadBitmaps(UINT nBitmapUp, UINT nBitmapDown, UINT nBitmapFocus, UINT nBitmapDisabled);
  60. BOOL LoadBitmaps(LPCSTR lpszBitmapUp, LPCSTR lpszBitmapDown, LPCSTR lpszBitmapFocus, LPCSTR lpszBitmapDisabled);
  61. // Generated message map functions
  62. protected:
  63. //{{AFX_MSG(CHoverButton)
  64. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  65. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  66. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  67. //}}AFX_MSG
  68. DECLARE_MESSAGE_MAP()
  69. };
  70. /////////////////////////////////////////////////////////////////////////////
  71. //{{AFX_INSERT_LOCATION}}
  72. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  73. #endif // !defined(AFX_HOVERBUTTON_H__1155737E_628E_11D2_81B5_0020AFC24C58__INCLUDED_)