| 
 | 
 
 
发表于 2020-5-12 01:45:01
|
显示全部楼层
 
 
 
void CSeismicView::OnPrepareDC(CDC* pDC,CPrintInfo* pInfo) 
{ 
        CScrollView::OnPrepareDC(pDC, pInfo); 
        CSeismicDoc* pDoc = GetDocument(); 
        if(!pDoc->IfHaveData(index)) return; 
        if(pDC->IsPrinting())===判断CDC是否用于打印 
        { 
             CSize size;===相对坐标或位置,下边是坐标xy 
          size.cx=(int)((float)pDoc->pSeismicData[index]->nMapWidth*zoomfactor); 
          size.cy=(int)((float)pDoc->pSeismicData[index]->nMapHeight*zoomfactor); 
 
          CRect rect; 
          GetUpdateRect(&rect,FALSE);==获得可刷新区域 
  
           pDC->SetMapMode(MM_LOMETRIC);设置映射模式 
           pDC->SetWindowOrg(0,0);设置坐标原点 
        } 
        else 
        { 
 
          CSize size(pDoc->pSeismicData[index]->nMapWidthA,pDoc->pSeismicData[index]->nMapHeightA); 
          if((size.cx==0)||(size.cy==0)) return; 
                 
           pDC->SetMapMode(MM_TEXT); 
           pDC->SetWindowOrg(0,0); 
          SetScrollSizes(MM_TEXT,size);设置滚动条        } 
} 
 
void CSeismicView::OnDraw(CDC* pDC) 
{ 
        //Beep(1000,100); 
        CSeismicDoc* pDoc = GetDocument(); 
        ASSERT_VALID(pDoc); 
        CView* pView=((CSeismicFrm*)AfxGetMainWnd())->GetActiveView(); 
        if(pView==this) 
        { 
                CRect rect; 
                GetClientRect(&rect);==取得客户区范围 
                CPoint point(0,0); 
                pDC->DPtoLP(&point);==转换设备坐标倒逻辑坐标 
                rect.left+=point.x; 
                rect.right+=point.x; 
                rect.top+=point.y; 
                rect.bottom=rect.top+5; 
                CBrush brush(RGB(255,0,0));==设置画刷 
//                pDC->FillRect(&rect,&brush);=用画刷填充 
                brush.DeleteObject();==删除 
        } 
        if(!pDoc->IfHaveData(index)) return; 
        //this->MessageBox("##",NULL,MB_OK); 
        pDoc->pSeismicData[index]->Draw(pDC,(CView*)this); 
        pDoc->pLayerData[index]->Draw(pDC,(CView*)this); 
        pDoc->pFaultData[index]->Draw(pDC,(CView*)this); 
        pDoc->pSeismicData[index]->DrawGridAndLabel(pDC,(CView*)this); 
} 
============= 
这里边都是一些基本的函数,在view里调用了一些DOC类里的成员函数,所以有听多的pDoc->. 
建议楼主应该把mfc基础打好再来研究这些,可以看看 技术内幕 或者 深入浅出MFC 什么东西的,对一些基本函数 MFC框架 文档视有一定了解以后再看这段程序应该很简单 |   
 
 
 
 |