我用DDRAW作过,
代码丢了,
怀念啊

解决方案 »

  1.   

    to  jiangsheng(蒋晟.Net):
       有一些道理,就算一样吧!那具体应该如何实现呢,描述一下就行了
    我想知道个大概!多谢了哥们
      

  2.   

    void CEMapView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
    {
    // TODO: Add your specialized code here and/or call the base class
    CScrollView::OnPrepareDC(pDC, pInfo);
    CEMapDoc* pDoc = GetDocument();
    CSize sizeDoc = pDoc->GetSize();
    CPoint ptOrg;
    CRect rectClient;
    GetClientRect(&rectClient);
    pDC->DPtoLP(&rectClient);
    ptOrg.x = min(-sizeDoc.cx / 2,-rectClient.Size().cx/2);
    ptOrg.y = max(sizeDoc.cy / 2,-rectClient.Size().cy/2);
    // ptOrg is in logical coordinates
    pDC->SetWindowOrg(ptOrg);
    }
    void CEMapThumbnailView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
    {
    // TODO: Add your specialized code here and/or call the base class
    CEMapDoc* pDoc = GetDocument();
    CSize sizeDoc=pDoc->GetSize();
    CRect rectClient;
    GetClientRect(&rectClient);
    pDoc->PixelToLongEngish(&rectClient);
    CView::OnPrepareDC(pDC, pInfo);
    pDC->SetMapMode(MM_ANISOTROPIC);
    CSize sizeView;
    LONGLONG x1y2,x2y1;
    x1y2=Int32x32To64(sizeDoc.cx,rectClient.Width());
    x2y1=Int32x32To64(sizeDoc.cy,rectClient.Height());
    if(x1y2>x2y1){//image is too wide,stretch y
    sizeView.cx=::MulDiv(sizeDoc.cy,rectClient.Width(),rectClient.Height());
    sizeView.cy=sizeDoc.cy;
    }
    else{//image is too thin,stretch x
    sizeView.cx=sizeDoc.cx;
    sizeView.cy=::MulDiv(sizeDoc.cx,rectClient.Height(),rectClient.Width());
    }
    GetClientRect(&rectClient);
    pDC->SetWindowExt(sizeView);
    pDC->SetViewportExt(rectClient.Width(),-rectClient.Height());
    CPoint ptOrg;
    ptOrg.x = -sizeView.cx/2;
    ptOrg.y = sizeView.cy/2;
    // ptOrg is in logical coordinates
    pDC->SetWindowOrg(ptOrg.x,ptOrg.y);}
    void CEMapThumbnailView::OnDraw(CDC* pDC)
    {
    CEMapDoc* pDoc = GetDocument();
    // TODO: add draw code here
    CRect rectMap=pDoc->GetMapRect() ;
    pDoc->m_dibMapCurrent.Draw(*pDC,&rectMap);
    if(pDoc->m_pEMapView->GetSafeHwnd()){
    CRect rectViewPort;
    pDoc->m_pEMapView->GetViewPort(&rectViewPort);
    CSize sizeTotal=pDoc->m_pEMapView->GetTotalSize();
    //rectViewPort.OffsetRect(sizeTotal.cx/2,sizeTotal.cy/2);
    m_RectTracker.m_rect.left=MulDiv(rectViewPort.left,rectMap.Width(),sizeTotal.cx);
    m_RectTracker.m_rect.right=MulDiv(rectViewPort.right,rectMap.Width(),sizeTotal.cx);
    m_RectTracker.m_rect.top=-MulDiv(rectViewPort.bottom,rectMap.Height(),sizeTotal.cy);
    m_RectTracker.m_rect.bottom=-MulDiv(rectViewPort.top,rectMap.Height(),sizeTotal.cy);
    pDC->LPtoDP(m_RectTracker.m_rect);
    m_RectTracker.Draw(pDC);
    }
    }
    void CEMapView::GetViewPort(LPRECT lpRect)
    {
    GetClientRect(lpRect);
    ClientToDoc(lpRect);
    }