The 1.sdkwin32 API function obtains the DC handle in the view class hdc HDCHDC=::GETDC (M_hwnd);:: ReleaseDC (M_HWND,HDC)//must release handle 2. Using MFC to get the DC handle CDC *pdc= GetDC (); ReleaseDC (PDC)//must release handle 3. Use CCLIENTDC to obtain a DC handle (no call to release function, destructor automatically called) CClientDC DC (this)//scope within the view window CCLIENTDC DC ( GetParent ())//scope within the Fraim framework CCLIENTDC does not need to call the release function, the parse function automatically calls 4. Use CWINDOWDC to get a DC handle (no call to release function, destructor automatically called) CWINDOWDC DC (this) Scope within the view window CWINDOWDC DC (GetParent ())//scope within Fraim frame CWINDOWDC DC (GetDesktopWindow ())//scope of action across the desktop
Several ways to get a DC handle under Windows