?
Solved

MFC Double buffering

Posted on 2003-03-01
4
Medium Priority
?
2,138 Views
Last Modified: 2013-11-20
I wanna make double buffering using MFC but i only know how do do it using
the #include "windows.h" , not with MFC.

can anyone help me? i've tryed to find tutorials and
sources on google but i've just found non MFC code


void CApplicationView::OnDraw(CDC* pDC)
{
     CTransCorpDoc* pDoc = GetDocument();
     ASSERT_VALID(pDoc);

    // i've put this code to help u

}

THANKS A LOT!!!!
0
Comment
Question by:ghuga
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:jackrabbit22
ID: 8050794
Not tested for errors...

// Get clip box
CRect rcClipBox;
pDC->GetClipBox(rcClipBox);

// Create memory dc and update it's mapping state
CDC memDC;
memDC.CreateCompatibleDC(pDC);
memDC.SetMapMode(pDC->GetMapMode());
memDC.SetViewportOrg(pDC->GetViewportOrg());
memDC.IntersectClipRect(rcClipBox);

// Create memory bitmap
CBitmap bmp;
bmp.CreateCompatibleBitmap(pDC, rcClipBox.Width(), rcClipBox.Height());
CBitmap* pOldBmp = memDC.SelectObject(&bmp);

// Draw to memDC
memDC.TextOut(50, 50, _T("Whatever"));

// Blit to the original dc
pDC->BitBlt(rcClipBox.left, rcClipBox.top, rcClipBox.Width(), rcClipBox.Height(), &memDC, rcClipBox.left, rcClipBox.top, SRCCOPY);

// Restore old bitmap
memDC.SelectObject(pOldBmp);



0
 
LVL 1

Accepted Solution

by:
jackrabbit22 earned 150 total points
ID: 8050806
forgot something...

Before you draw to the memory dc, fill the background.

memDC.FillSolidRect(rcClipBox, GetSysColor(COLOR_WINDOW));

also override OnEraseBackground and return TRUE

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question