Several DCs and differences

xiaoxiao2021-04-05  239

CClientDC: (Customer Area Device Context) For the user's output, associated with a specific window, allowing the developer to access the customer area in the target window, and the constructor contains getDC, and the destructor contains ReleaseDC:

Cclientdc :: CclientDC (CWND * PWND) {... if (! Attach (:: getdc (m_hwnd = pwnd-> getsafehwnd ()))) AFXTHROWRESOURCEEXCEPTION ();

Cclientdc :: ~ cclientdc () {... :: releasedc (m_hwnd, detach ());} Usage is: CclientDC DC (this); // This general points to this window or current activity view Dc.Textout (10, 10 , Str, Str.getLength ()); // Use DC output text, if you are used in CScrollView, pay attention to call OnPrePAREDC (& DC) to adjust the coordinates of the device. CPAINTDC is used to respond to redraw messages (WM_PAINT) is the drawing output. CPAINTDC Calls beginpaint () acquisition device context in the constructor, and call the endpaint () release device context in the destructuring function. Endpaint () In addition to the release of the device, you are also responsible for clearing the WM_PAINT message from the message queue. Therefore, when processing the window redraw, you must use CPAINTDC, otherwise the WM_PAINT message cannot be cleared from the message queue, which will cause constant windows. CPAINTDC can only be used in WM_PAINT messages. CPAINTDC :: CPAINTDC (CWND * PWND) {... if (! Attach (:: beginpaint (m_hwnd = pwnd-> m_hwnd, & m_ps))) AFXTHROWRESOURCEEXCEPTION ();

CPAINTDC :: ~ cpaintdc () {... :: endpaint (m_hwnd, & m_ps); Detach ();} cwindowdc: Associate a specific window, allowing developers to draw any part of the target window, including boundaries and titles, this DC send together with WM_NCPAINT messages

CWindowDC and CClientDC, CPAINTDC Difference: CWindowDC can draw graphics in non-client districts, while cclientdc, cpAintdc can only draw graphics in customer districts. CWindowDC The original is in the upper left corner of the screen, cclientdc, and cpainTDC disposable in the upper left corner of the client area. CclientDC and CPAINTDC:

The object of CPAINTDC is generally used in onpaint to respond to Windows message WM_PAINT, automatically complete the drawing, and redraw in the entire window, maintaining the original window integrity. CclientDC Applications Draw, drawn in real-time, drawn in real-time, and drawn in real time in the case of non-response to Windows Messaging WM_PAINT.

转载请注明原文地址:https://www.9cbs.com/read-132185.html

New Post(0)