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

  1. // vfPictView.cpp : implementation of the CVfPictView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "vfTest.h"
  6.  
  7. #include "vfTestDoc.h"
  8. #include "vfPictView.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. // CVfPictView
  18.  
  19. IMPLEMENT_DYNCREATE(CVfPictView, CView)
  20.  
  21. BEGIN_MESSAGE_MAP(CVfPictView, CView)
  22.     //{{AFX_MSG_MAP(CVfPictView)
  23.     ON_WM_CREATE()
  24.     ON_WM_ERASEBKGND()
  25.     ON_WM_SETFOCUS()
  26.     ON_WM_SIZE()
  27.     ON_COMMAND(ID_FILE_PRINT_SCREEN, OnFilePrintScreen)
  28.     ON_COMMAND(ID_FILE_PRINT_ALL, OnFilePrintAll)
  29.     ON_COMMAND(ID_FILE_PRINT_SELECTED, OnFilePrintSelected)
  30.     //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CVfPictView construction/destruction
  35.  
  36. CVfPictView::CVfPictView()
  37. {
  38.     // TODO: add construction code here
  39.  
  40. }
  41.  
  42. CVfPictView::~CVfPictView()
  43. {
  44. }
  45.  
  46. BOOL CVfPictView::PreCreateWindow(CREATESTRUCT& cs)
  47. {
  48.     // TODO: Modify the Window class or styles here by modifying
  49.     //  the CREATESTRUCT cs
  50.  
  51.     return CView::PreCreateWindow(cs);
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CVfPictView drawing
  56.  
  57. void CVfPictView::OnDraw(CDC* pDC)
  58. {
  59.     CVfTestDoc* pDoc = GetDocument();
  60.     ASSERT_VALID(pDoc);
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // CVfPictView printing
  65.  
  66. void CVfPictView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
  67. {
  68.     m_pictVf.DoPrint(pDC, pInfo);    
  69.     // CView::OnPrint(pDC, pInfo);
  70. }
  71.  
  72.  
  73. BOOL CVfPictView::OnPreparePrinting(CPrintInfo* pInfo)
  74. {
  75.     return m_pictVf.DoPreparePrinting(this, pInfo);
  76.     // return DoPreparePrinting(pInfo);
  77. }
  78.  
  79. void CVfPictView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
  80. {
  81.     // Set the page info again, since the user may have changed the printer since
  82.     // we set it up in OnPreparePrinting
  83.     m_pictVf.CalcPageInfo(pDC, pInfo);
  84. }
  85.  
  86. void CVfPictView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  87. {
  88.     // TODO: add cleanup after printing
  89. }
  90.  
  91. void CVfPictView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo) 
  92. {
  93.     CView::OnPrepareDC(pDC, pInfo);
  94.     m_pictVf.DoPrepareDC(pDC, pInfo);
  95. }
  96.  
  97. void CVfPictView::OnFilePrintScreen() 
  98. {
  99.     m_pictVf.PrintStyle(VFPRINT_SCREEN);
  100.     CView::OnFilePrintPreview();
  101. }
  102.  
  103. void CVfPictView::OnFilePrintAll() 
  104. {
  105.     m_pictVf.PrintStyle(VFPRINT_ALL);
  106.     CView::OnFilePrintPreview();
  107. }
  108.  
  109. void CVfPictView::OnFilePrintSelected() 
  110. {
  111.     m_pictVf.PrintStyle(VFPRINT_SELECTED);
  112.     CView::OnFilePrintPreview();    
  113. }
  114.  
  115.  
  116. /////////////////////////////////////////////////////////////////////////////
  117. // CVfPictView diagnostics
  118.  
  119. #ifdef _DEBUG
  120. void CVfPictView::AssertValid() const
  121. {
  122.     CView::AssertValid();
  123. }
  124.  
  125. void CVfPictView::Dump(CDumpContext& dc) const
  126. {
  127.     CView::Dump(dc);
  128. }
  129.  
  130. CVfTestDoc* CVfPictView::GetDocument() // non-debug version is inline
  131. {
  132.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVfTestDoc)));
  133.     return (CVfTestDoc*)m_pDocument;
  134. }
  135. #endif //_DEBUG
  136.  
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CVfPictView message handlers
  139.  
  140. int CVfPictView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  141. {
  142.     if (CView::OnCreate(lpCreateStruct) == -1)
  143.         return -1;
  144.  
  145.     CRect rect(10, 10, 400, 400);
  146.     if(!m_pictVf.Create(_T("Picture VForm"), rect, this, IDC_PICTVFORM))
  147.         AfxMessageBox(_T("Could not create VForm")); 
  148.  
  149.     return 0;
  150. }
  151.  
  152. BOOL CVfPictView::OnEraseBkgnd(CDC* pDC) 
  153. {
  154. /*    // --- Only use if using snap resize 
  155.     // --- this will cause flicker when sizing
  156.     CBrush backBrush(GetSysColor(COLOR_3DFACE));
  157.     CBrush* pOldBrush = pDC->SelectObject(&backBrush);
  158.  
  159.     CRect rect;
  160.     pDC->GetClipBox(&rect);     // Erase the area needed
  161.     pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
  162.     pDC->SelectObject(pOldBrush);
  163. */
  164.     return TRUE;    
  165.     // return CView::OnEraseBkgnd(pDC);
  166. }
  167.  
  168. void CVfPictView::OnSetFocus(CWnd* pOldWnd) 
  169. {
  170.     CView::OnSetFocus(pOldWnd);
  171.     // m_pictVf.SetFocus();    
  172. }
  173.  
  174. void CVfPictView::OnSize(UINT nType, int cx, int cy) 
  175. {
  176.     CView::OnSize(nType, cx, cy);
  177.     m_pictVf.ResizeToParent();
  178. }
  179.