ShowSelPhoto.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. // ShowSelPhoto.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowSelPhoto.h"
  6. #include "ShowPic22.h"
  7. #include "JPEG.h"
  8. #define THUMBNAIL_WIDTH 100
  9. #define THUMBNAIL_HEIGHT 90
  10. /////////////////////////////////////////////////////////////////////////////
  11. // ShowSelPhoto dialog IDC_BU Tdelall
  12. ShowSelPhoto::ShowSelPhoto(CWnd* pParent /*=NULL*/) : CDialog(ShowSelPhoto::IDD, pParent)
  13. {
  14. m_bTerminate = false;
  15. m_bRunning = false;
  16. m_hThread = NULL;
  17. m_bTerminate2 = false;
  18. m_bRunning2 = false;
  19. m_hThread2 = NULL;
  20. }
  21. void ShowSelPhoto::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. DDX_Control(pDX, IDC_STATIC1, m_sta1);
  25. DDX_Control(pDX, IDC_LIST4, m_List4);
  26. DDX_Control(pDX, IDC_LIST1, m_List1);
  27. DDX_Control(pDX, IDC_LIST3, m_List3);
  28. DDX_Control(pDX, IDC_LIST2, m_List2);
  29. }
  30. BEGIN_MESSAGE_MAP(ShowSelPhoto, CDialog)
  31. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  32. ON_WM_DESTROY()
  33. ON_NOTIFY(NM_DBLCLK, IDC_LIST4, OnDblclkList4)
  34. END_MESSAGE_MAP()
  35. BOOL ShowSelPhoto::OnInitDialog()
  36. {
  37. CDialog::OnInitDialog();
  38. CRect rc;
  39. rc = m_rc;
  40. rc.right -= m_rc.Width()*0.5;
  41. MoveWindow(rc);
  42. int hei = rc.Height();
  43. m_sta1.GetWindowRect(rc);
  44. int hei2 = rc.Height();
  45. GetClientRect(rc);
  46. rc.bottom -= hei / 2;
  47. m_List1.MoveWindow(rc);
  48. rc.top = rc.bottom + 5;
  49. rc.bottom = rc.top + hei2;
  50. m_sta1.MoveWindow(rc);
  51. rc.top = rc.bottom;
  52. rc.bottom = hei;
  53. m_List4.MoveWindow(rc);
  54. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  55. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  56. m_ImageListThumb2.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  57. m_List4.SetImageList(&m_ImageListThumb2, LVSIL_NORMAL);
  58. m_List2.InitStyle();
  59. m_List2.InsertColumn(0, _T("autuid"), LVCFMT_LEFT, 0);
  60. m_List2.InsertColumn(1, _T("编号"), LVCFMT_LEFT, 45);
  61. m_List2.InsertColumn(2, _T("商品名称"), LVCFMT_LEFT, 150);
  62. m_List2.InsertColumn(3, _T("数量"), LVCFMT_LEFT, 45);
  63. m_List2.InsertColumn(4, _T("照片编号"), LVCFMT_LEFT, 410);
  64. m_List3.InitStyle();
  65. m_List3.InsertColumn(0, _T("autuid"), LVCFMT_LEFT, 0);
  66. m_List3.InsertColumn(1, _T("编号"), LVCFMT_LEFT, 45);
  67. m_List3.InsertColumn(2, _T("商品名称"), LVCFMT_LEFT, 150);
  68. m_List3.InsertColumn(3, _T("价格"), LVCFMT_LEFT, 45);
  69. m_List3.InsertColumn(4, _T("数量"), LVCFMT_LEFT, 45);
  70. m_List3.InsertColumn(5, _T("照片编号"), LVCFMT_LEFT, 365);
  71. #ifdef CHILD_VERSION
  72. CString filter = "id='" + m_id + "'";
  73. #else
  74. CString filter="id='"+m_id+"' and kind<>'2'";
  75. #endif
  76. g_sendhead.code[0] = 50;
  77. g_sendhead.tabcount = 1;
  78. g_sendhead.bsql = 0;
  79. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
  80. CArray<CStringArray, CStringArray>sparray;
  81. DataToArray(&sparray);
  82. m_patharray1.RemoveAll();
  83. CString str, kind;
  84. int list2pos = 0;
  85. int list3pos = 0;
  86. m_path = g_path1 + "\\";
  87. m_path += m_id;
  88. m_path += "\\";
  89. for (int i = 0; i < sparray.GetSize(); i++)
  90. {
  91. kind = sparray.ElementAt(i).ElementAt(4);
  92. if (kind == "4")
  93. {
  94. m_List3.InsertItem(list3pos, sparray.ElementAt(i).ElementAt(7));
  95. m_List3.SetItemText(list3pos, 1, sparray.ElementAt(i).ElementAt(1));
  96. m_List3.SetItemText(list3pos, 2, sparray.ElementAt(i).ElementAt(5));
  97. m_List3.SetItemText(list3pos, 3, sparray.ElementAt(i).ElementAt(2));
  98. m_List3.SetItemText(list3pos, 4, sparray.ElementAt(i).ElementAt(3));
  99. m_List3.SetItemText(list3pos, 5, sparray.ElementAt(i).ElementAt(6));
  100. list3pos++;
  101. }
  102. else
  103. {
  104. m_List2.InsertItem(list2pos, sparray.ElementAt(i).ElementAt(7));
  105. m_List2.SetItemText(list2pos, 1, sparray.ElementAt(i).ElementAt(1));
  106. m_List2.SetItemText(list2pos, 2, sparray.ElementAt(i).ElementAt(5));
  107. m_List2.SetItemText(list2pos, 3, sparray.ElementAt(i).ElementAt(3));
  108. m_List2.SetItemText(list2pos, 4, sparray.ElementAt(i).ElementAt(6));
  109. list2pos++;
  110. }
  111. str = sparray.ElementAt(i).ElementAt(6);
  112. str.MakeLower();
  113. GetPath(str);
  114. if (!str.IsEmpty())
  115. str = "," + str + ",";
  116. if (kind == "4")
  117. m_no2array.Add(str);
  118. else
  119. m_noarray.Add(str);
  120. }
  121. LoadPhotos();
  122. return TRUE;
  123. }
  124. unsigned __stdcall LoadThumbNail8(LPVOID lpParam)
  125. {
  126. ShowSelPhoto *pDlg = (ShowSelPhoto*)lpParam;
  127. CListCtrl *ListCtrl = &pDlg->m_List1;
  128. try
  129. {
  130. CImageList* pImgList = &pDlg->m_ImageListThumb;
  131. // reset our image list
  132. for (int i = 0; i < pImgList->GetImageCount(); i++)
  133. pImgList->Remove(i);
  134. // remove all items from list view
  135. ListCtrl->DeleteAllItems();
  136. pImgList->SetImageCount(pDlg->m_vFileName.size());
  137. // TCHAR path[MAX_PATH];
  138. vector<CString>::iterator iter;
  139. // Set redraw to FALSE to avoid flickering during adding new items
  140. ListCtrl->SetRedraw(FALSE);
  141. int nIndex = 0;
  142. CString str, spath;
  143. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  144. {
  145. str = *iter;
  146. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  147. str = str.Left(str.Find('.'));
  148. str += pDlg->GetSelName(str);
  149. ListCtrl->InsertItem(nIndex, str, nIndex);
  150. }
  151. ListCtrl->SetRedraw(TRUE);
  152. ListCtrl->Invalidate();
  153. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  154. int XDest, YDest, nDestWidth, nDestHeight;
  155. nIndex = 0;
  156. SolidBrush whitebrush(Color(255, 255, 255, 255));
  157. Bitmap *pNULLBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  158. Graphics graph2(pNULLBmp);
  159. graph2.Clear(Color(255, 0, 0, 0));
  160. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  161. {
  162. // Load Image File
  163. Image *image = NULL;
  164. Bitmap *pBmp = NULL;
  165. str = *iter;
  166. spath = str.Left(str.ReverseFind('\\') + 1);
  167. spath += "s";
  168. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  169. BOOL bNullimg = 0;
  170. if (PathFileExists(spath))
  171. ::LoadImageFromBuf(&image, spath);
  172. else if (PathFileExists(str))
  173. ::LoadImageFromBuf(&image, str);
  174. else
  175. {
  176. bNullimg = 1;
  177. image = pNULLBmp;
  178. }
  179. if (image == NULL)continue;
  180. if (image->GetWidth() == 0)
  181. continue;
  182. int orientation = GetOrientation(image);
  183. if (orientation == 8)
  184. image->RotateFlip(Rotate270FlipNone);
  185. else if (orientation == 6)
  186. image->RotateFlip(Rotate90FlipNone);
  187. // Calculate Rect to fit to canvas
  188. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  189. if (fImgRatio > fRatio)
  190. {
  191. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  192. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  193. YDest = 0;
  194. nDestHeight = THUMBNAIL_HEIGHT;
  195. }
  196. else
  197. {
  198. XDest = 0;
  199. nDestWidth = THUMBNAIL_WIDTH;
  200. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  201. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  202. }
  203. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  204. Graphics graph2(pBmp);
  205. graph2.Clear(Color(255, 192, 192, 192));
  206. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  207. Graphics graph(pBmp);
  208. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  209. // Draw Image
  210. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  211. if (bNullimg == 0)
  212. delete image;
  213. // Attach to Bitmap and Replace image in CImageList
  214. CBitmap bitmap;
  215. HBITMAP hbmp;
  216. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  217. bitmap.Attach(hbmp);
  218. pImgList->Replace(nIndex, &bitmap, NULL);
  219. delete pBmp;
  220. // Redraw only a current item for removing flickering and fast speed.
  221. ListCtrl->RedrawItems(nIndex, nIndex);
  222. // Release used DC and Object
  223. }
  224. delete pNULLBmp;
  225. ListCtrl->Invalidate();
  226. pDlg->m_bRunning = false;
  227. pDlg->m_bTerminate = false;
  228. pDlg->PostMessage(WM_USER + 200, 0, 0);
  229. _endthreadex(0);
  230. return 0;
  231. }
  232. catch (...)
  233. {
  234. ListCtrl->Invalidate();
  235. pDlg->m_bRunning = false;
  236. pDlg->m_bTerminate = false;
  237. pDlg->PostMessage(WM_USER + 200, 0, 0);
  238. _endthreadex(0);
  239. }
  240. }
  241. unsigned __stdcall LoadThumbNail9(LPVOID lpParam)
  242. {
  243. ShowSelPhoto *pDlg = (ShowSelPhoto*)lpParam;
  244. CImageList* pImgList = &pDlg->m_ImageListThumb2;
  245. CListCtrl *ListCtrl = &pDlg->m_List4;
  246. try
  247. {
  248. // reset our image list
  249. for (int i = 0; i < pImgList->GetImageCount(); i++)
  250. pImgList->Remove(i);
  251. // remove all items from list view
  252. ListCtrl->DeleteAllItems();
  253. pImgList->SetImageCount(pDlg->m_vFileName2.size());
  254. TCHAR path[MAX_PATH];
  255. vector<CString>::iterator iter;
  256. // Set redraw to FALSE to avoid flickering during adding new items
  257. ListCtrl->SetRedraw(FALSE);
  258. int nIndex = 0;
  259. CString str, spath;
  260. for (iter = pDlg->m_vFileName2.begin(); iter != pDlg->m_vFileName2.end() && pDlg->m_bTerminate2 != true; iter++, nIndex++)
  261. {
  262. str = *iter;
  263. spath.Empty();
  264. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  265. {
  266. spath = str.Left(str.ReverseFind('\\') + 1);
  267. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  268. }
  269. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  270. str = spath + str.Left(str.GetLength() - 4);
  271. ListCtrl->InsertItem(nIndex, str, nIndex);
  272. }
  273. ListCtrl->SetRedraw(TRUE);
  274. ListCtrl->Invalidate();
  275. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  276. int XDest, YDest, nDestWidth, nDestHeight;
  277. nIndex = 0;
  278. SolidBrush whitebrush(Color(255, 255, 255, 255));
  279. for (iter = pDlg->m_vFileName2.begin(); iter != pDlg->m_vFileName2.end() && pDlg->m_bTerminate2 != true; iter++, nIndex++)
  280. {
  281. // Load Image File
  282. Image *image = NULL;
  283. Bitmap *pBmp = NULL;
  284. str = *iter;
  285. spath = str.Left(str.ReverseFind('\\') + 1);
  286. spath += "s";
  287. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  288. if (PathFileExists(spath))
  289. ::LoadImageFromBuf(&image, spath);
  290. else
  291. ::LoadImageFromBuf(&image, str);
  292. int orientation = GetOrientation(image);
  293. if (orientation == 8)
  294. image->RotateFlip(Rotate270FlipNone);
  295. else if (orientation == 6)
  296. image->RotateFlip(Rotate90FlipNone);
  297. if (image->GetWidth() == 0)
  298. continue;
  299. // Calculate Rect to fit to canvas
  300. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  301. if (fImgRatio > fRatio)
  302. {
  303. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  304. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  305. YDest = 0;
  306. nDestHeight = THUMBNAIL_HEIGHT;
  307. }
  308. else
  309. {
  310. XDest = 0;
  311. nDestWidth = THUMBNAIL_WIDTH;
  312. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  313. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  314. }
  315. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  316. Graphics graph2(pBmp);
  317. graph2.Clear(Color(255, 192, 192, 192));
  318. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  319. Graphics graph(pBmp);
  320. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  321. // Draw Image
  322. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  323. delete image;
  324. // Attach to Bitmap and Replace image in CImageList
  325. CBitmap bitmap;
  326. HBITMAP hbmp;
  327. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  328. bitmap.Attach(hbmp);
  329. pImgList->Replace(nIndex, &bitmap, NULL);
  330. delete pBmp;
  331. // Redraw only a current item for removing flickering and fast speed.
  332. ListCtrl->RedrawItems(nIndex, nIndex);
  333. // Release used DC and Object
  334. }
  335. ListCtrl->Invalidate();
  336. pDlg->m_bRunning2 = false;
  337. pDlg->m_bTerminate2 = false;
  338. _endthreadex(0);
  339. return 0;
  340. }
  341. catch (...)
  342. {
  343. ListCtrl->Invalidate();
  344. pDlg->m_bRunning2 = false;
  345. pDlg->m_bTerminate2 = false;
  346. _endthreadex(0);
  347. }
  348. }
  349. void ShowSelPhoto::LoadThumbImages()
  350. {
  351. TerminateThread();
  352. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail8, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  353. m_bRunning = true;
  354. }
  355. BOOL ShowSelPhoto::TerminateThread()
  356. {
  357. if (!m_bRunning)
  358. return TRUE;
  359. m_bTerminate = true;
  360. for (;;)
  361. {
  362. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  363. break;
  364. MSG msg;
  365. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  366. {
  367. if (!AfxGetApp()->PumpMessage())
  368. break;
  369. }
  370. }
  371. ::CloseHandle(m_hThread);
  372. return TRUE;
  373. }
  374. void ShowSelPhoto::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  375. {
  376. POSITION pos;
  377. pos = m_List1.GetFirstSelectedItemPosition();
  378. if (pos == NULL)
  379. {
  380. return;
  381. }
  382. int iItem = m_List1.GetNextSelectedItem(pos);
  383. ShowPic22 dlg;
  384. dlg.m_pos = iItem;
  385. dlg.m_pPathArray = &m_patharray1;
  386. dlg.DoModal();
  387. *pResult = 0;
  388. }
  389. void ShowSelPhoto::OnDestroy()
  390. {
  391. TerminateThread();
  392. TerminateThread2();
  393. CDialog::OnDestroy();
  394. }
  395. void ShowSelPhoto::LoadPhotos()
  396. {
  397. if (m_bRunning)return;
  398. CStringArray *pArray = &m_patharray1;
  399. m_vFileName.clear();
  400. for (int i = 0; i < pArray->GetSize(); i++)
  401. {
  402. CString filePath = pArray->ElementAt(i);
  403. filePath.MakeLower();
  404. m_vFileName.push_back(filePath);
  405. }
  406. LoadThumbImages();
  407. /////////////
  408. m_patharray2.RemoveAll();
  409. m_path.MakeLower();
  410. CStringArray dirarray;
  411. CString str;
  412. if (1)
  413. {
  414. using namespace helper_coffs;
  415. ffsco o;
  416. o.dirs(1);
  417. o.find(LPCSTR(m_path), LPCSTR("*.*"));
  418. ffsco::typeT coo;
  419. ffsco::typeT::iterator it;
  420. coo = o.co_dir();
  421. for (it = coo.begin(); coo.end() != it;it++)
  422. {
  423. str = (*it).c_str();
  424. if (FindArray(&dirarray, str) == -1)
  425. {
  426. dirarray.Add(str);
  427. }
  428. }
  429. }
  430. if (1)
  431. {
  432. for (int i = 0; i < dirarray.GetSize(); i++)
  433. {
  434. using namespace helper_coffs;
  435. ffsco o;
  436. o.dirs(0);
  437. o.find(LPCSTR(dirarray.ElementAt(i)), LPCSTR("*.jpg"));
  438. ffsco::typeT coo;
  439. ffsco::typeT::iterator it;
  440. coo = o.co_file();
  441. for (it = coo.begin();coo.end() != it;it++)
  442. {
  443. str = (*it).c_str();
  444. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  445. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  446. str.MakeLower();
  447. m_patharray2.Add(str);
  448. }
  449. }
  450. }
  451. if (m_bRunning2)return;
  452. pArray = &m_patharray2;
  453. m_vFileName2.clear();
  454. for (i = 0; i < pArray->GetSize(); i++)
  455. {
  456. CString filePath = pArray->ElementAt(i);
  457. filePath.MakeLower();
  458. m_vFileName2.push_back(filePath);
  459. }
  460. TerminateThread2();
  461. m_hThread2 = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail9, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID2);
  462. m_bRunning2 = true;
  463. }
  464. extern CString GetPathFromNo(CString dir, CString no, CStringArray *pArray);
  465. void ShowSelPhoto::GetPath(CString str)
  466. {
  467. if (m_DirArrayBuf.GetSize() == 0)
  468. {
  469. CString dir = m_path;
  470. dir.TrimRight('\\');
  471. dir += "\\";
  472. CString temp;
  473. using namespace helper_coffs;
  474. ffsco o;
  475. o.dirs(1);
  476. o.find(LPCSTR(dir), LPCSTR("*.*"));
  477. ffsco::typeT coo;
  478. ffsco::typeT::iterator it;
  479. coo = o.co_dir();
  480. for (it = coo.begin();coo.end() != it;it++)
  481. {
  482. temp = (*it).c_str();
  483. if (::FindArray(&m_DirArrayBuf, temp) == -1 && temp != dir)
  484. {
  485. m_DirArrayBuf.Add(temp);
  486. }
  487. }
  488. }
  489. str.TrimLeft(",");
  490. str.TrimRight(",");
  491. if (str.IsEmpty())return;
  492. int pos = str.Find(',');
  493. CString path, path2;
  494. while (pos != -1)
  495. {
  496. path = GetPathFromNo(m_path, str.Left(pos), &m_DirArrayBuf);//+".jpg";
  497. path2 = path;
  498. path2.Replace("客户原片", "修好的片");
  499. int pos1 = path2.Find(m_id);
  500. pos1 += m_id.GetLength();
  501. int pos2 = path2.ReverseFind('\\');
  502. path2 = path2.Left(pos1) + path2.Right(path2.GetLength() - pos2);
  503. if (::PathFileExists(path2))
  504. path = path2;
  505. if (::FindArray(&m_patharray1, path) == -1)// && ::FindArray(&m_patharray1, &path)!=-1)
  506. {
  507. m_patharray1.Add(path);
  508. }
  509. str = str.Right(str.GetLength() - pos - 1);
  510. pos = str.Find(',');
  511. }
  512. path = GetPathFromNo(m_path, str, &m_DirArrayBuf);//+".jpg";
  513. path2 = path;
  514. path2.Replace("客户原片", "修好的片");
  515. int pos1 = path2.Find(m_id);
  516. pos1 += m_id.GetLength();
  517. int pos2 = path2.ReverseFind('\\');
  518. path2 = path2.Left(pos1) + path2.Right(path2.GetLength() - pos2);
  519. if (::PathFileExists(path2))
  520. path = path2;
  521. if (::FindArray(&m_patharray1, path) == -1)// && ::FindArray(&m_patharray1, &path)!=-1)
  522. m_patharray1.Add(path);
  523. }
  524. CString ShowSelPhoto::GetSelName(CString name)
  525. {
  526. CString ret;
  527. name = "," + name + ",";
  528. for (int i = 0; i < m_List2.GetItemCount(); i++)
  529. {
  530. if (m_noarray.ElementAt(i).Find(name) != -1)
  531. {
  532. ret += m_List2.GetItemText(i, 2);
  533. ret += "\r\n";
  534. }
  535. }
  536. for (i = 0; i < m_List3.GetItemCount(); i++)
  537. {
  538. if (m_no2array.ElementAt(i).Find(name) != -1)
  539. {
  540. ret += m_List3.GetItemText(i, 2);
  541. ret += "\r\n";
  542. }
  543. }
  544. if (!ret.IsEmpty())
  545. {
  546. ret = "\r\n" + ret;
  547. ret.TrimRight("\r\n");
  548. }
  549. return ret;
  550. }
  551. BOOL ShowSelPhoto::TerminateThread2()
  552. {
  553. if (!m_bRunning2)
  554. return TRUE;
  555. m_bTerminate2 = true;
  556. for (;;)
  557. {
  558. if (::WaitForSingleObject(m_hThread2, 0) == WAIT_OBJECT_0)
  559. break;
  560. MSG msg;
  561. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  562. {
  563. if (!AfxGetApp()->PumpMessage())
  564. break;
  565. }
  566. }
  567. ::CloseHandle(m_hThread2);
  568. return TRUE;
  569. }
  570. void ShowSelPhoto::OnDblclkList4(NMHDR* pNMHDR, LRESULT* pResult)
  571. {
  572. POSITION pos;
  573. pos = m_List4.GetFirstSelectedItemPosition();
  574. if (pos == NULL)
  575. {
  576. return;
  577. }
  578. int iItem = m_List4.GetNextSelectedItem(pos);
  579. ShowPic22 dlg;
  580. dlg.m_pos = iItem;
  581. dlg.m_pPathArray = &m_patharray2;
  582. dlg.DoModal();
  583. *pResult = 0;
  584. }