duanjianjun 2 years ago
parent
commit
521cee2494
2 changed files with 20 additions and 3 deletions
  1. 18 3
      MFCApplication1/MFCApplication1Dlg.cpp
  2. 2 0
      MFCApplication1/MFCApplication1Dlg.h

+ 18 - 3
MFCApplication1/MFCApplication1Dlg.cpp

@@ -91,6 +91,7 @@ END_MESSAGE_MAP()
 // CMFCApplication1Dlg 对话框
 
 vector<string> g_vecFileList;//扫描文件列表
+int g_scanCount = 0;//扫描文件个数
 HANDLE _threadProcess = NULL;
 DWORD WINAPI ProcessThread(void *param)
 {
@@ -239,16 +240,17 @@ HANDLE _threadScan = NULL;
 char* g_strIdentifyMsg[7] = { "正常","内部error","批次号异常","保存路径异常","模板为空","图像列表异常","图像列表不是模板整数倍" };
 DWORD WINAPI ScanThread(void *param)
 {
+	g_scanCount = 0;
 	g_vecFileList.clear();
 	GetImages(CConfig::Instance()->m_strImg);
-
 	CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
+	pWnd->PostMessage(WM_PROCESS, NULL, NULL);
 	pWnd->FormatScanMsg("启动扫描线程......");
 	auto exitfun = [&]() {
 		pWnd->FormatScanMsg("扫描线程退出。");
 		SendMessage(pWnd->m_hWnd, WM_SHOWSCANINFO, 0, 1);
 	};
-	std::vector<std::string> imgPath = {"C:\\Users\\admin\\Desktop\\3\\dtk\\20220913133034765_0001.jpg","C:\\Users\\admin\\Desktop\\3\\dtk\\20220913133034765_0002.jpg" };    //图片本地路径(和上面url地址一一对应)
+	
 	preinfo::templatesInfo  temeplatInfo;
 	preinfo::SubjChiInfo sujChiInfo;
 	std::string strTempDir = CT2A(CConfig::Instance()->m_strCut);
@@ -270,7 +272,7 @@ DWORD WINAPI ScanThread(void *param)
 		strTempDir.c_str(),
 		temeplatInfo,
 		sujChiInfo,
-		imgPath,
+		g_vecFileList,
 		LOG_AUTO,
 		false,
 		OLNS,
@@ -308,6 +310,7 @@ BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
 	ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
 	ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
 	ON_MESSAGE(WM_SHOWSCANINFO, OnShowScanInfo)
+	ON_MESSAGE(WM_PROCESS, OnProcessInfo)
 	ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
 	ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
 	ON_BN_CLICKED(IDC_BTN_PDF, &CMFCApplication1Dlg::OnBnClickedBtnPdf)
@@ -494,6 +497,18 @@ LRESULT CMFCApplication1Dlg::OnShowScanInfo(WPARAM  wParam, LPARAM  lParam)
 	return 0;
 }
 
+LRESULT CMFCApplication1Dlg::OnProcessInfo(WPARAM wParam, LPARAM lParam)
+{
+	CString strProcess = _T("--");
+	if (g_vecFileList.size())
+	{
+		float fProcess = (float)g_scanCount / (float)g_vecFileList.size();
+		strProcess.Format(L"%0.0lf%%", fProcess*100);
+	}
+	SetDlgItemText(IDC_EDIT_SCANPROCESS, strProcess);
+	return 0;
+}
+
 void CMFCApplication1Dlg::OnBnClickedCancel()
 {
 	SAFETY_EXIT_THREAD(_threadProcess, 100);

+ 2 - 0
MFCApplication1/MFCApplication1Dlg.h

@@ -6,6 +6,7 @@
 
 #define WM_SHOWINFO (WM_USER+0x1)
 #define WM_SHOWSCANINFO (WM_USER+0x2)
+#define WM_PROCESS (WM_USER+0x3)
 // CMFCApplication1Dlg 对话框
 class CMFCApplication1Dlg : public CDialogEx
 {
@@ -33,6 +34,7 @@ protected:
 	afx_msg HCURSOR OnQueryDragIcon();
 	afx_msg LRESULT OnShowInfo(WPARAM  wParam, LPARAM  lParam);
 	afx_msg LRESULT OnShowScanInfo(WPARAM  wParam, LPARAM  lParam);
+	afx_msg LRESULT OnProcessInfo(WPARAM  wParam, LPARAM  lParam);
 	DECLARE_MESSAGE_MAP()
 public:
 	afx_msg void OnBnClickedOk();