VC Double Canvas eliminates screen flicker

Source: Internet
Author: User

In VC mapping, the direct mapping to the screen of the CDC, because the surface of the time is stuck in different times caused the screen flicker. The solution to this problem is to first draw the picture onto the memory canvas, at once to the screen, memory mapped to the screen quickly, so it does not cause flicker.

 CDC m_dcMem;              //创建内存画布
  CBitmap m_bmpMemDC;         //创建内存画布的
//初始化内存画布
CDC* pDC = GetDC();
  if(pDC->GetSafeHdc())
  {
   if(!m_dcMem.CreateCompatibleDC(pDC))
   {
    ReleaseDC(pDC);
    return;
   }
   if(!m_bmpMemDC.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height()))
   {
    ReleaseDC(pDC);
    return;
   }
   m_dcMem.SelectObject(&m_bmpMemDC);
   ReleaseDC(pDC);
//把图像画到内存画布上
//内存画布映射到屏幕
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m_dcMem,0,0,SRCCOPY);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.