home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Samples / vfDao / vfDaoView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  3.6 KB  |  157 lines

  1. // vfDaoView.cpp : implementation of the CVfDaoView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vfDao.h"
  6.  
  7. #include "vfDaoDoc.h"
  8. #include "vfDaoView.h"
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CVfDaoView
  18.  
  19. IMPLEMENT_DYNCREATE(CVfDaoView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(CVfDaoView, CView)
  22.     //{{AFX_MSG_MAP(CVfDaoView)
  23.     ON_WM_CREATE()
  24.     ON_WM_SIZE()
  25.     ON_WM_SETFOCUS()
  26.     ON_WM_ERASEBKGND()
  27.     //}}AFX_MSG_MAP
  28.     // Standard printing commands
  29.     ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  30.     ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  31.     ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  32. END_MESSAGE_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CVfDaoView construction/destruction
  36.  
  37. CVfDaoView::CVfDaoView()
  38. {
  39. }
  40.  
  41. CVfDaoView::~CVfDaoView()
  42. {
  43. }
  44.  
  45. BOOL CVfDaoView::PreCreateWindow(CREATESTRUCT& cs)
  46. {
  47.     // TODO: Modify the Window class or styles here by modifying
  48.     //  the CREATESTRUCT cs
  49.     return CView::PreCreateWindow(cs);
  50. }
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CVfDaoView drawing
  54.  
  55. void CVfDaoView::OnDraw(CDC* pDC)
  56. {
  57.     CVfDaoDoc* pDoc = GetDocument();
  58.     ASSERT_VALID(pDoc);
  59.  
  60.     // TODO: add draw code for native data here
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CVfDaoView diagnostics
  65.  
  66. #ifdef _DEBUG
  67. void CVfDaoView::AssertValid() const
  68. {
  69.     CView::AssertValid();
  70. }
  71.  
  72. void CVfDaoView::Dump(CDumpContext& dc) const
  73. {
  74.     CView::Dump(dc);
  75. }
  76.  
  77. CVfDaoDoc* CVfDaoView::GetDocument() // non-debug version is inline
  78. {
  79.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVfDaoDoc)));
  80.     return (CVfDaoDoc*)m_pDocument;
  81. }
  82. #endif //_DEBUG
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // CVfDaoView message handlers
  86.  
  87. int CVfDaoView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  88. {
  89.     int rc;
  90.     CRect rect(10, 10, 200, 200);
  91.  
  92.     if (CView::OnCreate(lpCreateStruct) == -1)
  93.         return -1;
  94.  
  95.     rc = m_vfMovie.Create("VForm", rect, this, 100);
  96.     if(!rc)
  97.     {
  98.         AfxMessageBox("Could not create Movie VForm"); 
  99.         return -1;
  100.     }
  101.  
  102.     m_vfMovie.PrintStyle(VFPRINT_ALL);
  103.     return 0;
  104. }
  105.  
  106. void CVfDaoView::OnSize(UINT nType, int cx, int cy) 
  107. {
  108.     CView::OnSize(nType, cx, cy);
  109.     m_vfMovie.ResizeToParent();
  110. }
  111.  
  112. void CVfDaoView::OnSetFocus(CWnd* pOldWnd) 
  113. {
  114.     // CView::OnSetFocus(pOldWnd);
  115.     m_vfMovie.SetFocus();
  116. }
  117.  
  118. BOOL CVfDaoView::OnEraseBkgnd(CDC* pDC) 
  119. {
  120.     /* --- Only use this if using Snap Resizing ----
  121.     CRect rect;
  122.     CBrush backBrush(GetSysColor(COLOR_3DFACE));
  123.     CBrush* pOldBrush = pDC->SelectObject(&backBrush);
  124.  
  125.     pDC->GetClipBox(&rect);     // Erase the area needed
  126.     pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
  127.     pDC->SelectObject(pOldBrush);
  128.     ----- */
  129.     return TRUE;    
  130. }
  131.  
  132. void CVfDaoView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
  133. {
  134.     m_vfMovie.DoPrint(pDC, pInfo);    
  135.     // CView::OnPrint(pDC, pInfo);
  136. }
  137.  
  138. void CVfDaoView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
  139. {
  140.     // Set the page info again, since the user may have changed the printer since
  141.     // we set it up in OnPreparePrinting
  142.     m_vfMovie.CalcPageInfo(pDC, pInfo);
  143. }
  144.  
  145. BOOL CVfDaoView::OnPreparePrinting(CPrintInfo* pInfo) 
  146. {
  147.     return m_vfMovie.DoPreparePrinting(this, pInfo);
  148.     // return DoPreparePrinting(pInfo);
  149. }
  150.  
  151. void CVfDaoView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
  152. {
  153.     CView::OnPrepareDC(pDC, pInfo);
  154.     m_vfMovie.DoPrepareDC(pDC, pInfo);
  155. }
  156.  
  157.