SubLabel.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #if !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
  2. #define AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. // Label.h : header file
  7. //
  8. #define NM_LINKCLICK WM_APP + 0x200
  9. /////////////////////////////////////////////////////////////////////////////
  10. // CLabel window
  11. class CLabel : public CStatic
  12. {
  13. // Construction
  14. public:
  15. static enum LinkStyle { LinkNone, HyperLink, MailLink };
  16. static enum FlashType {None, Text, Background };
  17. static enum Type3D { Raised, Sunken};
  18. static enum BackFillMode { Normal, Gradient };
  19. CLabel();
  20. virtual CLabel& SetBkColor(COLORREF crBkgnd, COLORREF crBkgndHigh = 0, BackFillMode mode = Normal);
  21. virtual CLabel& SetTextColor(COLORREF crText);
  22. virtual CLabel& SetText(const CString& strText);
  23. virtual CLabel& SetFontBold(BOOL bBold);
  24. virtual CLabel& SetFontName(const CString& strFont, BYTE byCharSet = ANSI_CHARSET);
  25. virtual CLabel& SetFontUnderline(BOOL bSet);
  26. virtual CLabel& SetFontItalic(BOOL bSet);
  27. virtual CLabel& SetFontSize(int nSize);
  28. virtual CLabel& SetSunken(BOOL bSet);
  29. virtual CLabel& SetBorder(BOOL bSet);
  30. virtual CLabel& SetTransparent(BOOL bSet);
  31. virtual CLabel& FlashText(BOOL bActivate);
  32. virtual CLabel& FlashBackground(BOOL bActivate);
  33. virtual CLabel& SetLink(BOOL bLink,BOOL bNotifyParent);
  34. virtual CLabel& SetLinkCursor(HCURSOR hCursor);
  35. virtual CLabel& SetFont3D(BOOL bSet,Type3D type=Raised);
  36. virtual CLabel& SetRotationAngle(UINT nAngle,BOOL bRotation);
  37. virtual CLabel& SetText3DHiliteColor(COLORREF cr3DHiliteColor);
  38. virtual CLabel& SetFont(LOGFONT lf);
  39. virtual CLabel& SetMailLink(BOOL bEnable, BOOL bNotifyParent);
  40. virtual CLabel& SetHyperLink(const CString& sLink);
  41. // Attributes
  42. public:
  43. protected:
  44. void UpdateSurface();
  45. void ReconstructFont();
  46. void DrawGradientFill(CDC* pDC, CRect* pRect, COLORREF crStart, COLORREF crEnd, int nSegments);
  47. COLORREF m_crText;
  48. COLORREF m_cr3DHiliteColor;
  49. HBRUSH m_hwndBrush;
  50. HBRUSH m_hBackBrush;
  51. LOGFONT m_lf;
  52. CFont m_font;
  53. BOOL m_bState;
  54. BOOL m_bTimer;
  55. LinkStyle m_Link;
  56. BOOL m_bTransparent;
  57. BOOL m_bFont3d;
  58. BOOL m_bToolTips;
  59. BOOL m_bNotifyParent;
  60. BOOL m_bRotation;
  61. FlashType m_Type;
  62. HCURSOR m_hCursor;
  63. Type3D m_3dType;
  64. BackFillMode m_fillmode;
  65. COLORREF m_crHiColor;
  66. COLORREF m_crLoColor;
  67. CString m_sLink;
  68. CDC* m_pMemDC;
  69. //CDC* pDCMem;
  70. // Operations
  71. public:
  72. // Overrides
  73. // ClassWizard generated virtual function overrides
  74. //{{AFX_VIRTUAL(CLabel)
  75. protected:
  76. virtual void PreSubclassWindow();
  77. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  78. //}}AFX_VIRTUAL
  79. // Implementation
  80. public:
  81. virtual ~CLabel();
  82. // Generated message map functions
  83. protected:
  84. //{{AFX_MSG(CLabel)
  85. afx_msg void OnTimer(UINT nIDEvent);
  86. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  87. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  88. afx_msg void OnSysColorChange();
  89. afx_msg void OnPaint();
  90. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  91. //}}AFX_MSG
  92. DECLARE_MESSAGE_MAP()
  93. public:
  94. //tc:这就是新添加的ON_WM_CTLCOLOR_REFLECT()消息的响应函数
  95. afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
  96. };
  97. /////////////////////////////////////////////////////////////////////////////
  98. //{{AFX_INSERT_LOCATION}}
  99. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  100. #endif // !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)