86 lines
1.8 KiB
C++
86 lines
1.8 KiB
C++
// CDlgInput.cpp: 实现文件
|
||
//
|
||
|
||
#include "pch.h"
|
||
#include "scanner-check.h"
|
||
#include "CDlgInput.h"
|
||
#include "afxdialogex.h"
|
||
|
||
|
||
// CDlgInput 对话框
|
||
|
||
IMPLEMENT_DYNAMIC(CDlgInput, CDialogEx)
|
||
|
||
CDlgInput::CDlgInput(CWnd* pParent /*=nullptr*/)
|
||
: CDialogEx(IDD_INPUT, pParent), val_(L""), title_(L"\u4FEE\u6539")
|
||
{
|
||
|
||
}
|
||
|
||
CDlgInput::~CDlgInput()
|
||
{
|
||
}
|
||
|
||
void CDlgInput::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialogEx::DoDataExchange(pDX);
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CDlgInput, CDialogEx)
|
||
ON_BN_CLICKED(IDOK, &CDlgInput::OnBnClickedOk)
|
||
ON_EN_CHANGE(IDC_EDIT1, &CDlgInput::OnEnChangeEdit1)
|
||
END_MESSAGE_MAP()
|
||
|
||
|
||
// CDlgInput 消息处理程序
|
||
BOOL CDlgInput::OnInitDialog()
|
||
{
|
||
CDialogEx::OnInitDialog();
|
||
|
||
::SetWindowTextW(m_hWnd, title_.c_str());
|
||
|
||
size_t pos = val_.find(L"\\n");
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
val_.replace(pos, 2, L"\r\n");
|
||
pos = val_.find(L"\\n");
|
||
}
|
||
while ((pos = val_.find(L"\\t")) != std::wstring::npos)
|
||
val_.replace(pos, 2, L"\t");
|
||
::SetDlgItemTextW(m_hWnd, IDC_EDIT1, val_.c_str());
|
||
|
||
return FALSE;
|
||
}
|
||
|
||
void CDlgInput::OnBnClickedOk()
|
||
{
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
wchar_t val[1024] = { 0 };
|
||
|
||
::GetDlgItemTextW(m_hWnd, IDC_EDIT1, val, _countof(val) - 1);
|
||
val_ = val;
|
||
|
||
size_t pos = val_.find(L"\r\n");
|
||
while (pos != std::wstring::npos)
|
||
{
|
||
val_.replace(pos, 2, L"\\n");
|
||
pos = val_.find(L"\r\n");
|
||
}
|
||
while ((pos = val_.find(L"\t")) != std::wstring::npos)
|
||
val_.replace(pos, 1, L"\\t");
|
||
CDialogEx::OnOK();
|
||
}
|
||
|
||
|
||
void CDlgInput::OnEnChangeEdit1()
|
||
{
|
||
// TODO: 如果该控件是 RICHEDIT 控件,它将不
|
||
// 发送此通知,除非重写 CDialogEx::OnInitDialog()
|
||
// 函数并调用 CRichEditCtrl().SetEventMask(),
|
||
// 同时将 ENM_CHANGE 标志“或”运算到掩码中。
|
||
|
||
// TODO: 在此添加控件通知处理程序代码
|
||
}
|
||
|