duanjianjun 2 anos atrás
pai
commit
8959820acf

BIN
MFCApplication1/MFCApplication1.rc


+ 125 - 1
MFCApplication1/MFCApplication1Dlg.cpp

@@ -148,9 +148,24 @@ DWORD WINAPI ProcessThread(void *param)
 	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*/)
 	: CDialogEx(IDD_MFCAPPLICATION1_DIALOG, pParent)
-	, m_strMsg(_T(""))
+	, m_strMsg(_T("")), m_strScanMsg(_T(""))
 {
 	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
 }
@@ -159,6 +174,7 @@ void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
 	DDX_Text(pDX, IDC_EDIT_MSG, m_strMsg);
+	DDX_Text(pDX, IDC_EDIT_SCANMSG, m_strScanMsg);
 }
 
 BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
@@ -167,9 +183,14 @@ BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
 	ON_WM_QUERYDRAGICON()
 	ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
 	ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
+	ON_MESSAGE(WM_SHOWSCANINFO, OnShowScanInfo)
 	ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
 	ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
 	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()
 
 
@@ -290,6 +311,13 @@ void CMFCApplication1Dlg::UpdateMsg(CString strMsg)
 	UpdateData(FALSE);
 }
 
+void CMFCApplication1Dlg::UpdateScanMsg(CString strMsg)
+{
+	m_strScanMsg += strMsg;
+	UpdateData(FALSE);
+}
+
+
 
 LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM  wParam, LPARAM  lParam)
 {
@@ -306,9 +334,25 @@ LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM  wParam, LPARAM  lParam)
 	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()
 {
 	SAFETY_EXIT_THREAD(_threadProcess, 100);
+	SAFETY_EXIT_THREAD(_threadScan, 100);
 	CDialogEx::OnCancel();
 }
 
@@ -376,3 +420,83 @@ void CMFCApplication1Dlg::OnBnClickedBtnPdf()
 	}
 	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);
+}

+ 13 - 1
MFCApplication1/MFCApplication1Dlg.h

@@ -5,6 +5,7 @@
 #pragma once
 
 #define WM_SHOWINFO (WM_USER+0x1)
+#define WM_SHOWSCANINFO (WM_USER+0x2)
 // CMFCApplication1Dlg 对话框
 class CMFCApplication1Dlg : public CDialogEx
 {
@@ -31,12 +32,14 @@ protected:
 	afx_msg void OnPaint();
 	afx_msg HCURSOR OnQueryDragIcon();
 	afx_msg LRESULT OnShowInfo(WPARAM  wParam, LPARAM  lParam);
+	afx_msg LRESULT OnShowScanInfo(WPARAM  wParam, LPARAM  lParam);
 	DECLARE_MESSAGE_MAP()
 public:
 	afx_msg void OnBnClickedOk();
 	CString m_strMsg;
-
+	CString m_strScanMsg;
 	void UpdateMsg(CString strMsg);
+	void UpdateScanMsg(CString strMsg);
 	afx_msg void OnBnClickedCancel();
 
 	void SelectFolder(HWND hwnd, CString& lpszFolder);
@@ -46,4 +49,13 @@ public:
 	
 	CString m_strTextPath;
 	CString m_strPdfDir;
+
+	CString m_strModePath;
+	CString m_strImgPath;
+	CString m_strCutPath;
+
+	afx_msg void OnBnClickedBtnModepath();
+	afx_msg void OnBnClickedBtnImgpath();
+	afx_msg void OnBnClickedBtnCutpath();
+	afx_msg void OnBnClickedBtnScan();
 };

+ 9 - 1
MFCApplication1/resource.h

@@ -11,7 +11,15 @@
 #define IDC_EDIT_TXT                    1001
 #define IDC_EDIT_PDF                    1002
 #define IDC_BTN_PDF                     1003
+#define IDC_BTN_MODEPATH                1004
 #define IDC_EDIT_MSG                    1005
+#define IDC_EDIT_MODEPATH               1006
+#define IDC_BTN_IMGPATH                 1007
+#define IDC_EDIT_IMGPATH                1008
+#define ID_BTN_SCAN                     1010
+#define IDC_BTN_CUTPATH                 1011
+#define IDC_EDIT_CUTPATH                1012
+#define IDC_EDIT_SCANMSG                1013
 
 // Next default values for new objects
 // 
@@ -19,7 +27,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        130
 #define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1006
+#define _APS_NEXT_CONTROL_VALUE         1011
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif