www.pudn.com > MFCVista.rar > IButton.h
//静态图片按钮 CButtonXP
#pragma once
#include "imagelist.h"
#include "Iontrlpos.h"
class AFX_EXT_CLASS CIButton : public CButton,public CIontrlPos,public CImageListEx
{
protected://正在控件上画文字
CFont m_fntBtn; //按钮字体
int m_iIndex, //按钮贴图索引(1,2,3,...7)
m_iOldIndex; //上次按钮贴图索引(1,2,3,...7)
CString m_strTitle; //按钮的标签文本
private:
bool m_bDcAtt, //是否修改DC属性
m_bMouseLeftDown, //是否触发鼠标左键按下
m_bFocus; //按钮是否得到焦点
COLORREF m_clrBtnMask, //按钮的透明色和无效区域的颜色
m_clrTextClr; //按钮的标签文本的颜色
CRgn m_rgnBtn; //按钮的有效区域
CPoint m_ptOldMouse, //记录着前一次MOUSE的位置
m_ptMouse; //光标坐标
HCURSOR m_hBtnCursor; //按钮光标句柄
CRect m_rctBtn; //按钮矩形区域
CDC m_dcMem; //内存DC
CToolTipCtrl m_tipCtrl; //工具提示
public:
CIButton();
virtual ~CIButton();
protected:
DECLARE_DYNAMIC(CIButton)
DECLARE_MESSAGE_MAP()
public:
void SetAtt(LPCSTR strText,COLORREF TextClr,UINT nIDBmp,COLORREF dwMask);
void EnableWindow(BOOL bEnable=TRUE);
void SetWindowTextEx(LPCSTR strText);
void SetTextColor(COLORREF);
void SetCursor(UINT nIDCursor);
void SetCursor(HCURSOR hIDCursor);
void SetToolTip(LPCSTR cText=0,COLORREF TextClr=RGB(0,128,64),COLORREF BKClr=RGB(255,255,255),DWORD dwTime=100);
void UpdateTipText(LPCSTR cText=0);
bool IsMove();
public:
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnPaint();
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
protected:
virtual void DrawItem(LPDRAWITEMSTRUCT );
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void DrawText(CDC *pDC,int iPosX,int iPosY,const CString &amt;strText,COLORREF TextClr);
};