PrintView.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:2k
源码类别:

百货/超市行业

开发平台:

Visual C++

  1. // PrintView.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "PrintView.h"
  5. #include "PrintFrame.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. IMPLEMENT_DYNCREATE(CPrintView, CView)
  12. CPrintView::CPrintView()
  13. {
  14. m_bPrint = TRUE;
  15. }
  16. CPrintView::~CPrintView()
  17. {
  18. }
  19. BEGIN_MESSAGE_MAP(CPrintView, CView)
  20. //{{AFX_MSG_MAP(CPrintView)
  21. // NOTE - the ClassWizard will add and remove mapping macros here.
  22. //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24. void CPrintView::OnDraw(CDC* pDC)
  25. {
  26. CDocument* pDoc = GetDocument();
  27. }
  28. #ifdef _DEBUG
  29. void CPrintView::AssertValid() const
  30. {
  31. CView::AssertValid();
  32. }
  33. void CPrintView::Dump(CDumpContext& dc) const
  34. {
  35. CView::Dump(dc);
  36. }
  37. #endif //_DEBUG
  38. void CPrintView::OnMyPrint()
  39. {
  40. GetParent()->ShowWindow(SW_SHOWMINIMIZED);
  41. m_bPrint = TRUE;
  42. CView::OnFilePrint();
  43. }
  44. void CPrintView::OnMyPrintPreview()
  45. {
  46. GetParent()->ShowWindow(SW_SHOWMAXIMIZED);
  47. m_bPrint=FALSE;
  48. CView::OnFilePrintPreview();
  49. }
  50. BOOL CPrintView::OnPreparePrinting(CPrintInfo* pInfo) 
  51. {
  52. if(DoPreparePrinting(pInfo))
  53. return TRUE;
  54. else
  55. {
  56. GetParent()->DestroyWindow();
  57. return FALSE;
  58. }
  59. AfxMessageBox("ff");
  60. }
  61. void CPrintView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo) 
  62. {
  63. CView::OnBeginPrinting(pDC, pInfo);
  64. CPrintFrame *pFrame =(CPrintFrame *)GetParent();
  65. pFrame->m_pCallerDlg->SendMessage(WM_BEGIN_PRINTING,(WPARAM) pDC, (LPARAM) pInfo);
  66. }
  67. void CPrintView::OnEndPrinting(CDC* pDC, CPrintInfo* pInfo) 
  68. {
  69. CView::OnEndPrinting(pDC, pInfo);
  70. CPrintFrame *pFrame =(CPrintFrame *)GetParent();
  71. pFrame->m_pCallerDlg->SendMessage(WM_END_PRINTING,(WPARAM) pDC, (LPARAM) pInfo);
  72. if(m_bPrint) //直接打印,不是预览
  73. GetParent()->DestroyWindow();
  74. }
  75. void CPrintView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
  76. {
  77. CPrintFrame *pFrame =(CPrintFrame *)GetParent();
  78. pFrame->m_pCallerDlg->SendMessage(WM_MY_PRINT,(WPARAM) pDC, (LPARAM) pInfo) ;
  79. }
  80. void CPrintView::OnEndPrintPreview(CDC* pDC, CPrintInfo* pInfo, POINT point, CPreviewView* pView) 
  81. {
  82. CView::OnEndPrintPreview(pDC, pInfo, point, pView);
  83. GetParent()->DestroyWindow();
  84. }