VC dual-buffer drawing example

Source: Internet
Author: User
Void CTest: OnPaint () {CPaintDC dc (this); // device context for painting // TODO: Add your message handler code here // Do not call CWnd :: onPaint () for painting messages CPoint ptCenter; CRect rect, ellipseRect; GetClientRect (& rect); ptCenter = rect. centerPoint (); // memory dc cdc dcMem used to buffer plotting; // bitmap CBitmap bmp containing temporary images in the memory; // The attached window DC creates compatible memory DC dcMem. createCompatibleDC (& dc); // create a compatible bitmap bmp. createCompatibleBitmap (& dc, rect. width (), rect. height (); // select the bitmap into the memory DC dcMem. selectObject (& bmp); // fill the customer area according to the original background, otherwise it will be black dcMem. fillSolidRect (rect, dc. getBkColor (); // make the same concentric circular image for (int I = 20; I> 0; I --) {ellipseRect on the memory DC. setRect (ptCenter, ptCenter); ellipseRect. inflateRect (I * 10, I * 10); dcMem. ellipse (ellipseRect);} // copy the image from the memory DC to the front-end dc. bitBlt (0, 0, rect. width (), rect. height (), & dcMem, 0, 0, SRCCOPY); // Delete DC dcMem. deleteDC (); // deletes the bitmap bmp. deleteObject ();}

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.