我写了一个继承CScrollView的类
能显示图像
但我在OnUpdate处进行SetScrollSizes时出错并且view的右边和下面没有滚轴why?????

解决方案 »

  1.   

    没有滚轴我知道是怎么回事了
    但在OnUpdate函数中还是有错,代码如下: switch (lHint)
    {
    case WM_USER_NEWIMAGE:
    {
    m_tracker.m_rect = CRect(0,0,0,0); CWstArchivesDoc* pDoc = GetDocument();
    CxImage*  ima  = pDoc->GetImage();
    if (ima) 
    {
    int px=GetScrollPos(SB_HORZ);
    int py=GetScrollPos(SB_VERT);
    CSize sz(GetTotalSize());
    int x=(int)(ima->GetWidth()*pDoc->GetZoomFactor());
    int y=(int)(ima->GetHeight()*pDoc->GetZoomFactor());
    SetScrollSizes(MM_TEXT, CSize(x,y));///出错
    CSize sz2(GetTotalSize()); CWnd* pFrame=GetParentFrame();
    RECT rClient;
    pFrame->GetClientRect(&rClient); if (sz.cx!=0 && sz.cy!=0)
    {
    if (x > rClient.right) 
    SetScrollPos(SB_HORZ,sz2.cx*px/sz.cx); 
    else  
    SetScrollPos(SB_HORZ,0);
    if (y > rClient.bottom) 
    SetScrollPos(SB_VERT,sz2.cy*py/sz.cy); 
    else 
    SetScrollPos(SB_VERT,0);
    } if (!(pFrame->IsIconic()||pFrame->IsZoomed())){
    RECT rMainCl,rFrame,rMainFr;
    ((CMainFrame *)(AfxGetApp()->m_pMainWnd))->GetClientRect(&rMainCl);
    ((CMainFrame *)(AfxGetApp()->m_pMainWnd))->GetWindowRect(&rMainFr);
    pFrame->GetWindowRect(&rFrame);
    pFrame->SetWindowPos(0,0,0,
    (4+rFrame.right-rFrame.left-rClient.right+rClient.left)+
    min(rMainCl.right-(rFrame.left-rMainFr.left+12),x),
    (4+rFrame.bottom-rFrame.top-rClient.bottom+rClient.top)+
    min(rMainCl.bottom-(rFrame.top-rMainFr.top+12),y),
    SWP_NOMOVE|SWP_NOZORDER);
    //ResizeParentToFit(1);
    } if (!ima->SelectionIsValid()) 
    KillTimer(1);#ifdef VATI_EXTENSIONS
    ima->SetJpegQuality(theApp.m_optJpegQuality);
    #endif
    pDoc->m_hmax = 0;
    } break;
    }
    default:
    {
    CWstArchivesDoc* pDoc = GetDocument();
    if (pDoc){
    CxImage*  ima  = pDoc->GetImage();
    if (ima){
    if (pDoc->GetStretchMode()) 
    SetScrollSizes(MM_TEXT, CSize(0,0));
    else 
    SetScrollSizes(MM_TEXT,CSize((int)(ima->GetWidth()*pDoc->GetZoomFactor()),
      (int)(ima->GetHeight()*pDoc->GetZoomFactor())));
    }
    }
    }
    }
    CScrollView::OnUpdate(pSender, lHint, pHint);