问题是这样的:我在一个ScrollView中画图,并且画布大于可视区,
在实现画图区的缩略图时,怎样才能取得整个画布(包括滚动出可视区的部分)的图像呢?CFrameWnd* pFrame;
pFrame=(CFrameWnd*)theApp.GetMainWnd();
CScrollView* pView=(CScrollView*)pFrame->GetActiveView();
CDC* pDC=pView->GetDC();CSize szTotalSource;
szTotalSource=pView->GetTotalSize();
CRect rectTotalSource(0,0,szTotalSource.cx,szTotalSource.cy);//整个画布dc.StretchBlt(0,0,rectDest.Width(),rectDest.Height(),pDC,
0,0,rectTotalSource.Width(),rectTotalSource.Height(),SRCCOPY );.Height(),SRCCOPY );上面代码的结果是,把ScrollView外部的画面(如状态栏)也纳入了缩略图,但ScrollView中滚动出可视区的部分却显示不了,
各位大侠给个招吧!

解决方案 »

  1.   

    我在目标区域(要显示缩略图的位置,CWnd的子类对象)中写了如下的代码,
    然后在ScrollView中绘图时,调用下面的函数,并把pDC参数设为ScrollView的CDC
    CMyWnd::RefreshNavigator(CDC* pDC)
    {
    CClientDC dc(this);
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);CBitmap* bitmap=new CBitmap;
    CBitmap* pOldBitmap;CRect rectTotalSource(0,0,1024,1024);//CScrollView类的全部区域,包括滚动出可视区的范围
    CRect rectDest;//显示缩略图的目标区域
    GetClientRect(rectDest);bitmap->CreateCompatibleBitmap(pDC,rectTotalSource.Width(),rectTotalSource.Height());
    pOldBitmap=memDC.SelectObject(bitmap);

    dc.StretchBlt(0,0,rectDest.Width(),rectDest.Height(),
    &memDC,
    0,0,rectTotalSource.Width(),rectTotalSource.Height(),SRCCOPY);memDC.SelectObject(pOldBitmap);
    delete bitmap;
    }这样写有什么问题吗?为什么画出来的仍然是黑色呢
    什么时候用pDC、dc、memDC我已经晕了。
      

  2.   

    参考CxImage demo程序。
    在内存DC保存原始大小的图形,在显示DC中处理。