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()/, rectWnd.Height()/,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();
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\nY6027PA\nS5G34442-185-01\n88ASB00980L");
waferqrcode[number_print] = _T("LMBT3906LT1G^Y6027PA^88ASB00980L^S5G34442-185-01"); }
else
{
waferchars[number_print] = wafermodel[number_print] + '\n' + wafersource[number_print] + '\n' + waferlot[number_print] + '\n' + 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(, bpac::bpoDefault);
pObjDoc->EndPrint();
pObjDoc->Close();
}
}
catch (_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
remaining_label_life--;
itoa(remaining_label_life, LRLText, );
} 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() <= )
strPath += _T("APS200labelplate1.lbx");
else
strPath += _T("APS200labelplate2.lbx"); strWaferChars = m_strModel + '\n' + m_strSource + '\n' + m_strWaferlot + '\n' + 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 }

兄弟打印机MFC代码示范的更多相关文章

  1. MFC基于CAsyncSocket套接字客户端代码示范

    MFC基于CAsyncSocket套接字客户端代码示范 https://blog.csdn.net/txwtech/article/details/93016190

  2. 关于AJAX 的交互模型、交互流程及代码示范

    AJAX  = 异步JavaScript + XML. 它是一种用于创建快速动态网页的技术.通过在后台与服务器进行少量数据交换,AJAX 可以使网页实现异步更新.这意味着可以在不重新加载整个网页的情况 ...

  3. c++ UDP套接字服务器端代码示范

    c++ UDP套接字服务器端代码示范 #include<winsock2.h> //包含头文件 #include<stdio.h> #include<windows.h& ...

  4. cc28c_demo.cpp,派生类的构造函数和析构函数-代码示范3

    cc28c_demo.cpp,派生类的构造函数和析构函数-代码示范3 //派生类的构造函数和析构函数//派生类的构造函数(执行步骤)//--执行基类的构造函数//--执行成员对象的构造函数//--执行 ...

  5. c++ cc24a_demo //转换函数,用来做转换操作符,int()括号里面必须是空的,必须定义为const,代码示范

    c++ cc24a_demo //转换函数,用来做转换操作符,int()括号里面必须是空的,必须定义为const,代码示范 #include <iostream> #include < ...

  6. cc22a_demo_c++重载自增自减操作符-代码示范

    cc22a_demo_c++重载自增自减操作符-代码示范 #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespa ...

  7. 套接字TCP控制台服务器程序代码示范

    套接字TCP控制台服务器程序代码示范  https://blog.csdn.net/txwtech/article/details/90344081

  8. upd套接字服务器与客户端交互C++代码示范

    upd套接字服务器与客户端交互C++代码示范 // vc2_2_4UDPserver_Txwtech.cpp : 定义控制台应用程序的入口点. //服务器端 #include "StdAfx ...

  9. c++ UDP套接字客服端代码示范

    c++ UDP套接字客服端代码示范 #include<winsock2.h> //包含头文件 #include<stdio.h> #include<windows.h&g ...

随机推荐

  1. PHP数组简单操作

    1.数字索引数组 1.1创建一个数组 php中最常用的两个类型是:数组,字符串.数组也分为两种,一种是数字索引,一种是关键是索引,关键字索引有点像python中字典的意思.数字索引类型的数组的创建方法 ...

  2. Java——异常处理,数据库连接

    在学习数据库连接时看到try(){}结构,查了一下写在这里: import java.sql.Connection; import java.sql.DriverManager; import jav ...

  3. [注]6W运营法则教你盘活社区内容运营

    社区运营人员大体分为两种:一种是内容运营,这类人才基于产品,一般对文字以及对广告文案比较敏感:另外一种则是更多基于产品推广运营,前者需要把内容最大化地曝光,后者则是把产品推送给用户,两者的是相辅相成, ...

  4. MySql Oracle SqlServer 数据库的数据类型列表

    Oracle数据类型 一.概述  在ORACLE8中定义了:标量(SCALAR).复合(COMPOSITE).引用(REFERENCE)和LOB四种数据类型,下面详细介绍它们的特性. 二.标量(SCA ...

  5. 50个SQL语句(MySQL版) 问题七

    --------------------------表结构-------------------------- student(StuId,StuName,StuAge,StuSex) 学生表 tea ...

  6. Java实现蓝桥杯VIP算法训练 自行车停放

    试题 算法训练 自行车停放 资源限制 时间限制:1.0s 内存限制:256.0MB 问题描述 有n辆自行车依次来到停车棚,除了第一辆自行车外,每辆自行车都会恰好停放在已经在停车棚里的某辆自行车的左边或 ...

  7. Java实现LeetCode_0009_PalindromeNumber

    package javaLeetCode_primary; import java.util.Scanner; import java.util.Stack; public class Palindr ...

  8. Java实现 蓝桥杯 历届试题 矩阵翻硬币

    问题描述 小明先把硬币摆成了一个 n 行 m 列的矩阵. 随后,小明对每一个硬币分别进行一次 Q 操作. 对第x行第y列的硬币进行 Q 操作的定义:将所有第 ix 行,第 jy 列的硬币进行翻转. 其 ...

  9. Java实现 蓝桥杯 历届试题 翻硬币

    问题描述 小明正在玩一个"翻硬币"的游戏. 桌上放着排成一排的若干硬币.我们用 * 表示正面,用 o 表示反面(是小写字母,不是零). 比如,可能情形是:**oo***oooo 如 ...

  10. java实现第六届蓝桥杯生成回文数

    生成回文数 所谓回文数就是左右对称的数字,比如: 585,5885,123321- 当然,单个的数字也可以算作是对称的. 小明发现了一种生成回文数的方法: 比如,取数字19,把它与自己的翻转数相加: ...