// qrcode.cpp : 实现文件
//

#include "stdafx.h"
#include "MFC_TSPL.h"
#include "qrcode.h"
#include "afxdialogex.h"
#include "tspl_printer_base.h"


// qrcode 对话框

IMPLEMENT_DYNAMIC(qrcode, CDialogEx)

qrcode::qrcode(CWnd* pParent /*=NULL*/)
	: CDialogEx(qrcode::IDD, pParent)
{

}

qrcode::~qrcode()
{
}

void qrcode::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, x_start);
	DDX_Control(pDX, IDC_EDIT3, y_start);
	DDX_Control(pDX, IDC_EDIT4, ecclevel);
	DDX_Control(pDX, IDC_EDIT5, wide);
	DDX_Control(pDX, IDC_EDIT6, mode);
	DDX_Control(pDX, IDC_EDIT7, rotation);
	DDX_Control(pDX, IDC_EDIT8, model);
	DDX_Control(pDX, IDC_EDIT13, mask);
	DDX_Control(pDX, IDC_EDIT14, data);
	x_start.SetWindowText(_T("100"));
	y_start.SetWindowText(_T("100"));
	ecclevel.SetWindowText(_T("1"));
	wide.SetWindowText(_T("5"));
	rotation.SetWindowText(_T("0"));
	mode.SetWindowText(_T("0"));
	model.SetWindowText(_T("0"));
	mask.SetWindowText(_T("0"));

	data.SetWindowText(_T("\"QR Code 123456\""));

}


BEGIN_MESSAGE_MAP(qrcode, CDialogEx)
	ON_BN_CLICKED(IDOK, &qrcode::OnBnClickedOk)
END_MESSAGE_MAP()


// qrcode 消息处理程序


void qrcode::OnBnClickedOk()
{
	// TODO:  在此添加控件通知处理程序代码
	CString x, y, qreccl, qrwide, qrmode, qrrotation, qrdata,qrmodel,qrmask;

	GetDlgItemText(IDC_EDIT8, qrmodel);
	GetDlgItemText(IDC_EDIT13, qrmask);

	GetDlgItemText(IDC_EDIT1, x);
	if (!(x != ""))
		AfxMessageBox(_T("横坐标起始位置不能为空！"));

	GetDlgItemText(IDC_EDIT3, y);
	if (!(y != ""))
		AfxMessageBox(_T("纵坐标起始位置不能为空！"));

	GetDlgItemText(IDC_EDIT4, qreccl);
	if (!(qreccl != ""))
		AfxMessageBox(_T("错误校验等级不能为空！"));

	GetDlgItemText(IDC_EDIT5, qrwide);
	if (!(qrwide != ""))
		AfxMessageBox(_T("二维码宽不能为空！"));

	GetDlgItemText(IDC_EDIT6, qrmode);
	if (!(qrmode != ""))
		AfxMessageBox(_T("模式选择不能为空！"));

	GetDlgItemText(IDC_EDIT7, qrrotation);
	if (!(qrrotation != ""))
		AfxMessageBox(_T("旋转打印不能为空！"));

	GetDlgItemText(IDC_EDIT14, qrdata);
	if (!(qrdata != ""))
		AfxMessageBox(_T("文本内容不能为空！"));


	DemClearBuffer(hprinter);
	DemSetup(hprinter, 100, 80, 2, 6, 1, 2, 0);
	DemQrCode(hprinter, _ttoi(x), _ttoi(y), _ttoi(qreccl), _ttoi(qrwide), _ttoi(qrmode), _ttoi(qrrotation), _ttoi(qrmodel), _ttoi(qrmask), cstringtocharstring(qrdata));
	DemPrint(hprinter, 1, 1);
}
