MFC中使用Invalidate()函数图像就会闪烁,这个怎么解决?
我的ondraw函数是:voidCSnowflakesView::OnDraw(CDC*pDC){ CSnowflakesDoc*pDoc=GetDocumen...
我的ondraw函数是:void CSnowflakesView::OnDraw(CDC* pDC){ CSnowflakesDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc);CDC MemDC;MemDC.CreateCompatibleDC(pDC);CBitmap *pOldBitmap=MemDC.SelectObject(&m_Bitmap);BITMAP bm;m_Bitmap.GetObject(sizeof(BITMAP),&bm);pDC->BitBlt(snow1x,snow1y,bm.bmWidth,bm.bmHeight,&MemDC,0,0,SRCCOPY);MemDC.SelectObject(pOldBitmap);}Timer函数是:void CSnowflakesView::OnTimer(UINT nIDEvent) { CRect rect; GetClientRect(rect); if(nIDEvent==1) { snow1x+=rand()%2; snow1x-=rand()%5; snow1y+=4; if(snow1y >= rect.bottom) {snow1y = 0;} if(snow1x <= rect.left) snow1x = rect.right-20; if(snow1x >= rect.right) snow1x = 0; Invalidate(); } CView::OnTimer(nIDEvent);}在用Invalidate()函数刷新时移动的图像就会闪烁,这个怎么解决?不要那些网上的Invalidate(flase),Invalidateract()之类的,这些我都试过了,都没用,将OnEraseBkgnd中设为returne true后不会闪烁,但是那个轨迹却不会刷新。请说具体点,我是新手,不是很会。能解决问题的我再加分!
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询