CWindowDC, CClientDC, CPaintDCC, cwindowdccclientdc

Source: Internet
Author: User

CWindowDC, CClientDC, CPaintDCC, cwindowdccclientdc
[Switch] CClientDC: (client zone device context) is used for the output of the customer zone. It is associated with a specific window and allows developers to access the customer zone in the target window. Its constructor contains GetDC, the Destructor contains ReleaseDC. Usage: CClientDC dc (this); // this generally points to the current window or current active view dc. textOut (10, 10, str, str. getLength (); // use dc to output text. If it is used in CScrollView, call OnPrepareDC (& dc) to adjust the coordinates of the device context. CPaintDC is used to return the Drawing Output when the message (WM_PAINT) is re-painted in the response window. CPaintDC calls BeginPaint () in the constructor to obtain the device context, and CALLS EndPaint () in the destructor to release the device context. In addition to releasing the device context, EndPaint () is also responsible for clearing the WM_PAINT message from the message queue. Therefore, you must use CPaintDC when processing the window re-painting. Otherwise, the WM_PAINT message cannot be cleared from the message queue and will cause constant window re-painting. CPaintDC can only be used in WM_PAINT message processing. CWindowDC: associate a specific window to allow developers to draw any part of the target window, including boundaries and titles. The difference between DC and WM_NCPAINT messages that send CWindowDC together with CClientDC and CPaintDC: CWindowDC can draw images in non-customer areas, while CClientDC and CPaintDC can only draw images in customer areas. In CWindowDC, the coordinate origin is in the upper left corner of the screen, and in CClientDC and CPaintDC, the coordinate origin is in the upper left corner of the customer zone. Difference between CClientDC and CPaintDC: CPaintDC objects are generally used in OnPaint to respond to Windows message WM_PAINT. The painting is automatically completed and re-painted throughout the window to maintain the integrity of the original window. When the CClientDC application does not respond to the Windows message WM_PAINT, it is drawn in real time.

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.