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

百货/超市行业

开发平台:

Visual C++

  1. // DlgPrint.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ncshop.h"
  5. #include "DlgPrint.h"
  6. #include "PrintFrame.h"
  7. #include "PrintView.h"
  8. #include "math.h"
  9. #include "ADOConn.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CDlgPrint dialog
  17. CDlgPrint::CDlgPrint(CWnd* pParent /*=NULL*/)
  18. : CDialog(CDlgPrint::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(CDlgPrint)
  21. // NOTE: the ClassWizard will add member initialization here
  22. //}}AFX_DATA_INIT
  23. }
  24. void CDlgPrint::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CDlgPrint)
  28. // NOTE: the ClassWizard will add DDX and DDV calls here
  29. DDX_Control(pDX, IDC_GRID, m_Grid);
  30. //}}AFX_DATA_MAP
  31. }
  32. BEGIN_MESSAGE_MAP(CDlgPrint, CDialog)
  33. //{{AFX_MSG_MAP(CDlgPrint)
  34. ON_BN_CLICKED(IDC_PRINT_SET, OnPrintSet)
  35. ON_BN_CLICKED(IDC_PRINT, OnPrint)
  36. ON_MESSAGE(WM_BEGIN_PRINTING,OnBeginPrinting)
  37. ON_MESSAGE(WM_END_PRINTING,OnEndPrinting)
  38. ON_MESSAGE(WM_MY_PRINT,OnMyPrint)
  39. ON_BN_CLICKED(IDC_PRINT_PREVIEW, OnPrintPreview)
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CDlgPrint message handlers
  44. BOOL CDlgPrint::OnInitDialog() 
  45. {
  46. CDialog::OnInitDialog();
  47. // TODO: Add extra initialization here
  48. CADOConn adoMain;
  49. int i,j;
  50. SetWindowText(strTitle);
  51. adoMain.Open(strSql);
  52. m_Grid.SetRowCount(m_ListMain->GetItemCount()+1);
  53. m_Grid.SetColumnCount(adoMain.GetFeildsCount());
  54. m_Grid.SetEditable(TRUE);
  55.     m_Grid.SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));
  56. m_Grid.SetFixedColumnCount(1);
  57. m_Grid.SetFixedRowCount(1);
  58. for(i=0;i<adoMain.GetFeildsCount();i++)
  59. {
  60. m_Grid.SetItemText(0,i,adoMain.GetFieldsName(i));
  61. }
  62. for(i=0;i<m_ListMain->GetItemCount();i++)
  63. {
  64. for(j=0;j<m_ListMain->GetHeaderCtrl()->GetItemCount();j++)
  65. {
  66. m_Grid.SetItemText(i+1,j,m_ListMain->GetItemText(i,j));
  67. }
  68. }
  69. m_Grid.EnableWysiwygPrinting(TRUE);
  70. adoMain.ExitConnect();
  71. return TRUE;  // return TRUE unless you set the focus to a control
  72.               // EXCEPTION: OCX Property Pages should return FALSE
  73. }
  74. void CDlgPrint::OnPrintSet() 
  75. {
  76. // TODO: Add your control notification handler code here
  77. CNCShopApp *myapp=(CNCShopApp *)AfxGetApp();
  78. myapp->OnSetPrinter();
  79. }
  80. LRESULT CDlgPrint::OnBeginPrinting(WPARAM wParam,LPARAM lParam)
  81. {
  82. CDC* pDC = (CDC*)wParam;
  83. CPrintInfo* pInfo = (CPrintInfo *)lParam;
  84. m_Grid.OnBeginPrinting(pDC,pInfo);
  85. return TRUE;
  86. }
  87. LRESULT CDlgPrint::OnEndPrinting(WPARAM wParam,LPARAM lParam)
  88. {
  89. CDC* pDC = (CDC*)wParam;
  90. CPrintInfo* pInfo = (CPrintInfo *)lParam;
  91. m_Grid.OnEndPrinting(pDC,pInfo);
  92. return TRUE;
  93. }
  94. LRESULT CDlgPrint::OnMyPrint(WPARAM wParam,LPARAM lParam)
  95. {
  96. CDC* pDC = (CDC*)wParam;
  97. CPrintInfo* pInfo = (CPrintInfo *)lParam;
  98. m_Grid.OnPrint(pDC,pInfo);
  99. return TRUE;
  100. }
  101. void CDlgPrint::OnPrint() 
  102. {
  103. // TODO: Add your control notification handler code here
  104. CPrintFrame *pFrame = new CPrintFrame;
  105. pFrame->m_pCallerDlg = this;
  106. pFrame->Create(NULL,"Curve Print",WS_OVERLAPPEDWINDOW,CRect(0,0,0,0));
  107. pFrame->m_pView->OnMyPrint();
  108. }
  109. void CDlgPrint::OnPrintPreview() 
  110. {
  111. // TODO: Add your control notification handler code here
  112. CPrintFrame *pFrame = new CPrintFrame;
  113. pFrame->m_pCallerDlg = this;
  114. pFrame->Create(NULL,"Curve Print Preview",WS_OVERLAPPEDWINDOW,CRect(0,0,0,0));
  115. pFrame->m_pView->OnMyPrintPreview();
  116. }