m_strModel.LoadString(IDS_MODEL_STRING); //IDS_MODEL_STRING,字符串控件的ID,资源视图-String Table里面设置
m_strSource.LoadString(IDS_SOURCE_STRING);//IDS_SOURCE_STRING
m_strWaferlot.LoadString(IDS_WAFER_LOT_STRING);
m_strWelding.LoadString(IDS_WELDING_STRING);
m_strWaferID.LoadString(IDS_WAFER_ID_STRING);
// PrintDlg.cpp : implementation file // #include "stdafx.h" #include "smw200.h" #include "PrintDlg.h" #include "Main.h" #include <fstream> #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPrintDlg dialog const CString TEMPLATE_PATH = _T("C:\Program Files\Brother bPAC3 SDK\Templates\"); CPrintDlg::CPrintDlg(CWnd* pParent /*=NULL*/) : CDialog(CPrintDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPrintDlg) m_strModel = _T(""); m_strSource = _T(""); m_strWaferlot = _T(""); m_strWelding = _T(""); m_strWaferID = _T(""); //}}AFX_DATA_INIT } void CPrintDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPrintDlg) DDX_Control(pDX, IDC_COMBO_TEMPLATE, m_cbTemplate); DDX_Text(pDX, IDC_EDIT_MODEL, m_strModel); DDX_Text(pDX, IDC_EDIT_SOURCE, m_strSource); DDX_Text(pDX, IDC_EDIT_WAFER_LOT, m_strWaferlot); DDX_Text(pDX, IDC_EDIT_WELDING, m_strWelding); DDX_Text(pDX, IDC_EDIT_WAFER_ID, m_strWaferID); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPrintDlg, CDialog) //{{AFX_MSG_MAP(CPrintDlg) ON_BN_CLICKED(IDC_BTN_PRINT, OnBtnPrint) ON_BN_CLICKED(IDC_BTN_SEARCH, OnBtnSearch) ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPrintDlg message handlers BOOL CPrintDlg::OnInitDialog() { CRect rectWnd; GetWindowRect(rectWnd); SetWindowPos(NULL, rectWnd.Width()/4, rectWnd.Height()/4,rectWnd.Width(),rectWnd.Height(),SWP_NOZORDER | SWP_NOACTIVATE); if (language == ENGLISH) { SetWindowText("Print Label"); SetDlgItemText(IDC_STATIC_TEMPLATE,"Template :"); SetDlgItemText(IDC_STATIC_WAFER_ID,"Wafer ID :"); SetDlgItemText(IDC_STATIC_MODEL,"Wafer Model :"); SetDlgItemText(IDC_STATIC_SOURCE,"Wafer Source :"); SetDlgItemText(IDC_STATIC_WAFER_LOT,"Wafer Lot # :"); SetDlgItemText(IDC_STATIC_WELDING,"Bonding Doc :"); SetDlgItemText(IDC_BTN_SEARCH,"Search Label"); SetDlgItemText(IDC_BTN_PRINT,"Print Label"); SetDlgItemText(IDOK,"OK"); SetDlgItemText(IDCANCEL,"Cancel"); } else { SetWindowText("打印标签"); SetDlgItemText(IDC_STATIC_TEMPLATE,"模板选择 :"); SetDlgItemText(IDC_STATIC_WAFER_ID,"晶圆识别符 :"); SetDlgItemText(IDC_STATIC_MODEL,"晶圆型号 :"); SetDlgItemText(IDC_STATIC_SOURCE,"晶圆来源 :"); SetDlgItemText(IDC_STATIC_WAFER_LOT,"晶圆标识符 :"); SetDlgItemText(IDC_STATIC_WELDING,"焊接图号 :"); SetDlgItemText(IDC_BTN_SEARCH,"查询标签"); SetDlgItemText(IDC_BTN_PRINT,"打印标签"); SetDlgItemText(IDOK,"确定"); SetDlgItemText(IDCANCEL,"取消"); } // Set Paremeter m_strModel.LoadString(IDS_MODEL_STRING); m_strSource.LoadString(IDS_SOURCE_STRING); m_strWaferlot.LoadString(IDS_WAFER_LOT_STRING); m_strWelding.LoadString(IDS_WELDING_STRING); m_strWaferID.LoadString(IDS_WAFER_ID_STRING); CDialog::OnInitDialog(); // TODO: Add extra initialization here m_cbTemplate.SetCurSel(0); StartClickNTypeKeyboard(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void print_label() { if(!print_flag) return; print_flag = false; ::CoInitialize(NULL);//初始化COM库 CString strPath = _T("C:\Program Files\Brother bPAC3 SDK\Templates\APS200labelplate1.lbx"); if (CaliPrintLabelFlag) { waferchars[number_print] = _T("LMBT3906LT1G Y6027PA S5G34442-185-01 88ASB00980L"); waferqrcode[number_print] = _T("LMBT3906LT1G^Y6027PA^88ASB00980L^S5G34442-185-01"); } else { waferchars[number_print] = wafermodel[number_print] + ' ' + wafersource[number_print] + ' ' + waferlot[number_print] + ' ' + waferwelding[number_print]; waferqrcode[number_print] = wafermodel[number_print] + '^' + wafersource[number_print] + '^' + waferwelding[number_print] + '^' + waferlot[number_print] ; } print(strPath,waferchars[number_print],waferqrcode[number_print]); ::CoUninitialize(); print_end = false; // log_print_message(); } void print(CString path,CString printChars,CString printQRcode) { try { IDocumentPtr pObjDoc(__uuidof(Document)); if (pObjDoc->Open(path.AllocSysString())) { pObjDoc->GetObject(_bstr_t(_T("objWaferModel")))->PutText(printChars.AllocSysString()); pObjDoc->GetObject(_bstr_t(_T("objWaferQRcode")))->PutText(printQRcode.AllocSysString()); pObjDoc->SetMediaById(pObjDoc->Printer->GetMediaId(), true); pObjDoc->StartPrint(_bstr_t(_T("")), bpac::bpoDefault); pObjDoc->PrintOut(1, bpac::bpoDefault); pObjDoc->EndPrint(); pObjDoc->Close(); } } catch (_com_error e) { AfxMessageBox(e.ErrorMessage()); } remaining_label_life--; itoa(remaining_label_life, LRLText, 10); } void log_print_message() { using namespace std; std::string filename1 = "print.txt"; std::ofstream outfile1( filename1.c_str(), std::ios_base::app ); if( outfile1 ) { outfile1 << "chars " << waferchars[number_print] << " qrcode " << waferqrcode[number_print] << std::endl; } if (outfile1) { outfile1.close(); } } void CPrintDlg::OnBtnPrint() { UpdateData(TRUE); CString strPath,strWaferChars,strWaferQRcode; strPath = TEMPLATE_PATH; if (m_cbTemplate.GetCurSel() <= 0) strPath += _T("APS200labelplate1.lbx"); else strPath += _T("APS200labelplate2.lbx"); strWaferChars = m_strModel + ' ' + m_strSource + ' ' + m_strWaferlot + ' ' + m_strWelding; strWaferQRcode = m_strModel + '^' + m_strSource + '^' + m_strWelding + '^' + m_strWaferlot; print(strPath,strWaferChars,strWaferQRcode); } void CPrintDlg::OnBtnSearch() { // TODO: Add your control notification handler code here if (!mes_success_flag) { AfxMessageBox("数据库未成功连接,请检查网络,自动配置IP,并重启软件进行连接!",MB_ICONSTOP | MB_OK | MB_TOPMOST); return; } UpdateData(TRUE); m_strModel = ""; m_strWaferlot = ""; m_strSource = ""; m_strWelding = ""; searchmes(m_strWaferID); m_strWaferlot = waferlot[number_ocr]; m_strModel = wafermodel[number_ocr]; m_strSource = wafersource[number_ocr]; m_strWelding = waferwelding[number_ocr]; UpdateData(FALSE); } void CPrintDlg::OnDestroy() { CDialog::OnDestroy(); CloseKeyboard(); // TODO: Add your message handler code here }