代码
sizeTotal.cx = 2100;
sizeTotal.cy = 2970;

sizePage.cx = 50;
sizePage.cy = 50;

sizeLine.cx = 10;
sizeLine.cy = 10;void CMyView::OnInitialUpdate()
{
// Create memory DC
HDC hDC = ::GetDC(NULL);
m_hMemDC = CreateCompatibleDC(hDC);
m_hMemBitmap = CreateCompatibleBitmap(hDC, sizeTotal.cx, sizeTotal.cy);
m_hOldMemBitmap = (HBITMAP)::SelectObject(m_hMemDC, m_hMemBitmap);
::ReleaseDC(NULL, hDC); CScrollView::OnInitialUpdate(); //设置滚动视图尺寸
SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine);
}
void CMyView::OnDraw(CDC* pDC)
{
CSoftCubeDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;

RECT rect = {0,0,sizeTotal.cx,sizeTotal.cy}; RECT clientRect;
GetClientRect(&clientRect);
pDC->DPtoLP(&clientRect); // Clear background
FillRect(m_hMemDC, &rect, (HBRUSH)GetStockObject(GRAY_BRUSH));
FillRect(m_hMemDC, &clientRect, (HBRUSH)GetStockObject(WHITE_BRUSH)); //Draw Grid
if(m_grid != FALSE)
{
DrawGrid(m_hMemDC,&clientRect);
} //在某些位置画矩形

if (!m_bPrinting)
{
// Blit on screen DC
BitBlt(pDC->m_hDC, clientRect.left, clientRect.top, clientRect.right-clientRect.left, clientRect.bottom-clientRect.top, m_hMemDC, clientRect.left, clientRect.top, SRCCOPY);
}
}现在当我滚动滚动条时,原来未滚动部分RECT是没问题的即原点0,0开始的一个区域,剩下的区域就是没刷新
我想实现的是比如弄个A4大小的Doc,可打印到A4的纸上,

解决方案 »

  1.   

    用CScrollView的时候不能用GetClientRect来画,也不需要判断窗口滚动到哪里了。每次都当成画全屏一样的画就可以了。CScrollView会修改DC的相对座标和剪裁区域,让你画的内容可以随滚动条滚动。
      

  2.   

    superarhow
    我改成这样还是不行
    RECT rect = {0,0,sizeTotal.cx,sizeTotal.cy}; // Clear background
    FillRect(m_hMemDC, &clientRect, (HBRUSH)GetStockObject(GRAY_BRUSH));
    FillRect(m_hMemDC, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); //Draw Grid
    if(m_grid != FALSE)
    {
    DrawGrid(m_hMemDC,&rect);
    } //在某些位置画矩形

    if (!m_bPrinting)
    {
    // Blit on screen DC
    BitBlt(pDC->m_hDC, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, m_hMemDC, rect.left, rect.top, SRCCOPY);
    }
      

  3.   

    话说不用双缓存  使用 ipicture加载图片后  视图也会出现滚动后视图不刷新呢使用 INVALIDATE 后 屏幕会无限闪烁!  我也正闷  
      

  4.   

    那还是DrawGrid里面有问题吧,是不是考虑太多了?
    偶用你的代码,把DrawGrid换成一句:::TextOut(m_hMemDC, 1, 1, L"Hello, world", 12);  是没有问题的。要点就是绝对坐标。
      

  5.   

    那是因为你的背景没有内容(全白) 外加一句TextOut
    我背景是网格DrawGrid也是绘制网格的,但他只绘制了一部分
      

  6.   

    恩 是我OnSize里出了问题 谢谢确实代码OnDraw没问题
    结贴