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

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

// dmatrix 对话框

IMPLEMENT_DYNAMIC(dmatrix, CDialogEx)

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

}

dmatrix::~dmatrix()
{
}

void dmatrix::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, width);
	DDX_Control(pDX, IDC_EDIT5, height);
	DDX_Control(pDX, IDC_EDIT6, xm);
	DDX_Control(pDX, IDC_EDIT7, row);
	DDX_Control(pDX, IDC_EDIT8, col);
	DDX_Control(pDX, IDC_EDIT14, data);
	x_start.SetWindowText(_T("100"));
	y_start.SetWindowText(_T("100"));
	width.SetWindowText(_T("4"));
	height.SetWindowText(_T("4"));
	xm.SetWindowText(_T("8"));
	row.SetWindowText(_T("18"));
	col.SetWindowText(_T("18"));

	data.SetWindowText(_T("\"DMATRIX EXAMPLE\""));
}


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


// dmatrix 消息处理程序


void dmatrix::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	CString x, y, dmwidth, dmheight, dmxm, dmrow, dmcol,dmdata;

	

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

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

	GetDlgItemText(IDC_EDIT4, dmwidth);
	if (!(dmwidth != ""))
		AfxMessageBox(_T("条码宽度不能为空！"));

	GetDlgItemText(IDC_EDIT5, dmheight);
	if (!(dmheight != ""))
		AfxMessageBox(_T("条码高度不能为空！"));

	GetDlgItemText(IDC_EDIT6, dmxm);
	if (!(dmxm != ""))
		AfxMessageBox(_T("条码尺寸不能为空！"));

	GetDlgItemText(IDC_EDIT7, dmrow);
	if (!(dmrow != ""))
		AfxMessageBox(_T("行大小不能为空！"));

	GetDlgItemText(IDC_EDIT8, dmcol);
	if (!(dmcol != ""))
		AfxMessageBox(_T("列大小不能为空！"));

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


	DemClearBuffer(hprinter);
	DemSetup(hprinter, 100, 80, 2, 6, 1, 2, 0);
	DemDmatrix(hprinter, _ttoi(x), _ttoi(y), _ttoi(dmwidth), _ttoi(dmheight), _ttoi(dmxm), _ttoi(dmrow), _ttoi(dmcol), cstringtocharstring(dmdata));
	DemPrint(hprinter, 1, 1);
}
