// only paint the rect that needs repainting
CRect client;
pDC->GetClipBox(client);
//--------------------------------------------------- if (!pDC->IsPrinting()) //如果没有使用打印机
{
// draw to offscreen bitmap for fast looking repaints
if (dc.CreateCompatibleDC(pDC)) //创建一个与其它设备相兼容的内存设备表,可在内存中准备图像
{
if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height())) //初始化一个与pDC相容的位图,作为PDC指定的设备相
//容的任何内存设备的当前位图
{
OnPrepareDC(&dc, NULL); //为打印预览调用ONDRAW OR ONPAINT 函数之前
pDrawDC = &dc; //CDC类的对象附值给CDC的指针
// offset origin more because bitmap is just piece of the whole drawing
dc.OffsetViewportOrg(-rect.left, -rect.top); //修改视口原点坐标
pOldBitmap = dc.SelectObject(&bitmap);
dc.SetBrushOrg(rect.left % 8, rect.top % 8); //指定下一个进入设备环境的画刷的原点坐标
// might as well clip to the same rectangle
dc.IntersectClipRect(client);
//当前区与指定区相交区创建的一个新的裁剪区。
}
}
}