|
@@ -148,9 +148,24 @@ DWORD WINAPI ProcessThread(void *param)
|
|
return 0L;
|
|
return 0L;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+HANDLE _threadScan = NULL;
|
|
|
|
+DWORD WINAPI ScanThread(void *param)
|
|
|
|
+{
|
|
|
|
+ CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //通知发送消息到窗口
|
|
|
|
+ CString strErrorMsg = L"";
|
|
|
|
+ strErrorMsg.Format(L"扫描完成!\r\n");
|
|
|
|
+ SendMessage(pWnd->m_hWnd, WM_SHOWSCANINFO, (WPARAM)strErrorMsg.GetBuffer(), 1);
|
|
|
|
+ strErrorMsg.ReleaseBuffer();
|
|
|
|
+ return 0L;
|
|
|
|
+}
|
|
CMFCApplication1Dlg::CMFCApplication1Dlg(CWnd* pParent /*=nullptr*/)
|
|
CMFCApplication1Dlg::CMFCApplication1Dlg(CWnd* pParent /*=nullptr*/)
|
|
: CDialogEx(IDD_MFCAPPLICATION1_DIALOG, pParent)
|
|
: CDialogEx(IDD_MFCAPPLICATION1_DIALOG, pParent)
|
|
- , m_strMsg(_T(""))
|
|
|
|
|
|
+ , m_strMsg(_T("")), m_strScanMsg(_T(""))
|
|
{
|
|
{
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
}
|
|
}
|
|
@@ -159,6 +174,7 @@ void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT_MSG, m_strMsg);
|
|
DDX_Text(pDX, IDC_EDIT_MSG, m_strMsg);
|
|
|
|
+ DDX_Text(pDX, IDC_EDIT_SCANMSG, m_strScanMsg);
|
|
}
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
|
|
BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
|
|
@@ -167,9 +183,14 @@ BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
|
|
ON_WM_QUERYDRAGICON()
|
|
ON_WM_QUERYDRAGICON()
|
|
ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
|
|
ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
|
|
ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
|
|
|
|
+ ON_MESSAGE(WM_SHOWSCANINFO, OnShowScanInfo)
|
|
ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
|
|
ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
|
|
ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
|
|
ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
|
|
ON_BN_CLICKED(IDC_BTN_PDF, &CMFCApplication1Dlg::OnBnClickedBtnPdf)
|
|
ON_BN_CLICKED(IDC_BTN_PDF, &CMFCApplication1Dlg::OnBnClickedBtnPdf)
|
|
|
|
+ ON_BN_CLICKED(IDC_BTN_MODEPATH, &CMFCApplication1Dlg::OnBnClickedBtnModepath)
|
|
|
|
+ ON_BN_CLICKED(IDC_BTN_IMGPATH, &CMFCApplication1Dlg::OnBnClickedBtnImgpath)
|
|
|
|
+ ON_BN_CLICKED(IDC_BTN_CUTPATH, &CMFCApplication1Dlg::OnBnClickedBtnCutpath)
|
|
|
|
+ ON_BN_CLICKED(ID_BTN_SCAN, &CMFCApplication1Dlg::OnBnClickedBtnScan)
|
|
END_MESSAGE_MAP()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
@@ -290,6 +311,13 @@ void CMFCApplication1Dlg::UpdateMsg(CString strMsg)
|
|
UpdateData(FALSE);
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void CMFCApplication1Dlg::UpdateScanMsg(CString strMsg)
|
|
|
|
+{
|
|
|
|
+ m_strScanMsg += strMsg;
|
|
|
|
+ UpdateData(FALSE);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM wParam, LPARAM lParam)
|
|
LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM wParam, LPARAM lParam)
|
|
{
|
|
{
|
|
@@ -306,9 +334,25 @@ LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM wParam, LPARAM lParam)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+LRESULT CMFCApplication1Dlg::OnShowScanInfo(WPARAM wParam, LPARAM lParam)
|
|
|
|
+{
|
|
|
|
+ wchar_t* p = (wchar_t*)wParam;
|
|
|
|
+ CString str;
|
|
|
|
+ str.Format(_T("%s"), p);
|
|
|
|
+ m_strScanMsg += str;
|
|
|
|
+ UpdateData(FALSE);
|
|
|
|
+
|
|
|
|
+ if (lParam == 1)
|
|
|
|
+ {
|
|
|
|
+ GetDlgItem(ID_BTN_SCAN)->EnableWindow(TRUE);
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
void CMFCApplication1Dlg::OnBnClickedCancel()
|
|
void CMFCApplication1Dlg::OnBnClickedCancel()
|
|
{
|
|
{
|
|
SAFETY_EXIT_THREAD(_threadProcess, 100);
|
|
SAFETY_EXIT_THREAD(_threadProcess, 100);
|
|
|
|
+ SAFETY_EXIT_THREAD(_threadScan, 100);
|
|
CDialogEx::OnCancel();
|
|
CDialogEx::OnCancel();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -376,3 +420,83 @@ void CMFCApplication1Dlg::OnBnClickedBtnPdf()
|
|
}
|
|
}
|
|
pEdit->SetWindowText(strText);
|
|
pEdit->SetWindowText(strText);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void CMFCApplication1Dlg::OnBnClickedBtnModepath()
|
|
|
|
+{
|
|
|
|
+ CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_MODEPATH);
|
|
|
|
+ if (!pEdit)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ CString strText;
|
|
|
|
+ SelectFolder(GetSafeHwnd(), strText);
|
|
|
|
+ if (strText.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ pEdit->SetWindowText(strText);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void CMFCApplication1Dlg::OnBnClickedBtnImgpath()
|
|
|
|
+{
|
|
|
|
+ CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_IMGPATH);
|
|
|
|
+ if (!pEdit)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ CString strText;
|
|
|
|
+ SelectFolder(GetSafeHwnd(), strText);
|
|
|
|
+ if (strText.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ pEdit->SetWindowText(strText);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void CMFCApplication1Dlg::OnBnClickedBtnCutpath()
|
|
|
|
+{
|
|
|
|
+ CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_CUTPATH);
|
|
|
|
+ if (!pEdit)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ CString strText;
|
|
|
|
+ SelectFolder(GetSafeHwnd(), strText);
|
|
|
|
+ if (strText.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ pEdit->SetWindowText(strText);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void CMFCApplication1Dlg::OnBnClickedBtnScan()
|
|
|
|
+{
|
|
|
|
+ ((CEdit*)GetDlgItem(IDC_EDIT_MODEPATH))->GetWindowText(m_strModePath);
|
|
|
|
+ ((CEdit*)GetDlgItem(IDC_EDIT_IMGPATH))->GetWindowText(m_strImgPath);
|
|
|
|
+ ((CEdit*)GetDlgItem(IDC_EDIT_CUTPATH))->GetWindowText(m_strCutPath);
|
|
|
|
+
|
|
|
|
+ if (m_strModePath.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ AfxMessageBox(L"模板文件夹未选择");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (m_strImgPath.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ AfxMessageBox(L"PDF答题卡文件夹未选择");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (m_strCutPath.GetLength() == 0)
|
|
|
|
+ {
|
|
|
|
+ AfxMessageBox(L"切割生成文件夹未选择");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ GetDlgItem(ID_BTN_SCAN)->EnableWindow(FALSE);
|
|
|
|
+ m_strScanMsg = "";
|
|
|
|
+
|
|
|
|
+ SAFETY_EXIT_THREAD(_threadScan, 100);
|
|
|
|
+ _threadScan = CreateThread(NULL, 0, ScanThread, NULL, 0, NULL);
|
|
|
|
+}
|