|
void CSeismicView :: OnPrepareDC (CDC * pDC, CPrintInfo * pInfo)
{
CScrollView :: OnPrepareDC (pDC, pInfo);
CSeismicDoc * pDoc = GetDocument ();
if (! pDoc-> IfHaveData (index)) return;
if (pDC-> IsPrinting ()) === judge whether CDC is used for printing
{
CSize size; === Relative coordinates or position, below is the coordinate xy
size.cx = (int) ((float) pDoc-> pSeismicData [index]-> nMapWidth * zoomfactor);
size.cy = (int) ((float) pDoc-> pSeismicData [index]-> nMapHeight * zoomfactor);
CRect rect;
GetUpdateRect (&rect, FALSE); == get refreshable area
pDC-> SetMapMode (MM_LOMETRIC); Set the mapping mode
pDC-> SetWindowOrg (0,0); set coordinate origin
}
else
{
CSize size (pDoc-> pSeismicData [index]-> nMapWidthA, pDoc-> pSeismicData [index]-> nMapHeightA);
if ((size.cx == 0) || (size.cy == 0)) return;
The
pDC-> SetMapMode (MM_TEXT);
pDC-> SetWindowOrg (0,0);
SetScrollSizes (MM_TEXT, size); Set scroll bar}
}
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); == Get the client area
CPoint point (0,0);
pDC-> DPtoLP (&point); == Convert device coordinates to logical coordinates
rect.left + = point.x;
rect.right + = point.x;
rect.top + = point.y;
rect.bottom = rect.top + 5;
CBrush brush (RGB (255,0,0)); == Set brush
// pDC-> FillRect (&rect,&brush); = fill with brush
brush.DeleteObject (); == delete
}
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);
}
==============
Here are some basic functions. Some member functions in the DOC class are called in the view, so there are many pDoc->.
It is recommended that the landlord should lay the mfc foundation and study them again. You can look at the technical insider or explain the MFC and other things in depth. For some basic functions MFC framework documents, it is very simple to look at this program in the future. |
|