ShowPic3.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. // ShowPic3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowPic3.h"
  6. #include "ShowPic22.h"
  7. #include "JPEG.h"
  8. #include "MyLock.h"
  9. #define THUMBNAIL_WIDTH 100
  10. #define THUMBNAIL_HEIGHT 90
  11. ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/) : CDialog(ShowPic3::IDD, pParent)
  12. {
  13. m_bTerminate = false;
  14. m_bRunning = false;
  15. m_hThread = NULL;
  16. }
  17. void ShowPic3::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialog::DoDataExchange(pDX);
  20. //{{AFX_DATA_MAP(ShowPic3)
  21. DDX_Control(pDX, IDC_LIST2, m_List2);
  22. DDX_Control(pDX, IDC_LIST1, m_List1);
  23. //}}AFX_DATA_MAP
  24. DDX_Control(pDX, IDC_COMBO1, m_combobox);
  25. }
  26. BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
  27. //{{AFX_MSG_MAP(ShowPic3)
  28. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  29. ON_WM_DESTROY()
  30. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  31. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  32. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  33. ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
  34. ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
  35. ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
  36. ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
  37. ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
  38. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  39. ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
  40. ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
  41. //}}AFX_MSG_MAP
  42. ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
  43. ON_BN_CLICKED(Btn_NextOne, OnBnClickedNextone)
  44. ON_MESSAGE(OWNER_MSG_SHOWPHOTO, ShowPhoto2Found)
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // ShowPic3 message handlers
  48. BOOL ShowPic3::OnInitDialog()
  49. {
  50. CDialog::OnInitDialog();
  51. CRect rc, rc2;
  52. GetWindowRect(rc2);
  53. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  54. GetClientRect(rc);
  55. m_List2.GetWindowRect(rc2);
  56. ScreenToClient(rc2);
  57. int dt = rc2.left;
  58. rc2.bottom = rc.bottom - dt;
  59. m_List2.MoveWindow(rc2);
  60. m_List1.GetWindowRect(rc2);
  61. ScreenToClient(rc2);
  62. rc2.bottom = rc.bottom - dt;
  63. rc2.right = rc.right - dt;
  64. m_List1.MoveWindow(rc2);
  65. #if JEFF_TEST_ON
  66. CString strFilters = _T("[status3] = 'OK'");
  67. g_sendhead.bsql = 0;
  68. g_sendhead.code[0] = 217; // case 217:dindan表;
  69. g_sendhead.tabcount = 1;
  70. g_pMainWnd->ProcessChatMessageRequest2(strFilters);
  71. #else
  72. g_sendhead.bsql = 0;
  73. g_sendhead.code[0] = 217; // case 217:dindan表;
  74. g_sendhead.tabcount = 1;
  75. g_pMainWnd->ProcessChatMessageRequest2(1);
  76. #endif
  77. if (g_bSendOK == 0)
  78. {
  79. CDialog::OnCancel();
  80. return 0;
  81. }
  82. DataToArray(&g_List1array);
  83. LoadPhotos();// Jeff.获取客户原片里的所有订单文件夹名称;
  84. CString str;
  85. for (int i = 0; i < g_List1array.GetSize(); i++)
  86. {
  87. str = g_List1array.ElementAt(i).ElementAt(0); // Jeff.nIndex==0,为订单号id;
  88. if (FindArray(&m_dirarray1, str) == -1)
  89. {
  90. if (FindArray(&m_dirarray2, str) == -1)
  91. {
  92. if (FindArray(&m_dirarray3, str) == -1)
  93. {
  94. if (FindArray(&m_dirarray4, str) == -1)
  95. {
  96. continue;
  97. }
  98. }
  99. }
  100. }
  101. str += "\r\n";
  102. str += g_List1array.ElementAt(i).ElementAt(1); // Jeff.nIndex==1,为订单客户姓名1;
  103. str += g_List1array.ElementAt(i).ElementAt(2); // Jeff.nIndex==2,为订单客户姓名2;
  104. m_strArrayName.Add(str);
  105. m_combobox.AddString(g_List1array.ElementAt(i).ElementAt(1) + g_List1array.ElementAt(i).ElementAt(2));
  106. if (m_List2.GetCount() % 2)
  107. m_List2.AddEntry(str, g_gridcol1, m_List2.GetCount());
  108. else
  109. m_List2.AddEntry(str, g_gridcol2, m_List2.GetCount());
  110. }
  111. m_List2.Invalidate();
  112. // CenterWindow();
  113. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  114. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  115. return TRUE;
  116. }
  117. unsigned __stdcall LoadThumbNail20(LPVOID lpParam)
  118. {
  119. try
  120. {
  121. ShowPic3 *pDlg = (ShowPic3*)lpParam;
  122. CListCtrl *ListCtrl = &pDlg->m_List1;
  123. CImageList* pImgList = &pDlg->m_ImageListThumb;
  124. // reset our image list
  125. for (int i = 0; i < pImgList->GetImageCount(); i++)
  126. pImgList->Remove(i);
  127. // remove all items from list view
  128. ListCtrl->DeleteAllItems();
  129. pImgList->SetImageCount(pDlg->m_vFileName.size());
  130. TCHAR path[MAX_PATH];
  131. vector<CString>::iterator iter;
  132. // Set redraw to FALSE to avoid flickering during adding new items
  133. ListCtrl->SetRedraw(FALSE);
  134. int nIndex = 0;
  135. CString str, spath;
  136. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  137. {
  138. str = *iter;
  139. spath.Empty();
  140. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  141. {
  142. spath = str.Left(str.ReverseFind('\\') + 1);
  143. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  144. }
  145. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  146. str = spath + str.Left(str.GetLength() - 4);
  147. ListCtrl->InsertItem(nIndex, str, nIndex);
  148. }
  149. ListCtrl->SetRedraw(TRUE);
  150. ListCtrl->Invalidate();
  151. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  152. int XDest, YDest, nDestWidth, nDestHeight;
  153. nIndex = 0;
  154. SolidBrush whitebrush(Color(255, 255, 255, 255));
  155. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  156. {
  157. // Load Image File
  158. Image *image = NULL;
  159. Bitmap *pBmp = NULL;
  160. str = *iter;
  161. spath = str.Left(str.ReverseFind('\\') + 1);
  162. spath += "s";
  163. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  164. if (PathFileExists(spath))
  165. ::LoadImageFromBuf(&image, spath);
  166. else
  167. {
  168. str.MakeLower();
  169. if (str.Right(3) != "jpg")continue;
  170. ::LoadImageFromBuf(&image, str);
  171. }
  172. if (image == NULL)continue;
  173. int orientation = GetOrientation(image);
  174. if (orientation == 8)
  175. image->RotateFlip(Rotate270FlipNone);
  176. else if (orientation == 6)
  177. image->RotateFlip(Rotate90FlipNone);
  178. if (image->GetWidth() == 0)
  179. continue;
  180. // Calculate Rect to fit to canvas
  181. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  182. if (fImgRatio > fRatio)
  183. {
  184. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  185. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  186. YDest = 0;
  187. nDestHeight = THUMBNAIL_HEIGHT;
  188. }
  189. else
  190. {
  191. XDest = 0;
  192. nDestWidth = THUMBNAIL_WIDTH;
  193. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  194. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  195. }
  196. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  197. Graphics graph2(pBmp);
  198. graph2.Clear(Color(255, 192, 192, 192));
  199. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  200. Graphics graph(pBmp);
  201. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  202. // Draw Image
  203. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  204. delete image;
  205. // Attach to Bitmap and Replace image in CImageList
  206. CBitmap bitmap;
  207. HBITMAP hbmp;
  208. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  209. bitmap.Attach(hbmp);
  210. pImgList->Replace(nIndex, &bitmap, NULL);
  211. delete pBmp;
  212. // Redraw only a current item for removing flickering and fast speed.
  213. ListCtrl->RedrawItems(nIndex, nIndex);
  214. // Release used DC and Object
  215. }
  216. ListCtrl->Invalidate();
  217. pDlg->m_bRunning = false;
  218. pDlg->m_bTerminate = false;
  219. _endthreadex(0);
  220. return 0;
  221. }
  222. catch (...)
  223. {
  224. }
  225. }
  226. void ShowPic3::LoadThumbImages()
  227. {
  228. TerminateThread();
  229. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail20, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  230. m_bRunning = true;
  231. }
  232. BOOL ShowPic3::TerminateThread()
  233. {
  234. if (!m_bRunning)
  235. return TRUE;
  236. m_bTerminate = true;
  237. for (;;)
  238. {
  239. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  240. break;
  241. MSG msg;
  242. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  243. {
  244. if (!AfxGetApp()->PumpMessage())
  245. break;
  246. }
  247. }
  248. ::CloseHandle(m_hThread);
  249. return TRUE;
  250. }
  251. void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  252. {
  253. POSITION pos;
  254. pos = m_List1.GetFirstSelectedItemPosition();
  255. if (pos == NULL)
  256. {
  257. return;
  258. }
  259. int iItem = m_List1.GetNextSelectedItem(pos);
  260. ShowPic22 dlg;
  261. dlg.m_pos = iItem;
  262. dlg.m_pPathArray = &m_patharray1;
  263. dlg.DoModal();
  264. *pResult = 0;
  265. }
  266. void ShowPic3::OnDestroy()
  267. {
  268. TerminateThread();
  269. CDialog::OnDestroy();
  270. }
  271. void ShowPic3::LoadPhotos()
  272. {
  273. CString str;
  274. if (1)
  275. {
  276. // printf("Jeff:g_path1=%s\n\n",g_path1);//Jeff.获取客户原片里的所有订单文件夹名称;
  277. using namespace helper_coffs;
  278. ffsco o;
  279. o.dirs(0);
  280. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  281. ffsco::typeT coo;
  282. ffsco::typeT::iterator it;
  283. coo = o.co_dir();
  284. for (it = coo.begin(); coo.end() != it; it++)
  285. {
  286. str = (*it).c_str();
  287. if (str == g_path1 + "\\")continue;
  288. str.TrimRight("\\");
  289. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  290. // printf("Jeff:str=%s\n\n",str);
  291. m_dirarray1.Add(str);
  292. }
  293. }
  294. return;
  295. if (1)
  296. {
  297. using namespace helper_coffs;
  298. ffsco o;
  299. o.dirs(0);
  300. o.find(LPCSTR(g_path2), LPCSTR("*.*"));
  301. ffsco::typeT coo;
  302. ffsco::typeT::iterator it;
  303. coo = o.co_dir();
  304. for (it = coo.begin(); coo.end() != it; it++)
  305. {
  306. str = (*it).c_str();
  307. if (str == g_path2 + "\\")continue;
  308. str.TrimRight("\\");
  309. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  310. m_dirarray2.Add(str);
  311. }
  312. }
  313. if (1)
  314. {
  315. using namespace helper_coffs;
  316. ffsco o;
  317. o.dirs(0);
  318. o.find(LPCSTR(g_path3), LPCSTR("*.*"));
  319. ffsco::typeT coo;
  320. ffsco::typeT::iterator it;
  321. coo = o.co_dir();
  322. for (it = coo.begin(); coo.end() != it; it++)
  323. {
  324. str = (*it).c_str();
  325. if (str == g_path3 + "\\")continue;
  326. str.TrimRight("\\");
  327. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  328. m_dirarray3.Add(str);
  329. }
  330. }
  331. if (1)
  332. {
  333. using namespace helper_coffs;
  334. ffsco o;
  335. o.dirs(0);
  336. o.find(LPCSTR(g_path4), LPCSTR("*.*"));
  337. ffsco::typeT coo;
  338. ffsco::typeT::iterator it;
  339. coo = o.co_dir();
  340. for (it = coo.begin(); coo.end() != it; it++)
  341. {
  342. str = (*it).c_str();
  343. if (str == g_path4 + "\\")continue;
  344. str.TrimRight("\\");
  345. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  346. m_dirarray4.Add(str);
  347. }
  348. }
  349. return;
  350. }
  351. void ShowPic3::OnBUTdel()
  352. {
  353. }
  354. void ShowPic3::OnSelchangeList2()
  355. {
  356. UpdateData();
  357. int pos = m_List2.GetCurSel();
  358. if (pos == -1)return;
  359. CString str;
  360. m_List2.GetText(pos, str);
  361. pos = str.Find("\r\n");
  362. if (pos == -1)return;;
  363. m_strOrderNumber = str.Left(pos);
  364. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  365. ShowPhoto1();
  366. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  367. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  368. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  369. }
  370. void ShowPic3::ShowPhoto1()
  371. {
  372. if (m_strOrderNumber == "")
  373. {
  374. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  375. }
  376. CString str;
  377. m_path = g_path1 + "\\" + m_strOrderNumber + "\\";
  378. m_patharray1.RemoveAll();
  379. if (1)
  380. {
  381. using namespace helper_coffs;
  382. ffsco o;
  383. o.dirs(1);
  384. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  385. ffsco::typeT coo;
  386. ffsco::typeT::iterator it;
  387. coo = o.co_file();
  388. for (it = coo.begin(); coo.end() != it; it++)
  389. {
  390. str = (*it).c_str();
  391. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  392. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  393. str.MakeLower();
  394. m_patharray1.Add(str);
  395. }
  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. void ShowPic3::ShowPhoto2()
  409. {
  410. if (m_strOrderNumber == "")
  411. {
  412. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  413. }
  414. CString str;
  415. m_path = g_path2 + "\\" + m_strOrderNumber + "\\";
  416. m_patharray1.RemoveAll();
  417. if (1)
  418. {
  419. using namespace helper_coffs;
  420. ffsco o;
  421. o.dirs(1);
  422. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  423. ffsco::typeT coo;
  424. ffsco::typeT::iterator it;
  425. coo = o.co_file();
  426. for (it = coo.begin(); coo.end() != it; it++)
  427. {
  428. str = (*it).c_str();
  429. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  430. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  431. str.MakeLower();
  432. m_patharray1.Add(str);
  433. }
  434. }
  435. if (m_bRunning)return;
  436. CStringArray *pArray = &m_patharray1;
  437. m_vFileName.clear();
  438. for (int i = 0; i < pArray->GetSize(); i++)
  439. {
  440. CString filePath = pArray->ElementAt(i);
  441. filePath.MakeLower();
  442. m_vFileName.push_back(filePath);
  443. }
  444. LoadThumbImages();
  445. }
  446. void ShowPic3::ShowPhoto3()
  447. {
  448. if (m_strOrderNumber == "")
  449. {
  450. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  451. }
  452. CString str;
  453. m_path = g_path3 + "\\" + m_strOrderNumber + "\\";
  454. m_patharray1.RemoveAll();
  455. if (1)
  456. {
  457. using namespace helper_coffs;
  458. ffsco o;
  459. o.dirs(1);
  460. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  461. ffsco::typeT coo;
  462. ffsco::typeT::iterator it;
  463. coo = o.co_file();
  464. for (it = coo.begin(); coo.end() != it; it++)
  465. {
  466. str = (*it).c_str();
  467. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  468. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  469. str.MakeLower();
  470. m_patharray1.Add(str);
  471. }
  472. }
  473. if (m_bRunning)return;
  474. CStringArray *pArray = &m_patharray1;
  475. m_vFileName.clear();
  476. for (int i = 0; i < pArray->GetSize(); i++)
  477. {
  478. CString filePath = pArray->ElementAt(i);
  479. filePath.MakeLower();
  480. m_vFileName.push_back(filePath);
  481. }
  482. LoadThumbImages();
  483. }
  484. void ShowPic3::ShowPhoto4()
  485. {
  486. if (m_strOrderNumber == "")
  487. {
  488. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  489. }
  490. CString str;
  491. m_path = g_path4 + "\\" + m_strOrderNumber + "\\";
  492. m_patharray1.RemoveAll();
  493. if (1)
  494. {
  495. using namespace helper_coffs;
  496. ffsco o;
  497. o.dirs(1);
  498. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  499. ffsco::typeT coo;
  500. ffsco::typeT::iterator it;
  501. coo = o.co_file();
  502. for (it = coo.begin(); coo.end() != it; it++)
  503. {
  504. str = (*it).c_str();
  505. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  506. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  507. str.MakeLower();
  508. m_patharray1.Add(str);
  509. }
  510. }
  511. if (m_bRunning)return;
  512. CStringArray *pArray = &m_patharray1;
  513. m_vFileName.clear();
  514. for (int i = 0; i < pArray->GetSize(); i++)
  515. {
  516. CString filePath = pArray->ElementAt(i);
  517. filePath.MakeLower();
  518. m_vFileName.push_back(filePath);
  519. }
  520. LoadThumbImages();
  521. }
  522. void ShowPic3::OnBTNshow1()
  523. {
  524. ShowPhoto1();
  525. }
  526. void ShowPic3::OnBTNshow2()
  527. {
  528. ShowPhoto2();
  529. }
  530. void ShowPic3::OnBTNshow3()
  531. {
  532. ShowPhoto4();
  533. }
  534. void ShowPic3::OnBTNshow4()
  535. {
  536. ShowPhoto3();
  537. }
  538. void ShowPic3::OnBUTdelall() // 全部删除;
  539. {
  540. if (m_strOrderNumber == "")
  541. {
  542. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  543. }
  544. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  545. WriteLog(_T(" 客照管理中心:") + m_strOrderNumber + _T(":全部相片被删除"));
  546. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  547. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  548. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  549. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  550. OnBTNshow1();
  551. }
  552. void ShowPic3::OnBUTdel1() // 原片删除按钮;
  553. {
  554. if (m_strOrderNumber == "")
  555. {
  556. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  557. }
  558. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  559. WriteLog(_T(" 客照管理中心:") + m_strOrderNumber + _T(":原片被删除"));
  560. DeleteDirectory(g_path1 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单原片;
  561. OnBTNshow1();
  562. }
  563. void ShowPic3::OnBUTdel2() // 初修删除按钮;
  564. {
  565. if (m_strOrderNumber == "")
  566. {
  567. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  568. }
  569. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  570. WriteLog(_T(" 客照管理中心:") + m_strOrderNumber + _T(":初修片被删除"));
  571. DeleteDirectory(g_path2 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单初修;
  572. OnBTNshow2();
  573. }
  574. void ShowPic3::OnBUTdel3() // 精修删除按钮;
  575. {
  576. if (m_strOrderNumber == "")
  577. {
  578. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  579. }
  580. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  581. WriteLog(_T(" 客照管理中心:") + m_strOrderNumber + _T(":精修片被删除"));
  582. DeleteDirectory(g_path4 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单精修;
  583. OnBTNshow3();
  584. }
  585. void ShowPic3::OnBUTdel4() // 设计片删除按钮;
  586. {
  587. if (m_strOrderNumber == "")
  588. {
  589. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  590. }
  591. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  592. WriteLog(_T(" 客照管理中心:") + m_strOrderNumber + _T(":设计片被删除"));
  593. DeleteDirectory(g_path3 + "\\" + m_strOrderNumber + "\\"); // 递归删除订单设计;
  594. OnBTNshow4();
  595. }
  596. void ShowPic3::OnCbnSelchangeCombo1()
  597. {
  598. static int nIndex = 0;
  599. if (nIndex)
  600. m_List2.SetSel(nIndex, FALSE);
  601. int i = 0;
  602. int nSelCount = m_List2.GetSelCount();
  603. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  604. {
  605. int nSelItem;
  606. m_List2.GetSelItems(nSelCount, &nSelItem);
  607. m_List2.SetSel(nSelItem, FALSE);
  608. }
  609. int nPos = m_combobox.GetCurSel();
  610. CString strName;
  611. //m_combobox.GetWindowText(strName);
  612. m_combobox.GetLBText(nPos, strName);
  613. // printf("Jeff:****当前查找内容=%s\n\n",strName);
  614. int nSize = m_strArrayName.GetSize();
  615. for (i = 0; i < nSize; i++)
  616. {
  617. CString str = m_strArrayName.ElementAt(i);
  618. if (str.Find(strName) != -1)
  619. {
  620. // printf("Jeff:****当前查找内容=%s\n\n",str);
  621. //nIndex = m_List2.SelectString(-1,str);
  622. nIndex = i;
  623. if (nIndex == LB_ERR)
  624. {
  625. break;
  626. }
  627. m_List2.SetSel(nIndex, TRUE);
  628. PostMessage(OWNER_MSG_SHOWPHOTO, nIndex);
  629. break;
  630. }
  631. }
  632. }
  633. void ShowPic3::OnBnClickedNextone()
  634. {
  635. static int nIndex = 0;
  636. static CString strOld = "";
  637. m_List2.SetSel(nIndex - 1, FALSE);
  638. int i = 0;
  639. int nSelCount = m_List2.GetSelCount();
  640. for (i = 0; i < nSelCount; i++)//去除还处于选择状态的项;
  641. {
  642. int nSelItem;
  643. m_List2.GetSelItems(nSelCount, &nSelItem);
  644. m_List2.SetSel(nSelItem, FALSE);
  645. }
  646. CString strFind = "";
  647. m_combobox.GetWindowText(strFind);
  648. if (strOld != strFind)
  649. {
  650. strOld = strFind;
  651. nIndex = 0;
  652. }
  653. // printf("Jeff:当前查找内容=%s\n\n",strFind);
  654. CString str;
  655. BOOL bFind = FALSE;
  656. int nSize = m_strArrayName.GetSize();
  657. for (i = nIndex; i < nSize; i++)
  658. {
  659. str = m_strArrayName.ElementAt(i);
  660. // printf("Jeff:匹配内容=%s\n\n",str);
  661. if (str.Find(strFind) != -1)
  662. {
  663. nIndex = i;
  664. // printf("Jeff:nIndex=%d,找到内容=%s\n\n",i,str);
  665. bFind = TRUE;
  666. break;
  667. }
  668. }
  669. if (bFind == FALSE)
  670. {
  671. nIndex = 0;
  672. AfxMessageBox("未找到查找匹配的内容,将再次从头开始查找");
  673. }
  674. else
  675. {
  676. m_List2.SetSel(nIndex++, TRUE);
  677. PostMessage(OWNER_MSG_SHOWPHOTO, -1);
  678. }
  679. }
  680. void ShowPic3::ShowPhoto2Found(WPARAM wParam, LPARAM lParam)
  681. {
  682. UpdateData();
  683. int nPos = m_List2.GetCurSel();
  684. if (wParam != -1)
  685. nPos = wParam;
  686. if (nPos == -1) return;
  687. CString str;
  688. m_List2.GetText(nPos, str);
  689. nPos = str.Find("\r\n");
  690. if (nPos == -1)return;;
  691. m_strOrderNumber = str.Left(nPos);
  692. // printf("Jeff:欲显示的订单号=%s\n\n",m_strOrderNumber);
  693. ShowPhoto1();
  694. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  695. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  696. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  697. }