文档介绍:这是一个实现自绘CButton的类,期望对大家有点帮助,我提供这个类,只是为大家提供一个自绘控件的思路,你可以在此基础上,随意地修改代码•直到它能完成你所需要的功能•其它控件的自绘,.#if !defined(AFXBUTTONSTH1271FF9CE28C4D3BB429AFE65924A5D0INCLUDED) 2.#defineAFXBUTTONSTH1271FF9CE28C4D3BB429AFE65924A5D0INCLUDED34.#讦MSCVER>10005.#pragmaonce6.#endif//_MSC_VER>10007.//:headerfile&〃9」0.////////////〃//〃///////////////////////////////////〃////////////////////〃11.//:Button{//:();.//:./:().32.〃设置背景颜色25. voidSetBkColor(COLORREFBkColor);〃设置鼠标在按钮上的偏移颜色27. voidSetShOffseUintnShOffset);〃设置字体颜色29. voidSetTextColor(COLORREFTextColor);〃设置网页链接31. voidSetURL(CStringstrURL);〃设置背景图片33. voidSetBkPicture(CBitmap*pBitMap);.〃Overrides36. //ClassWizardgeneratedvirtualfunctionoverrides37. //{{AFX_VIRTUAL(CButtonST)3&public:(LPDRAWITEMSTRUCTIpDrawItemStruct);virtualBOOLCreate(LPCTSTRIpszClassName,LPCTSTRIpszWindowName,DWORDdwStyle,constRECT&rect,CWnd*pParentWnd,reateContext*pContext=NULL);protected:virtualBOOLPreCreateWindow(CREATESTRUCT&cs);virtualvoidPreSubclassWindow();//}}.//:virtual~CButtonST();(LPDRAWITEMSTRUCTlpDrawItemStruct);. //://{{AFX_MSG(CButtonST)55. afx_msgvoidOnMouseMove(UINTnFlags,CPointpoint);afx_msgBOOLOnNcActivate(BOOLbActive);afx_msgvoidOnNcMouseMove(UINTnHitTest,CPointpoint);afx_msgvoidOnKillFocus(CWnd*pNewWnd);afx_msgvoidOnLButtonDown(UINTnFlags,CPointpoint);//}}:62. 〃;COLORREFm_BkColor;int m_nShOffset;COLORREFm_TextColor;CStringm_strURL;CBitmap*m_pBitMapBK;protected:〃背景颜色偏移71. COLORREFOffsetColor(COLORREFcolor,intnOffset);〃鼠标离开73. LRESULTOnMouseLeave(WPARAMwPararn,LPARAMIParam);DECLARE-MESSAGE_MAP()};7&79.//{{AFX」NSERT_LOCATION))80.//MicrosoftVisualC++willinsertadditionaldeclarations immediately before the previous line. .#endif//!define