ShowSelPhoto.cpp 17 KB

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