// ImportPhoto.cpp : implementation file // #include "stdafx.h" #include "LYFZIPManage.h" #include "ImportPhoto.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // ImportPhoto dialog ImportPhoto::ImportPhoto(CWnd* pParent /*=NULL*/) : CDialog(ImportPhoto::IDD, pParent) { //{{AFX_DATA_INIT(ImportPhoto) // NOTE: the ClassWizard will add member initialization here m_mode=0; //}}AFX_DATA_INIT m_pArray2=NULL; m_pDesArray=NULL; m_exitcode=0; m_bOverWrite=1; } void ImportPhoto::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(ImportPhoto) DDX_Control(pDX, IDC_PROGRESS1, m_progress); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(ImportPhoto, CDialog) //{{AFX_MSG_MAP(ImportPhoto) ON_WM_CLOSE() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // ImportPhoto message handlers void ImportPhoto::OnOK() { // TODO: Add extra validation here } void ImportPhoto::OnCancel() { // TODO: Add extra cleanup here } int GetFileNo(CString dir) { CString path; int begin=1; path.Format ("%s%03d.jpg", dir, begin); while(::PathFileExists (path)) { begin++; path.Format ("%s%03d.jpg", dir, begin); } return begin; } UINT ImportPhotoThread( LPVOID lpParameter ) { ImportPhoto *pThis=(ImportPhoto*)lpParameter; pThis->m_progress .SetRange (0, pThis->m_pArray->GetSize ()); CString filename, filename2; if(pThis->m_pArray2) { for(int i=0; im_pArray->GetSize (); i++) { filename=pThis->m_pArray->ElementAt (i); ::CopyFile (filename, pThis->m_savepath+pThis->m_pArray2->ElementAt (i)+".jpg", pThis->m_bOverWrite==0); pThis->m_progress.SetPos (i+1); } } else if(pThis->m_pDesArray) { for(int i=0; im_pArray->GetSize (); i++) { filename=pThis->m_pArray->ElementAt (i); if(pThis->m_mode==2) { filename2.Format("%s%03d.jpg",pThis->m_savepath, GetFileNo(pThis->m_savepath) ); ::CopyFile(filename, filename2, pThis->m_bOverWrite==0); } else ::CopyFile (filename, pThis->m_pDesArray->ElementAt (i), pThis->m_bOverWrite==0); pThis->m_progress.SetPos (i+1); } } else { for(int i=0; im_pArray->GetSize (); i++) { filename=pThis->m_pArray->ElementAt (i); if(pThis->m_mode==2) { filename2.Format("%s%03d.jpg",pThis->m_savepath, GetFileNo(pThis->m_savepath) ); ::CopyFile(filename, filename2, pThis->m_bOverWrite==0); } else ::CopyFile (filename, pThis->m_savepath+filename.Right (filename.GetLength ()-filename.ReverseFind ('\\')-1), pThis->m_bOverWrite==0); pThis->m_progress.SetPos (i+1); } } pThis->PostMessage (WM_CLOSE, 0, 0); return 1; } BOOL ImportPhoto::OnInitDialog() { CDialog::OnInitDialog(); if(m_mode==1) SetDlgItemText(IDC_STATIC1, "正在导出客照, 请稍候..."); // TODO: Add extra initialization here AfxBeginThread((AFX_THREADPROC)ImportPhotoThread,(LPVOID)this ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void ImportPhoto::OnClose() { // TODO: Add your message handler code here and/or call default CDialog::OnOK(); }