123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /************************************************************************/
- /* Copyright (C), 2016-2020, [IT], 保留所有权利;
- /* 模 块 名:;
- /* 描 述:;
- /*
- /* 版 本:[V];
- /* 作 者:[IT];
- /* 日 期:[8/19/2016];
- /*
- /*
- /* 注 意:;
- /*
- /* 修改记录:[IT];
- /* 修改日期:;
- /* 修改版本:;
- /* 修改内容:;
- /************************************************************************/
- #pragma once
- #include <atlimage.h>
- #include "EnBitmap.h"
- // CSkinButton
- class CSkinButton : public CButton
- {
- DECLARE_DYNAMIC(CSkinButton)
- public:
- CSkinButton();
- virtual ~CSkinButton();
- typedef enum state
- {
- NORMAL,
- HOVER,
- DOWN,
- DISABLE
- }state;
- protected:
- DECLARE_MESSAGE_MAP()
- CEnBitmap m_bmpButton;
- CEnBitmap m_bmpNormal;
- CEnBitmap m_bmpHover;
- CEnBitmap m_bmpDown;
- CEnBitmap m_bmpDisable;
- CEnBitmap m_bmpIconButton;
- private:
- // 是否显示按钮本身文本;
- BOOL m_bShowOwnerText;
- state m_state;
- COLORREF m_fg, m_bg;
- COLORREF m_crBack;
- bool m_bMouseOver;
- BOOL m_bDown;
- bool m_bEnabled;
- CFont *m_pFont;
- bool m_bDCStored;//是否已经保存背景图
- CImage m_hMouseInIcon;
- CImage m_hMouseOutIcon;
- CPoint m_textPos;
- CRect m_iconRect;
- CDC m_memDC;
- public:
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- protected:
- virtual void PreSubclassWindow();
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS);
- protected:
- //在按钮中填充颜色
- void DrawFilledRect(CDC *DC, CRect R, COLORREF color);
- //设置按钮上的字体颜色
- void DrawButtonText(CDC *DC, CRect R, CString str, COLORREF TextColor);
- void DrawButton();
- public:
- void ShowOwnerText(IN BOOL bShowOwnerText = TRUE) { m_bShowOwnerText = bShowOwnerText; };
- void SetOwnerDraw(bool IsDraw);
- void SetImage(UINT nNormalID, UINT nHoverID, UINT nDownID, UINT nDisableID);
- void SetImage(CString strNormal, CString strHover, CString strDown, CString strDisable);
- void loadHoverBGBmp(LPCTSTR szImagePath);
- void LoadImage(LPCTSTR szImagePath,COLORREF crBack = RGB(255,0,255),BOOL bResetSize =TRUE);
- BOOL LoadBitmap(UINT uIDRes,COLORREF crBack,BOOL bResetSize = TRUE);
- void SetIcon(CString strMouseOut,CString strMouseIn);
- void SetColor(COLORREF fgcolor,COLORREF bgcolor);
- void SetTextPos(CPoint point);
- CEnBitmap* GetPaintBmp(){return &m_bmpNormal;}
- CImage* GetPaintIcon(){return &m_hMouseOutIcon;}
- CPoint GetTextPos(){return m_textPos;}
- COLORREF GetFGColor() { return m_fg; }
- COLORREF GetBGColor() { return m_bg; }
- CRect GetRectInParent();
- void SetStatusBmp();
- CRect GetIconRect(){return m_iconRect;}
- int Width(){return m_bmpNormal.Width();}
- int Heighth(){return m_bmpNormal.Height();}
- void ResetButtonSize(BOOL bResetSize);
- public:
- afx_msg void OnEnable(BOOL bEnable);
- };
|