15,979
社区成员
发帖
与我相关
我的任务
分享
void CDBBTestView::InitialDBB()
{
CRect rt;
this->GetClientRect(&rt);
// 为屏幕DC创建兼容的内存DC
if(!m_dcMemory.CreateCompatibleDC(NULL))
{
::PostQuitMessage(0);
}
// 创建位图
m_Bmp.CreateCompatibleBitmap(&m_dcMemory, rt.Width(), rt.Height());
// 相当于选择画布
::SelectObject(m_dcMemory.GetSafeHdc(), m_Bmp);
}
CDC *pdcView = this->GetDC();
CRect rt;
this->GetClientRect(&rt);
m_dcMemory.FillSolidRect(&rt, 0x00FFFFFF); // 白色填充, 注意,这次是画在内存设备环境上
// 画圆
for(int i = 0; i < rt.Width() - 1; i+= 16)
{
for(int j = 0; j < rt.Height() - 1; j+= 16)
{
m_dcMemory.Ellipse(i, j, i + m_nRadius, j + m_nRadius);
}
}
this->ReleaseDC(pdcView); // 释放view的设备环境
m_change=true;
this->Invalidate();
CRect rt;
this->GetClientRect(&rt);
if(m_change)
pdc->BitBlt(0, 0, rt.Width(), rt.Height(), &m_dcMemory, 0, 0, SRCCOPY);
if(m_change)
{
m_bitmap=m_dcMemory.SelectObject(&m_Bmp);
pDC->BitBlt(0, 0, rt.Width(), rt.Height(), &m_dcMemory, 0, 0, SRCCOPY);
}
// TODO: add draw code for native data here
pDC->SelectObject(&m_bitmap);