SDC C-Project CF Review 프로그램
LYW
2022-04-01 9c13bc5af33d28bb217995597f88fe863db42442
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
#pragma once
 
 
class CakMemDC : public CDC
{
public:
 
    CakMemDC(CDC* pDC, CRect rectDC) : CDC()
    {
        ASSERT(pDC != NULL);
 
        m_pDC = pDC;
        m_pOldBitmap = NULL;
        m_bMemDC = false;
        m_hDC = NULL;
        if(pDC == NULL)
        {
            CreateCompatibleDC(pDC);
            return;
        }
 
#ifndef WCE_NO_PRINTING
        m_bMemDC = !pDC->IsPrinting();
#else
        m_bMemDC = FALSE;
#endif
 
        if (m_bMemDC)    
        {
            //pDC->GetClipBox(&m_rect);
            m_rect = rectDC;
            CreateCompatibleDC(pDC);
            m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
            m_pOldBitmap = SelectObject(&m_bitmap);
#ifndef _WIN32_WCE
            //SetWindowOrg(m_rect.left, m_rect.top);
            SetWindowOrg(0,0);
#endif
            FillSolidRect(m_rect, pDC->GetBkColor());
        }
        else   
        {
#ifndef WCE_NO_PRINTING
            m_bPrinting = pDC->m_bPrinting;
#endif
            m_hDC       = pDC->m_hDC;
            m_hAttribDC = pDC->m_hAttribDC;
        }
 
    }
 
    virtual ~CakMemDC()
    {
        if (m_bMemDC)
        {
            m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.right, m_rect.bottom,
                this, m_rect.left, m_rect.top, SRCCOPY);
            
 
            SelectObject(m_pOldBitmap);
            //DeleteDC(); 
            //m_bitmap.DeleteObject();
            
        }
        else
        {
            m_hDC = m_hAttribDC = NULL;
        }
    }
 
    CakMemDC* operator->()
    {
        return this;
    }
 
    operator CakMemDC*()
    {
        return this;
    }
 
private:
    CBitmap  m_bitmap;      // Offscreen bitmap
    CBitmap* m_pOldBitmap;  // bitmap originally found in CakMemDC
    CDC*     m_pDC;         // Saves CDC passed in constructor
    BOOL     m_bMemDC;      // TRUE if CDC really is a Memory DC.
public:
    CRect    m_rect;        // Rectangle of drawing area.
}
;