MFC中为什么我用了双缓冲,结果还是有点闪,我试了一下,和不用双缓冲差别不大呢
voidCTestView::OnDraw(CDC*pDC){CTestDoc*pDoc=GetDocument();ASSERT_VALID(pDoc);CBrushb...
void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush backbrush(RGB(0,0,0));
pDC->SelectObject(&backbrush);
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
CDC memDC; //用于缓冲作图的内存DC
memDC.CreateCompatibleDC(NULL); //依附窗口DC创建内存兼容DC
CBitmap memBT; //内存中承载临时图象的位图
//CSize sz = GetTotalSize();
memBT.CreateCompatibleBitmap(pDC, rect.Width(),rect.Height());//创建兼容位图
memDC.SelectObject(&memBT); //将位图选择进内存DC
memDC.FillSolidRect(0,0,rect.Width(),rect.Height(), RGB(0,0,0));//按原来背景填充客户区,不然会是黑色
DrawALL(&memDC);
pDC->BitBlt(0, 0,rect.Width(),rect.Height(), &memDC, 0, 0, SRCCOPY);//将内存DC上的图象拷贝到窗口DC
memDC.DeleteDC(); //删除内存DC
memBT.DeleteObject(); //删除内存BT
}
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Creadwcqdfile();////////读信息
pDoc->Creadqdaction1();//////////////////
SetTimer(0,1000,NULL);
shansuo=TRUE;
return 0;
} 展开
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush backbrush(RGB(0,0,0));
pDC->SelectObject(&backbrush);
CRect rect;
pDC->GetClipBox(&rect);
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
CDC memDC; //用于缓冲作图的内存DC
memDC.CreateCompatibleDC(NULL); //依附窗口DC创建内存兼容DC
CBitmap memBT; //内存中承载临时图象的位图
//CSize sz = GetTotalSize();
memBT.CreateCompatibleBitmap(pDC, rect.Width(),rect.Height());//创建兼容位图
memDC.SelectObject(&memBT); //将位图选择进内存DC
memDC.FillSolidRect(0,0,rect.Width(),rect.Height(), RGB(0,0,0));//按原来背景填充客户区,不然会是黑色
DrawALL(&memDC);
pDC->BitBlt(0, 0,rect.Width(),rect.Height(), &memDC, 0, 0, SRCCOPY);//将内存DC上的图象拷贝到窗口DC
memDC.DeleteDC(); //删除内存DC
memBT.DeleteObject(); //删除内存BT
}
int CTestView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->Creadwcqdfile();////////读信息
pDoc->Creadqdaction1();//////////////////
SetTimer(0,1000,NULL);
shansuo=TRUE;
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询