//在onDraw或OnPaint中调用
BOOL CLampSystemView::DrawLamp(CDC* pDC, int iLampType, int iLampState)
vector<CPoint>::iterator iter1 = m_upLampVect.begin();
vector<CPoint>::iterator iter2 = m_downLampVect.begin();
for(;iter1!=m_upLampVect.end(); iter1++, iter2++)
{
this->InvalidateRect(CRect(iter1->x , iter1->y - 165, iter1->x +90, iter1->y));
this->InvalidateRect(CRect(iter2->x, iter2->y - 165, iter2->x +90, iter2->y));
}
return TRUE;
}
每次刷新的时候 图片背景会闪烁,解决的方法是用:
.h
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
.cpp
ON_WM_ERASEBKGND()
//在刷新的时候,背景不会闪烁,只是切换图片,在这个函数写画背景的东西。
BOOL CLampSystemView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;///000CView::OnEraseBkgnd(pDC);
}