pay_dlg.cpp 3.13 KB
// D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.cpp : 实现文件
//

#include "stdafx.h"
#include "ETradeClient.h"
#include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h"
#include "afxdialogex.h"
#include "etradeclient/hardware/hardware_cmd.h"
#include "etradeclient/boost_patch/property_tree/json_parser.hpp"

// PayDlg 对话框

IMPLEMENT_DYNAMIC(PayDlg, CDialogEx)

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

}

PayDlg::~PayDlg()
{
}

void PayDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_PAY_STATIC_TOTAL_MONEY, total_money_static_);
	DDX_Control(pDX, IDC_PAY_STATIC_REAL_MONEY, real_money_static_);
	DDX_Control(pDX, IDC_PAY_STATIC_PASSWORD, password_static_);
	DDX_Control(pDX, IDC_PAY_EDIT_PASSWORD, password_edit_);
	DDX_Control(pDX, IDC_PAY_BUTTON_PAY, pay_button_);
	DDX_Control(pDX, IDC_PAY_BUTTON_CLOSE, close_button_);
	DDX_Control(pDX, IDC_PAY_BUTTON_PASSWORD, password_button_);
}


BEGIN_MESSAGE_MAP(PayDlg, CDialogEx)
	ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose)
	ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay)
END_MESSAGE_MAP()


// PayDlg 消息处理程序


BOOL PayDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	SetCtrlPos();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE
}

void PayDlg::SetCtrlPos()
{
	const int StaticWidth = 80, StaticHeigth = 35;
	const int EditWidth = 140, EditHeigth = 35;
	const int EditWidthShort = 70, StaticWidthShort = 70;
	const int ButtonWidth = 120, ButtonHeight = 40;

	CRect ctrl_rect;
	ctrl_rect.top = 30 + 10;
	ctrl_rect.bottom = ctrl_rect.top + StaticHeigth;
	ctrl_rect.left = 30;
	ctrl_rect.right = ctrl_rect.left + StaticWidth;
	total_money_static_.MoveWindow(&ctrl_rect);

	ctrl_rect.left = ctrl_rect.right;
	ctrl_rect.right += StaticWidth;
	real_money_static_.MoveWindow(&ctrl_rect);

	ctrl_rect.top = ctrl_rect.bottom + 30;
	ctrl_rect.bottom = ctrl_rect.top + StaticHeigth;
	ctrl_rect.left = 30;
	ctrl_rect.right = ctrl_rect.left + StaticWidth;
	password_static_.MoveWindow(ctrl_rect);

	ctrl_rect.left = ctrl_rect.right;
	ctrl_rect.right += EditWidth;
	password_edit_.MoveWindow(&ctrl_rect);

	ctrl_rect.left = ctrl_rect.right + 10;
	ctrl_rect.right += ButtonWidth;
	password_button_.MoveWindow(&ctrl_rect);

	CRect dlg_rect;
	GetClientRect(&dlg_rect);
	ctrl_rect.bottom = dlg_rect.bottom;
	ctrl_rect.top = ctrl_rect.bottom - ButtonHeight;
	ctrl_rect.right = dlg_rect.right - 100;
	ctrl_rect.left = ctrl_rect.right - ButtonWidth;
	close_button_.MoveWindow(&ctrl_rect);

	ctrl_rect.right = ctrl_rect.left - 100;
	ctrl_rect.left = ctrl_rect.right - ButtonWidth;
	pay_button_.MoveWindow(ctrl_rect);

	CRect rect;
	password_edit_.GetClientRect(&rect);
	OffsetRect(&rect, 0, 10);
	password_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect);

	password_edit_.EnableWindow(FALSE);
}

void PayDlg::OnBnClickedPayButtonClose()
{
	CDialogEx::OnCancel();
}


void PayDlg::OnBnClickedPayButtonPay()
{
	auto printer_device = StylusPrinterCmd();
	HardwareCmd::Reply reply = printer_device.Execute("");
}