RgnButton.h
#pragma once
#include "afxwin.h"
class CRgnButton :
public CButton
{
DECLARE_DYNAMIC(CRgnButton)
public:
CRgnButton();
~CRgnButton();
virtual void SetImage(Image* img);
virtual void SetImageHover(Image* img);
virtual void Create(CWnd* pParentWnd, UINT nID);
private:
// 设置窗体区域
void SetRgn(CRgn *region);
// 读取图片的非透明区生成区域
Region* CreateRegion(Image* img);
Image* m_image;
Point m_imgOffset;
HRGN rgn, trgn;
Image* m_imageHover;
bool m_isHover;
bool m_isHoverShowing;
protected:
DECLARE_MESSAGE_MAP()
virtual void PreSubclassWindow();
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseLeave();
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnMouseHover(UINT nFlags, CPoint point);
};
RgnBu