Windows/MFC

GDI+ 용 Double Buffering (더블 버퍼링)

aucd29 2013. 10. 2. 18:09
[code]CPaintDC dc(this); // device context for painting

// 윈도우 크기 얻고
GetClientRect(&m_rtCtrlSize);

// 메모리상에 도화지? 를 만들고
Bitmap mBitmap(m_rtCtrlSize.Width(), m_rtCtrlSize.Height());
Graphics G(dc);
Graphics mDC(&mBitmap);

// 팬과 브러시 그라이던트 브러쉬를 선택한 뒤
Pen P(Color(103, 99, 114),1);
SolidBrush S(Color(255,255,255));
LinearGradientBrush LGB(Rect(1, 2, m_rtCtrlSize.Width()-4, m_rtCtrlSize.Height()-4),
    Color(255, 255, 255), Color(255, 0, 0),
    LinearGradientModeHorizontal);

// 메모리 도화지에 그렸다.
mDC.FillRectangle(&S, Rect(0, 0, m_rtCtrlSize.Width(), m_rtCtrlSize.Height()));
mDC.DrawRectangle(&P, Rect(0, 0, m_rtCtrlSize.Width()-1, m_rtCtrlSize.Height()-1));
mDC.FillRectangle(&LGB, 2, 2, m_rtCtrlSize.Width()-10, m_rtCtrlSize.Height()-4);

// 그리고 마지막으로 윈도우에 뿌린다.
G.DrawImage(&mBitmap, 0, 0);[/code]