#include "COSText.h"
#include "resource.h"

IMPLEMENT_DYNAMIC(COSText, CDialog)

BEGIN_MESSAGE_MAP(COSText, CDialog)
	ON_BN_CLICKED(IDOK, &COSText::OnBnClickedOk)
END_MESSAGE_MAP()

COSText::COSText(CWnd* pParent)
	: CDialog(IDD_COSTEXT, pParent)
{
}

COSText::~COSText()
{
}

void COSText::SetWindowTitleAndLabel(CString title, CString label)
{
	this->title = title;
	this->label = label;
}

void COSText::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT_OSTEXT, edit_label);
	static_label = (CStatic*)GetDlgItem(IDC_STATIC_OSTEXT);
}

BOOL COSText::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetWindowTextW(title);
	static_label->SetWindowTextW(label);
	if (load)
		edit_label.SetWindowTextW(outLabel.GetString());
	return 0;
}


void COSText::OnBnClickedOk()
{
	
	//检测文本框是否填写
	CString text;
	edit_label.GetWindowTextW(text);
	if (text.GetLength() == 0)
	{
		MessageBox(L"内容不能为空", L"未输入提交数据", MB_ICONINFORMATION);
		return;
	}
	//输出
	outLabel = text;
	CDialog::OnOK();
}
