123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946 |
- // ShowPic3.cpp : implementation file
- //
- #include "stdafx.h"
- #include "dbserver.h"
- #include "ShowPic3.h"
- #include "./helper/ffsco.h"
- #include "DelPhotoSet.h"
- #include <process.h>
- #include "Lzari.h"
- #include "mysqldata.h"
- #define THUMBNAIL_WIDTH 100
- #define THUMBNAIL_HEIGHT 90
- #include "ConnectThread.h"
- #include "ShowPhoto.h"
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic3 dialog IDC_BU IDC_COMBO2
- ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/)
- : CDialog(ShowPic3::IDD, pParent)
- {
- //{{AFX_DATA_INIT(ShowPic3)
- m_check1 = 1;
- //}}AFX_DATA_INIT
- m_bTerminate = false;
- m_bRunning = false;
- m_hThread = NULL;
- }
- void ShowPic3::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(ShowPic3)
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_Control(pDX, IDC_LIST2, m_List2);
- DDX_Control(pDX, IDC_LIST1, m_List1);
- DDX_Check(pDX, IDC_CHECK1, m_check1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
- //{{AFX_MSG_MAP(ShowPic3)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
- ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
- ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
- ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
- ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
- ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
- ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
- ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
- ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
- ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
- ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
- ON_WM_CTLCOLOR()
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /*
- void DataToArray(CArray<CStringArray, CStringArray>*List1array, BYTE code, BYTE *g_pData, int g_nLeng)
- {
- try
- {
- List1array->RemoveAll ();
- if(g_nLeng==0)return;
- if(code)
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData,g_nLeng,lpszOut,nOutSize);
- CMemFile memfile;
- memfile.Attach (lpszOut,nOutSize);
- Lzari.Release();
- CArchive ar(&memfile, CArchive::load);
- List1array->SetSize(g_sendhead.count[0]);
- for(int ii=0; ii<List1array->GetSize (); ii++)
- {
- List1array->ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- memfile.Detach ();
- }
- else
- {
- CMemFile memfile;
- memfile.Attach (g_pData,g_nLeng);
- CArchive ar(&memfile, CArchive::load);
- List1array->SetSize(g_sendhead.count[0]);
- for(int ii=0; ii<List1array->GetSize (); ii++)
- {
- List1array->ElementAt (ii).Serialize (ar);
- }
- ar.Close();
- memfile.Detach ();
- }
- }
- catch(...)
- {
- }
- }*/
- /////////////////////////////////////////////////////////////////////////////
- // ShowPic3 message handlers
- extern int FindArray(CStringArray *pArray, CString Str);
- extern void GetPathFromNetShareName(CString name, CString &sRet);
- BOOL ShowPic3::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CString str = "\r\n 1. 备份硬盘要与原保存硬盘要为2块独立硬盘(保存在同一块硬盘起不到保护作用)。\r\n\
- 2. 备份硬盘满后可以更换一块新的备份硬盘(如需帮助,请与利亚方舟技术联系)\r\n\
- 3. 备份硬盘满后可以按文件夹修改日期从前往后的顺序刻进光盘后删除\r\n\
- 4. 如不需要保存备份,可以在管理备份照片中手工删除备份";
- GetDlgItem(IDC_STATIC1)->SetWindowText(str);
- m_combo1.AddString("全部");
- m_combo1.AddString("取完件1个月");
- m_combo1.AddString("取完件2个月");
- m_combo1.AddString("取完件3个月");
- m_combo1.AddString("取完件6个月");
- m_combo1.AddString("取完件9个月");
- m_combo1.AddString("取完件12个月");
- m_combo1.AddString("取完件18个月");
- m_combo1.AddString("取完件24个月");
- m_combo1.AddString("取完件36个月");
- m_combo1.SetCurSel(0);
- CRect rc, rc2;
- GetWindowRect(rc2);
- DEVMODE g_dm;
- g_dm.dmSize = sizeof(DEVMODE);
- EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &g_dm);
- int wid = g_dm.dmPelsWidth * 3 / 4;
- int hei = g_dm.dmPelsHeight * 3 / 4;
- ::MoveWindow(m_hWnd, 0, 0, wid, hei, TRUE);
- CenterWindow();
- GetClientRect(rc);
- GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.left = 0;
- rc2.right = rc.right;
- GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
- GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
- m_List2.GetWindowRect(rc2);
- ScreenToClient(rc2);
- int dt = rc2.left;
- rc2.bottom = rc.bottom - dt;
- m_List2.MoveWindow(rc2);
- m_List1.GetWindowRect(rc2);
- ScreenToClient(rc2);
- rc2.bottom = rc.bottom - dt;
- rc2.right = rc.right - dt;
- m_List1.MoveWindow(rc2);
- /* CConnectSocket consock;
- consock.m_pConndb =&g_db;
- BYTE code=217;
- DWORD length,arraysize;
- BYTE *pReturn=NULL;
- consock.GetDataFromCode(code, &pReturn, length, arraysize, "");
- DataToArray(&m_List1array, code, pReturn, length);delete []pReturn;*/
- {
- m_List1array.RemoveAll();
- CArray<CDatabase*, CDatabase*>dbarraytemp;
- dbarraytemp.Copy(g_dbHistoryArray);
- dbarraytemp.InsertAt(0, &g_db);
- for (int a = dbarraytemp.GetSize() - 1; a >= 0; a--)
- {
- CString filter = "status3='OK'";
- CDatabase *m_pConndb = dbarraytemp.ElementAt(a);
- CRecordset myset(m_pConndb);
- CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
- myset.Open(CRecordset::forwardOnly, sql);
- myset.GetFieldValue("cot", sql);
- myset.Close();
- int count = atol(sql);
- sql.Format("%d", a - 1);
- // if(a==0)sql="-1";
- int oldsize = m_List1array.GetSize();
- m_List1array.SetSize(oldsize + count, 1);
- CRstDindanForm rsSt; rsSt.m_pDatabase = m_pConndb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
- rsSt.m_strSort = "id";
- rsSt.Open();
- int ii = 0;
- while (!rsSt.IsEOF())
- {
- m_List1array.ElementAt(oldsize + ii).RemoveAll();
- m_List1array.ElementAt(oldsize + ii).Add(rsSt.id);
- m_List1array.ElementAt(oldsize + ii).Add(rsSt.name1);
- m_List1array.ElementAt(oldsize + ii).Add(rsSt.name2);
- /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.txtype) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.discount2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.authorize2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status4) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status6) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status5) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status8) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.status3) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.time1) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.time2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.time4) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.time6) ;*/
- m_List1array.ElementAt(oldsize + ii).Add(rsSt.time5);
- /* m_List1array.ElementAt (oldsize+ii).Add(rsSt.ren) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxiname) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.taoxijiage) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter1) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter5) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter3) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter7) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter4) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter8) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.waiter6) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone1) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.phone2) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin1) ;
- m_List1array.ElementAt (oldsize+ii).Add(rsSt.pinyin2) ;
- m_List1array.ElementAt (oldsize+ii).Add(sql) ;*/
- ii++;
- rsSt.MoveNext(); if (m_List1array.GetSize() <= (oldsize + ii))break;
- }
- rsSt.Close(); m_List1array.SetSize(oldsize + ii, 1);
- }
- }
- {
- CRstversion rsSt; rsSt.m_pDatabase = &g_db;
- rsSt.Open();
- if (!rsSt.IsEOF())
- {
- g_path1 = rsSt.m_bakserver1;
- g_path2 = rsSt.m_bakserver2;
- g_path4 = rsSt.m_bakserver3;
- g_path3 = rsSt.m_bakserver4;
- }
- rsSt.Close();
- }
- #ifdef CHILD_VERSION
- if(g_path1.Find(":")==-1&& g_path1!="")
- g_path1="\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$";
- if(1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
- GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
- if(g_path2.Find(":")==-1&& g_path2!="")
- g_path2="\\\\"+g_path2+"\\修好的片备份(儿童管理软件)$";
- if(1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
- if(g_path4.Find(":")==-1&& g_path4!="")
- g_path4="\\\\"+g_path4+"\\精修好的片备份(儿童管理软件)$";
- if(1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
- if(g_path3.Find(":")==-1&& g_path3!="")
- g_path3="\\\\"+g_path3+"\\设计好的片备份(儿童管理软件)$";
- if(1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
- #else
- if (g_path1.Find(":") == -1 && g_path1 != "")
- g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
- GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
- if (g_path2.Find(":") == -1 && g_path2 != "")
- g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
- GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
- if (g_path4.Find(":") == -1 && g_path4 != "")
- g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
- GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
- if (g_path3.Find(":") == -1 && g_path3 != "")
- g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
- if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
- GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
- #endif
- LoadPhotos();
- for (int i = 0; i < m_List1array.GetSize(); i++)
- {
- str = m_List1array.ElementAt(i).ElementAt(0);
- if (FindArray(&m_dirarray1, str) == -1)
- {
- if (FindArray(&m_dirarray2, str) == -1)
- {
- if (FindArray(&m_dirarray3, str) == -1)
- {
- if (FindArray(&m_dirarray4, str) == -1)
- {
- continue;
- }
- }
- }
- }
- str += "\r\n";
- str += m_List1array.ElementAt(i).ElementAt(1);
- str += m_List1array.ElementAt(i).ElementAt(2);
- if (m_List2.GetCount() % 2)
- m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
- else
- m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
- m_idarray.Add(str);
- m_datearray.Add(m_List1array.ElementAt(i).ElementAt(3));
- }
- m_List2.Invalidate();
- m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
- m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- extern void LoadImageFromFile(Image **img, CString path);
- extern void LoadImageFromBuf(Image **img, CString path);
- int GetOrientation(Image *image)
- {
- try
- {
- if (image)
- {
- UINT totalBufferSize;
- UINT numProperties;
- image->GetPropertySize(&totalBufferSize, &numProperties);
- // Allocate the buffer that will receive the property items.
- PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
- // Fill the buffer.
- image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
- // Print the id data member of each property item.
- for (UINT j = 0; j < numProperties; ++j)
- {
- if (PropertyTagOrientation == pAllItems[j].id)
- {
- short* ptrLong = (short*)(pAllItems[j].value);
- int ret = (int)*ptrLong;
- free(pAllItems);
- return ret;
- }
- }
- free(pAllItems);
- }
- }
- catch (...)
- {
- }
- return 1;
- }
- unsigned __stdcall LoadThumbNail20(LPVOID lpParam)
- {
- try
- {
- ShowPic3 *pDlg = (ShowPic3*)lpParam;
- CListCtrl *ListCtrl = &pDlg->m_List1;
- CImageList* pImgList = &pDlg->m_ImageListThumb;
- // reset our image list
- for (int i = 0; i < pImgList->GetImageCount(); i++)
- pImgList->Remove(i);
- // remove all items from list view
- ListCtrl->DeleteAllItems();
- pImgList->SetImageCount(pDlg->m_vFileName.size());
- TCHAR path[MAX_PATH];
- vector<CString>::iterator iter;
- // Set redraw to FALSE to avoid flickering during adding new items
- ListCtrl->SetRedraw(FALSE);
- int nIndex = 0;
- CString str, spath;
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- str = *iter;
- spath.Empty();
- if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
- {
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
- }
- str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- str = spath + str.Left(str.GetLength() - 4);
- ListCtrl->InsertItem(nIndex, str, nIndex);
- }
- ListCtrl->SetRedraw(TRUE);
- ListCtrl->Invalidate();
- const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
- int XDest, YDest, nDestWidth, nDestHeight;
- nIndex = 0;
- SolidBrush whitebrush(Color(255, 255, 255, 255));
- for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
- {
- // Load Image File
- Image *image = NULL;
- Bitmap *pBmp = NULL;
- str = *iter;
- spath = str.Left(str.ReverseFind('\\') + 1);
- spath += "s";
- spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- if (::CheckFileExist(spath))
- ::LoadImageFromBuf(&image, spath);
- else
- {
- str.MakeLower();
- if (str.Right(3) != "jpg")continue;
- ::LoadImageFromBuf(&image, str);
- }
- if (image == NULL)continue;
- int orientation = GetOrientation(image);
- if (orientation == 8)
- image->RotateFlip(Rotate270FlipNone);
- else if (orientation == 6)
- image->RotateFlip(Rotate90FlipNone);
- if (image->GetWidth() == 0)
- continue;
- // Calculate Rect to fit to canvas
- const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
- if (fImgRatio > fRatio)
- {
- nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
- XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
- YDest = 0;
- nDestHeight = THUMBNAIL_HEIGHT;
- }
- else
- {
- XDest = 0;
- nDestWidth = THUMBNAIL_WIDTH;
- nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
- YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
- }
- pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
- Graphics graph2(pBmp);
- graph2.Clear(Color(255, 192, 192, 192));
- graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
- Graphics graph(pBmp);
- Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
- // Draw Image
- graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
- delete image;
- // Attach to Bitmap and Replace image in CImageList
- CBitmap bitmap;
- HBITMAP hbmp;
- pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
- bitmap.Attach(hbmp);
- pImgList->Replace(nIndex, &bitmap, NULL);
- delete pBmp;
- // Redraw only a current item for removing flickering and fast speed.
- ListCtrl->RedrawItems(nIndex, nIndex);
- // Release used DC and Object
- }
- ListCtrl->Invalidate();
- pDlg->m_bRunning = false;
- pDlg->m_bTerminate = false;
- _endthreadex(0);
- return 0;
- }
- catch (...)
- {
- }
- }
- void ShowPic3::LoadThumbImages()
- {
- TerminateThread();
- m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail20, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
- m_bRunning = true;
- }
- BOOL ShowPic3::TerminateThread()
- {
- if (!m_bRunning)
- return TRUE;
- m_bTerminate = true;
- for (;;)
- {
- if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
- break;
- MSG msg;
- while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
- {
- if (!AfxGetApp()->PumpMessage())
- break;
- }
- }
- ::CloseHandle(m_hThread);
- return TRUE;
- }
- extern void LoadImageFromBuf(Image **img, CString path);
- void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos = m_List1.GetFirstSelectedItemPosition();
- if (pos == NULL)
- {
- return;
- }
- int iItem = m_List1.GetNextSelectedItem(pos);
- Image *m_pImg = NULL;
- ::LoadImageFromBuf(&m_pImg, m_patharray1.ElementAt(iItem));
- ShowPhoto dlg;
- dlg.m_pImg = m_pImg;
- dlg.DoModal();
- delete m_pImg;
- /* ShowPic22 dlg;
- dlg.m_pos=iItem;
- dlg.m_pPathArray=&m_patharray1;
- dlg.DoModal ();*/
- *pResult = 0;
- }
- void ShowPic3::OnDestroy()
- {
- TerminateThread();
- CDialog::OnDestroy();
- // TODO: Add your message handler code here
- }
- extern BOOL myisdigit(CString str);
- void ShowPic3::LoadPhotos()
- {
- if (g_path1 == "")return;
- CString str;
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(g_path1), LPCSTR("*.*"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_dir();
- for (it = coo.begin(); coo.end() != it; it++)
- {
- str = (*it).c_str();
- if (str == g_path1 + "\\")continue;
- str.TrimRight("\\");
- str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
- m_dirarray1.Add(str);
- }
- }
- }
- void ShowPic3::OnBUTdel()
- {
- DelPhotoSet dlg;
- dlg.DoModal();
- }
- void ShowPic3::OnSelchangeList2()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int pos = m_List2.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_List2.GetText(pos, str);
- pos = str.Find("\r\n");
- if (pos == -1)return;;
- m_id = str.Left(pos);
- ShowPhoto1();
- if (m_patharray1.GetSize() == 0)OnBTNshow2();
- if (m_patharray1.GetSize() == 0)OnBTNshow3();
- if (m_patharray1.GetSize() == 0)OnBTNshow4();
- }
- void ShowPic3::ShowPhoto1()
- {
- if (m_id == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path1 + "\\" + m_id + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();
- coo.end() != it;
- it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- m_patharray1.Add(str);
- }
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- }
- void ShowPic3::ShowPhoto2()
- {
- if (m_id == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path2 + "\\" + m_id + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();
- coo.end() != it;
- it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- m_patharray1.Add(str);
- }
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- }
- void ShowPic3::ShowPhoto3()
- {
- if (m_id == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path3 + "\\" + m_id + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();
- coo.end() != it;
- it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- m_patharray1.Add(str);
- }
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- }
- void ShowPic3::ShowPhoto4()
- {
- if (m_id == "")
- {
- AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
- }
- CString str;
- m_path = g_path4 + "\\" + m_id + "\\";
- m_patharray1.RemoveAll();
- if (1)
- {
- using namespace helper_coffs;
- ffsco o;
- o.dirs(1);
- o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();
- coo.end() != it;
- it++)
- {
- str = (*it).c_str();
- if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
- if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
- str.MakeLower();
- m_patharray1.Add(str);
- }
- }
- if (m_bRunning)return;
- CStringArray *pArray = &m_patharray1;
- m_vFileName.clear();
- for (int i = 0; i < pArray->GetSize(); i++)
- {
- CString filePath = pArray->ElementAt(i);
- filePath.MakeLower();
- m_vFileName.push_back(filePath);
- }
- LoadThumbImages();
- }
- void ShowPic3::OnBTNshow1()
- {
- // TODO: Add your control notification handler code here
- ShowPhoto1();
- }
- void ShowPic3::OnBTNshow2()
- {
- // TODO: Add your control notification handler code here
- ShowPhoto2();
- }
- void ShowPic3::OnBTNshow3()
- {
- // TODO: Add your control notification handler code here
- ShowPhoto4();
- }
- void ShowPic3::OnBTNshow4()
- {
- // TODO: Add your control notification handler code here
- ShowPhoto3();
- }
- void ShowPic3::OnBUTdelall()
- {
- // TODO: Add your control notification handler code here
- if (m_id == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- DeleteDirectory(g_path1 + "\\" + m_id + "\\");
- DeleteDirectory(g_path2 + "\\" + m_id + "\\");
- DeleteDirectory(g_path3 + "\\" + m_id + "\\");
- DeleteDirectory(g_path4 + "\\" + m_id + "\\");
- OnBTNshow1();
- }
- void ShowPic3::OnBUTdel1()
- {
- // TODO: Add your control notification handler code here
- if (m_id == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- DeleteDirectory(g_path1 + "\\" + m_id + "\\"); OnBTNshow1();
- }
- void ShowPic3::OnBUTdel2()
- {
- // TODO: Add your control notification handler code here
- if (m_id == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- DeleteDirectory(g_path2 + "\\" + m_id + "\\"); OnBTNshow2();
- }
- void ShowPic3::OnBUTdel3()
- {
- // TODO: Add your control notification handler code here
- if (m_id == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- DeleteDirectory(g_path4 + "\\" + m_id + "\\"); OnBTNshow3();
- }
- void ShowPic3::OnBUTdel4()
- {
- // TODO: Add your control notification handler code here
- if (m_id == "")
- {
- AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
- }
- if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
- DeleteDirectory(g_path3 + "\\" + m_id + "\\"); OnBTNshow4();
- }
- HBRUSH ShowPic3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: Change any attributes of the DC here
- if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() == IDC_STATIC1)
- {
- pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
- return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
- }
- // TODO: Return a different brush if the default is not desired
- return hbr;
- }
- void ShowPic3::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- int pos = m_combo1.GetCurSel();
- if (pos != -1)
- {
- CString str;
- m_combo1.GetLBText(pos, str);
- int days = -1;
- if (str == "全部")days = -1;
- else if (str == "取完件1个月")days = 31;
- else if (str == "取完件2个月")days = 31 + 30;
- else if (str == "取完件3个月")days = 31 * 2 + 30;
- else if (str == "取完件6个月")days = 31 * 3 + 30 * 3;
- else if (str == "取完件9个月")days = 31 * 5 + 30 * 4;
- else if (str == "取完件12个月")days = 365;
- else if (str == "取完件18个月")days = 365 + 31 * 3 + 30 * 3;
- else if (str == "取完件24个月")days = 365 * 2;
- else if (str == "取完件36个月")days = 365 * 3;
- m_List2.ResetContent();
- CString date;
- CTime today = CTime::GetCurrentTime();
- CTimeSpan dt;
- for (int i = 0; i < m_datearray.GetSize(); i++)
- {
- date = m_datearray.ElementAt(i);
- // MessageBox(date);
- CTime tm = GetTmFromStr(date);
- dt = today - tm;
- // str.Format("%d", dt.GetDays());
- // MessageBox(str);
- if (days != -1 && dt.GetDays() < days)continue;
- str = m_idarray.ElementAt(i);
- if (m_List2.GetCount() % 2)
- m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
- else
- m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
- }
- m_List2.Invalidate();
- }
- }
|