读书人

GDI+的PNG透明4状态按钮放到DIALOG或

发布时间: 2012-05-08 22:09:41 作者: rapoo

GDI+的PNG透明4状态按钮,放到DIALOG或者FRAMEWND上就不刷新自己了
诚向各位高手求教!!!
这个类可以在网络上找到,单独使用没问题,可加上背景以后,透明的地方就漏出来了。
对GID+不太熟,见谅!
背景已处理 OnCtlColor, OnEraseBkGrnd之类的函数。

class CGdipButton : public CButton
{
public:

CGdipButton();
virtual ~CGdipButton();

// image types
enum{
STD_TYPE= 0,
ALT_TYPE,
DIS_TYPE
};

// sets the image type
void SetImage(int type);

BOOL LoadAltImage(UINT id, LPCTSTR pType);
BOOL LoadStdImage(UINT id, LPCTSTR pType);

// if false, disables the press state and uses grayscale image if it exists
void EnableButton(BOOL bEnable = TRUE) { m_bIsDisabled = !bEnable; }

// in toggle mode each press toggles between std and alt images
void EnableToggle(BOOL bEnable = TRUE);

// return the enable/disable state
BOOL IsDisabled(void) {return (m_bIsDisabled == TRUE); }

void SetBkGnd(CDC* pDC);

void SetToolTipText(CString spText, BOOL bActivate = TRUE);
void SetToolTipText(UINT nId, BOOL bActivate = TRUE);
void SetHorizontal(bool ImagesAreLaidOutHorizontally = FALSE);
void DeleteToolTip();


protected:

void PaintBk(CDC* pDC);
void PaintBtn(CDC* pDC);

BOOLm_bHaveAltImage;
BOOLm_bHaveBitmaps;

BOOLm_bIsDisabled;
BOOLm_bIsToggle;
BOOLm_bIsHovering;
BOOLm_bIsTracking;

intm_nCurType;

CGdiPlusBitmapResource* m_pAltImage;
CGdiPlusBitmapResource* m_pStdImage;

CStringm_tooltext;
CToolTipCtrl*m_pToolTip;

voidInitToolTip();

virtual void PreSubclassWindow();
virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
virtual BOOL PreTranslateMessage(MSG* pMsg);

//{{AFX_MSG(CGdipButton)
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg LRESULT OnMouseLeave(WPARAM wparam, LPARAM lparam);
afx_msg LRESULT OnMouseHover(WPARAM wparam, LPARAM lparam) ;
//}}AFX_MSG

DECLARE_MESSAGE_MAP()

private:

CDCm_dcBk;// button background

CDCm_dcStd;// standard button
CDCm_dcStdP;// standard button pressed
CDCm_dcStdH;// standard button hot

CDCm_dcAlt;// alternate button
CDCm_dcAltP;// alternate button pressed
CDCm_dcAltH;// alternate button hot

CDCm_dcGS;// grayscale button (does not have a hot or pressed state)

CDC*m_pCurBtn;// current pointer to one of the above

};

[解决办法]
大牛啊,这么多分子
[解决办法]
这么多分啊。。过来接分。。楼主好人啊

读书人网 >VC/MFC

热点推荐