(Origin section: C/C
Compressed file format: text content
Attachment source: Internet
Operation mode: Windows mode
Is it verified by yourself: yes
Attachment nature: free
Detailed description: "VC Advanced Programming"
2.3 The end of the drawing operation
The source program of the drawing operation is introduced below to give you a general understanding of the use of the device context.
First generate a device context. CPaintDC is a class provided by MFC that inherits from CDC. What are the benefits of using it? If we use CDC directly, we need to call the BeginPaint function of CWnd first to do some preparatory work for the redrawing work, and use the EndPaint function to indicate the completion of the production work before the end of the production. All drawing operations must terminate between these two functions. CPaintDC encapsulates these two functions and calls them automatically, and the user does not need to make these calls.
CPaintDCdc(this);
BITMAPbm;
m_bitmap_gt;GetBitmap(bm);
CDCdcImage;
if(!dcImage.CreateCompatibleDC(dc))
return;
CBitmap
pOldBitmap=dcImage.SelectObject(m_bitmap);
dc.BitBlt(0,0,bm.bmWidth,bm.bmHeight,
dcImage,0,0,SRCCOPY);)