ShowPic3.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. // ShowPic3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "dbserver.h"
  5. #include "ShowPic3.h"
  6. #include "./helper/ffsco.h"
  7. #include "DelPhotoSet.h"
  8. #include <process.h>
  9. #include "Lzari.h"
  10. #include "mysqldata.h"
  11. #define THUMBNAIL_WIDTH 100
  12. #define THUMBNAIL_HEIGHT 90
  13. #include "ConnectThread.h"
  14. #include "ShowPhoto.h"
  15. using namespace helper_coffs;
  16. /////////////////////////////////////////////////////////////////////////////
  17. // ShowPic3 dialog IDC_BU IDC_COMBO2
  18. ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/): CDialog(ShowPic3::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(ShowPic3)
  21. m_check1 = 1;
  22. //}}AFX_DATA_INIT
  23. m_bTerminate = false;
  24. m_bRunning = false;
  25. m_hThread = NULL;
  26. }
  27. void ShowPic3::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(ShowPic3)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List2);
  33. DDX_Control(pDX, IDC_LIST1, m_List1);
  34. DDX_Check(pDX, IDC_CHECK1, m_check1);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
  38. //{{AFX_MSG_MAP(ShowPic3)
  39. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  40. ON_WM_DESTROY()
  41. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  42. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  43. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  44. ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
  45. ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
  46. ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
  47. ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
  48. ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
  49. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  50. ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
  51. ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
  52. ON_WM_CTLCOLOR()
  53. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // ShowPic3 message handlers
  58. extern int FindArray(CStringArray *pArray, CString Str);
  59. extern void GetPathFromNetShareName(CString name, CString &sRet);
  60. BOOL ShowPic3::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. CString str = "\r\n 1. 备份硬盘要与原保存硬盘要为2块独立硬盘(保存在同一块硬盘起不到保护作用)。\r\n\
  64. 2. 备份硬盘满后可以更换一块新的备份硬盘(如需帮助,请与利亚方舟技术联系)\r\n\
  65. 3. 备份硬盘满后可以按文件夹修改日期从前往后的顺序刻进光盘后删除\r\n\
  66. 4. 如不需要保存备份,可以在管理备份照片中手工删除备份";
  67. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  68. m_combo1.AddString("全部");
  69. m_combo1.AddString("取完件1个月");
  70. m_combo1.AddString("取完件2个月");
  71. m_combo1.AddString("取完件3个月");
  72. m_combo1.AddString("取完件6个月");
  73. m_combo1.AddString("取完件9个月");
  74. m_combo1.AddString("取完件12个月");
  75. m_combo1.AddString("取完件18个月");
  76. m_combo1.AddString("取完件24个月");
  77. m_combo1.AddString("取完件36个月");
  78. m_combo1.SetCurSel(0);
  79. CRect rc, rc2;
  80. GetWindowRect(rc2);
  81. DEVMODE g_dm;
  82. g_dm.dmSize = sizeof(DEVMODE);
  83. EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &g_dm);
  84. int wid = g_dm.dmPelsWidth * 3 / 4;
  85. int hei = g_dm.dmPelsHeight * 3 / 4;
  86. ::MoveWindow(m_hWnd, 0, 0, wid, hei, TRUE);
  87. CenterWindow();
  88. GetClientRect(rc);
  89. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
  90. ScreenToClient(rc2);
  91. rc2.left = 0;
  92. rc2.right = rc.right;
  93. GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
  94. GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
  95. m_List2.GetWindowRect(rc2);
  96. ScreenToClient(rc2);
  97. int dt = rc2.left;
  98. rc2.bottom = rc.bottom - dt;
  99. m_List2.MoveWindow(rc2);
  100. m_List1.GetWindowRect(rc2);
  101. ScreenToClient(rc2);
  102. rc2.bottom = rc.bottom - dt;
  103. rc2.right = rc.right - dt;
  104. m_List1.MoveWindow(rc2);
  105. {
  106. m_List1array.RemoveAll();
  107. CArray<CDatabase*, CDatabase*>dbarraytemp;
  108. dbarraytemp.Copy(g_dbHistoryArray);
  109. dbarraytemp.InsertAt(0, &g_db);
  110. for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
  111. {
  112. CString filter = "status3='OK'";
  113. CDatabase *m_pConndb = dbarraytemp.ElementAt(a);
  114. CRecordset myset(m_pConndb);
  115. CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
  116. myset.Open(CRecordset::forwardOnly, sql);
  117. myset.GetFieldValue("cot", sql);
  118. myset.Close();
  119. int count = atol(sql);
  120. sql.Format("%d", a - 1);
  121. // if(a==0)sql="-1";
  122. int oldsize = m_List1array.GetSize();
  123. m_List1array.SetSize(oldsize + count, 1);
  124. CRstDindanForm rsSt; rsSt.m_pDatabase = m_pConndb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  125. rsSt.m_strSort = "id";
  126. rsSt.Open();
  127. int ii = 0;
  128. while (!rsSt.IsEOF())
  129. {
  130. m_List1array.ElementAt(oldsize + ii).RemoveAll();
  131. m_List1array.ElementAt(oldsize + ii).Add(rsSt.id);
  132. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name1);
  133. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name2);
  134. /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.txtype) ;
  135. m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount) ;
  136. m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize) ;
  137. m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount2) ;
  138. m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize2) ;
  139. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status) ;
  140. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status4) ;
  141. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status2) ;
  142. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status6) ;
  143. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status5) ;
  144. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status8) ;
  145. m_List1array.ElementAt (oldsize+ii).Add(rsSt.status3) ;
  146. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time1) ;
  147. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time2) ;
  148. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time4) ;
  149. m_List1array.ElementAt (oldsize+ii).Add(rsSt.time6) ;*/
  150. m_List1array.ElementAt(oldsize + ii).Add(rsSt.time5);
  151. /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.ren) ;
  152. m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxiname) ;
  153. m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxijiage) ;
  154. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter1) ;
  155. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter2) ;
  156. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter5) ;
  157. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter3) ;
  158. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter7) ;
  159. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter4) ;
  160. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter8) ;
  161. m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter6) ;
  162. m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone1) ;
  163. m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone2) ;
  164. m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin1) ;
  165. m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin2) ;
  166. m_List1array.ElementAt (oldsize+ii).Add(sql) ;*/
  167. ii++;
  168. rsSt.MoveNext(); if (m_List1array.GetSize() <= (oldsize + ii))break;
  169. }
  170. rsSt.Close(); m_List1array.SetSize(oldsize + ii, 1);
  171. }
  172. }
  173. {
  174. CRstversion rsSt; rsSt.m_pDatabase = &g_db;
  175. rsSt.Open();
  176. if (!rsSt.IsEOF())
  177. {
  178. g_path1 = rsSt.m_bakserver1;
  179. g_path2 = rsSt.m_bakserver2;
  180. g_path4 = rsSt.m_bakserver3;
  181. g_path3 = rsSt.m_bakserver4;
  182. }
  183. rsSt.Close();
  184. }
  185. #ifdef CHILD_VERSION
  186. if(g_path1.Find(":")==-1&& g_path1!="")
  187. g_path1="\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$";
  188. if(1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
  189. GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
  190. if(g_path2.Find(":")==-1&& g_path2!="")
  191. g_path2="\\\\"+g_path2+"\\修好的片备份(儿童管理软件)$";
  192. if(1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
  193. GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
  194. if(g_path4.Find(":")==-1&& g_path4!="")
  195. g_path4="\\\\"+g_path4+"\\精修好的片备份(儿童管理软件)$";
  196. if(1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
  197. GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
  198. if(g_path3.Find(":")==-1&& g_path3!="")
  199. g_path3="\\\\"+g_path3+"\\设计好的片备份(儿童管理软件)$";
  200. if(1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
  201. GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
  202. #else
  203. if (g_path1.Find(":") == -1 && g_path1 != "")
  204. g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
  205. if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
  206. GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
  207. if (g_path2.Find(":") == -1 && g_path2 != "")
  208. g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
  209. if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
  210. GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
  211. if (g_path4.Find(":") == -1 && g_path4 != "")
  212. g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
  213. if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
  214. GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
  215. if (g_path3.Find(":") == -1 && g_path3 != "")
  216. g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
  217. if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
  218. GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
  219. #endif
  220. LoadPhotos();
  221. for (int i = 0; i < m_List1array.GetSize(); i++)
  222. {
  223. str = m_List1array.ElementAt(i).ElementAt(0);
  224. if (FindArray(&m_dirarray1, str) == -1)
  225. {
  226. if (FindArray(&m_dirarray2, str) == -1)
  227. {
  228. if (FindArray(&m_dirarray3, str) == -1)
  229. {
  230. if (FindArray(&m_dirarray4, str) == -1)
  231. {
  232. continue;
  233. }
  234. }
  235. }
  236. }
  237. str += "\r\n";
  238. str += m_List1array.ElementAt(i).ElementAt(1);
  239. str += m_List1array.ElementAt(i).ElementAt(2);
  240. if (m_List2.GetCount() % 2)
  241. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  242. else
  243. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  244. m_idarray.Add(str);
  245. m_datearray.Add(m_List1array.ElementAt(i).ElementAt(3));
  246. }
  247. m_List2.Invalidate();
  248. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  249. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  250. return TRUE; // return TRUE unless you set the focus to a control
  251. // EXCEPTION: OCX Property Pages should return FALSE
  252. }
  253. extern void LoadImageFromFile(Image **img, CString path);
  254. extern void LoadImageFromBuf(Image **img, CString path);
  255. int GetOrientation(Image *image)
  256. {
  257. try
  258. {
  259. if (image)
  260. {
  261. UINT totalBufferSize;
  262. UINT numProperties;
  263. image->GetPropertySize(&totalBufferSize, &numProperties);
  264. // Allocate the buffer that will receive the property items.
  265. PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
  266. // Fill the buffer.
  267. image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  268. // Print the id data member of each property item.
  269. for (UINT j = 0; j < numProperties; ++j)
  270. {
  271. if (PropertyTagOrientation == pAllItems[j].id)
  272. {
  273. short* ptrLong = (short*)(pAllItems[j].value);
  274. int ret = (int)*ptrLong;
  275. free(pAllItems);
  276. return ret;
  277. }
  278. }
  279. free(pAllItems);
  280. }
  281. }
  282. catch (...)
  283. {
  284. }
  285. return 1;
  286. }
  287. unsigned __stdcall LoadThumbNail20(LPVOID lpParam)
  288. {
  289. try
  290. {
  291. ShowPic3 *pDlg = (ShowPic3*)lpParam;
  292. CListCtrl *ListCtrl = &pDlg->m_List1;
  293. CImageList* pImgList = &pDlg->m_ImageListThumb;
  294. // reset our image list
  295. for (int i = 0; i < pImgList->GetImageCount(); i++)
  296. pImgList->Remove(i);
  297. // remove all items from list view
  298. ListCtrl->DeleteAllItems();
  299. pImgList->SetImageCount(pDlg->m_vFileName.size());
  300. TCHAR path[MAX_PATH];
  301. vector<CString>::iterator iter;
  302. // Set redraw to FALSE to avoid flickering during adding new items
  303. ListCtrl->SetRedraw(FALSE);
  304. int nIndex = 0;
  305. CString str, spath;
  306. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  307. {
  308. str = *iter;
  309. spath.Empty();
  310. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  311. {
  312. spath = str.Left(str.ReverseFind('\\') + 1);
  313. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  314. }
  315. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  316. str = spath + str.Left(str.GetLength() - 4);
  317. ListCtrl->InsertItem(nIndex, str, nIndex);
  318. }
  319. ListCtrl->SetRedraw(TRUE);
  320. ListCtrl->Invalidate();
  321. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  322. int XDest, YDest, nDestWidth, nDestHeight;
  323. nIndex = 0;
  324. SolidBrush whitebrush(Color(255, 255, 255, 255));
  325. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  326. {
  327. // Load Image File
  328. Image *image = NULL;
  329. Bitmap *pBmp = NULL;
  330. str = *iter;
  331. spath = str.Left(str.ReverseFind('\\') + 1);
  332. spath += "s";
  333. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  334. if (::CheckFileExist(spath))
  335. ::LoadImageFromBuf(&image, spath);
  336. else
  337. {
  338. str.MakeLower();
  339. if (str.Right(3) != "jpg")continue;
  340. ::LoadImageFromBuf(&image, str);
  341. }
  342. if (image == NULL)continue;
  343. int orientation = GetOrientation(image);
  344. if (orientation == 8)
  345. image->RotateFlip(Rotate270FlipNone);
  346. else if (orientation == 6)
  347. image->RotateFlip(Rotate90FlipNone);
  348. if (image->GetWidth() == 0)
  349. continue;
  350. // Calculate Rect to fit to canvas
  351. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  352. if (fImgRatio > fRatio)
  353. {
  354. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  355. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  356. YDest = 0;
  357. nDestHeight = THUMBNAIL_HEIGHT;
  358. }
  359. else
  360. {
  361. XDest = 0;
  362. nDestWidth = THUMBNAIL_WIDTH;
  363. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  364. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  365. }
  366. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  367. Graphics graph2(pBmp);
  368. graph2.Clear(Color(255, 192, 192, 192));
  369. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  370. Graphics graph(pBmp);
  371. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  372. // Draw Image
  373. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  374. delete image;
  375. // Attach to Bitmap and Replace image in CImageList
  376. CBitmap bitmap;
  377. HBITMAP hbmp;
  378. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  379. bitmap.Attach(hbmp);
  380. pImgList->Replace(nIndex, &bitmap, NULL);
  381. delete pBmp;
  382. // Redraw only a current item for removing flickering and fast speed.
  383. ListCtrl->RedrawItems(nIndex, nIndex);
  384. // Release used DC and Object
  385. }
  386. ListCtrl->Invalidate();
  387. pDlg->m_bRunning = false;
  388. pDlg->m_bTerminate = false;
  389. _endthreadex(0);
  390. return 0;
  391. }
  392. catch (...)
  393. {
  394. }
  395. return 1;
  396. }
  397. void ShowPic3::LoadThumbImages()
  398. {
  399. TerminateThread();
  400. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail20, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  401. m_bRunning = true;
  402. }
  403. BOOL ShowPic3::TerminateThread()
  404. {
  405. if (!m_bRunning)
  406. return TRUE;
  407. m_bTerminate = true;
  408. for (;;)
  409. {
  410. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  411. break;
  412. MSG msg;
  413. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  414. {
  415. if (!AfxGetApp()->PumpMessage())
  416. break;
  417. }
  418. }
  419. ::CloseHandle(m_hThread);
  420. return TRUE;
  421. }
  422. extern void LoadImageFromBuf(Image **img, CString path);
  423. void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  424. {
  425. // TODO: Add your control notification handler code here
  426. POSITION pos;
  427. pos = m_List1.GetFirstSelectedItemPosition();
  428. if (pos == NULL)
  429. {
  430. return;
  431. }
  432. int iItem = m_List1.GetNextSelectedItem(pos);
  433. Image *m_pImg = NULL;
  434. ::LoadImageFromBuf(&m_pImg, m_patharray1.ElementAt(iItem));
  435. ShowPhoto dlg;
  436. dlg.m_pImg = m_pImg;
  437. dlg.DoModal();
  438. delete m_pImg;
  439. /* ShowPic22 dlg;
  440. dlg.m_pos=iItem;
  441. dlg.m_pPathArray=&m_patharray1;
  442. dlg.DoModal ();*/
  443. *pResult = 0;
  444. }
  445. void ShowPic3::OnDestroy()
  446. {
  447. TerminateThread();
  448. CDialog::OnDestroy();
  449. // TODO: Add your message handler code here
  450. }
  451. extern BOOL myisdigit(CString str);
  452. void ShowPic3::LoadPhotos()
  453. {
  454. if (g_path1 == "")return;
  455. CString str;
  456. if (1)
  457. {
  458. ffsco o;
  459. o.dirs(0);
  460. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  461. ffsco::typeT coo;
  462. ffsco::typeT::iterator it;
  463. coo = o.co_dir();
  464. for (it = coo.begin(); coo.end() != it; it++)
  465. {
  466. str = (*it).c_str();
  467. if (str == g_path1 + "\\")continue;
  468. str.TrimRight("\\");
  469. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  470. m_dirarray1.Add(str);
  471. }
  472. }
  473. }
  474. void ShowPic3::OnBUTdel()
  475. {
  476. DelPhotoSet dlg;
  477. dlg.DoModal();
  478. }
  479. void ShowPic3::OnSelchangeList2()
  480. {
  481. // TODO: Add your control notification handler code here
  482. UpdateData();
  483. int pos = m_List2.GetCurSel();
  484. if (pos == -1)return;
  485. CString str;
  486. m_List2.GetText(pos, str);
  487. pos = str.Find("\r\n");
  488. if (pos == -1)return;;
  489. m_id = str.Left(pos);
  490. ShowPhoto1();
  491. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  492. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  493. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  494. }
  495. void ShowPic3::ShowPhoto1()
  496. {
  497. if (m_id == "")
  498. {
  499. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  500. }
  501. CString str;
  502. m_path = g_path1 + "\\" + m_id + "\\";
  503. m_patharray1.RemoveAll();
  504. if (1)
  505. {
  506. ffsco o;
  507. o.dirs(1);
  508. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  509. ffsco::typeT coo;
  510. ffsco::typeT::iterator it;
  511. coo = o.co_file();
  512. for (it = coo.begin();
  513. coo.end() != it;
  514. it++)
  515. {
  516. str = (*it).c_str();
  517. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  518. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  519. str.MakeLower();
  520. m_patharray1.Add(str);
  521. }
  522. }
  523. if (m_bRunning)return;
  524. CStringArray *pArray = &m_patharray1;
  525. m_vFileName.clear();
  526. for (int i = 0; i < pArray->GetSize(); i++)
  527. {
  528. CString filePath = pArray->ElementAt(i);
  529. filePath.MakeLower();
  530. m_vFileName.push_back(filePath);
  531. }
  532. LoadThumbImages();
  533. }
  534. void ShowPic3::ShowPhoto2()
  535. {
  536. if (m_id == "")
  537. {
  538. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  539. }
  540. CString str;
  541. m_path = g_path2 + "\\" + m_id + "\\";
  542. m_patharray1.RemoveAll();
  543. if (1)
  544. {
  545. ffsco o;
  546. o.dirs(1);
  547. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  548. ffsco::typeT coo;
  549. ffsco::typeT::iterator it;
  550. coo = o.co_file();
  551. for (it = coo.begin();
  552. coo.end() != it;
  553. it++)
  554. {
  555. str = (*it).c_str();
  556. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  557. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  558. str.MakeLower();
  559. m_patharray1.Add(str);
  560. }
  561. }
  562. if (m_bRunning)return;
  563. CStringArray *pArray = &m_patharray1;
  564. m_vFileName.clear();
  565. for (int i = 0; i < pArray->GetSize(); i++)
  566. {
  567. CString filePath = pArray->ElementAt(i);
  568. filePath.MakeLower();
  569. m_vFileName.push_back(filePath);
  570. }
  571. LoadThumbImages();
  572. }
  573. void ShowPic3::ShowPhoto3()
  574. {
  575. if (m_id == "")
  576. {
  577. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  578. }
  579. CString str;
  580. m_path = g_path3 + "\\" + m_id + "\\";
  581. m_patharray1.RemoveAll();
  582. if (1)
  583. {
  584. ffsco o;
  585. o.dirs(1);
  586. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  587. ffsco::typeT coo;
  588. ffsco::typeT::iterator it;
  589. coo = o.co_file();
  590. for (it = coo.begin();
  591. coo.end() != it;
  592. it++)
  593. {
  594. str = (*it).c_str();
  595. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  596. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  597. str.MakeLower();
  598. m_patharray1.Add(str);
  599. }
  600. }
  601. if (m_bRunning)return;
  602. CStringArray *pArray = &m_patharray1;
  603. m_vFileName.clear();
  604. for (int i = 0; i < pArray->GetSize(); i++)
  605. {
  606. CString filePath = pArray->ElementAt(i);
  607. filePath.MakeLower();
  608. m_vFileName.push_back(filePath);
  609. }
  610. LoadThumbImages();
  611. }
  612. void ShowPic3::ShowPhoto4()
  613. {
  614. if (m_id == "")
  615. {
  616. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  617. }
  618. CString str;
  619. m_path = g_path4 + "\\" + m_id + "\\";
  620. m_patharray1.RemoveAll();
  621. if (1)
  622. {
  623. ffsco o;
  624. o.dirs(1);
  625. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  626. ffsco::typeT coo;
  627. ffsco::typeT::iterator it;
  628. coo = o.co_file();
  629. for (it = coo.begin();
  630. coo.end() != it;
  631. it++)
  632. {
  633. str = (*it).c_str();
  634. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  635. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  636. str.MakeLower();
  637. m_patharray1.Add(str);
  638. }
  639. }
  640. if (m_bRunning)return;
  641. CStringArray *pArray = &m_patharray1;
  642. m_vFileName.clear();
  643. for (int i = 0; i < pArray->GetSize(); i++)
  644. {
  645. CString filePath = pArray->ElementAt(i);
  646. filePath.MakeLower();
  647. m_vFileName.push_back(filePath);
  648. }
  649. LoadThumbImages();
  650. }
  651. void ShowPic3::OnBTNshow1()
  652. {
  653. // TODO: Add your control notification handler code here
  654. ShowPhoto1();
  655. }
  656. void ShowPic3::OnBTNshow2()
  657. {
  658. // TODO: Add your control notification handler code here
  659. ShowPhoto2();
  660. }
  661. void ShowPic3::OnBTNshow3()
  662. {
  663. // TODO: Add your control notification handler code here
  664. ShowPhoto4();
  665. }
  666. void ShowPic3::OnBTNshow4()
  667. {
  668. // TODO: Add your control notification handler code here
  669. ShowPhoto3();
  670. }
  671. void ShowPic3::OnBUTdelall()
  672. {
  673. // TODO: Add your control notification handler code here
  674. if (m_id == "")
  675. {
  676. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  677. }
  678. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  679. DeleteDirectory(g_path1 + "\\" + m_id + "\\");
  680. DeleteDirectory(g_path2 + "\\" + m_id + "\\");
  681. DeleteDirectory(g_path3 + "\\" + m_id + "\\");
  682. DeleteDirectory(g_path4 + "\\" + m_id + "\\");
  683. OnBTNshow1();
  684. }
  685. void ShowPic3::OnBUTdel1()
  686. {
  687. // TODO: Add your control notification handler code here
  688. if (m_id == "")
  689. {
  690. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  691. }
  692. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  693. DeleteDirectory(g_path1 + "\\" + m_id + "\\"); OnBTNshow1();
  694. }
  695. void ShowPic3::OnBUTdel2()
  696. {
  697. // TODO: Add your control notification handler code here
  698. if (m_id == "")
  699. {
  700. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  701. }
  702. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  703. DeleteDirectory(g_path2 + "\\" + m_id + "\\"); OnBTNshow2();
  704. }
  705. void ShowPic3::OnBUTdel3()
  706. {
  707. // TODO: Add your control notification handler code here
  708. if (m_id == "")
  709. {
  710. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  711. }
  712. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  713. DeleteDirectory(g_path4 + "\\" + m_id + "\\"); OnBTNshow3();
  714. }
  715. void ShowPic3::OnBUTdel4()
  716. {
  717. // TODO: Add your control notification handler code here
  718. if (m_id == "")
  719. {
  720. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  721. }
  722. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  723. DeleteDirectory(g_path3 + "\\" + m_id + "\\"); OnBTNshow4();
  724. }
  725. HBRUSH ShowPic3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  726. {
  727. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  728. // TODO: Change any attributes of the DC here
  729. if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() == IDC_STATIC1)
  730. {
  731. pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
  732. return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
  733. }
  734. // TODO: Return a different brush if the default is not desired
  735. return hbr;
  736. }
  737. void ShowPic3::OnSelchangeCombo1()
  738. {
  739. // TODO: Add your control notification handler code here
  740. int pos = m_combo1.GetCurSel();
  741. if (pos != -1)
  742. {
  743. CString str;
  744. m_combo1.GetLBText(pos, str);
  745. int days = -1;
  746. if (str == "全部")days = -1;
  747. else if (str == "取完件1个月")days = 31;
  748. else if (str == "取完件2个月")days = 31 + 30;
  749. else if (str == "取完件3个月")days = 31 * 2 + 30;
  750. else if (str == "取完件6个月")days = 31 * 3 + 30 * 3;
  751. else if (str == "取完件9个月")days = 31 * 5 + 30 * 4;
  752. else if (str == "取完件12个月")days = 365;
  753. else if (str == "取完件18个月")days = 365 + 31 * 3 + 30 * 3;
  754. else if (str == "取完件24个月")days = 365 * 2;
  755. else if (str == "取完件36个月")days = 365 * 3;
  756. m_List2.ResetContent();
  757. CString date;
  758. CTime today = CTime::GetCurrentTime();
  759. CTimeSpan dt;
  760. for (int i = 0; i < m_datearray.GetSize(); i++)
  761. {
  762. date = m_datearray.ElementAt(i);
  763. // MessageBox(date);
  764. CTime tm = GetTmFromStr(date);
  765. dt = today - tm;
  766. // str.Format("%d", dt.GetDays());
  767. // MessageBox(str);
  768. if (days != -1 && dt.GetDays() < days)continue;
  769. str = m_idarray.ElementAt(i);
  770. if (m_List2.GetCount() % 2)
  771. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  772. else
  773. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  774. }
  775. m_List2.Invalidate();
  776. }
  777. }