VC_按钮颜色设置.docVIP

  • 3
  • 0
  • 约1.32万字
  • 约 6页
  • 2017-06-07 发布于重庆
  • 举报
VC_按钮颜色设置

这是一个实现自绘CButton的类,期望对大家有点帮助,我提供这个类,只是为大家提供一个自绘控件的思路,你可以在此基础上,随意地修改代码,直到它能完成你所需要的功能.其它控件的自绘,原理了和这个差不多. 1.#if !defined(AFX_BUTTONST_H__1271FF9C_E28C_4D3B_B429_AFE65924A5D0__INCLUDED_) 2.#define AFX_BUTTONST_H__1271FF9C_E28C_4D3B_B429_AFE65924A5D0__INCLUDED_ 3.4.#if _MSC_VER 1000 5.#pragma once 6.#endif // _MSC_VER 1000 7.// ButtonST.h : header file 8.// 9.10.///////////////////////////////////////////////////////////////////////////// 11.// CButtonST window 12.13.class CButtonST : public CButton 14.{ 15.// Construction 16.public: 17. CButtonST(); 18.19.// Attributes 20.public: 21. 22.// Operations 23.public: 24. //设置背景颜色 25. void SetBkColor(COLORREF BkColor); 26. //设置鼠标在按钮上的偏移颜色 27. void SetShOffset(int nShOffset); 28. //设置字体颜色 29. void SetTextColor(COLORREF TextColor); 30. //设置网页链接 31. void SetURL(CString strURL); 32. //设置背景图片 33. void SetBkPicture(CBitmap *pBitMap); 34.35.// Overrides 36. // ClassWizard generated virtual function overrides 37. //{{AFX_VIRTUAL(CButtonST) 38. public: 39. virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); 40. virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); 41. protected: 42. virtual BOOL PreCreateWindow(CREATESTRUCT cs); 43. virtual void PreSubclassWindow(); 44. //}}AFX_VIRTUAL 45.46.// Implementation 47.public: 48. virtual ~CButtonST(); 49. 50. void DrawItem1(LPDRAWITEMSTRUCT lpDrawItemStruct); 51.52. // Generated message map functions 53.protected: 54. //{{AFX_MSG(CButtonST) 55. afx_msg void OnMouseMove(UINT nFlags, CPoint point); 56. afx_msg BOOL OnNcActivate(BOOL bActive); 57. afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); 58. afx_msg void OnKillFocus(CWnd* pNewWnd); 59. afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 60. //}}AFX_MSG 61.protected: 62. //鼠标是否在按钮上面 63. BOOL m_IsPressed; 64. C

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档