我从CButton继承了一个新的类,在
void CExButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CRect itemRect = lpDIS->rcItem; DrawTheFrame(pDC);
if (m_csBitmaps[0].hBitmap)
{
pDC->SetBkColor(RGB(255,255,255));
DrawTheBitmap(pDC);
}
DrawTheText(pDC);
}void CExButton::DrawTheFrame(CDC* pDC)
{
CBrush m_newBrush;
VERIFY(m_newBrush.CreateSolidBrush( m_colBackground ));
VERIFY(pDC->FillRgn( &m_Rgn, &m_newBrush));
}BOOL CExButton::OnEraseBkgnd(CDC* pDC)
{ return 1; }// doesn't erase the button background如果鼠标在按钮内外快速的进出,就会发现闪屏的问题
void CExButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CRect itemRect = lpDIS->rcItem; DrawTheFrame(pDC);
if (m_csBitmaps[0].hBitmap)
{
pDC->SetBkColor(RGB(255,255,255));
DrawTheBitmap(pDC);
}
DrawTheText(pDC);
}void CExButton::DrawTheFrame(CDC* pDC)
{
CBrush m_newBrush;
VERIFY(m_newBrush.CreateSolidBrush( m_colBackground ));
VERIFY(pDC->FillRgn( &m_Rgn, &m_newBrush));
}BOOL CExButton::OnEraseBkgnd(CDC* pDC)
{ return 1; }// doesn't erase the button background如果鼠标在按钮内外快速的进出,就会发现闪屏的问题
如果分批画到pDC上的话会出现闪烁。
=======================================
C++程序做UI方法的革命,用flash打造超炫UI
http://flash4ui.googlepages.com
用CBitmapButton