ShowPic3.cpp 18 KB

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