DlgPrint.cpp
上传用户:jzscgs158
上传日期:2022-05-25
资源大小:8709k
文件大小:3k
- // DlgPrint.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ncshop.h"
- #include "DlgPrint.h"
- #include "PrintFrame.h"
- #include "PrintView.h"
- #include "math.h"
- #include "ADOConn.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDlgPrint dialog
- CDlgPrint::CDlgPrint(CWnd* pParent /*=NULL*/)
- : CDialog(CDlgPrint::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDlgPrint)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CDlgPrint::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDlgPrint)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- DDX_Control(pDX, IDC_GRID, m_Grid);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDlgPrint, CDialog)
- //{{AFX_MSG_MAP(CDlgPrint)
- ON_BN_CLICKED(IDC_PRINT_SET, OnPrintSet)
- ON_BN_CLICKED(IDC_PRINT, OnPrint)
- ON_MESSAGE(WM_BEGIN_PRINTING,OnBeginPrinting)
- ON_MESSAGE(WM_END_PRINTING,OnEndPrinting)
- ON_MESSAGE(WM_MY_PRINT,OnMyPrint)
- ON_BN_CLICKED(IDC_PRINT_PREVIEW, OnPrintPreview)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDlgPrint message handlers
- BOOL CDlgPrint::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CADOConn adoMain;
- int i,j;
- SetWindowText(strTitle);
- adoMain.Open(strSql);
- m_Grid.SetRowCount(m_ListMain->GetItemCount()+1);
- m_Grid.SetColumnCount(adoMain.GetFeildsCount());
- m_Grid.SetEditable(TRUE);
- m_Grid.SetTextBkColor(RGB(0xFF, 0xFF, 0xE0));
- m_Grid.SetFixedColumnCount(1);
- m_Grid.SetFixedRowCount(1);
- for(i=0;i<adoMain.GetFeildsCount();i++)
- {
- m_Grid.SetItemText(0,i,adoMain.GetFieldsName(i));
- }
- for(i=0;i<m_ListMain->GetItemCount();i++)
- {
- for(j=0;j<m_ListMain->GetHeaderCtrl()->GetItemCount();j++)
- {
- m_Grid.SetItemText(i+1,j,m_ListMain->GetItemText(i,j));
- }
- }
- m_Grid.EnableWysiwygPrinting(TRUE);
- adoMain.ExitConnect();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CDlgPrint::OnPrintSet()
- {
- // TODO: Add your control notification handler code here
- CNCShopApp *myapp=(CNCShopApp *)AfxGetApp();
- myapp->OnSetPrinter();
- }
- LRESULT CDlgPrint::OnBeginPrinting(WPARAM wParam,LPARAM lParam)
- {
- CDC* pDC = (CDC*)wParam;
- CPrintInfo* pInfo = (CPrintInfo *)lParam;
- m_Grid.OnBeginPrinting(pDC,pInfo);
- return TRUE;
- }
- LRESULT CDlgPrint::OnEndPrinting(WPARAM wParam,LPARAM lParam)
- {
- CDC* pDC = (CDC*)wParam;
- CPrintInfo* pInfo = (CPrintInfo *)lParam;
- m_Grid.OnEndPrinting(pDC,pInfo);
- return TRUE;
- }
- LRESULT CDlgPrint::OnMyPrint(WPARAM wParam,LPARAM lParam)
- {
- CDC* pDC = (CDC*)wParam;
- CPrintInfo* pInfo = (CPrintInfo *)lParam;
- m_Grid.OnPrint(pDC,pInfo);
- return TRUE;
- }
- void CDlgPrint::OnPrint()
- {
- // TODO: Add your control notification handler code here
- CPrintFrame *pFrame = new CPrintFrame;
- pFrame->m_pCallerDlg = this;
- pFrame->Create(NULL,"Curve Print",WS_OVERLAPPEDWINDOW,CRect(0,0,0,0));
- pFrame->m_pView->OnMyPrint();
- }
- void CDlgPrint::OnPrintPreview()
- {
- // TODO: Add your control notification handler code here
- CPrintFrame *pFrame = new CPrintFrame;
- pFrame->m_pCallerDlg = this;
- pFrame->Create(NULL,"Curve Print Preview",WS_OVERLAPPEDWINDOW,CRect(0,0,0,0));
- pFrame->m_pView->OnMyPrintPreview();
- }