MFCApplication1Dlg.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. 
  2. // MFCApplication1Dlg.cpp: 实现文件
  3. //
  4. #include "pch.h"
  5. #include "framework.h"
  6. #include "MFCApplication1.h"
  7. #include "MFCApplication1Dlg.h"
  8. #include "afxdialogex.h"
  9. #include "CvxText.h"
  10. #include "BaseUtility.h"
  11. #include "libpdf.h"
  12. #include "AssignWords.h"
  13. #include "lib_common_depence.h"
  14. #include <direct.h>
  15. #include <io.h>
  16. #include "Buffers.h"
  17. #include "Config.h"
  18. #if defined(GNUC)
  19. #pragma GCC diagnostic push
  20. #pragma GCC diagnostic ignored “-Wdeprecated-declarations”
  21. #elif defined(_MSC_VER)
  22. #pragma warning(disable : 4996)
  23. #endif
  24. #include <json/json.h>
  25. #ifdef _DEBUG
  26. #pragma comment(lib, "libpdfd.lib")
  27. #pragma comment(lib, "lib_common_depence_d.lib")
  28. #else
  29. #pragma comment(lib, "libpdf.lib")
  30. #pragma comment(lib, "lib_common_depence.lib")
  31. #endif
  32. #ifdef _DEBUG
  33. #define new DEBUG_NEW
  34. #endif
  35. #define SAFETY_CLOSE_HANDLE( handle ) \
  36. if( NULL != handle ) \
  37. { \
  38. CloseHandle( handle ); \
  39. handle = NULL; \
  40. }
  41. #define SAFETY_EXIT_THREAD( hThread, Timeout ) \
  42. if( NULL != hThread ) \
  43. { \
  44. if( WaitForSingleObject( hThread, Timeout ) == WAIT_TIMEOUT ) \
  45. TerminateThread( hThread, -1 ); \
  46. CloseHandle( hThread ); \
  47. hThread = NULL; \
  48. }
  49. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  50. class CAboutDlg : public CDialogEx
  51. {
  52. public:
  53. CAboutDlg();
  54. // 对话框数据
  55. #ifdef AFX_DESIGN_TIME
  56. enum { IDD = IDD_ABOUTBOX };
  57. #endif
  58. protected:
  59. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  60. // 实现
  61. protected:
  62. DECLARE_MESSAGE_MAP()
  63. };
  64. CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
  65. {
  66. }
  67. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  68. {
  69. CDialogEx::DoDataExchange(pDX);
  70. }
  71. BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
  72. END_MESSAGE_MAP()
  73. // CMFCApplication1Dlg 对话框
  74. HANDLE _threadProcess = NULL;
  75. DWORD WINAPI ProcessThread(void *param)
  76. {
  77. CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
  78. std::vector<std::string> twoList;
  79. std::vector<std::string> threeList;
  80. std::vector<std::string> fourList;
  81. AssignWordsFromTest(UnicodeToGB2312(pWnd->m_strTextPath), twoList, threeList, fourList);
  82. auto CovertPdfFunc = [&](std::vector<std::string>& vctFiles, int col, int& pageNum){
  83. std::string strPage1;
  84. for (size_t i = 0; i < vctFiles.size(); i += max_line * col)
  85. {
  86. std::vector<std::string> vecSmall;
  87. auto last = std::min(vctFiles.size(), i + max_line * col);
  88. vecSmall.insert(vecSmall.begin(), vctFiles.begin() + i, vctFiles.begin() + last);
  89. std::string strPagePath;
  90. dataCollectionPaper(col, pageNum, 30, 100, false, vecSmall, pWnd->m_strPdfDir, strPagePath);
  91. if (strPage1.length() == 0)
  92. {
  93. strPage1 = strPagePath;
  94. }
  95. else
  96. {
  97. CString strPdfPath;
  98. strPdfPath.Format(L"%s/pdf/%d.pdf", pWnd->m_strPdfDir, pageNum);
  99. PdfNewFromImage({ strPage1, strPagePath }, TstringToGB2312(strPdfPath.GetBuffer()));
  100. strPage1 = "";
  101. CString strMsg = L"";
  102. strMsg.Format(L"%s\r\n", strPdfPath);
  103. SendMessage(pWnd->m_hWnd, WM_SHOWINFO, (WPARAM)strMsg.GetBuffer(), 0);
  104. strMsg.ReleaseBuffer();
  105. }
  106. pageNum++;
  107. }
  108. if (strPage1.length() > 0)
  109. {
  110. CString strPdfPath;
  111. strPdfPath.Format(L"%s/pdf/%d.pdf", pWnd->m_strPdfDir, pageNum);
  112. PdfNewFromImage({ strPage1 }, TstringToGB2312(strPdfPath.GetBuffer()));
  113. CString strMsg = L"";
  114. strMsg.Format(L"%s\r\n", strPdfPath);
  115. SendMessage(pWnd->m_hWnd, WM_SHOWINFO, (WPARAM)strMsg.GetBuffer(), 0);
  116. strMsg.ReleaseBuffer();
  117. }
  118. };
  119. int pageNum = 100;
  120. CovertPdfFunc(twoList, 2, pageNum);
  121. CovertPdfFunc(threeList, 3, pageNum);
  122. CovertPdfFunc(fourList, 4, pageNum);
  123. //通知发送消息到窗口
  124. CString strErrorMsg = L"";
  125. strErrorMsg.Format(L"PDF生成完成!\r\n");
  126. SendMessage(pWnd->m_hWnd, WM_SHOWINFO, (WPARAM)strErrorMsg.GetBuffer(), 1);
  127. strErrorMsg.ReleaseBuffer();
  128. return 0L;
  129. }
  130. int IdentifyCallback(result::spinfo& pinfo, void* param)
  131. {
  132. return 0;
  133. }
  134. HANDLE _threadScan = NULL;
  135. DWORD WINAPI ScanThread(void *param)
  136. {
  137. CMFCApplication1Dlg* pWnd = (CMFCApplication1Dlg*)theApp.m_pMainWnd;
  138. auto exitfun = [&]() {
  139. //通知发送消息到窗口
  140. CString strErrorMsg = L"";
  141. strErrorMsg.Format(L"扫描线程退出!\r\n");
  142. SendMessage(pWnd->m_hWnd, WM_SHOWSCANINFO, (WPARAM)strErrorMsg.GetBuffer(), 1);
  143. strErrorMsg.ReleaseBuffer();
  144. };
  145. std::vector<std::string> imgPath; //图片本地路径(和上面url地址一一对应)
  146. preinfo::templatesInfo temeplatInfo;
  147. preinfo::SubjChiInfo sujChiInfo;
  148. std::string strTempDir = "./scantemp/";
  149. if (_access(strTempDir.c_str(), 0) == -1)
  150. {
  151. _mkdir(strTempDir.c_str());
  152. }
  153. int nRet = PareseModeJson(temeplatInfo);
  154. if (nRet)
  155. {
  156. pWnd->FormatScanMsg("模板解析识别");
  157. exitfun();
  158. return 0;
  159. }
  160. nRet = api_processing_images("",
  161. strTempDir.c_str(),
  162. temeplatInfo,
  163. sujChiInfo,
  164. imgPath,
  165. LOG_AUTO,
  166. false,
  167. OLNS,
  168. IdentifyCallback,
  169. NULL);
  170. ////启动算法扫描功能
  171. if (nRet != RT_OK)
  172. {
  173. pWnd->FormatScanMsg("扫描失败,errorCode:%d", nRet);
  174. }
  175. exitfun();
  176. return 0L;
  177. }
  178. CMFCApplication1Dlg::CMFCApplication1Dlg(CWnd* pParent /*=nullptr*/)
  179. : CDialogEx(IDD_MFCAPPLICATION1_DIALOG, pParent)
  180. , m_strMsg(_T("")), m_strScanMsg(_T(""))
  181. {
  182. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  183. }
  184. void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
  185. {
  186. CDialogEx::DoDataExchange(pDX);
  187. DDX_Text(pDX, IDC_EDIT_MSG, m_strMsg);
  188. DDX_Text(pDX, IDC_EDIT_SCANMSG, m_strScanMsg);
  189. }
  190. BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
  191. ON_WM_SYSCOMMAND()
  192. ON_WM_PAINT()
  193. ON_WM_QUERYDRAGICON()
  194. ON_BN_CLICKED(IDOK, &CMFCApplication1Dlg::OnBnClickedOk)
  195. ON_MESSAGE(WM_SHOWINFO, OnShowInfo)
  196. ON_MESSAGE(WM_SHOWSCANINFO, OnShowScanInfo)
  197. ON_BN_CLICKED(IDCANCEL, &CMFCApplication1Dlg::OnBnClickedCancel)
  198. ON_BN_CLICKED(IDC_BTN_TXT, &CMFCApplication1Dlg::OnBnClickedBtnTxt)
  199. ON_BN_CLICKED(IDC_BTN_PDF, &CMFCApplication1Dlg::OnBnClickedBtnPdf)
  200. ON_BN_CLICKED(IDC_BTN_MODEPATH, &CMFCApplication1Dlg::OnBnClickedBtnModepath)
  201. ON_BN_CLICKED(IDC_BTN_IMGPATH, &CMFCApplication1Dlg::OnBnClickedBtnImgpath)
  202. ON_BN_CLICKED(IDC_BTN_CUTPATH, &CMFCApplication1Dlg::OnBnClickedBtnCutpath)
  203. ON_BN_CLICKED(ID_BTN_SCAN, &CMFCApplication1Dlg::OnBnClickedBtnScan)
  204. END_MESSAGE_MAP()
  205. // CMFCApplication1Dlg 消息处理程序
  206. BOOL CMFCApplication1Dlg::OnInitDialog()
  207. {
  208. CDialogEx::OnInitDialog();
  209. // 将“关于...”菜单项添加到系统菜单中。
  210. // IDM_ABOUTBOX 必须在系统命令范围内。
  211. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  212. ASSERT(IDM_ABOUTBOX < 0xF000);
  213. CMenu* pSysMenu = GetSystemMenu(FALSE);
  214. if (pSysMenu != nullptr)
  215. {
  216. BOOL bNameValid;
  217. CString strAboutMenu;
  218. bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
  219. ASSERT(bNameValid);
  220. if (!strAboutMenu.IsEmpty())
  221. {
  222. pSysMenu->AppendMenu(MF_SEPARATOR);
  223. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  224. }
  225. }
  226. // 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
  227. // 执行此操作
  228. SetIcon(m_hIcon, TRUE); // 设置大图标
  229. SetIcon(m_hIcon, FALSE); // 设置小图标
  230. CConfig::Instance()->LoadFromINI();
  231. GetDlgItem(IDC_EDIT_TXT)->SetWindowText(CConfig::Instance()->m_strTxt);
  232. GetDlgItem(IDC_EDIT_PDF)->SetWindowText(CConfig::Instance()->m_strPdf);
  233. GetDlgItem(IDC_EDIT_MODEPATH)->SetWindowText(CConfig::Instance()->m_strMode);
  234. GetDlgItem(IDC_EDIT_IMGPATH)->SetWindowText(CConfig::Instance()->m_strImg);
  235. GetDlgItem(IDC_EDIT_CUTPATH)->SetWindowText(CConfig::Instance()->m_strCut);
  236. return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
  237. }
  238. void CMFCApplication1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
  239. {
  240. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  241. {
  242. CAboutDlg dlgAbout;
  243. dlgAbout.DoModal();
  244. }
  245. else
  246. {
  247. CDialogEx::OnSysCommand(nID, lParam);
  248. }
  249. }
  250. // 如果向对话框添加最小化按钮,则需要下面的代码
  251. // 来绘制该图标。 对于使用文档/视图模型的 MFC 应用程序,
  252. // 这将由框架自动完成。
  253. void CMFCApplication1Dlg::OnPaint()
  254. {
  255. if (IsIconic())
  256. {
  257. CPaintDC dc(this); // 用于绘制的设备上下文
  258. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  259. // 使图标在工作区矩形中居中
  260. int cxIcon = GetSystemMetrics(SM_CXICON);
  261. int cyIcon = GetSystemMetrics(SM_CYICON);
  262. CRect rect;
  263. GetClientRect(&rect);
  264. int x = (rect.Width() - cxIcon + 1) / 2;
  265. int y = (rect.Height() - cyIcon + 1) / 2;
  266. // 绘制图标
  267. dc.DrawIcon(x, y, m_hIcon);
  268. }
  269. else
  270. {
  271. CDialogEx::OnPaint();
  272. }
  273. }
  274. //当用户拖动最小化窗口时系统调用此函数取得光标
  275. //显示。
  276. HCURSOR CMFCApplication1Dlg::OnQueryDragIcon()
  277. {
  278. return static_cast<HCURSOR>(m_hIcon);
  279. }
  280. void CMFCApplication1Dlg::OnBnClickedOk()
  281. {
  282. ((CEdit*)GetDlgItem(IDC_EDIT_TXT))->GetWindowText(m_strTextPath);
  283. ((CEdit*)GetDlgItem(IDC_EDIT_PDF))->GetWindowText(m_strPdfDir);
  284. if (m_strTextPath.GetLength() == 0)
  285. {
  286. AfxMessageBox(L"语料库文件未选择");
  287. return;
  288. }
  289. if (m_strPdfDir.GetLength() == 0)
  290. {
  291. AfxMessageBox(L"PDF文件夹未选择");
  292. return;
  293. }
  294. GetDlgItem(IDOK)->EnableWindow(FALSE);
  295. m_strMsg = "";
  296. CString strJsonDir(m_strPdfDir);
  297. strJsonDir.Append(L"\\json");
  298. if (!PathIsDirectory(strJsonDir))
  299. {
  300. ::CreateDirectory(strJsonDir, 0);
  301. }
  302. CString strPdfDir(m_strPdfDir);
  303. strPdfDir.Append(L"\\pdf");
  304. if (!PathIsDirectory(strPdfDir))
  305. {
  306. ::CreateDirectory(strPdfDir, 0);
  307. }
  308. SAFETY_EXIT_THREAD(_threadProcess, 100);
  309. _threadProcess = CreateThread(NULL, 0, ProcessThread, NULL, 0, NULL);
  310. //CDialogEx::OnOK();
  311. }
  312. void CMFCApplication1Dlg::UpdateMsg(CString strMsg)
  313. {
  314. m_strMsg += strMsg;
  315. UpdateData(FALSE);
  316. }
  317. void CMFCApplication1Dlg::UpdateScanMsg(CString strMsg)
  318. {
  319. m_strScanMsg += strMsg;
  320. UpdateData(FALSE);
  321. }
  322. LRESULT CMFCApplication1Dlg::OnShowInfo(WPARAM wParam, LPARAM lParam)
  323. {
  324. wchar_t* p = (wchar_t*)wParam;
  325. CString str;
  326. str.Format(_T("%s"), p);
  327. m_strMsg += str;
  328. UpdateData(FALSE);
  329. if (lParam == 1)
  330. {
  331. GetDlgItem(IDOK)->EnableWindow(TRUE);
  332. }
  333. return 0;
  334. }
  335. LRESULT CMFCApplication1Dlg::OnShowScanInfo(WPARAM wParam, LPARAM lParam)
  336. {
  337. wchar_t* p = (wchar_t*)wParam;
  338. CString str;
  339. str.Format(_T("%s"), p);
  340. m_strScanMsg += str;
  341. UpdateData(FALSE);
  342. if (lParam == 1)
  343. {
  344. GetDlgItem(ID_BTN_SCAN)->EnableWindow(TRUE);
  345. }
  346. return 0;
  347. }
  348. void CMFCApplication1Dlg::OnBnClickedCancel()
  349. {
  350. SAFETY_EXIT_THREAD(_threadProcess, 100);
  351. SAFETY_EXIT_THREAD(_threadScan, 100);
  352. CConfig::Instance()->SaveSetting();
  353. CDialogEx::OnCancel();
  354. }
  355. void CMFCApplication1Dlg::SelectFolder(HWND hwnd, CString& lpszFolder)
  356. {
  357. TCHAR szFolderPath[MAX_PATH];
  358. szFolderPath[0] = 0;
  359. BROWSEINFO sInfo;
  360. ::ZeroMemory(&sInfo, sizeof(BROWSEINFO));
  361. sInfo.pidlRoot = 0;
  362. sInfo.lpszTitle = _T("请选择一个文件夹");
  363. sInfo.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_EDITBOX;
  364. sInfo.lpfn = NULL;
  365. sInfo.hwndOwner = hwnd;
  366. LPITEMIDLIST lpidlBrowse = ::SHBrowseForFolder(&sInfo);
  367. if (lpidlBrowse != NULL) {
  368. if (::SHGetPathFromIDList(lpidlBrowse, szFolderPath)) {
  369. lpszFolder = szFolderPath;
  370. lpszFolder.Replace('\\', '/');
  371. }
  372. ::CoTaskMemFree(lpidlBrowse);
  373. }
  374. }
  375. void CMFCApplication1Dlg::SelectFile(CString& lpszFile)
  376. {
  377. CString OpenFilter = _T("文本文件(*.txt)|*.txt;|");
  378. CFileDialog FileOpen(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, OpenFilter);
  379. if (IDOK == FileOpen.DoModal())
  380. {
  381. lpszFile = FileOpen.GetPathName();
  382. }
  383. }
  384. void CMFCApplication1Dlg::OnBnClickedBtnTxt()
  385. {
  386. CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_TXT);
  387. if (!pEdit)
  388. {
  389. return;
  390. }
  391. CString strText;
  392. SelectFile(strText);
  393. if (strText.GetLength() == 0)
  394. {
  395. return;
  396. }
  397. pEdit->SetWindowText(strText);
  398. CConfig::Instance()->m_strTxt = strText;
  399. }
  400. void CMFCApplication1Dlg::OnBnClickedBtnPdf()
  401. {
  402. CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_PDF);
  403. if (!pEdit)
  404. {
  405. return;
  406. }
  407. CString strText;
  408. SelectFolder(GetSafeHwnd(), strText);
  409. if (strText.GetLength() == 0)
  410. {
  411. return;
  412. }
  413. pEdit->SetWindowText(strText);
  414. CConfig::Instance()->m_strPdf = strText;
  415. }
  416. void CMFCApplication1Dlg::OnBnClickedBtnModepath()
  417. {
  418. CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_MODEPATH);
  419. if (!pEdit)
  420. {
  421. return;
  422. }
  423. CString strText;
  424. SelectFolder(GetSafeHwnd(), strText);
  425. if (strText.GetLength() == 0)
  426. {
  427. return;
  428. }
  429. pEdit->SetWindowText(strText);
  430. CConfig::Instance()->m_strMode = strText;
  431. }
  432. void CMFCApplication1Dlg::OnBnClickedBtnImgpath()
  433. {
  434. CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_IMGPATH);
  435. if (!pEdit)
  436. {
  437. return;
  438. }
  439. CString strText;
  440. SelectFolder(GetSafeHwnd(), strText);
  441. if (strText.GetLength() == 0)
  442. {
  443. return;
  444. }
  445. pEdit->SetWindowText(strText);
  446. CConfig::Instance()->m_strImg = strText;
  447. }
  448. void CMFCApplication1Dlg::OnBnClickedBtnCutpath()
  449. {
  450. CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_CUTPATH);
  451. if (!pEdit)
  452. {
  453. return;
  454. }
  455. CString strText;
  456. SelectFolder(GetSafeHwnd(), strText);
  457. if (strText.GetLength() == 0)
  458. {
  459. return;
  460. }
  461. pEdit->SetWindowText(strText);
  462. CConfig::Instance()->m_strCut = strText;
  463. }
  464. void CMFCApplication1Dlg::OnBnClickedBtnScan()
  465. {
  466. ((CEdit*)GetDlgItem(IDC_EDIT_MODEPATH))->GetWindowText(m_strModePath);
  467. ((CEdit*)GetDlgItem(IDC_EDIT_IMGPATH))->GetWindowText(m_strImgPath);
  468. ((CEdit*)GetDlgItem(IDC_EDIT_CUTPATH))->GetWindowText(m_strCutPath);
  469. if (m_strModePath.GetLength() == 0)
  470. {
  471. AfxMessageBox(L"模板文件夹未选择");
  472. return;
  473. }
  474. if (m_strImgPath.GetLength() == 0)
  475. {
  476. AfxMessageBox(L"答题卡文件夹未选择");
  477. return;
  478. }
  479. if (m_strCutPath.GetLength() == 0)
  480. {
  481. AfxMessageBox(L"切割生成文件夹未选择");
  482. return;
  483. }
  484. GetDlgItem(ID_BTN_SCAN)->EnableWindow(FALSE);
  485. m_strScanMsg = "";
  486. SAFETY_EXIT_THREAD(_threadScan, 100);
  487. _threadScan = CreateThread(NULL, 0, ScanThread, NULL, 0, NULL);
  488. }
  489. void CMFCApplication1Dlg::FormatScanMsg(const char *szFmt, ...)
  490. {
  491. if (!szFmt)
  492. return;
  493. va_list ap;
  494. va_start(ap, szFmt);
  495. size_t nLength = _vsnprintf(nullptr, 0, szFmt, ap) + 1;
  496. CBuffers buffer;
  497. char* szLogMsg = buffer.GetBuf(nLength);
  498. _vsnprintf(szLogMsg, nLength, szFmt, ap);
  499. va_end(ap);
  500. CString strMsg;
  501. // 扫描异常
  502. strMsg.Format(L"%s!\r\n", GB2312ToTstring(szLogMsg).c_str());
  503. SendMessage(WM_SHOWSCANINFO, (WPARAM)strMsg.GetBuffer(), 0);
  504. }