SPPropertyGridInplaceButton.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /********************************************
  2. ** 工作室:S&P工作室
  3. ** 作者 :张东斌
  4. ** 日期 :2007年6月
  5. *********************************************/
  6. #if !defined(__SPPROPERTYGRIDINPLACEBUTTON_H__)
  7. #define __SPPROPERTYGRIDINPLACEBUTTON_H__
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11. // class forwards
  12. class CSPPropertyGridView;
  13. class CSPPropertyGridItem;
  14. //===========================================================================
  15. // Summary:
  16. // CSPPropertyGridInplaceButton is a CStatic derived class.
  17. // It is an internal class used by Property Grid control.
  18. //===========================================================================
  19. class CSPPropertyGridInplaceButton : public CStatic
  20. {
  21. DECLARE_DYNAMIC( CSPPropertyGridInplaceButton )
  22. public:
  23. //-----------------------------------------------------------------------
  24. // Summary:
  25. // Constructs a CSPPropertyGridInplaceButton object
  26. //-----------------------------------------------------------------------
  27. CSPPropertyGridInplaceButton();
  28. //-----------------------------------------------------------------------
  29. // Summary:
  30. // Destroys a CSPPropertyGridInplaceButton object, handles cleanup
  31. // and deallocation.
  32. //-----------------------------------------------------------------------
  33. virtual ~CSPPropertyGridInplaceButton();
  34. //-----------------------------------------------------------------------
  35. // Summary:
  36. // Call this method to hide the in-place button control.
  37. //-----------------------------------------------------------------------
  38. virtual void HideWindow();
  39. //-----------------------------------------------------------------------
  40. // Summary:
  41. // Call this method to create the in-place button control.
  42. // Parameters:
  43. // pItem - Points to a CSPPropertyGridItem object
  44. // rect - Specifies the size and position of the item.
  45. //-----------------------------------------------------------------------
  46. virtual void Create( CSPPropertyGridItem * pItem , CRect rect );
  47. //-----------------------------------------------------------------------
  48. // Summary:
  49. // This method is called when the parent item is destroyed.
  50. //-----------------------------------------------------------------------
  51. virtual void DestroyItem();
  52. //-----------------------------------------------------------------------
  53. // Summary:
  54. // This member function retrieves the child property grid item
  55. // Returns:
  56. // A pointer to a CSPPropertyGridItem object
  57. //-----------------------------------------------------------------------
  58. CSPPropertyGridItem * GetItem();
  59. public:
  60. BOOL m_bPressed; // TRUE if the button is pressed.
  61. BOOL m_bOver; // TRUE if the mouse cursor is over the button.
  62. private:
  63. CWnd * m_pGrid;
  64. CSPPropertyGridItem * m_pItem;
  65. protected:
  66. //{{AFX_CODEJOCK_PRIVATE
  67. //{{AFX_MSG(CSPPropertyGridInplaceButton)
  68. afx_msg void OnPaint();
  69. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  70. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  71. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  72. afx_msg void OnCaptureChanged(CWnd *pWnd);
  73. afx_msg void OnSetFocus(CWnd* pOldWnd);
  74. afx_msg void OnKillFocus(CWnd* pNewWnd);
  75. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  76. afx_msg UINT OnGetDlgCode();
  77. afx_msg void OnMouseLeave();
  78. //}}AFX_MSG
  79. private:
  80. BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
  81. BOOL Create(LPCTSTR lpszText, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID = 0xffff);
  82. DECLARE_MESSAGE_MAP()
  83. friend class CSPPropertyGridItem;
  84. //}}AFX_CODEJOCK_PRIVATE
  85. };
  86. AFX_INLINE CSPPropertyGridItem * CSPPropertyGridInplaceButton::GetItem()
  87. {
  88. return m_pItem;
  89. }
  90. AFX_INLINE BOOL CSPPropertyGridInplaceButton::Create( LPCTSTR lpszClassName , LPCTSTR lpszWindowName , DWORD dwStyle , const RECT & rect , CWnd * pParentWnd , UINT nID , CCreateContext * pContext )
  91. {
  92. return CWnd::Create( lpszClassName,lpszWindowName,dwStyle,rect,pParentWnd,nID,pContext );
  93. }
  94. AFX_INLINE BOOL CSPPropertyGridInplaceButton::Create( LPCTSTR lpszText , DWORD dwStyle , const RECT & rect , CWnd * pParentWnd , UINT nID )
  95. {
  96. return CStatic::Create( lpszText,dwStyle,rect,pParentWnd,nID );
  97. }
  98. #endif //#if !defined(__SPPROPERTYGRIDINPLACEBUTTON_H__)