Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -rcdc76e1a95383dff63a5254aeb8d37035028512c -r926b1177cffa2face218fabb3d8af71910d1b8e5 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision cdc76e1a95383dff63a5254aeb8d37035028512c) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 926b1177cffa2face218fabb3d8af71910d1b8e5) @@ -27,7 +27,6 @@ #include "FilterDlg.h" #include "StringHelpers.h" #include "ch.h" -#include "../libicpf/file.h" #include "../libchcore/TTaskConfigBufferSizes.h" #ifdef _DEBUG @@ -43,15 +42,7 @@ CCustomCopyDlg::CCustomCopyDlg() : ictranslate::CLanguageDialog(CCustomCopyDlg::IDD) { - m_bOnlyCreate = FALSE; - m_bIgnoreFolders = FALSE; - m_bFilters = FALSE; - m_bAdvanced = FALSE; - m_bForceDirectories = FALSE; - GetConfig().ExtractSubConfig(BRANCH_TASK_SETTINGS, m_tTaskDefinition.GetConfiguration()); - - m_bActualisation = false; } CCustomCopyDlg::CCustomCopyDlg(const chcore::TTaskDefinition& rTaskDefinition) : @@ -78,7 +69,6 @@ //}}AFX_DATA_MAP } - BEGIN_MESSAGE_MAP(CCustomCopyDlg,ictranslate::CLanguageDialog) //{{AFX_MSG_MAP(CCustomCopyDlg) ON_BN_CLICKED(IDC_ADDDIR_BUTTON, OnAddDirectoryButton) @@ -99,6 +89,7 @@ ON_BN_CLICKED(IDC_IGNOREFOLDERS_CHECK, OnIgnorefoldersCheck) ON_BN_CLICKED(IDC_FORCEDIRECTORIES_CHECK, OnForcedirectoriesCheck) ON_BN_CLICKED(IDC_EXPORT_BUTTON, OnExportButtonClicked) + ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -150,6 +141,7 @@ AddResizableControl(IDOK, 1.0, 1.0, 0.0, 0.0); AddResizableControl(IDCANCEL, 1.0, 1.0, 0.0, 0.0); AddResizableControl(IDC_HELP_BUTTON, 1.0, 1.0, 0.0, 0.0); + AddResizableControl(IDC_EXPORT_BUTTON, 0.0, 1.0, 0.0, 0.0); InitializeResizableControls(); @@ -158,7 +150,7 @@ // paths' listbox - init images - system image list SHFILEINFO sfi; - HIMAGELIST hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + HIMAGELIST hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); m_ilImages.Attach(hImageList); @@ -170,8 +162,7 @@ rc.right-=GetSystemMetrics(SM_CXEDGE)*2; // some styles - m_ctlFiles.SetExtendedStyle(m_ctlFiles.GetExtendedStyle() | LVS_EX_FULLROWSELECT); - m_ctlFilters.SetExtendedStyle(m_ctlFiles.GetExtendedStyle() | LVS_EX_FULLROWSELECT); + m_ctlFilters.SetExtendedStyle(m_ctlFilters.GetExtendedStyle() | LVS_EX_FULLROWSELECT); // paths' listbox - add one column LVCOLUMN lvc; @@ -208,8 +199,7 @@ } // destination path - SetComboPath(m_tTaskDefinition.GetDestinationPath().ToString()); -// m_strDest=m_ccData.m_strDestPath; //** + m_ctlDstPath.SetPath(m_tTaskDefinition.GetDestinationPath().ToString()); // operation type m_ctlOperation.AddString(GetResManager().LoadString(IDS_CCDCOPY_STRING)); @@ -231,7 +221,7 @@ // list width m_ctlFilters.GetWindowRect(&rc); - rc.right-=GetSystemMetrics(SM_CXEDGE)*2; + rc.right -= GetSystemMetrics(SM_CXEDGE)*2; // filter - some columns in a header lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; @@ -299,16 +289,8 @@ UpdateData(TRUE); // count the width of a list - CRect rc; - m_ctlFiles.GetWindowRect(&rc); - rc.right-=GetSystemMetrics(SM_CXEDGE)*2; + UpdateFilesListCtrlHeaderWidth(); - // change the width of a column - LVCOLUMN lvc; - lvc.mask=LVCF_WIDTH; - lvc.cx=rc.Width(); - m_ctlFiles.SetColumn(0, &lvc); - // operation int iPos=m_ctlOperation.GetCurSel(); m_ctlOperation.ResetContent(); @@ -331,6 +313,11 @@ // filter section (filter, size, date, attributes) while(m_ctlFilters.DeleteColumn(0)); // delete all columns + CRect rc; + m_ctlFilters.GetWindowRect(&rc); + rc.right -= GetSystemMetrics(SM_CXEDGE) * 2; + + LVCOLUMN lvc; lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; lvc.fmt=LVCFMT_LEFT; @@ -452,8 +439,7 @@ CString strPath; if (BrowseForFolder(GetResManager().LoadString(IDS_DSTFOLDERBROWSE_STRING), &strPath)) { - SetComboPath(strPath); -// m_strDest=strPath; //** + m_ctlDstPath.SetPath(strPath); } } @@ -484,31 +470,30 @@ m_ctlBufferSizes.ResetContent(); // fill the list - TCHAR szSize[64]; ictranslate::CFormat fmt; chcore::TBufferSizes bsSizes = chcore::GetTaskPropBufferSizes(m_tTaskDefinition.GetConfiguration()); fmt.SetFormat(GetResManager().LoadString(IDS_BSEDEFAULT_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetDefaultSize(), szSize, 64, true)); + fmt.SetParam(_T("%size"), GetSizeString(bsSizes.GetDefaultSize(), true)); m_ctlBufferSizes.AddString(fmt); if (!bsSizes.IsOnlyDefault()) { fmt.SetFormat(GetResManager().LoadString(IDS_BSEONEDISK_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetOneDiskSize(), szSize, 64, true)); + fmt.SetParam(_T("%size"), GetSizeString(bsSizes.GetOneDiskSize(), true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSETWODISKS_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetTwoDisksSize(), szSize, 64, true)); + fmt.SetParam(_T("%size"), GetSizeString(bsSizes.GetTwoDisksSize(), true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSECD_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetCDSize(), szSize, 64, true)); + fmt.SetParam(_T("%size"), GetSizeString(bsSizes.GetCDSize(), true)); m_ctlBufferSizes.AddString(fmt); fmt.SetFormat(GetResManager().LoadString(IDS_BSELAN_STRING)); - fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetLANSize(), szSize, 64, true)); + fmt.SetParam(_T("%size"), GetSizeString(bsSizes.GetLANSize(), true)); m_ctlBufferSizes.AddString(fmt); } } @@ -580,7 +565,6 @@ { LVITEM lvi; TCHAR szLoaded[1024]; - TCHAR szData[64]; lvi.mask=LVIF_TEXT; lvi.iItem=(iPos == -1) ? m_ctlFilters.GetItemCount() : iPos; @@ -620,13 +604,13 @@ if (rFilter.GetUseSize1()) { - _sntprintf(szLoaded, 1024, _T("%s %s"), GetResManager().LoadString(IDS_LT_STRING+rFilter.GetSizeType1()), GetSizeString(rFilter.GetSize1(), szData, 64, true)); + _sntprintf(szLoaded, 1024, _T("%s %s"), GetResManager().LoadString(IDS_LT_STRING+rFilter.GetSizeType1()), GetSizeString(rFilter.GetSize1(), true)); szLoaded[1023] = _T('\0'); if (rFilter.GetUseSize2()) { _tcscat(szLoaded, GetResManager().LoadString(IDS_AND_STRING)); CString strLoaded2; - strLoaded2.Format(_T("%s %s"), GetResManager().LoadString(IDS_LT_STRING+rFilter.GetSizeType2()), GetSizeString(rFilter.GetSize2(), szData, 64, true)); + strLoaded2.Format(_T("%s %s"), GetResManager().LoadString(IDS_LT_STRING+rFilter.GetSizeType2()), GetSizeString(rFilter.GetSize2(), true)); _tcscat(szLoaded, strLoaded2); } } @@ -830,30 +814,6 @@ } } -void CCustomCopyDlg::SetComboPath(LPCTSTR lpszText) -{ - _ASSERTE(lpszText); - if(!lpszText) - return; - - // set current select to -1 - m_ctlDstPath.SetCurSel(-1); - - SHFILEINFO sfi; - sfi.iIcon=-1; - - COMBOBOXEXITEM cbi; - TCHAR szPath[_MAX_PATH]; - - cbi.mask=CBEIF_TEXT | CBEIF_IMAGE; - cbi.iItem=-1; - _tcscpy(szPath, lpszText); - cbi.pszText=szPath; - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - cbi.iImage=sfi.iIcon; - m_ctlDstPath.SetItem(&cbi); -} - void CCustomCopyDlg::UpdateComboIcon() { // get text from combo @@ -906,31 +866,29 @@ { boost::shared_array spBuffer; - ulong_t ulSize = 0; - CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager().LoadString(IDS_FLTALLFILTER_STRING)); if(dlg.DoModal() == IDOK) { + unsigned long ulSize = 0; UINT uiCount=0; try { - icpf::file file; - file.open(dlg.GetPathName(), FA_READ); + CFile file(dlg.GetPathName(), CFile::modeRead); // load files max 1MB in size; - ll_t llSize = file.get_size(); - if(llSize > 1*1024*1024 || llSize < 2) + unsigned long long ullSize = file.GetLength(); + if(ullSize > 1*1024*1024 || ullSize < 2) { AfxMessageBox(GetResManager().LoadString(IDS_IMPORTERROR_STRING)); return; } - ulSize = boost::numeric_cast(llSize); + ulSize = boost::numeric_cast(ullSize); spBuffer.reset(new BYTE[ulSize + 3]); // guarantee that we have null at the end of the string (3 bytes to compensate for possible odd number of bytes and for unicode) memset(spBuffer.get(), 0, ulSize + 3); - ulSize = file.read(spBuffer.get(), ulSize); - file.close(); + ulSize = file.Read(spBuffer.get(), ulSize); + file.Close(); } catch(...) { @@ -988,7 +946,7 @@ // report ictranslate::CFormat fmt(GetResManager().LoadString(IDS_IMPORTREPORT_STRING)); - fmt.SetParam(_t("%count"), uiCount); + fmt.SetParam(_T("%count"), uiCount); AfxMessageBox(fmt); } } @@ -1036,7 +994,7 @@ { ictranslate::CFormat fmt; fmt.SetFormat(GetResManager().LoadString(IDS_EXPORTING_TASK_FAILED)); - fmt.SetParam(_t("%reason"), strError); + fmt.SetParam(_T("%reason"), strError); AfxMessageBox(fmt, MB_OK | MB_ICONERROR); } @@ -1080,3 +1038,26 @@ return true; } + +void CCustomCopyDlg::UpdateFilesListCtrlHeaderWidth() +{ + CRect rc; + m_ctlFiles.GetWindowRect(&rc); + rc.right -= GetSystemMetrics(SM_CXEDGE) * 2; + + // change the width of a column + LVCOLUMN lvc; + lvc.mask = LVCF_WIDTH; + lvc.cx = rc.Width(); + m_ctlFiles.SetColumn(0, &lvc); +} + +void CCustomCopyDlg::OnSize(UINT nType, int /*cx*/, int /*cy*/) +{ + if(nType == SIZE_RESTORED || nType == SIZE_MAXIMIZED) + { + CWnd* pWnd = GetDlgItem(IDC_FILES_LIST); + if(pWnd) + UpdateFilesListCtrlHeaderWidth(); + } +}