Index: src/ch.sln =================================================================== diff -u -N --- src/ch.sln (revision 0) +++ src/ch.sln (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,34 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Copy Handler", "ch\ch.vcproj", "{4B215B9A-58CA-4987-AC95-7DFC3043E100}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyHandlerShellExt", "chext\chext.vcproj", "{7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + Release MinDependency = Release MinDependency + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Debug.ActiveCfg = Debug|Win32 + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Debug.Build.0 = Debug|Win32 + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release.ActiveCfg = Release|Win32 + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release.Build.0 = Release|Win32 + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release MinDependency.ActiveCfg = Release|Win32 + {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release MinDependency.Build.0 = Release|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Debug.ActiveCfg = Debug|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Debug.Build.0 = Debug|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release.ActiveCfg = Release MinDependency|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release.Build.0 = Release MinDependency|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release MinDependency.ActiveCfg = Release MinDependency|Win32 + {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release MinDependency.Build.0 = Release MinDependency|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Index: ch.sln =================================================================== diff -u -N --- ch.sln (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch.sln (revision 0) @@ -1,34 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Copy Handler", "ch\ch.vcproj", "{4B215B9A-58CA-4987-AC95-7DFC3043E100}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CopyHandlerShellExt", "chext\chext.vcproj", "{7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - Release MinDependency = Release MinDependency - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Debug.ActiveCfg = Debug|Win32 - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Debug.Build.0 = Debug|Win32 - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release.ActiveCfg = Release|Win32 - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release.Build.0 = Release|Win32 - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release MinDependency.ActiveCfg = Release|Win32 - {4B215B9A-58CA-4987-AC95-7DFC3043E100}.Release MinDependency.Build.0 = Release|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Debug.ActiveCfg = Debug|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Debug.Build.0 = Debug|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release.ActiveCfg = Release MinDependency|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release.Build.0 = Release MinDependency|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release MinDependency.ActiveCfg = Release MinDependency|Win32 - {7CE8B0C5-8CD4-4551-ACBF-EC4749E15E69}.Release MinDependency.Build.0 = Release MinDependency|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal Index: src/ch/AboutDlg.cpp =================================================================== diff -u -N --- src/ch/AboutDlg.cpp (revision 0) +++ src/ch/AboutDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,137 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" +#include "resource.h" +#include "AboutDlg.h" +#include "StaticEx.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +bool CAboutDlg::m_bLock=false; + +CAboutDlg::CAboutDlg() : CHLanguageDialog(CAboutDlg::IDD, NULL, &m_bLock) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT + RegisterStaticExControl(AfxGetInstanceHandle()); +} + +CAboutDlg::~CAboutDlg() +{ +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CAboutDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +void CAboutDlg::UpdateProgramVersion() +{ + CWnd* pCtl=(CWnd*)GetDlgItem(IDC_PROGRAM_STATICEX); + CWnd* pCtl2=(CWnd*)GetDlgItem(IDC_FULLVERSION_STATICEX); + if (!pCtl || !pCtl2) + return; + else + { + TCHAR szFull[256]; + _stprintf(szFull, GetResManager()->LoadString(IDS_ABOUTVERSION_STRING), GetApp()->GetAppVersion()); + + pCtl->SetWindowText(GetApp()->GetAppNameVer()); + pCtl2->SetWindowText(szFull); + } +} + +void CAboutDlg::UpdateThanks() +{ + CEdit* pEdit=(CEdit*)GetDlgItem(IDC_THANX_EDIT); + if (pEdit == NULL) + return; + + // get the info about current translations + TCHAR szData[1024]; + GetConfig()->GetStringValue(PP_PLANGDIR, szData, 1024); + GetApp()->ExpandPath(szData); + vector vData; + GetResManager()->Scan(szData, &vData); + + // format the info + TCHAR szTI[8192]; + szTI[0]=_T('\0'); + for (vector::iterator it=vData.begin();it!=vData.end();it++) + { + _stprintf(szData, _T("%s\t\t%s [%s%lu, %s%s]\r\n"), it->GetAuthor(), it->GetLangName(), GetResManager()->LoadString(IDS_LANGCODE_STRING), it->GetLangCode(), GetResManager()->LoadString(IDS_LANGVER_STRING), it->GetVersion()); + _tcscat(szTI, szData); + } + + TCHAR szText[16384]; + _sntprintf(szText, 16384, GetResManager()->LoadString(IDR_THANKS_TEXT), szTI); + szText[16383]=0; + pEdit->SetWindowText(szText); +} + +BOOL CAboutDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + UpdateProgramVersion(); + UpdateThanks(); + + return TRUE; +} + +void CAboutDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + UpdateProgramVersion(); + UpdateThanks(); +} + +BOOL CAboutDlg::OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip) +{ + switch(uiID) + { + case IDC_HOMEPAGELINK_STATIC: + case IDC_HOMEPAGELINK2_STATIC: + case IDC_CONTACT1LINK_STATIC: + case IDC_CONTACT2LINK_STATIC: + case IDC_CONTACT3LINK_STATIC: + case IDC_GENFORUMPAGELINK_STATIC: + case IDC_GENFORUMSUBSCRIBELINK_STATIC: + case IDC_GENFORUMUNSUBSCRIBELINK_STATIC: + case IDC_GENFORUMSENDLINK_STATIC: + case IDC_DEVFORUMPAGELINK_STATIC: + case IDC_DEVFORUMSUBSCRIBELINK_STATIC: + case IDC_DEVFORUMUNSUBSCRIBELINK_STATIC: + case IDC_DEVFORUMSENDLINK_STATIC: + { + HWND hWnd=::GetDlgItem(this->m_hWnd, uiID); + if (!hWnd) + return FALSE; + ::SendMessage(hWnd, SEM_GETLINK, (WPARAM)79, (LPARAM)pTip->szText); + pTip->szText[79]=_T('\0'); + return TRUE; + } + default: + return FALSE; + } +} Index: ch/AboutDlg.cpp =================================================================== diff -u -N --- ch/AboutDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/AboutDlg.cpp (revision 0) @@ -1,137 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" -#include "resource.h" -#include "AboutDlg.h" -#include "StaticEx.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -bool CAboutDlg::m_bLock=false; - -CAboutDlg::CAboutDlg() : CHLanguageDialog(CAboutDlg::IDD, NULL, &m_bLock) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT - RegisterStaticExControl(AfxGetInstanceHandle()); -} - -CAboutDlg::~CAboutDlg() -{ -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CAboutDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -void CAboutDlg::UpdateProgramVersion() -{ - CWnd* pCtl=(CWnd*)GetDlgItem(IDC_PROGRAM_STATICEX); - CWnd* pCtl2=(CWnd*)GetDlgItem(IDC_FULLVERSION_STATICEX); - if (!pCtl || !pCtl2) - return; - else - { - TCHAR szFull[256]; - _stprintf(szFull, GetResManager()->LoadString(IDS_ABOUTVERSION_STRING), GetApp()->GetAppVersion()); - - pCtl->SetWindowText(GetApp()->GetAppNameVer()); - pCtl2->SetWindowText(szFull); - } -} - -void CAboutDlg::UpdateThanks() -{ - CEdit* pEdit=(CEdit*)GetDlgItem(IDC_THANX_EDIT); - if (pEdit == NULL) - return; - - // get the info about current translations - TCHAR szData[1024]; - GetConfig()->GetStringValue(PP_PLANGDIR, szData, 1024); - GetApp()->ExpandPath(szData); - vector vData; - GetResManager()->Scan(szData, &vData); - - // format the info - TCHAR szTI[8192]; - szTI[0]=_T('\0'); - for (vector::iterator it=vData.begin();it!=vData.end();it++) - { - _stprintf(szData, _T("%s\t\t%s [%s%lu, %s%s]\r\n"), it->GetAuthor(), it->GetLangName(), GetResManager()->LoadString(IDS_LANGCODE_STRING), it->GetLangCode(), GetResManager()->LoadString(IDS_LANGVER_STRING), it->GetVersion()); - _tcscat(szTI, szData); - } - - TCHAR szText[16384]; - _sntprintf(szText, 16384, GetResManager()->LoadString(IDR_THANKS_TEXT), szTI); - szText[16383]=0; - pEdit->SetWindowText(szText); -} - -BOOL CAboutDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - UpdateProgramVersion(); - UpdateThanks(); - - return TRUE; -} - -void CAboutDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - UpdateProgramVersion(); - UpdateThanks(); -} - -BOOL CAboutDlg::OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip) -{ - switch(uiID) - { - case IDC_HOMEPAGELINK_STATIC: - case IDC_HOMEPAGELINK2_STATIC: - case IDC_CONTACT1LINK_STATIC: - case IDC_CONTACT2LINK_STATIC: - case IDC_CONTACT3LINK_STATIC: - case IDC_GENFORUMPAGELINK_STATIC: - case IDC_GENFORUMSUBSCRIBELINK_STATIC: - case IDC_GENFORUMUNSUBSCRIBELINK_STATIC: - case IDC_GENFORUMSENDLINK_STATIC: - case IDC_DEVFORUMPAGELINK_STATIC: - case IDC_DEVFORUMSUBSCRIBELINK_STATIC: - case IDC_DEVFORUMUNSUBSCRIBELINK_STATIC: - case IDC_DEVFORUMSENDLINK_STATIC: - { - HWND hWnd=::GetDlgItem(this->m_hWnd, uiID); - if (!hWnd) - return FALSE; - ::SendMessage(hWnd, SEM_GETLINK, (WPARAM)79, (LPARAM)pTip->szText); - pTip->szText[79]=_T('\0'); - return TRUE; - } - default: - return FALSE; - } -} Index: src/ch/AboutDlg.h =================================================================== diff -u -N --- src/ch/AboutDlg.h (revision 0) +++ src/ch/AboutDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,56 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __ABOUTDLG_H__ +#define __ABOUTDLG_H__ + +class CAboutDlg : public CHLanguageDialog +{ +public: + CAboutDlg(); + ~CAboutDlg(); + + void UpdateProgramVersion(); + void UpdateThanks(); + + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + virtual BOOL OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + //}}AFX_VIRTUAL + static bool m_bLock; // locker + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#endif Index: ch/AboutDlg.h =================================================================== diff -u -N --- ch/AboutDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/AboutDlg.h (revision 0) @@ -1,56 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __ABOUTDLG_H__ -#define __ABOUTDLG_H__ - -class CAboutDlg : public CHLanguageDialog -{ -public: - CAboutDlg(); - ~CAboutDlg(); - - void UpdateProgramVersion(); - void UpdateThanks(); - - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - virtual BOOL OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - //}}AFX_VIRTUAL - static bool m_bLock; // locker - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#endif Index: src/ch/AppHelper.cpp =================================================================== diff -u -N --- src/ch/AppHelper.cpp (revision 0) +++ src/ch/AppHelper.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,285 @@ +#include "stdafx.h" +#include "AppHelper.h" +#include "shlobj.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +CAppHelper::CAppHelper() +{ + // read program paths + RetrievePaths(); + + // retrieve VERSION-based info + RetrieveAppInfo(); + + // single-instance protection + m_bFirstInstance=true; + m_hMutex=NULL; + + // name of the protection mutex + m_pszMutexName=new TCHAR[_tcslen(m_pszAppName)+sizeof(_T("__ instance"))/sizeof(TCHAR)+1]; + _stprintf(m_pszMutexName, _T("_%s_ instance"), m_pszAppName); + _tcslwr(m_pszMutexName+2); // first letter of appname has to be of predefined case +} + +CAppHelper::~CAppHelper() +{ + if (m_hMutex) + ReleaseMutex(m_hMutex); + + delete [] m_pszProgramPath; + delete [] m_pszProgramName; + delete [] m_pszAppName; + delete [] m_pszAppNameVer; + delete [] m_pszAppVersion; + delete [] m_pszMutexName; +} + +// inits mutex app protection +void CAppHelper::InitProtection() +{ + m_hMutex=CreateMutex(NULL, TRUE, m_pszMutexName); + m_bFirstInstance=(m_hMutex != NULL && GetLastError() != ERROR_ALREADY_EXISTS); +} + +// retrieves application path +void CAppHelper::RetrievePaths() +{ + // try to find '\\' in path to see if this is only exe name or fully qualified path + TCHAR* pszName=_tcsrchr(__argv[0], _T('\\')); + if (pszName != NULL) + { + // copy name + m_pszProgramName=new TCHAR[_tcslen(pszName+1)+1]; + _tcscpy(m_pszProgramName, pszName+1); + + // path + UINT uiSize=(UINT)(pszName-__argv[0]); + m_pszProgramPath=new TCHAR[uiSize+1]; + _tcsncpy(m_pszProgramPath, __argv[0], uiSize); + m_pszProgramPath[uiSize]=_T('\0'); + } + else + { + // copy name + m_pszProgramName=new TCHAR[_tcslen(__argv[0])+1]; + _tcscpy(m_pszProgramName, __argv[0]); + + // path + TCHAR szPath[_MAX_PATH]; + UINT uiSize=GetCurrentDirectory(_MAX_PATH, szPath); + _tcscat(szPath, _T("\\")); + m_pszProgramPath=new TCHAR[uiSize+2]; + _tcsncpy(m_pszProgramPath, szPath, uiSize+2); + } +} + +void CAppHelper::RetrieveAppInfo() +{ + if (m_pszAppName) + { + delete [] m_pszAppName; + m_pszAppName=NULL; + } + if (m_pszAppNameVer) + { + delete [] m_pszAppNameVer; + m_pszAppNameVer=NULL; + } + if (m_pszAppVersion) + { + delete [] m_pszAppVersion; + m_pszAppVersion=NULL; + } + + TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; + _tcscpy(pszPath, m_pszProgramPath); + _tcscat(pszPath, _T("\\")); + _tcscat(pszPath, m_pszProgramName); + + DWORD dwHandle; + DWORD dwSize=GetFileVersionInfoSize(pszPath, &dwHandle); + if (dwSize) + { + BYTE *pbyBuffer=new BYTE[dwSize]; + if (GetFileVersionInfo(pszPath, 0, dwSize, pbyBuffer)) + { + TCHAR* pszProp; + UINT uiLen; + // product name with short version number + if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductName"), (LPVOID*)&pszProp, &uiLen)) + { + m_pszAppNameVer=new TCHAR[uiLen]; + _tcscpy(m_pszAppNameVer, pszProp); + } + + // product long version + if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductVersion"), (LPVOID*)&pszProp, &uiLen)) + { + m_pszAppVersion=new TCHAR[uiLen]; + _tcscpy(m_pszAppVersion, pszProp); + } + + // product name without version number + if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\InternalName"), (LPVOID*)&pszProp, &uiLen)) + { + m_pszAppName=new TCHAR[uiLen]; + _tcscpy(m_pszAppName, pszProp); + } + } + + delete [] pbyBuffer; + } + delete [] pszPath; + + if (m_pszAppNameVer == NULL) + { + m_pszAppNameVer=new TCHAR[sizeof(_T("Unknown App 1.0"))/sizeof(TCHAR)]; + _tcscpy(m_pszAppNameVer, _T("Unknown App 1.0")); + } + if (m_pszAppVersion == NULL) + { + m_pszAppVersion=new TCHAR[sizeof(_T("1.0.0.0"))/sizeof(TCHAR)]; + _tcscpy(m_pszAppVersion, _T("1.0.0.0")); + } + if (m_pszAppName == NULL) + { + m_pszAppName=new TCHAR[sizeof(_T("Unknown App"))/sizeof(TCHAR)]; + _tcscpy(m_pszAppName, _T("Unknown App")); + } +} + +// internal func - safe getting special folder locations +UINT CAppHelper::GetFolderLocation(int iFolder, PTSTR pszBuffer) +{ + LPITEMIDLIST piid; + HRESULT h=SHGetSpecialFolderLocation(NULL, iFolder, &piid); + if (!SUCCEEDED(h)) + return false; + + // get path + BOOL bRes=SHGetPathFromIDList(piid, pszBuffer); + + // free piid + LPMALLOC lpm; + if (!SUCCEEDED(SHGetMalloc(&lpm))) + return 0; + + lpm->Free((void*)piid); + lpm->Release(); + + // check for error + if (!bRes) + return 0; + + // strip the last '\\' + UINT uiLen=(UINT)_tcslen(pszBuffer); + if (pszBuffer[uiLen-1] == _T('\\')) + { + pszBuffer[uiLen-1]=_T('\0'); + return uiLen-1; + } + else + return uiLen; +} + +// expands given path +PTSTR CAppHelper::ExpandPath(PTSTR pszString) +{ + // check if there is need to perform all these checkings + if (pszString[0] != _T('<')) + return pszString; + + TCHAR szStr[_MAX_PATH]; + szStr[0]=_T('\0'); + + // search for string to replace + // _T(""), _T(""), _T(""), _T(""), _T(""), + // _T(""), _T("") + if (_tcsnicmp(pszString, _T(""), 9) == 0) + { + // get windows path + _tcscpy(szStr, m_pszProgramPath); + _tcscat(szStr, pszString+9); + } + else if (_tcsnicmp(pszString, _T(""), 9) == 0) + { + // get windows path + UINT uiSize=GetWindowsDirectory(szStr, _MAX_PATH); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+9); + } + else if (_tcsnicmp(pszString, _T(""), 6) == 0) // temp dir + { + // get windows path + UINT uiSize=GetTempPath(_MAX_PATH, szStr); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+6); + } + else if (_tcsnicmp(pszString, _T(""), 8) == 0) // system + { + // get windows path + UINT uiSize=GetSystemDirectory(szStr, _MAX_PATH); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+8); + } + else if (_tcsnicmp(pszString, _T(""), 9) == 0) // app data + { + // get windows path + UINT uiSize=GetFolderLocation(CSIDL_APPDATA, szStr); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+9); + } + else if (_tcsnicmp(pszString, _T(""), 9) == 0) // desktop + { + // get windows path + UINT uiSize=GetFolderLocation(CSIDL_DESKTOPDIRECTORY, szStr); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+9); + } + else if (_tcsnicmp(pszString, _T(""), 10) == 0) // personal... + { + // get windows path + UINT uiSize=GetFolderLocation(CSIDL_PERSONAL, szStr); + if (szStr[uiSize-1] == _T('\\')) + szStr[uiSize-1]=_T('\0'); + _tcscat(szStr, pszString+10); + } + + // copy to src string + if (szStr[0] != _T('\0')) + _tcscpy(pszString, szStr); + + return pszString; +} + +void CAppHelper::SetAutorun(bool bState) +{ + // storing key in registry + HKEY hkeyRun; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkeyRun) != ERROR_SUCCESS) + return; + + if (bState) + { + TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; + _tcscpy(pszPath, m_pszProgramPath); + _tcscat(pszPath, _T("\\")); + _tcscat(pszPath, m_pszProgramName); + + RegSetValueEx(hkeyRun, m_pszAppName, 0, REG_SZ, (BYTE*)pszPath, (DWORD)(_tcslen(pszPath)+1)*sizeof(TCHAR)); + + delete [] pszPath; + } + else + RegDeleteValue(hkeyRun, m_pszAppName); + + RegCloseKey(hkeyRun); +} Index: ch/AppHelper.cpp =================================================================== diff -u -N --- ch/AppHelper.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/AppHelper.cpp (revision 0) @@ -1,285 +0,0 @@ -#include "stdafx.h" -#include "AppHelper.h" -#include "shlobj.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -CAppHelper::CAppHelper() -{ - // read program paths - RetrievePaths(); - - // retrieve VERSION-based info - RetrieveAppInfo(); - - // single-instance protection - m_bFirstInstance=true; - m_hMutex=NULL; - - // name of the protection mutex - m_pszMutexName=new TCHAR[_tcslen(m_pszAppName)+sizeof(_T("__ instance"))/sizeof(TCHAR)+1]; - _stprintf(m_pszMutexName, _T("_%s_ instance"), m_pszAppName); - _tcslwr(m_pszMutexName+2); // first letter of appname has to be of predefined case -} - -CAppHelper::~CAppHelper() -{ - if (m_hMutex) - ReleaseMutex(m_hMutex); - - delete [] m_pszProgramPath; - delete [] m_pszProgramName; - delete [] m_pszAppName; - delete [] m_pszAppNameVer; - delete [] m_pszAppVersion; - delete [] m_pszMutexName; -} - -// inits mutex app protection -void CAppHelper::InitProtection() -{ - m_hMutex=CreateMutex(NULL, TRUE, m_pszMutexName); - m_bFirstInstance=(m_hMutex != NULL && GetLastError() != ERROR_ALREADY_EXISTS); -} - -// retrieves application path -void CAppHelper::RetrievePaths() -{ - // try to find '\\' in path to see if this is only exe name or fully qualified path - TCHAR* pszName=_tcsrchr(__argv[0], _T('\\')); - if (pszName != NULL) - { - // copy name - m_pszProgramName=new TCHAR[_tcslen(pszName+1)+1]; - _tcscpy(m_pszProgramName, pszName+1); - - // path - UINT uiSize=(UINT)(pszName-__argv[0]); - m_pszProgramPath=new TCHAR[uiSize+1]; - _tcsncpy(m_pszProgramPath, __argv[0], uiSize); - m_pszProgramPath[uiSize]=_T('\0'); - } - else - { - // copy name - m_pszProgramName=new TCHAR[_tcslen(__argv[0])+1]; - _tcscpy(m_pszProgramName, __argv[0]); - - // path - TCHAR szPath[_MAX_PATH]; - UINT uiSize=GetCurrentDirectory(_MAX_PATH, szPath); - _tcscat(szPath, _T("\\")); - m_pszProgramPath=new TCHAR[uiSize+2]; - _tcsncpy(m_pszProgramPath, szPath, uiSize+2); - } -} - -void CAppHelper::RetrieveAppInfo() -{ - if (m_pszAppName) - { - delete [] m_pszAppName; - m_pszAppName=NULL; - } - if (m_pszAppNameVer) - { - delete [] m_pszAppNameVer; - m_pszAppNameVer=NULL; - } - if (m_pszAppVersion) - { - delete [] m_pszAppVersion; - m_pszAppVersion=NULL; - } - - TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; - _tcscpy(pszPath, m_pszProgramPath); - _tcscat(pszPath, _T("\\")); - _tcscat(pszPath, m_pszProgramName); - - DWORD dwHandle; - DWORD dwSize=GetFileVersionInfoSize(pszPath, &dwHandle); - if (dwSize) - { - BYTE *pbyBuffer=new BYTE[dwSize]; - if (GetFileVersionInfo(pszPath, 0, dwSize, pbyBuffer)) - { - TCHAR* pszProp; - UINT uiLen; - // product name with short version number - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductName"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppNameVer=new TCHAR[uiLen]; - _tcscpy(m_pszAppNameVer, pszProp); - } - - // product long version - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductVersion"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppVersion=new TCHAR[uiLen]; - _tcscpy(m_pszAppVersion, pszProp); - } - - // product name without version number - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\InternalName"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppName=new TCHAR[uiLen]; - _tcscpy(m_pszAppName, pszProp); - } - } - - delete [] pbyBuffer; - } - delete [] pszPath; - - if (m_pszAppNameVer == NULL) - { - m_pszAppNameVer=new TCHAR[sizeof(_T("Unknown App 1.0"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppNameVer, _T("Unknown App 1.0")); - } - if (m_pszAppVersion == NULL) - { - m_pszAppVersion=new TCHAR[sizeof(_T("1.0.0.0"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppVersion, _T("1.0.0.0")); - } - if (m_pszAppName == NULL) - { - m_pszAppName=new TCHAR[sizeof(_T("Unknown App"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppName, _T("Unknown App")); - } -} - -// internal func - safe getting special folder locations -UINT CAppHelper::GetFolderLocation(int iFolder, PTSTR pszBuffer) -{ - LPITEMIDLIST piid; - HRESULT h=SHGetSpecialFolderLocation(NULL, iFolder, &piid); - if (!SUCCEEDED(h)) - return false; - - // get path - BOOL bRes=SHGetPathFromIDList(piid, pszBuffer); - - // free piid - LPMALLOC lpm; - if (!SUCCEEDED(SHGetMalloc(&lpm))) - return 0; - - lpm->Free((void*)piid); - lpm->Release(); - - // check for error - if (!bRes) - return 0; - - // strip the last '\\' - UINT uiLen=(UINT)_tcslen(pszBuffer); - if (pszBuffer[uiLen-1] == _T('\\')) - { - pszBuffer[uiLen-1]=_T('\0'); - return uiLen-1; - } - else - return uiLen; -} - -// expands given path -PTSTR CAppHelper::ExpandPath(PTSTR pszString) -{ - // check if there is need to perform all these checkings - if (pszString[0] != _T('<')) - return pszString; - - TCHAR szStr[_MAX_PATH]; - szStr[0]=_T('\0'); - - // search for string to replace - // _T(""), _T(""), _T(""), _T(""), _T(""), - // _T(""), _T("") - if (_tcsnicmp(pszString, _T(""), 9) == 0) - { - // get windows path - _tcscpy(szStr, m_pszProgramPath); - _tcscat(szStr, pszString+9); - } - else if (_tcsnicmp(pszString, _T(""), 9) == 0) - { - // get windows path - UINT uiSize=GetWindowsDirectory(szStr, _MAX_PATH); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+9); - } - else if (_tcsnicmp(pszString, _T(""), 6) == 0) // temp dir - { - // get windows path - UINT uiSize=GetTempPath(_MAX_PATH, szStr); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+6); - } - else if (_tcsnicmp(pszString, _T(""), 8) == 0) // system - { - // get windows path - UINT uiSize=GetSystemDirectory(szStr, _MAX_PATH); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+8); - } - else if (_tcsnicmp(pszString, _T(""), 9) == 0) // app data - { - // get windows path - UINT uiSize=GetFolderLocation(CSIDL_APPDATA, szStr); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+9); - } - else if (_tcsnicmp(pszString, _T(""), 9) == 0) // desktop - { - // get windows path - UINT uiSize=GetFolderLocation(CSIDL_DESKTOPDIRECTORY, szStr); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+9); - } - else if (_tcsnicmp(pszString, _T(""), 10) == 0) // personal... - { - // get windows path - UINT uiSize=GetFolderLocation(CSIDL_PERSONAL, szStr); - if (szStr[uiSize-1] == _T('\\')) - szStr[uiSize-1]=_T('\0'); - _tcscat(szStr, pszString+10); - } - - // copy to src string - if (szStr[0] != _T('\0')) - _tcscpy(pszString, szStr); - - return pszString; -} - -void CAppHelper::SetAutorun(bool bState) -{ - // storing key in registry - HKEY hkeyRun; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, KEY_ALL_ACCESS, &hkeyRun) != ERROR_SUCCESS) - return; - - if (bState) - { - TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; - _tcscpy(pszPath, m_pszProgramPath); - _tcscat(pszPath, _T("\\")); - _tcscat(pszPath, m_pszProgramName); - - RegSetValueEx(hkeyRun, m_pszAppName, 0, REG_SZ, (BYTE*)pszPath, (DWORD)(_tcslen(pszPath)+1)*sizeof(TCHAR)); - - delete [] pszPath; - } - else - RegDeleteValue(hkeyRun, m_pszAppName); - - RegCloseKey(hkeyRun); -} Index: src/ch/AppHelper.h =================================================================== diff -u -N --- src/ch/AppHelper.h (revision 0) +++ src/ch/AppHelper.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,42 @@ +#ifndef __APPHELPER_H__ +#define __APPHELPER_H__ + +class CAppHelper +{ +public: + CAppHelper(); + ~CAppHelper(); + + void SetAutorun(bool bState); // changes state of "run with system" option + PTSTR ExpandPath(PTSTR pszString); // expands path string - ie. into c:\windows + + bool IsFirstInstance() const { return m_bFirstInstance; }; + + PCTSTR GetAppName() const { return m_pszAppName; }; + PCTSTR GetAppNameVer() const { return m_pszAppNameVer; }; + PCTSTR GetAppVersion() const { return m_pszAppVersion; }; + + PCTSTR GetProgramPath() const { return m_pszProgramPath; }; + PCTSTR GetProgramName() const { return m_pszProgramName; }; + +protected: + void InitProtection(); // optional call - protects from running multiple instance + void RetrievePaths(); // reads program's path and name + void RetrieveAppInfo(); // reads app name and version from VERSION resource + UINT GetFolderLocation(int iFolder, PTSTR pszBuffer); + +protected: + HANDLE m_hMutex; + bool m_bFirstInstance; // tells if it is first instance(true) or second(or third, ...) + TCHAR *m_pszMutexName; // name of the protection mutex + + // program placement + TCHAR* m_pszProgramPath; // path from which this program was run + TCHAR* m_pszProgramName; // name of this program (ie. CH.exe) + + TCHAR* m_pszAppName; // app-name string of this app + TCHAR* m_pszAppNameVer; // extended app-name-with small version + TCHAR* m_pszAppVersion; // app-version string of this app (VERSION based) +}; + +#endif \ No newline at end of file Index: ch/AppHelper.h =================================================================== diff -u -N --- ch/AppHelper.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/AppHelper.h (revision 0) @@ -1,42 +0,0 @@ -#ifndef __APPHELPER_H__ -#define __APPHELPER_H__ - -class CAppHelper -{ -public: - CAppHelper(); - ~CAppHelper(); - - void SetAutorun(bool bState); // changes state of "run with system" option - PTSTR ExpandPath(PTSTR pszString); // expands path string - ie. into c:\windows - - bool IsFirstInstance() const { return m_bFirstInstance; }; - - PCTSTR GetAppName() const { return m_pszAppName; }; - PCTSTR GetAppNameVer() const { return m_pszAppNameVer; }; - PCTSTR GetAppVersion() const { return m_pszAppVersion; }; - - PCTSTR GetProgramPath() const { return m_pszProgramPath; }; - PCTSTR GetProgramName() const { return m_pszProgramName; }; - -protected: - void InitProtection(); // optional call - protects from running multiple instance - void RetrievePaths(); // reads program's path and name - void RetrieveAppInfo(); // reads app name and version from VERSION resource - UINT GetFolderLocation(int iFolder, PTSTR pszBuffer); - -protected: - HANDLE m_hMutex; - bool m_bFirstInstance; // tells if it is first instance(true) or second(or third, ...) - TCHAR *m_pszMutexName; // name of the protection mutex - - // program placement - TCHAR* m_pszProgramPath; // path from which this program was run - TCHAR* m_pszProgramName; // name of this program (ie. CH.exe) - - TCHAR* m_pszAppName; // app-name string of this app - TCHAR* m_pszAppNameVer; // extended app-name-with small version - TCHAR* m_pszAppVersion; // app-version string of this app (VERSION based) -}; - -#endif \ No newline at end of file Index: src/ch/BufferSizeDlg.cpp =================================================================== diff -u -N --- src/ch/BufferSizeDlg.cpp (revision 0) +++ src/ch/BufferSizeDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,334 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "BufferSizeDlg.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CBufferSizeDlg dialog + +CBufferSizeDlg::CBufferSizeDlg() + : CHLanguageDialog(CBufferSizeDlg::IDD) +{ + //{{AFX_DATA_INIT(CBufferSizeDlg) + m_uiDefaultSize = 0; + m_uiLANSize = 0; + m_uiCDROMSize = 0; + m_uiOneDiskSize = 0; + m_uiTwoDisksSize = 0; + m_bOnlyDefaultCheck = FALSE; + //}}AFX_DATA_INIT + m_iActiveIndex=BI_DEFAULT; +} + +void CBufferSizeDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBufferSizeDlg) + DDX_Control(pDX, IDC_TWODISKSMULTIPLIER_COMBO, m_ctlTwoDisksMulti); + DDX_Control(pDX, IDC_ONEDISKMULTIPLIER_COMBO, m_ctlOneDiskMulti); + DDX_Control(pDX, IDC_LANMULTIPLIER_COMBO, m_ctlLANMulti); + DDX_Control(pDX, IDC_DEFAULTMULTIPLIER_COMBO, m_ctlDefaultMulti); + DDX_Control(pDX, IDC_CDROMMULTIPLIER_COMBO, m_ctlCDROMMulti); + DDX_Text(pDX, IDC_DEFAULTSIZE_EDIT, m_uiDefaultSize); + DDX_Text(pDX, IDC_LANSIZE_EDIT, m_uiLANSize); + DDX_Text(pDX, IDC_CDROMSIZE_EDIT, m_uiCDROMSize); + DDX_Text(pDX, IDC_ONEDISKSIZE_EDIT, m_uiOneDiskSize); + DDX_Text(pDX, IDC_TWODISKSSIZE_EDIT, m_uiTwoDisksSize); + DDX_Check(pDX, IDC_ONLYDEFAULT_CHECK, m_bOnlyDefaultCheck); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CBufferSizeDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CBufferSizeDlg) + ON_BN_CLICKED(IDC_ONLYDEFAULT_CHECK, OnOnlydefaultCheck) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBufferSizeDlg message handlers + +BOOL CBufferSizeDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // set all the combos + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + + // fill edit controls and set multipliers + SetDefaultSize(m_bsSizes.m_uiDefaultSize); + SetOneDiskSize(m_bsSizes.m_uiOneDiskSize); + SetTwoDisksSize(m_bsSizes.m_uiTwoDisksSize); + SetCDSize(m_bsSizes.m_uiCDSize); + SetLANSize(m_bsSizes.m_uiLANSize); + m_bOnlyDefaultCheck=m_bsSizes.m_bOnlyDefault; + + EnableControls(!m_bsSizes.m_bOnlyDefault); + + UpdateData(FALSE); + + // set focus to the requested control + switch (m_iActiveIndex) + { + case BI_DEFAULT: + GetDlgItem(IDC_DEFAULTSIZE_EDIT)->SetFocus(); + static_cast(GetDlgItem(IDC_DEFAULTSIZE_EDIT))->SetSel(0, -1); + break; + case BI_ONEDISK: + GetDlgItem(IDC_ONEDISKSIZE_EDIT)->SetFocus(); + static_cast(GetDlgItem(IDC_ONEDISKSIZE_EDIT))->SetSel(0, -1); + break; + case BI_TWODISKS: + GetDlgItem(IDC_TWODISKSSIZE_EDIT)->SetFocus(); + static_cast(GetDlgItem(IDC_TWODISKSSIZE_EDIT))->SetSel(0, -1); + break; + case BI_CD: + GetDlgItem(IDC_CDROMSIZE_EDIT)->SetFocus(); + static_cast(GetDlgItem(IDC_CDROMSIZE_EDIT))->SetSel(0, -1); + break; + case BI_LAN: + GetDlgItem(IDC_LANSIZE_EDIT)->SetFocus(); + static_cast(GetDlgItem(IDC_LANSIZE_EDIT))->SetSel(0, -1); + break; + } + + return FALSE; +} + +void CBufferSizeDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + UpdateData(TRUE); + + // set all the combos + int iSel=m_ctlDefaultMulti.GetCurSel(); + m_ctlDefaultMulti.ResetContent(); + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + m_ctlDefaultMulti.SetCurSel(iSel); + + iSel=m_ctlOneDiskMulti.GetCurSel(); + m_ctlOneDiskMulti.ResetContent(); + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + m_ctlOneDiskMulti.SetCurSel(iSel); + + iSel=m_ctlTwoDisksMulti.GetCurSel(); + m_ctlTwoDisksMulti.ResetContent(); + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + m_ctlTwoDisksMulti.SetCurSel(iSel); + + iSel=m_ctlCDROMMulti.GetCurSel(); + m_ctlCDROMMulti.ResetContent(); + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + m_ctlCDROMMulti.SetCurSel(iSel); + + iSel=m_ctlLANMulti.GetCurSel(); + m_ctlLANMulti.ResetContent(); + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); + m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); + m_ctlLANMulti.SetCurSel(iSel); + + UpdateData(FALSE); +} + +UINT CBufferSizeDlg::IndexToValue(int iIndex) +{ + switch (iIndex) + { + case 0: + return 1; + case 1: + return 1024; + case 2: + return 1048576; + default: + ASSERT(true); // bad index + return 1; + } +} + +void CBufferSizeDlg::OnOK() +{ + if (!UpdateData(TRUE)) + return; + + // no buffer could be 0 + if (m_uiDefaultSize == 0 || m_uiOneDiskSize == 0 || m_uiTwoDisksSize == 0 || m_uiCDROMSize == 0 || m_uiLANSize == 0) + { + MsgBox(IDS_BUFFERSIZEZERO_STRING); + return; + } + + // assign values + m_bsSizes.m_bOnlyDefault=m_bOnlyDefaultCheck != 0; + m_bsSizes.m_uiDefaultSize=m_uiDefaultSize*IndexToValue(m_ctlDefaultMulti.GetCurSel()); + m_bsSizes.m_uiOneDiskSize=m_uiOneDiskSize*IndexToValue(m_ctlOneDiskMulti.GetCurSel()); + m_bsSizes.m_uiTwoDisksSize=m_uiTwoDisksSize*IndexToValue(m_ctlTwoDisksMulti.GetCurSel()); + m_bsSizes.m_uiCDSize=m_uiCDROMSize*IndexToValue(m_ctlCDROMMulti.GetCurSel()); + m_bsSizes.m_uiLANSize=m_uiLANSize*IndexToValue(m_ctlLANMulti.GetCurSel()); + + CHLanguageDialog::OnOK(); +} + +void CBufferSizeDlg::SetDefaultSize(UINT uiSize) +{ + if ((uiSize % 1048576) == 0) + { + m_uiDefaultSize=static_cast(uiSize/1048576); + m_ctlDefaultMulti.SetCurSel(2); + } + else if ((uiSize % 1024) == 0) + { + m_uiDefaultSize=static_cast(uiSize/1024); + m_ctlDefaultMulti.SetCurSel(1); + } + else + { + m_uiDefaultSize=uiSize; + m_ctlDefaultMulti.SetCurSel(0); + } +} + +void CBufferSizeDlg::SetOneDiskSize(UINT uiSize) +{ + if ((uiSize % 1048576) == 0) + { + m_uiOneDiskSize=static_cast(uiSize/1048576); + m_ctlOneDiskMulti.SetCurSel(2); + } + else if ((uiSize % 1024) == 0) + { + m_uiOneDiskSize=static_cast(uiSize/1024); + m_ctlOneDiskMulti.SetCurSel(1); + } + else + { + m_uiOneDiskSize=uiSize; + m_ctlOneDiskMulti.SetCurSel(0); + } +} + +void CBufferSizeDlg::SetTwoDisksSize(UINT uiSize) +{ + if ((uiSize % 1048576) == 0) + { + m_uiTwoDisksSize=static_cast(uiSize/1048576); + m_ctlTwoDisksMulti.SetCurSel(2); + } + else if ((uiSize % 1024) == 0) + { + m_uiTwoDisksSize=static_cast(uiSize/1024); + m_ctlTwoDisksMulti.SetCurSel(1); + } + else + { + m_uiTwoDisksSize=uiSize; + m_ctlTwoDisksMulti.SetCurSel(0); + } +} + +void CBufferSizeDlg::SetCDSize(UINT uiSize) +{ + if ((uiSize % 1048576) == 0) + { + m_uiCDROMSize=static_cast(uiSize/1048576); + m_ctlCDROMMulti.SetCurSel(2); + } + else if ((uiSize % 1024) == 0) + { + m_uiCDROMSize=static_cast(uiSize/1024); + m_ctlCDROMMulti.SetCurSel(1); + } + else + { + m_uiCDROMSize=uiSize; + m_ctlCDROMMulti.SetCurSel(0); + } +} + +void CBufferSizeDlg::SetLANSize(UINT uiSize) +{ + if ((uiSize % 1048576) == 0) + { + m_uiLANSize=static_cast(uiSize/1048576); + m_ctlLANMulti.SetCurSel(2); + } + else if ((uiSize % 1024) == 0) + { + m_uiLANSize=static_cast(uiSize/1024); + m_ctlLANMulti.SetCurSel(1); + } + else + { + m_uiLANSize=uiSize; + m_ctlLANMulti.SetCurSel(0); + } +} + +void CBufferSizeDlg::EnableControls(bool bEnable) +{ + GetDlgItem(IDC_ONEDISKSIZE_EDIT)->EnableWindow(bEnable); + m_ctlOneDiskMulti.EnableWindow(bEnable); + GetDlgItem(IDC_TWODISKSSIZE_EDIT)->EnableWindow(bEnable); + m_ctlTwoDisksMulti.EnableWindow(bEnable); + GetDlgItem(IDC_CDROMSIZE_EDIT)->EnableWindow(bEnable); + m_ctlCDROMMulti.EnableWindow(bEnable); + GetDlgItem(IDC_LANSIZE_EDIT)->EnableWindow(bEnable); + m_ctlLANMulti.EnableWindow(bEnable); +} + +void CBufferSizeDlg::OnOnlydefaultCheck() +{ + UpdateData(TRUE); + EnableControls(m_bOnlyDefaultCheck == 0); +} Index: ch/BufferSizeDlg.cpp =================================================================== diff -u -N --- ch/BufferSizeDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/BufferSizeDlg.cpp (revision 0) @@ -1,334 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "BufferSizeDlg.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CBufferSizeDlg dialog - -CBufferSizeDlg::CBufferSizeDlg() - : CHLanguageDialog(CBufferSizeDlg::IDD) -{ - //{{AFX_DATA_INIT(CBufferSizeDlg) - m_uiDefaultSize = 0; - m_uiLANSize = 0; - m_uiCDROMSize = 0; - m_uiOneDiskSize = 0; - m_uiTwoDisksSize = 0; - m_bOnlyDefaultCheck = FALSE; - //}}AFX_DATA_INIT - m_iActiveIndex=BI_DEFAULT; -} - -void CBufferSizeDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CBufferSizeDlg) - DDX_Control(pDX, IDC_TWODISKSMULTIPLIER_COMBO, m_ctlTwoDisksMulti); - DDX_Control(pDX, IDC_ONEDISKMULTIPLIER_COMBO, m_ctlOneDiskMulti); - DDX_Control(pDX, IDC_LANMULTIPLIER_COMBO, m_ctlLANMulti); - DDX_Control(pDX, IDC_DEFAULTMULTIPLIER_COMBO, m_ctlDefaultMulti); - DDX_Control(pDX, IDC_CDROMMULTIPLIER_COMBO, m_ctlCDROMMulti); - DDX_Text(pDX, IDC_DEFAULTSIZE_EDIT, m_uiDefaultSize); - DDX_Text(pDX, IDC_LANSIZE_EDIT, m_uiLANSize); - DDX_Text(pDX, IDC_CDROMSIZE_EDIT, m_uiCDROMSize); - DDX_Text(pDX, IDC_ONEDISKSIZE_EDIT, m_uiOneDiskSize); - DDX_Text(pDX, IDC_TWODISKSSIZE_EDIT, m_uiTwoDisksSize); - DDX_Check(pDX, IDC_ONLYDEFAULT_CHECK, m_bOnlyDefaultCheck); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CBufferSizeDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CBufferSizeDlg) - ON_BN_CLICKED(IDC_ONLYDEFAULT_CHECK, OnOnlydefaultCheck) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CBufferSizeDlg message handlers - -BOOL CBufferSizeDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // set all the combos - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - - // fill edit controls and set multipliers - SetDefaultSize(m_bsSizes.m_uiDefaultSize); - SetOneDiskSize(m_bsSizes.m_uiOneDiskSize); - SetTwoDisksSize(m_bsSizes.m_uiTwoDisksSize); - SetCDSize(m_bsSizes.m_uiCDSize); - SetLANSize(m_bsSizes.m_uiLANSize); - m_bOnlyDefaultCheck=m_bsSizes.m_bOnlyDefault; - - EnableControls(!m_bsSizes.m_bOnlyDefault); - - UpdateData(FALSE); - - // set focus to the requested control - switch (m_iActiveIndex) - { - case BI_DEFAULT: - GetDlgItem(IDC_DEFAULTSIZE_EDIT)->SetFocus(); - static_cast(GetDlgItem(IDC_DEFAULTSIZE_EDIT))->SetSel(0, -1); - break; - case BI_ONEDISK: - GetDlgItem(IDC_ONEDISKSIZE_EDIT)->SetFocus(); - static_cast(GetDlgItem(IDC_ONEDISKSIZE_EDIT))->SetSel(0, -1); - break; - case BI_TWODISKS: - GetDlgItem(IDC_TWODISKSSIZE_EDIT)->SetFocus(); - static_cast(GetDlgItem(IDC_TWODISKSSIZE_EDIT))->SetSel(0, -1); - break; - case BI_CD: - GetDlgItem(IDC_CDROMSIZE_EDIT)->SetFocus(); - static_cast(GetDlgItem(IDC_CDROMSIZE_EDIT))->SetSel(0, -1); - break; - case BI_LAN: - GetDlgItem(IDC_LANSIZE_EDIT)->SetFocus(); - static_cast(GetDlgItem(IDC_LANSIZE_EDIT))->SetSel(0, -1); - break; - } - - return FALSE; -} - -void CBufferSizeDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - UpdateData(TRUE); - - // set all the combos - int iSel=m_ctlDefaultMulti.GetCurSel(); - m_ctlDefaultMulti.ResetContent(); - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlDefaultMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - m_ctlDefaultMulti.SetCurSel(iSel); - - iSel=m_ctlOneDiskMulti.GetCurSel(); - m_ctlOneDiskMulti.ResetContent(); - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlOneDiskMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - m_ctlOneDiskMulti.SetCurSel(iSel); - - iSel=m_ctlTwoDisksMulti.GetCurSel(); - m_ctlTwoDisksMulti.ResetContent(); - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlTwoDisksMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - m_ctlTwoDisksMulti.SetCurSel(iSel); - - iSel=m_ctlCDROMMulti.GetCurSel(); - m_ctlCDROMMulti.ResetContent(); - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlCDROMMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - m_ctlCDROMMulti.SetCurSel(iSel); - - iSel=m_ctlLANMulti.GetCurSel(); - m_ctlLANMulti.ResetContent(); - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_BYTE_STRING)); - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_KBYTE_STRING)); - m_ctlLANMulti.AddString(GetResManager()->LoadString(IDS_MBYTE_STRING)); - m_ctlLANMulti.SetCurSel(iSel); - - UpdateData(FALSE); -} - -UINT CBufferSizeDlg::IndexToValue(int iIndex) -{ - switch (iIndex) - { - case 0: - return 1; - case 1: - return 1024; - case 2: - return 1048576; - default: - ASSERT(true); // bad index - return 1; - } -} - -void CBufferSizeDlg::OnOK() -{ - if (!UpdateData(TRUE)) - return; - - // no buffer could be 0 - if (m_uiDefaultSize == 0 || m_uiOneDiskSize == 0 || m_uiTwoDisksSize == 0 || m_uiCDROMSize == 0 || m_uiLANSize == 0) - { - MsgBox(IDS_BUFFERSIZEZERO_STRING); - return; - } - - // assign values - m_bsSizes.m_bOnlyDefault=m_bOnlyDefaultCheck != 0; - m_bsSizes.m_uiDefaultSize=m_uiDefaultSize*IndexToValue(m_ctlDefaultMulti.GetCurSel()); - m_bsSizes.m_uiOneDiskSize=m_uiOneDiskSize*IndexToValue(m_ctlOneDiskMulti.GetCurSel()); - m_bsSizes.m_uiTwoDisksSize=m_uiTwoDisksSize*IndexToValue(m_ctlTwoDisksMulti.GetCurSel()); - m_bsSizes.m_uiCDSize=m_uiCDROMSize*IndexToValue(m_ctlCDROMMulti.GetCurSel()); - m_bsSizes.m_uiLANSize=m_uiLANSize*IndexToValue(m_ctlLANMulti.GetCurSel()); - - CHLanguageDialog::OnOK(); -} - -void CBufferSizeDlg::SetDefaultSize(UINT uiSize) -{ - if ((uiSize % 1048576) == 0) - { - m_uiDefaultSize=static_cast(uiSize/1048576); - m_ctlDefaultMulti.SetCurSel(2); - } - else if ((uiSize % 1024) == 0) - { - m_uiDefaultSize=static_cast(uiSize/1024); - m_ctlDefaultMulti.SetCurSel(1); - } - else - { - m_uiDefaultSize=uiSize; - m_ctlDefaultMulti.SetCurSel(0); - } -} - -void CBufferSizeDlg::SetOneDiskSize(UINT uiSize) -{ - if ((uiSize % 1048576) == 0) - { - m_uiOneDiskSize=static_cast(uiSize/1048576); - m_ctlOneDiskMulti.SetCurSel(2); - } - else if ((uiSize % 1024) == 0) - { - m_uiOneDiskSize=static_cast(uiSize/1024); - m_ctlOneDiskMulti.SetCurSel(1); - } - else - { - m_uiOneDiskSize=uiSize; - m_ctlOneDiskMulti.SetCurSel(0); - } -} - -void CBufferSizeDlg::SetTwoDisksSize(UINT uiSize) -{ - if ((uiSize % 1048576) == 0) - { - m_uiTwoDisksSize=static_cast(uiSize/1048576); - m_ctlTwoDisksMulti.SetCurSel(2); - } - else if ((uiSize % 1024) == 0) - { - m_uiTwoDisksSize=static_cast(uiSize/1024); - m_ctlTwoDisksMulti.SetCurSel(1); - } - else - { - m_uiTwoDisksSize=uiSize; - m_ctlTwoDisksMulti.SetCurSel(0); - } -} - -void CBufferSizeDlg::SetCDSize(UINT uiSize) -{ - if ((uiSize % 1048576) == 0) - { - m_uiCDROMSize=static_cast(uiSize/1048576); - m_ctlCDROMMulti.SetCurSel(2); - } - else if ((uiSize % 1024) == 0) - { - m_uiCDROMSize=static_cast(uiSize/1024); - m_ctlCDROMMulti.SetCurSel(1); - } - else - { - m_uiCDROMSize=uiSize; - m_ctlCDROMMulti.SetCurSel(0); - } -} - -void CBufferSizeDlg::SetLANSize(UINT uiSize) -{ - if ((uiSize % 1048576) == 0) - { - m_uiLANSize=static_cast(uiSize/1048576); - m_ctlLANMulti.SetCurSel(2); - } - else if ((uiSize % 1024) == 0) - { - m_uiLANSize=static_cast(uiSize/1024); - m_ctlLANMulti.SetCurSel(1); - } - else - { - m_uiLANSize=uiSize; - m_ctlLANMulti.SetCurSel(0); - } -} - -void CBufferSizeDlg::EnableControls(bool bEnable) -{ - GetDlgItem(IDC_ONEDISKSIZE_EDIT)->EnableWindow(bEnable); - m_ctlOneDiskMulti.EnableWindow(bEnable); - GetDlgItem(IDC_TWODISKSSIZE_EDIT)->EnableWindow(bEnable); - m_ctlTwoDisksMulti.EnableWindow(bEnable); - GetDlgItem(IDC_CDROMSIZE_EDIT)->EnableWindow(bEnable); - m_ctlCDROMMulti.EnableWindow(bEnable); - GetDlgItem(IDC_LANSIZE_EDIT)->EnableWindow(bEnable); - m_ctlLANMulti.EnableWindow(bEnable); -} - -void CBufferSizeDlg::OnOnlydefaultCheck() -{ - UpdateData(TRUE); - EnableControls(m_bOnlyDefaultCheck == 0); -} Index: src/ch/BufferSizeDlg.h =================================================================== diff -u -N --- src/ch/BufferSizeDlg.h (revision 0) +++ src/ch/BufferSizeDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,85 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __BUFFERSIZEDLG_H__ +#define __BUFFERSIZEDLG_H__ + +#include "DataBuffer.h" + +///////////////////////////////////////////////////////////////////////////// +// CBufferSizeDlg dialog + +class CBufferSizeDlg : public CHLanguageDialog +{ +// Construction +public: + CBufferSizeDlg(); // standard constructor + + void SetLANSize(UINT uiSize); + void SetCDSize(UINT uiSize); + void SetTwoDisksSize(UINT uiSize); + void SetOneDiskSize(UINT uiSize); + void SetDefaultSize(UINT uiSize); + UINT IndexToValue(int iIndex); + + int m_iActiveIndex; + BUFFERSIZES m_bsSizes; + +// Dialog Data + //{{AFX_DATA(CBufferSizeDlg) + enum { IDD = IDD_BUFFERSIZE_DIALOG }; + CComboBox m_ctlTwoDisksMulti; + CComboBox m_ctlOneDiskMulti; + CComboBox m_ctlLANMulti; + CComboBox m_ctlDefaultMulti; + CComboBox m_ctlCDROMMulti; + UINT m_uiDefaultSize; + UINT m_uiLANSize; + UINT m_uiCDROMSize; + UINT m_uiOneDiskSize; + UINT m_uiTwoDisksSize; + BOOL m_bOnlyDefaultCheck; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBufferSizeDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + + void EnableControls(bool bEnable=true); + // Generated message map functions + //{{AFX_MSG(CBufferSizeDlg) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + afx_msg void OnOnlydefaultCheck(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/BufferSizeDlg.h =================================================================== diff -u -N --- ch/BufferSizeDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/BufferSizeDlg.h (revision 0) @@ -1,85 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __BUFFERSIZEDLG_H__ -#define __BUFFERSIZEDLG_H__ - -#include "DataBuffer.h" - -///////////////////////////////////////////////////////////////////////////// -// CBufferSizeDlg dialog - -class CBufferSizeDlg : public CHLanguageDialog -{ -// Construction -public: - CBufferSizeDlg(); // standard constructor - - void SetLANSize(UINT uiSize); - void SetCDSize(UINT uiSize); - void SetTwoDisksSize(UINT uiSize); - void SetOneDiskSize(UINT uiSize); - void SetDefaultSize(UINT uiSize); - UINT IndexToValue(int iIndex); - - int m_iActiveIndex; - BUFFERSIZES m_bsSizes; - -// Dialog Data - //{{AFX_DATA(CBufferSizeDlg) - enum { IDD = IDD_BUFFERSIZE_DIALOG }; - CComboBox m_ctlTwoDisksMulti; - CComboBox m_ctlOneDiskMulti; - CComboBox m_ctlLANMulti; - CComboBox m_ctlDefaultMulti; - CComboBox m_ctlCDROMMulti; - UINT m_uiDefaultSize; - UINT m_uiLANSize; - UINT m_uiCDROMSize; - UINT m_uiOneDiskSize; - UINT m_uiTwoDisksSize; - BOOL m_bOnlyDefaultCheck; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBufferSizeDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - - void EnableControls(bool bEnable=true); - // Generated message map functions - //{{AFX_MSG(CBufferSizeDlg) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnOnlydefaultCheck(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/CfgProperties.cpp =================================================================== diff -u -N --- src/ch/CfgProperties.cpp (revision 0) +++ src/ch/CfgProperties.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,113 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "CfgProperties.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +bool RegisterProperties(CConfigManager* pManager) +{ + pManager->RegisterBoolProperty(_T("Program"), _T("Enabled clipboard monitoring"), false); + pManager->RegisterIntProperty(_T("Program"), _T("Monitor scan interval"), 1000); + pManager->RegisterBoolProperty(_T("Program"), _T("Reload after restart"), false); + pManager->RegisterBoolProperty(_T("Program"), _T("Shutdown system after finished"), false); + pManager->RegisterIntProperty(_T("Program"), _T("Time before shutdown"), 10000); + pManager->RegisterBoolProperty(_T("Program"), _T("Force shutdown"), false); + pManager->RegisterIntProperty(_T("Program"), _T("Autosave interval"), 30000); + pManager->RegisterIntProperty(_T("Program"), _T("Process priority class"), NORMAL_PRIORITY_CLASS); + pManager->RegisterStringProperty(_T("Program"), _T("Autosave directory"), _T("\\"), RF_PATH); + pManager->RegisterStringProperty(_T("Program"), _T("Plugins directory"), _T("\\Plugins\\"), RF_PATH); + pManager->RegisterStringProperty(_T("Program"), _T("Help directory"), _T("\\Help\\"), RF_PATH); + pManager->RegisterStringProperty(_T("Program"), _T("Language"), _T("\\Langs\\English.lng")); + pManager->RegisterStringProperty(_T("Program"), _T("Languages directory"), _T("\\Langs\\"), RF_PATH); + + pManager->RegisterIntProperty(_T("Status dialog"), _T("Status refresh interval"), 1000); + pManager->RegisterBoolProperty(_T("Status dialog"), _T("Show details"), true); + pManager->RegisterBoolProperty(_T("Status dialog"), _T("Auto remove finished"), false); + + pManager->RegisterIntProperty(_T("Folder dialog"), _T("Dialog width"), -1); + pManager->RegisterIntProperty(_T("Folder dialog"), _T("Dialog height"), -1); + pManager->RegisterIntProperty(_T("Folder dialog"), _T("Shortcut list style"), 1); + pManager->RegisterBoolProperty(_T("Folder dialog"), _T("Extended view"), true); + pManager->RegisterBoolProperty(_T("Folder dialog"), _T("Ignore shell dialogs"), false); + + pManager->RegisterBoolProperty(_T("Mini view"), _T("Show filenames"), true); + pManager->RegisterBoolProperty(_T("Mini view"), _T("Show single tasks"), true); + pManager->RegisterIntProperty(_T("Mini view"), _T("Miniview refresh interval"), 200); + pManager->RegisterBoolProperty(_T("Mini view"), _T("Autoshow when run"), true); + pManager->RegisterBoolProperty(_T("Mini view"), _T("Autohide when empty"), true); + pManager->RegisterBoolProperty(_T("Mini view"), _T("Use smooth progress"), true); + + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Use auto-complete files"), true); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Always set destination attributes"), true); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Always set destination time"), true); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Protect read-only files"), false); + pManager->RegisterIntProperty(_T("Copying/moving"), _T("Limit max operations"), 1); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Read tasks size before blocking"), true); + pManager->RegisterIntProperty(_T("Copying/moving"), _T("Show visual feedback"), 2); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Use timed feedback dialogs"), false); + pManager->RegisterIntProperty(_T("Copying/moving"), _T("Feedback time"), 60000); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Auto retry on error"), true); + pManager->RegisterIntProperty(_T("Copying/moving"), _T("Auto retry interval"), 10000); + pManager->RegisterIntProperty(_T("Copying/moving"), _T("Default priority"), THREAD_PRIORITY_NORMAL); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Disable priority boost"), false); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Delete files after finished"), true); + pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Create log file"), true); + + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Move' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy/move special' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Paste' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Paste special' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy to' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Move to' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy to/Move to special' command"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show free space along with shortcut"), true); + pManager->RegisterBoolProperty(_T("Shell"), _T("Show shell icons in shortcuts menu"), false); + pManager->RegisterBoolProperty(_T("Shell"), _T("Use drag&drop default menu item override"), true); + pManager->RegisterIntProperty(_T("Shell"), _T("Default action when dragging"), 3); + + pManager->RegisterBoolProperty(_T("Buffer"), _T("Use only default buffer"), false); + pManager->RegisterIntProperty(_T("Buffer"), _T("Default buffer size"), 2097152); + pManager->RegisterIntProperty(_T("Buffer"), _T("One physical disk buffer size"), 4194304); + pManager->RegisterIntProperty(_T("Buffer"), _T("Two different hard disks buffer size"), 524288); + pManager->RegisterIntProperty(_T("Buffer"), _T("CD buffer size"), 262144); + pManager->RegisterIntProperty(_T("Buffer"), _T("LAN buffer size"), 131072); + pManager->RegisterBoolProperty(_T("Buffer"), _T("Use no buffering for large files"), true); + pManager->RegisterIntProperty(_T("Buffer"), _T("Large files lower boundary limit"), 2097152); + + pManager->RegisterStringProperty(_T("Log file"), _T("Path to main log file"), _T("\\ch.log")); + pManager->RegisterBoolProperty(_T("Log file"), _T("Enable logging"), true); + pManager->RegisterBoolProperty(_T("Log file"), _T("Enable log size limitation"), true); + pManager->RegisterIntProperty(_T("Log file"), _T("Max log size limit"), 65535); + pManager->RegisterBoolProperty(_T("Log file"), _T("Precise log size limiting"), false); + pManager->RegisterIntProperty(_T("Log file"), _T("Truncation buffer size"), 65535, PDL_PARANOID); + + pManager->RegisterBoolProperty(_T("Sounds"), _T("Play sounds"), true); + pManager->RegisterStringProperty(_T("Sounds"), _T("Error sound path"), _T("\\media\\chord.wav")); + pManager->RegisterStringProperty(_T("Sounds"), _T("Finished sound path"), _T("\\media\\ding.wav")); + + pManager->RegisterStringArrayProperty(_T("Shortcuts")); + pManager->RegisterStringArrayProperty(_T("Recent paths")); + + return true; +} Index: ch/CfgProperties.cpp =================================================================== diff -u -N --- ch/CfgProperties.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/CfgProperties.cpp (revision 0) @@ -1,113 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "CfgProperties.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -bool RegisterProperties(CConfigManager* pManager) -{ - pManager->RegisterBoolProperty(_T("Program"), _T("Enabled clipboard monitoring"), false); - pManager->RegisterIntProperty(_T("Program"), _T("Monitor scan interval"), 1000); - pManager->RegisterBoolProperty(_T("Program"), _T("Reload after restart"), false); - pManager->RegisterBoolProperty(_T("Program"), _T("Shutdown system after finished"), false); - pManager->RegisterIntProperty(_T("Program"), _T("Time before shutdown"), 10000); - pManager->RegisterBoolProperty(_T("Program"), _T("Force shutdown"), false); - pManager->RegisterIntProperty(_T("Program"), _T("Autosave interval"), 30000); - pManager->RegisterIntProperty(_T("Program"), _T("Process priority class"), NORMAL_PRIORITY_CLASS); - pManager->RegisterStringProperty(_T("Program"), _T("Autosave directory"), _T("\\"), RF_PATH); - pManager->RegisterStringProperty(_T("Program"), _T("Plugins directory"), _T("\\Plugins\\"), RF_PATH); - pManager->RegisterStringProperty(_T("Program"), _T("Help directory"), _T("\\Help\\"), RF_PATH); - pManager->RegisterStringProperty(_T("Program"), _T("Language"), _T("\\Langs\\English.lng")); - pManager->RegisterStringProperty(_T("Program"), _T("Languages directory"), _T("\\Langs\\"), RF_PATH); - - pManager->RegisterIntProperty(_T("Status dialog"), _T("Status refresh interval"), 1000); - pManager->RegisterBoolProperty(_T("Status dialog"), _T("Show details"), true); - pManager->RegisterBoolProperty(_T("Status dialog"), _T("Auto remove finished"), false); - - pManager->RegisterIntProperty(_T("Folder dialog"), _T("Dialog width"), -1); - pManager->RegisterIntProperty(_T("Folder dialog"), _T("Dialog height"), -1); - pManager->RegisterIntProperty(_T("Folder dialog"), _T("Shortcut list style"), 1); - pManager->RegisterBoolProperty(_T("Folder dialog"), _T("Extended view"), true); - pManager->RegisterBoolProperty(_T("Folder dialog"), _T("Ignore shell dialogs"), false); - - pManager->RegisterBoolProperty(_T("Mini view"), _T("Show filenames"), true); - pManager->RegisterBoolProperty(_T("Mini view"), _T("Show single tasks"), true); - pManager->RegisterIntProperty(_T("Mini view"), _T("Miniview refresh interval"), 200); - pManager->RegisterBoolProperty(_T("Mini view"), _T("Autoshow when run"), true); - pManager->RegisterBoolProperty(_T("Mini view"), _T("Autohide when empty"), true); - pManager->RegisterBoolProperty(_T("Mini view"), _T("Use smooth progress"), true); - - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Use auto-complete files"), true); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Always set destination attributes"), true); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Always set destination time"), true); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Protect read-only files"), false); - pManager->RegisterIntProperty(_T("Copying/moving"), _T("Limit max operations"), 1); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Read tasks size before blocking"), true); - pManager->RegisterIntProperty(_T("Copying/moving"), _T("Show visual feedback"), 2); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Use timed feedback dialogs"), false); - pManager->RegisterIntProperty(_T("Copying/moving"), _T("Feedback time"), 60000); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Auto retry on error"), true); - pManager->RegisterIntProperty(_T("Copying/moving"), _T("Auto retry interval"), 10000); - pManager->RegisterIntProperty(_T("Copying/moving"), _T("Default priority"), THREAD_PRIORITY_NORMAL); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Disable priority boost"), false); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Delete files after finished"), true); - pManager->RegisterBoolProperty(_T("Copying/moving"), _T("Create log file"), true); - - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Move' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy/move special' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Paste' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Paste special' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy to' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Move to' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show 'Copy to/Move to special' command"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show free space along with shortcut"), true); - pManager->RegisterBoolProperty(_T("Shell"), _T("Show shell icons in shortcuts menu"), false); - pManager->RegisterBoolProperty(_T("Shell"), _T("Use drag&drop default menu item override"), true); - pManager->RegisterIntProperty(_T("Shell"), _T("Default action when dragging"), 3); - - pManager->RegisterBoolProperty(_T("Buffer"), _T("Use only default buffer"), false); - pManager->RegisterIntProperty(_T("Buffer"), _T("Default buffer size"), 2097152); - pManager->RegisterIntProperty(_T("Buffer"), _T("One physical disk buffer size"), 4194304); - pManager->RegisterIntProperty(_T("Buffer"), _T("Two different hard disks buffer size"), 524288); - pManager->RegisterIntProperty(_T("Buffer"), _T("CD buffer size"), 262144); - pManager->RegisterIntProperty(_T("Buffer"), _T("LAN buffer size"), 131072); - pManager->RegisterBoolProperty(_T("Buffer"), _T("Use no buffering for large files"), true); - pManager->RegisterIntProperty(_T("Buffer"), _T("Large files lower boundary limit"), 2097152); - - pManager->RegisterStringProperty(_T("Log file"), _T("Path to main log file"), _T("\\ch.log")); - pManager->RegisterBoolProperty(_T("Log file"), _T("Enable logging"), true); - pManager->RegisterBoolProperty(_T("Log file"), _T("Enable log size limitation"), true); - pManager->RegisterIntProperty(_T("Log file"), _T("Max log size limit"), 65535); - pManager->RegisterBoolProperty(_T("Log file"), _T("Precise log size limiting"), false); - pManager->RegisterIntProperty(_T("Log file"), _T("Truncation buffer size"), 65535, PDL_PARANOID); - - pManager->RegisterBoolProperty(_T("Sounds"), _T("Play sounds"), true); - pManager->RegisterStringProperty(_T("Sounds"), _T("Error sound path"), _T("\\media\\chord.wav")); - pManager->RegisterStringProperty(_T("Sounds"), _T("Finished sound path"), _T("\\media\\ding.wav")); - - pManager->RegisterStringArrayProperty(_T("Shortcuts")); - pManager->RegisterStringArrayProperty(_T("Recent paths")); - - return true; -} Index: src/ch/CfgProperties.h =================================================================== diff -u -N --- src/ch/CfgProperties.h (revision 0) +++ src/ch/CfgProperties.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,112 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __PROPERTYTYPES_H__ +#define __PROPERTYTYPES_H__ + +#pragma once + +// properties definitions +#define PP_PCLIPBOARDMONITORING 0 +#define PP_PMONITORSCANINTERVAL 1 +#define PP_PRELOADAFTERRESTART 2 +#define PP_PSHUTDOWNAFTREFINISHED 3 +#define PP_PTIMEBEFORESHUTDOWN 4 +#define PP_PFORCESHUTDOWN 5 +#define PP_PAUTOSAVEINTERVAL 6 +#define PP_PPROCESSPRIORITYCLASS 7 +#define PP_PAUTOSAVEDIRECTORY 8 +#define PP_PPLUGINSDIR 9 +#define PP_PHELPDIR 10 +#define PP_PLANGUAGE 11 +#define PP_PLANGDIR 12 + +#define PP_STATUSREFRESHINTERVAL 13 +#define PP_STATUSSHOWDETAILS 14 +#define PP_STATUSAUTOREMOVEFINISHED 15 + +#define PP_FDWIDTH 16 +#define PP_FDHEIGHT 17 +#define PP_FDSHORTCUTLISTSTYLE 18 +#define PP_FDEXTENDEDVIEW 19 +#define PP_FDIGNORESHELLDIALOGS 20 + +#define PP_MVSHOWFILENAMES 21 +#define PP_MVSHOWSINGLETASKS 22 +#define PP_MVREFRESHINTERVAL 23 +#define PP_MVAUTOSHOWWHENRUN 24 +#define PP_MVAUTOHIDEWHENEMPTY 25 +#define PP_MVUSESMOOTHPROGRESS 26 + +#define PP_CMUSEAUTOCOMPLETEFILES 27 +#define PP_CMSETDESTATTRIBUTES 28 +#define PP_CMSETDESTDATE 29 +#define PP_CMPROTECTROFILES 30 +#define PP_CMLIMITMAXOPERATIONS 31 +#define PP_CMREADSIZEBEFOREBLOCKING 32 +#define PP_CMSHOWVISUALFEEDBACK 33 +#define PP_CMUSETIMEDFEEDBACK 34 +#define PP_CMFEEDBACKTIME 35 +#define PP_CMAUTORETRYONERROR 36 +#define PP_CMAUTORETRYINTERVAL 37 +#define PP_CMDEFAULTPRIORITY 38 +#define PP_CMDISABLEPRIORITYBOOST 39 +#define PP_CMDELETEAFTERFINISHED 40 +#define PP_CMCREATELOG 41 + +#define PP_SHSHOWCOPY 42 +#define PP_SHSHOWMOVE 43 +#define PP_SHSHOWCOPYMOVE 44 +#define PP_SHSHOWPASTE 45 +#define PP_SHSHOWPASTESPECIAL 46 +#define PP_SHSHOWCOPYTO 47 +#define PP_SHSHOWMOVETO 48 +#define PP_SHSHOWCOPYMOVETO 49 +#define PP_SHSHOWFREESPACE 50 +#define PP_SHSHOWSHELLICONS 51 +#define PP_SHUSEDRAGDROP 52 +#define PP_SHDEFAULTACTION 53 + +#define PP_BFUSEONLYDEFAULT 54 +#define PP_BFDEFAULT 55 +#define PP_BFONEDISK 56 +#define PP_BFTWODISKS 57 +#define PP_BFCD 58 +#define PP_BFLAN 59 +#define PP_BFUSENOBUFFERING 60 +#define PP_BFBOUNDARYLIMIT 61 + +#define PP_LOGPATH 62 +#define PP_LOGENABLELOGGING 63 +#define PP_LOGLIMITATION 64 +#define PP_LOGMAXLIMIT 65 +#define PP_LOGPRECISELIMITING 66 +#define PP_LOGTRUNCBUFFERSIZE 67 + +#define PP_SNDPLAYSOUNDS 68 +#define PP_SNDERRORSOUNDPATH 69 +#define PP_SNDFINISHEDSOUNDPATH 70 + +#define PP_SHORTCUTS 71 +#define PP_RECENTPATHS 72 + +// register function +bool RegisterProperties(CConfigManager* pManager); + +#endif \ No newline at end of file Index: ch/CfgProperties.h =================================================================== diff -u -N --- ch/CfgProperties.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/CfgProperties.h (revision 0) @@ -1,112 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PROPERTYTYPES_H__ -#define __PROPERTYTYPES_H__ - -#pragma once - -// properties definitions -#define PP_PCLIPBOARDMONITORING 0 -#define PP_PMONITORSCANINTERVAL 1 -#define PP_PRELOADAFTERRESTART 2 -#define PP_PSHUTDOWNAFTREFINISHED 3 -#define PP_PTIMEBEFORESHUTDOWN 4 -#define PP_PFORCESHUTDOWN 5 -#define PP_PAUTOSAVEINTERVAL 6 -#define PP_PPROCESSPRIORITYCLASS 7 -#define PP_PAUTOSAVEDIRECTORY 8 -#define PP_PPLUGINSDIR 9 -#define PP_PHELPDIR 10 -#define PP_PLANGUAGE 11 -#define PP_PLANGDIR 12 - -#define PP_STATUSREFRESHINTERVAL 13 -#define PP_STATUSSHOWDETAILS 14 -#define PP_STATUSAUTOREMOVEFINISHED 15 - -#define PP_FDWIDTH 16 -#define PP_FDHEIGHT 17 -#define PP_FDSHORTCUTLISTSTYLE 18 -#define PP_FDEXTENDEDVIEW 19 -#define PP_FDIGNORESHELLDIALOGS 20 - -#define PP_MVSHOWFILENAMES 21 -#define PP_MVSHOWSINGLETASKS 22 -#define PP_MVREFRESHINTERVAL 23 -#define PP_MVAUTOSHOWWHENRUN 24 -#define PP_MVAUTOHIDEWHENEMPTY 25 -#define PP_MVUSESMOOTHPROGRESS 26 - -#define PP_CMUSEAUTOCOMPLETEFILES 27 -#define PP_CMSETDESTATTRIBUTES 28 -#define PP_CMSETDESTDATE 29 -#define PP_CMPROTECTROFILES 30 -#define PP_CMLIMITMAXOPERATIONS 31 -#define PP_CMREADSIZEBEFOREBLOCKING 32 -#define PP_CMSHOWVISUALFEEDBACK 33 -#define PP_CMUSETIMEDFEEDBACK 34 -#define PP_CMFEEDBACKTIME 35 -#define PP_CMAUTORETRYONERROR 36 -#define PP_CMAUTORETRYINTERVAL 37 -#define PP_CMDEFAULTPRIORITY 38 -#define PP_CMDISABLEPRIORITYBOOST 39 -#define PP_CMDELETEAFTERFINISHED 40 -#define PP_CMCREATELOG 41 - -#define PP_SHSHOWCOPY 42 -#define PP_SHSHOWMOVE 43 -#define PP_SHSHOWCOPYMOVE 44 -#define PP_SHSHOWPASTE 45 -#define PP_SHSHOWPASTESPECIAL 46 -#define PP_SHSHOWCOPYTO 47 -#define PP_SHSHOWMOVETO 48 -#define PP_SHSHOWCOPYMOVETO 49 -#define PP_SHSHOWFREESPACE 50 -#define PP_SHSHOWSHELLICONS 51 -#define PP_SHUSEDRAGDROP 52 -#define PP_SHDEFAULTACTION 53 - -#define PP_BFUSEONLYDEFAULT 54 -#define PP_BFDEFAULT 55 -#define PP_BFONEDISK 56 -#define PP_BFTWODISKS 57 -#define PP_BFCD 58 -#define PP_BFLAN 59 -#define PP_BFUSENOBUFFERING 60 -#define PP_BFBOUNDARYLIMIT 61 - -#define PP_LOGPATH 62 -#define PP_LOGENABLELOGGING 63 -#define PP_LOGLIMITATION 64 -#define PP_LOGMAXLIMIT 65 -#define PP_LOGPRECISELIMITING 66 -#define PP_LOGTRUNCBUFFERSIZE 67 - -#define PP_SNDPLAYSOUNDS 68 -#define PP_SNDERRORSOUNDPATH 69 -#define PP_SNDFINISHEDSOUNDPATH 70 - -#define PP_SHORTCUTS 71 -#define PP_RECENTPATHS 72 - -// register function -bool RegisterProperties(CConfigManager* pManager); - -#endif \ No newline at end of file Index: src/ch/ConfigManager.cpp =================================================================== diff -u -N --- src/ch/ConfigManager.cpp (revision 0) +++ src/ch/ConfigManager.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,806 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "ConfigManager.h" +#ifndef DISABLE_CRYPT +#include "crypt.h" +#include "conv.h" +#endif + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define CFG_PROFILE _T("Common") +#define CFG_SECTION _T("Config") +#define CFG_KEY _T("Current configuration name") +#define CFG_DEFAULTSECTION _T("Default") + +#define CFG_MAXCOMPOUND 500 /* max count of items in a compound property */ + +/////////////////////////////////////////////////////////////// +// Opens configuration file. +// This function should be called only once - isn't thread safe +// Doesn't throw any file exception. If physical file couldn't +// be opened - this class does not require it. Could work +// without saving options to file, or with read-only files. +// pszFilename [in] - path to the configuration file +/////////////////////////////////////////////////////////////// +void CConfigManager::Open(LPCTSTR pszFilename) +{ + // load text file, and process it in ini file + try + { + ((CIniFile*)this)->Open(pszFilename, NULL, false); + } + catch(CFileExceptionEx* e) + { + // report error + TCHAR szData[1024]; + szData[1023]=_T('\0'); + _sntprintf(szData, 1023, _T("[Config Manager]: Couldn't open file %s to read initial data;\r\n\tReason: %s."), pszFilename, e->m_pszReason); + Report(szData); + + delete e; // get rid of this exception (file works doesn't work) + + // file couldn't be loaded... - create default section + m_pszCurrentConfig=new TCHAR[8]; + _tcscpy(m_pszCurrentConfig, CFG_DEFAULTSECTION); + SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); + return; + } + + // now - read current config name from cfg + if (!GetStr(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_szBuffer, _T(""))) + { + // current config not found - the first found would be current + vector<_PROFILE*>::const_iterator it=m_vConfigProfiles.begin(); + + while (it != m_vConfigProfiles.end()) + { + // check if element 0 isn't + if (_tcsicmp((*it)->pszProfileName, CFG_PROFILE) != 0) + { + // set current cfg to the found one + m_pszCurrentConfig=new TCHAR[_tcslen((*it)->pszProfileName)+1]; + _tcscpy(m_pszCurrentConfig, (*it)->pszProfileName); + + // save current selection + SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); + break; // we've found what was needed - stop processing + } + it++; + } + + // if not found - create default + if (m_pszCurrentConfig == NULL) + { + m_pszCurrentConfig=new TCHAR[8]; + _tcscpy(m_pszCurrentConfig, CFG_DEFAULTSECTION); + SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); + } + } + else + { + // section found - copy it + m_pszCurrentConfig=new TCHAR[_tcslen(m_szBuffer)+1]; + _tcscpy(m_pszCurrentConfig, m_szBuffer); + } +} + +/////////////////////////////////////////////////////////////// +// Tries to save settings to the configuration file. If +// couldn't be saved - function reports it through Report func +// and doesn't save data to file (this allows to use read-only +// attribute on config file). +/////////////////////////////////////////////////////////////// +void CConfigManager::Save() +{ + EnterCriticalSection(&m_cs); + // copy data into ini file object + vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); + while (it != m_vCfgData.end()) + WriteProperty(*it++); + + // save file + try + { + ((CIniFile*)this)->Save(); + } + catch(CFileExceptionEx* e) + { + TCHAR szData[1024]; + e->GetInfo(_T("[Config Manager]: Couldn't save configuration file."), szData, 1024); + Report(szData); + delete e; + + LeaveCriticalSection(&m_cs); + return; + } + catch(...) + { + LeaveCriticalSection(&m_cs); + throw; + } + + LeaveCriticalSection(&m_cs); +} + +/////////////////////////////////////////////////////////////// +// Closes this configuration file (saves data before closing). +// If couldn't be saved/closed - it reports the fact and allows +// to continue (allows usage of read-only files). +/////////////////////////////////////////////////////////////// +void CConfigManager::Close() +{ + // store all data into .ini object + EnterCriticalSection(&m_cs); + vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); + while (it != m_vCfgData.end()) + { + WriteProperty(*it); + FreeEntry(*it++); + } + + // free all + m_vCfgData.clear(); + + // free current config name + delete [] m_pszCurrentConfig; + m_pszCurrentConfig=NULL; + + // destroy base... + try + { + ((CIniFile*)this)->Close(); // storing data, closing file in a base class + } + catch(CFileExceptionEx* e) + { + TCHAR szData[1024]; + e->GetInfo(_T("[Config Manager]: Couldn't properly save/close file."), szData, 1024); + Report(szData); + + delete e; + + LeaveCriticalSection(&m_cs); + return; + } + catch(...) + { + LeaveCriticalSection(&m_cs); + throw; + } + + LeaveCriticalSection(&m_cs); +} + +#ifndef DISABLE_CRYPT +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CConfigManager::SetPassword(PCTSTR pszPass) +{ + // gen new 256b password + TCHAR szNewPass[64+1], szLine[8192]; + StringToKey256(pszPass, szNewPass); + + // recrypt the old data if needed + if (m_pszPassword) + { + // if there already was a password + for (vector<_CFGENTRY*>::iterator it=m_vCfgData.begin();it!=m_vCfgData.end();it++) + { + // reencrypt every encrypted item + if ((*it)->dwFlags & RF_ENCRYPTED && (*it)->cType == PT_STRING) + { + // decrypt the old data + if (AES256DecipherString((*it)->val.pszValue, m_pszPassword, szLine) < 0) + continue; + + // encrypt to the new one + if (AES256CipherString(szLine, szNewPass, szLine) < 0) + continue; + + // store the new value + delete [] (*it)->val.pszValue; + (*it)->val.pszValue=new TCHAR[_tcslen(szLine)+1]; + _tcscpy((*it)->val.pszValue, szLine); + (*it)->bModified=true; // set the modified flag + } + } + + delete [] m_pszPassword; // delete old password + } + m_pszPassword=new TCHAR[64+1]; + _tcscpy(m_pszPassword, szNewPass); +} + +#endif +/////////////////////////////////////////////////////////////// +// Registers some property given filled _CFGENTRY struct. +// pEntry [in] - specifies all possible information about the +// attribute being registered. +// Ret Value [out] - ID of registered property. It must be +// used when accessing this property. +/////////////////////////////////////////////////////////////// +UINT CConfigManager::RegisterProperty(_CFGENTRY* pEntry) +{ + _ASSERT(pEntry != NULL); + + EnterCriticalSection(&m_cs); + ReadProperty(pEntry); + m_vCfgData.push_back(pEntry); + UINT uiRet=(UINT)(m_vCfgData.size()-1); + LeaveCriticalSection(&m_cs); + return uiRet; +} + +/////////////////////////////////////////////////////////////// +// Registers int64 property. +// pszSection [in] - section in which resides given property +// pszKey [in] - key in which resides given property +// llDefault [in] - default value of this property (used if the +// config file doesn't contain it) +// cDetailLevel [in] - specifies "level" of this property. It +// could be simple property (for all users) or +// something that only some paranoics will use. +// Ret Value [out] - ID of registered property. It must be +// used when accessing this property. +/////////////////////////////////////////////////////////////// +UINT CConfigManager::RegisterInt64Property(LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, char cDetailLevel) +{ + // create config entry + _CFGENTRY* pcfg=new _CFGENTRY; + pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(pcfg->pszSection, pszSection); + pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; + _tcscpy(pcfg->pszKey, pszKey); + pcfg->cType=PT_INT64; + pcfg->def.llValue=llDefault; + pcfg->bModified=false; + pcfg->cDetailLevel=cDetailLevel; + pcfg->dwFlags=RF_NONE; + + // register + return RegisterProperty(pcfg); +} + +/////////////////////////////////////////////////////////////// +// Registers int property. +// pszSection [in] - section in which resides given property +// pszKey [in] - key in which resides given property +// iDefault [in] - default value of this property (used if the +// config file doesn't contain it) +// cDetailLevel [in] - specifies "level" of this property. It +// could be simple property (for all users) or +// something that only some paranoics will use. +// Ret Value [out] - ID of registered property. It must be +// used when accessing this property. +/////////////////////////////////////////////////////////////// +UINT CConfigManager::RegisterIntProperty(LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, char cDetailLevel) +{ + // create config entry + _CFGENTRY* pcfg=new _CFGENTRY; + pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(pcfg->pszSection, pszSection); + pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; + _tcscpy(pcfg->pszKey, pszKey); + pcfg->cType=PT_INT; + pcfg->def.iValue=iDefault; + pcfg->bModified=false; + pcfg->cDetailLevel=cDetailLevel; + pcfg->dwFlags=RF_NONE; + + // register + return RegisterProperty(pcfg); +} + +/////////////////////////////////////////////////////////////// +// Registers bool property. +// pszSection [in] - section in which resides given property +// pszKey [in] - key in which resides given property +// bDefault [in] - default value of this property (used if the +// config file doesn't contain it) +// cDetailLevel [in] - specifies "level" of this property. It +// could be simple property (for all users) or +// something that only some paranoics will use. +// Ret Value [out] - ID of registered property. It must be +// used when accessing this property. +/////////////////////////////////////////////////////////////// +UINT CConfigManager::RegisterBoolProperty(LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, char cDetailLevel) +{ + // create config entry + _CFGENTRY* pcfg=new _CFGENTRY; + pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(pcfg->pszSection, pszSection); + pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; + _tcscpy(pcfg->pszKey, pszKey); + pcfg->cType=PT_BOOL; + pcfg->def.bValue=bDefault; + pcfg->bModified=false; + pcfg->cDetailLevel=cDetailLevel; + pcfg->dwFlags=RF_NONE; + + // register + return RegisterProperty(pcfg); +} + +/////////////////////////////////////////////////////////////// +// Registers string property. +// pszSection [in] - section in which resides given property +// pszKey [in] - key in which resides given property +// pszDefault [in] - default value of this property (used if +// the config file doesn't contain it) +// cDetailLevel [in] - specifies "level" of this property. It +// could be simple property (for all users) or +// something that only some paranoics will use. +// Ret Value [out] - ID of registered property. It must be +// used when accessing this property. +/////////////////////////////////////////////////////////////// +UINT CConfigManager::RegisterStringProperty(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault, DWORD dwFlags, char cDetailLevel) +{ + // create config entry + _CFGENTRY* pcfg=new _CFGENTRY; + pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(pcfg->pszSection, pszSection); + pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; + _tcscpy(pcfg->pszKey, pszKey); + pcfg->cType=PT_STRING; + pcfg->def.pszValue=new TCHAR[_tcslen(pszDefault)+1]; + _tcscpy(pcfg->def.pszValue, pszDefault); + pcfg->bModified=false; + pcfg->cDetailLevel=cDetailLevel; + pcfg->dwFlags=dwFlags; + + // register + return RegisterProperty(pcfg); +} + +UINT CConfigManager::RegisterStringArrayProperty(LPCTSTR pszSection, char cDetailLevel) +{ + _CFGENTRY* pcfg=new _CFGENTRY; + pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(pcfg->pszSection, pszSection); + pcfg->pszKey=NULL; + pcfg->cType=PT_ASTRING; + pcfg->bModified=false; + pcfg->cDetailLevel=cDetailLevel; + pcfg->val.pvszValue=new char_vector; + pcfg->dwFlags=RF_NONE; + + return RegisterProperty(pcfg); +} + +/////////////////////////////////////////////////////////////// +// Returns value of int property given property ID +// uiPropID [in] - property ID (returned by RegisterProperty..) +// Ret Value [out] - value of this property (either from file +// or the default one specified at registration) +/////////////////////////////////////////////////////////////// +int CConfigManager::GetIntValue(UINT uiPropID) +{ + EnterCriticalSection(&m_cs); + int iRet=m_vCfgData.at(uiPropID)->val.iValue; + LeaveCriticalSection(&m_cs); + return iRet; +} + +/////////////////////////////////////////////////////////////// +// Sets value of a given property (by it's ID) +// uiPropID [in] - property ID (returned by RegisterProperty..) +// iValue [in] - the new value of this property +/////////////////////////////////////////////////////////////// +void CConfigManager::SetIntValue(UINT uiPropID, int iValue) +{ + EnterCriticalSection(&m_cs); + m_vCfgData.at(uiPropID)->val.iValue=iValue; + m_vCfgData.at(uiPropID)->bModified=true; + LeaveCriticalSection(&m_cs); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); +} + +/////////////////////////////////////////////////////////////// +// Returns value of int64 property given property ID +// uiPropID [in] - property ID (returned by RegisterProperty..) +// Ret Value [out] - value of this property (either from file +// or the default one specified at registration) +/////////////////////////////////////////////////////////////// +__int64 CConfigManager::GetInt64Value(UINT uiPropID) +{ + EnterCriticalSection(&m_cs); + __int64 llRet=m_vCfgData.at(uiPropID)->val.llValue; + LeaveCriticalSection(&m_cs); + return llRet; +} + +/////////////////////////////////////////////////////////////// +// Sets value of a given property (by it's ID) +// uiPropID [in] - property ID (returned by RegisterProperty..) +// llValue [in] - the new value of this property +/////////////////////////////////////////////////////////////// +void CConfigManager::SetInt64Value(UINT uiPropID, __int64 llValue) +{ + EnterCriticalSection(&m_cs); + m_vCfgData.at(uiPropID)->val.llValue=llValue; + m_vCfgData.at(uiPropID)->bModified=true; + LeaveCriticalSection(&m_cs); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); +} + +/////////////////////////////////////////////////////////////// +// Returns value of bool property given property ID +// uiPropID [in] - property ID (returned by RegisterProperty..) +// Ret Value [out] - value of this property (either from file +// or the default one specified at registration) +/////////////////////////////////////////////////////////////// +bool CConfigManager::GetBoolValue(UINT uiPropID) +{ + EnterCriticalSection(&m_cs); + bool bRet=m_vCfgData.at(uiPropID)->val.bValue; + LeaveCriticalSection(&m_cs); + return bRet; +} + +/////////////////////////////////////////////////////////////// +// Sets value of a given property (by it's ID) +// uiPropID [in] - property ID (returned by RegisterProperty..) +// bValue [in] - the new value of this property +/////////////////////////////////////////////////////////////// +void CConfigManager::SetBoolValue(UINT uiPropID, bool bValue) +{ + EnterCriticalSection(&m_cs); + m_vCfgData.at(uiPropID)->val.bValue=bValue; + m_vCfgData.at(uiPropID)->bModified=true; + LeaveCriticalSection(&m_cs); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); +} + +/////////////////////////////////////////////////////////////// +// Returns value of string property given property ID +// uiPropID [in] - property ID (returned by RegisterProperty..) +// Ret Value [out] - value of this property (either from file +// or the default one specified at registration) +/////////////////////////////////////////////////////////////// +PCTSTR CConfigManager::GetStringValue(UINT uiPropID, PTSTR pszBuffer, int iSize) +{ + EnterCriticalSection(&m_cs); + +#ifndef DISABLE_CRYPT + if (m_vCfgData.at(uiPropID)->dwFlags & RF_ENCRYPTED) + { + // make sure password has been set already + _ASSERT(m_pszPassword); + + TCHAR szLine[8192]; + if (AES256DecipherString(m_vCfgData.at(uiPropID)->val.pszValue, m_pszPassword, szLine) <= 0) + { + // return + _tcscpy(pszBuffer, _T("")); + LeaveCriticalSection(&m_cs); + return pszBuffer; + } + + // copy the decrypted data + _tcsncpy(pszBuffer, szLine, iSize); + pszBuffer[iSize-1]=_T('\0'); + } + else +#endif + _tcsncpy(pszBuffer, m_vCfgData.at(uiPropID)->val.pszValue, iSize); + + if (m_vCfgData.at(uiPropID)->dwFlags & RF_PATH) + { + if (pszBuffer[_tcslen(pszBuffer)-1] != _T('\\')) + _tcscat(pszBuffer, _T("\\")); + } + + LeaveCriticalSection(&m_cs); + + return pszBuffer; +} + +/////////////////////////////////////////////////////////////// +// Sets value of a given property (by it's ID) +// uiPropID [in] - property ID (returned by RegisterProperty..) +// pszValue [in] - the new value of this property +/////////////////////////////////////////////////////////////// +void CConfigManager::SetStringValue(UINT uiPropID, LPCTSTR pszValue) +{ + EnterCriticalSection(&m_cs); +#ifndef DISABLE_CRYPT + // encrypt the data before setting the property text + if (m_vCfgData.at(uiPropID)->dwFlags & RF_ENCRYPTED) + { + // make sure password has been set already + _ASSERT(m_pszPassword); + + TCHAR szLine[8192]; + if (AES256CipherString(pszValue, m_pszPassword, szLine) < 0) + { + _ASSERT(false); + TRACE("Cannot cipher string - what to do ????\n"); + } + + // store encrypted value + delete [] m_vCfgData.at(uiPropID)->val.pszValue; // delete old value + m_vCfgData.at(uiPropID)->val.pszValue=new TCHAR[_tcslen(szLine)+1]; // create space for new + _tcscpy(m_vCfgData.at(uiPropID)->val.pszValue, szLine); // copy the new one + m_vCfgData.at(uiPropID)->bModified=true; // modified state + } + else + { +#endif + delete [] m_vCfgData.at(uiPropID)->val.pszValue; // delete old value + m_vCfgData.at(uiPropID)->val.pszValue=new TCHAR[_tcslen(pszValue)+1]; // create space for new + _tcscpy(m_vCfgData.at(uiPropID)->val.pszValue, pszValue); // copy the new one + m_vCfgData.at(uiPropID)->bModified=true; // modified state +#ifndef DISABLE_CRYPT + } +#endif + LeaveCriticalSection(&m_cs); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); +} + +void CConfigManager::GetStringArrayValue(UINT uiPropID, char_vector* pcVector) +{ + EnterCriticalSection(&m_cs); + _CFGENTRY* pentry=m_vCfgData.at(uiPropID); + pcVector->assign(pentry->val.pvszValue->begin(), pentry->val.pvszValue->end(), true, true); + LeaveCriticalSection(&m_cs); +} + +void CConfigManager::SetStringArrayValue(UINT uiPropID, char_vector* pcVector) +{ + EnterCriticalSection(&m_cs); + _CFGENTRY* pentry=m_vCfgData.at(uiPropID); + pentry->val.pvszValue->assign(pcVector->begin(), pcVector->end(), true, true); + LeaveCriticalSection(&m_cs); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); +} + +/////////////////////////////////////////////////////////////// +// Selects new profile +// pszCfgName [in] - new profile name +/////////////////////////////////////////////////////////////// +void CConfigManager::SelectProfile(LPCTSTR pszCfgName) +{ + // store config into ini file + vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); + while (it != m_vCfgData.end()) + WriteProperty(*it++); + + // change config + delete [] m_pszCurrentConfig; + m_pszCurrentConfig=new TCHAR[_tcslen(pszCfgName)+1]; + _tcscpy(m_pszCurrentConfig, pszCfgName); + + // read data from ini file + it=m_vCfgData.begin(); + while (it != m_vCfgData.end()) + ReadProperty(*it++); + + // set data in ini file + SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, pszCfgName); + + if (m_pfnCallback) + (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROFILECHANGE, (LPARAM)pszCfgName); +} + +/////////////////////////////////////////////////////////////// +// (Internal) Frees one of the profile entries +// pEntry [in] - address of profile entry +/////////////////////////////////////////////////////////////// +void CConfigManager::FreeEntry(_CFGENTRY* pEntry) +{ + // free section and key + delete [] pEntry->pszSection; + delete [] pEntry->pszKey; + + // if this is a string property - free it + switch(pEntry->cType) + { + case PT_STRING: + delete [] pEntry->def.pszValue; + delete [] pEntry->val.pszValue; + break; + case PT_ASTRING: + { + pEntry->val.pvszValue->clear(true); + delete pEntry->val.pvszValue; + break; + } + } + + // last - delete object itself + delete pEntry; +} + +/////////////////////////////////////////////////////////////// +// Reads value of a given property entry from .ini file +// pEntry [in] - filled property entry structure +/////////////////////////////////////////////////////////////// +void CConfigManager::ReadProperty(_CFGENTRY* pEntry) +{ + // process each attribute + switch (pEntry->cType) + { + case PT_INT64: + { + pEntry->val.llValue=GetInt64(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.llValue, m_szBuffer); + break; + } + case PT_STRING: + { + GetString(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, m_szBuffer, pEntry->def.pszValue); + pEntry->val.pszValue=new TCHAR[_tcslen(m_szBuffer)+1]; + _tcscpy(pEntry->val.pszValue, m_szBuffer); + break; + } + case PT_BOOL: + { + pEntry->val.bValue=GetBool(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.bValue, m_szBuffer); + break; + } + case PT_INT: + { + pEntry->val.iValue=GetInt(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.iValue, m_szBuffer); + break; + } + case PT_ASTRING: + { + TCHAR szNum[8]; + for (int i=0;ipszSection, szNum, m_szBuffer, _T(""))) + pEntry->val.pvszValue->push_back(m_szBuffer, true); + else + break; + } + + break; + } + default: + _ASSERT(false); // unknown property type + } + + // set modified if this wasn't read from a file + pEntry->bModified=m_bDefault; // if this is a default value - store it when needed +} + +/////////////////////////////////////////////////////////////// +// Writes property to the .ini file +// pEntry [in] - filled property entry struct +/////////////////////////////////////////////////////////////// +void CConfigManager::WriteProperty(_CFGENTRY* pEntry) +{ + if (pEntry->bModified) + { + switch (pEntry->cType) + { + case PT_INT64: + { + SetInt64(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.llValue); + pEntry->bModified=false; + break; + } + case PT_STRING: + { + SetString(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.pszValue); + pEntry->bModified=false; + break; + } + case PT_BOOL: + { + SetBool(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.bValue); + pEntry->bModified=false; + break; + } + case PT_INT: + { + SetInt(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.iValue); + pEntry->bModified=false; + break; + } + case PT_ASTRING: + { + TCHAR szNum[8]; + for (int i=0;ival.pvszValue->size()) + { + // add string + SetString(m_pszCurrentConfig, pEntry->pszSection, szNum, pEntry->val.pvszValue->at(i)); + } + else + { + // remove string + RemoveKey(m_pszCurrentConfig, pEntry->pszSection, szNum, true); + break; + } + } + pEntry->bModified=false; + + break; + } + } + } +} + +LRESULT CConfigManager::MsgRouter(UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uiMsg) + { + case CCMI_REGISTERPROPERTY: + return (LRESULT)RegisterProperty((_CFGENTRY*)lParam); + case CCMI_GETINTVALUE: + return (LRESULT)GetIntValue((UINT)wParam); + case CCMI_SETINTVALUE: + SetIntValue((UINT)wParam, (int)lParam); + return (LRESULT)0; + case CCMI_GETINT64VALUE: + { + if (lParam) + { + *((__int64*)lParam)=GetInt64Value((UINT)wParam); + return (LRESULT)0; + } + else + return (LRESULT)1; + } + case CCMI_SETINT64VALUE: + { + if (lParam) + { + SetInt64Value((UINT)wParam, *((__int64*)lParam)); + return (LRESULT)0; + } + else + return (LRESULT)1; + } + case CCMI_GETBOOLVALUE: + return (LRESULT)GetBoolValue((UINT)wParam); + case CCMI_SETBOOLVALUE: + SetBoolValue((UINT)wParam, lParam != 0); + return (LRESULT)0; + case CCMI_GETSTRINGVALUE: + GetStringValue((UINT)wParam, (LPTSTR)lParam, 1024); + return (LRESULT)0; + case CCMI_SETSTRINGVALUE: + SetStringValue((UINT)wParam, (LPCTSTR)lParam); + return (LRESULT)0; + case CCMI_SELECTPROFILE: + SelectProfile((LPCTSTR)lParam); + return (LRESULT)0; + } + return (LRESULT)1; +} Index: ch/ConfigManager.cpp =================================================================== diff -u -N --- ch/ConfigManager.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/ConfigManager.cpp (revision 0) @@ -1,806 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "ConfigManager.h" -#ifndef DISABLE_CRYPT -#include "crypt.h" -#include "conv.h" -#endif - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#define CFG_PROFILE _T("Common") -#define CFG_SECTION _T("Config") -#define CFG_KEY _T("Current configuration name") -#define CFG_DEFAULTSECTION _T("Default") - -#define CFG_MAXCOMPOUND 500 /* max count of items in a compound property */ - -/////////////////////////////////////////////////////////////// -// Opens configuration file. -// This function should be called only once - isn't thread safe -// Doesn't throw any file exception. If physical file couldn't -// be opened - this class does not require it. Could work -// without saving options to file, or with read-only files. -// pszFilename [in] - path to the configuration file -/////////////////////////////////////////////////////////////// -void CConfigManager::Open(LPCTSTR pszFilename) -{ - // load text file, and process it in ini file - try - { - ((CIniFile*)this)->Open(pszFilename, NULL, false); - } - catch(CFileExceptionEx* e) - { - // report error - TCHAR szData[1024]; - szData[1023]=_T('\0'); - _sntprintf(szData, 1023, _T("[Config Manager]: Couldn't open file %s to read initial data;\r\n\tReason: %s."), pszFilename, e->m_pszReason); - Report(szData); - - delete e; // get rid of this exception (file works doesn't work) - - // file couldn't be loaded... - create default section - m_pszCurrentConfig=new TCHAR[8]; - _tcscpy(m_pszCurrentConfig, CFG_DEFAULTSECTION); - SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); - return; - } - - // now - read current config name from cfg - if (!GetStr(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_szBuffer, _T(""))) - { - // current config not found - the first found would be current - vector<_PROFILE*>::const_iterator it=m_vConfigProfiles.begin(); - - while (it != m_vConfigProfiles.end()) - { - // check if element 0 isn't - if (_tcsicmp((*it)->pszProfileName, CFG_PROFILE) != 0) - { - // set current cfg to the found one - m_pszCurrentConfig=new TCHAR[_tcslen((*it)->pszProfileName)+1]; - _tcscpy(m_pszCurrentConfig, (*it)->pszProfileName); - - // save current selection - SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); - break; // we've found what was needed - stop processing - } - it++; - } - - // if not found - create default - if (m_pszCurrentConfig == NULL) - { - m_pszCurrentConfig=new TCHAR[8]; - _tcscpy(m_pszCurrentConfig, CFG_DEFAULTSECTION); - SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, m_pszCurrentConfig); - } - } - else - { - // section found - copy it - m_pszCurrentConfig=new TCHAR[_tcslen(m_szBuffer)+1]; - _tcscpy(m_pszCurrentConfig, m_szBuffer); - } -} - -/////////////////////////////////////////////////////////////// -// Tries to save settings to the configuration file. If -// couldn't be saved - function reports it through Report func -// and doesn't save data to file (this allows to use read-only -// attribute on config file). -/////////////////////////////////////////////////////////////// -void CConfigManager::Save() -{ - EnterCriticalSection(&m_cs); - // copy data into ini file object - vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); - while (it != m_vCfgData.end()) - WriteProperty(*it++); - - // save file - try - { - ((CIniFile*)this)->Save(); - } - catch(CFileExceptionEx* e) - { - TCHAR szData[1024]; - e->GetInfo(_T("[Config Manager]: Couldn't save configuration file."), szData, 1024); - Report(szData); - delete e; - - LeaveCriticalSection(&m_cs); - return; - } - catch(...) - { - LeaveCriticalSection(&m_cs); - throw; - } - - LeaveCriticalSection(&m_cs); -} - -/////////////////////////////////////////////////////////////// -// Closes this configuration file (saves data before closing). -// If couldn't be saved/closed - it reports the fact and allows -// to continue (allows usage of read-only files). -/////////////////////////////////////////////////////////////// -void CConfigManager::Close() -{ - // store all data into .ini object - EnterCriticalSection(&m_cs); - vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); - while (it != m_vCfgData.end()) - { - WriteProperty(*it); - FreeEntry(*it++); - } - - // free all - m_vCfgData.clear(); - - // free current config name - delete [] m_pszCurrentConfig; - m_pszCurrentConfig=NULL; - - // destroy base... - try - { - ((CIniFile*)this)->Close(); // storing data, closing file in a base class - } - catch(CFileExceptionEx* e) - { - TCHAR szData[1024]; - e->GetInfo(_T("[Config Manager]: Couldn't properly save/close file."), szData, 1024); - Report(szData); - - delete e; - - LeaveCriticalSection(&m_cs); - return; - } - catch(...) - { - LeaveCriticalSection(&m_cs); - throw; - } - - LeaveCriticalSection(&m_cs); -} - -#ifndef DISABLE_CRYPT -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CConfigManager::SetPassword(PCTSTR pszPass) -{ - // gen new 256b password - TCHAR szNewPass[64+1], szLine[8192]; - StringToKey256(pszPass, szNewPass); - - // recrypt the old data if needed - if (m_pszPassword) - { - // if there already was a password - for (vector<_CFGENTRY*>::iterator it=m_vCfgData.begin();it!=m_vCfgData.end();it++) - { - // reencrypt every encrypted item - if ((*it)->dwFlags & RF_ENCRYPTED && (*it)->cType == PT_STRING) - { - // decrypt the old data - if (AES256DecipherString((*it)->val.pszValue, m_pszPassword, szLine) < 0) - continue; - - // encrypt to the new one - if (AES256CipherString(szLine, szNewPass, szLine) < 0) - continue; - - // store the new value - delete [] (*it)->val.pszValue; - (*it)->val.pszValue=new TCHAR[_tcslen(szLine)+1]; - _tcscpy((*it)->val.pszValue, szLine); - (*it)->bModified=true; // set the modified flag - } - } - - delete [] m_pszPassword; // delete old password - } - m_pszPassword=new TCHAR[64+1]; - _tcscpy(m_pszPassword, szNewPass); -} - -#endif -/////////////////////////////////////////////////////////////// -// Registers some property given filled _CFGENTRY struct. -// pEntry [in] - specifies all possible information about the -// attribute being registered. -// Ret Value [out] - ID of registered property. It must be -// used when accessing this property. -/////////////////////////////////////////////////////////////// -UINT CConfigManager::RegisterProperty(_CFGENTRY* pEntry) -{ - _ASSERT(pEntry != NULL); - - EnterCriticalSection(&m_cs); - ReadProperty(pEntry); - m_vCfgData.push_back(pEntry); - UINT uiRet=(UINT)(m_vCfgData.size()-1); - LeaveCriticalSection(&m_cs); - return uiRet; -} - -/////////////////////////////////////////////////////////////// -// Registers int64 property. -// pszSection [in] - section in which resides given property -// pszKey [in] - key in which resides given property -// llDefault [in] - default value of this property (used if the -// config file doesn't contain it) -// cDetailLevel [in] - specifies "level" of this property. It -// could be simple property (for all users) or -// something that only some paranoics will use. -// Ret Value [out] - ID of registered property. It must be -// used when accessing this property. -/////////////////////////////////////////////////////////////// -UINT CConfigManager::RegisterInt64Property(LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, char cDetailLevel) -{ - // create config entry - _CFGENTRY* pcfg=new _CFGENTRY; - pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(pcfg->pszSection, pszSection); - pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; - _tcscpy(pcfg->pszKey, pszKey); - pcfg->cType=PT_INT64; - pcfg->def.llValue=llDefault; - pcfg->bModified=false; - pcfg->cDetailLevel=cDetailLevel; - pcfg->dwFlags=RF_NONE; - - // register - return RegisterProperty(pcfg); -} - -/////////////////////////////////////////////////////////////// -// Registers int property. -// pszSection [in] - section in which resides given property -// pszKey [in] - key in which resides given property -// iDefault [in] - default value of this property (used if the -// config file doesn't contain it) -// cDetailLevel [in] - specifies "level" of this property. It -// could be simple property (for all users) or -// something that only some paranoics will use. -// Ret Value [out] - ID of registered property. It must be -// used when accessing this property. -/////////////////////////////////////////////////////////////// -UINT CConfigManager::RegisterIntProperty(LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, char cDetailLevel) -{ - // create config entry - _CFGENTRY* pcfg=new _CFGENTRY; - pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(pcfg->pszSection, pszSection); - pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; - _tcscpy(pcfg->pszKey, pszKey); - pcfg->cType=PT_INT; - pcfg->def.iValue=iDefault; - pcfg->bModified=false; - pcfg->cDetailLevel=cDetailLevel; - pcfg->dwFlags=RF_NONE; - - // register - return RegisterProperty(pcfg); -} - -/////////////////////////////////////////////////////////////// -// Registers bool property. -// pszSection [in] - section in which resides given property -// pszKey [in] - key in which resides given property -// bDefault [in] - default value of this property (used if the -// config file doesn't contain it) -// cDetailLevel [in] - specifies "level" of this property. It -// could be simple property (for all users) or -// something that only some paranoics will use. -// Ret Value [out] - ID of registered property. It must be -// used when accessing this property. -/////////////////////////////////////////////////////////////// -UINT CConfigManager::RegisterBoolProperty(LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, char cDetailLevel) -{ - // create config entry - _CFGENTRY* pcfg=new _CFGENTRY; - pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(pcfg->pszSection, pszSection); - pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; - _tcscpy(pcfg->pszKey, pszKey); - pcfg->cType=PT_BOOL; - pcfg->def.bValue=bDefault; - pcfg->bModified=false; - pcfg->cDetailLevel=cDetailLevel; - pcfg->dwFlags=RF_NONE; - - // register - return RegisterProperty(pcfg); -} - -/////////////////////////////////////////////////////////////// -// Registers string property. -// pszSection [in] - section in which resides given property -// pszKey [in] - key in which resides given property -// pszDefault [in] - default value of this property (used if -// the config file doesn't contain it) -// cDetailLevel [in] - specifies "level" of this property. It -// could be simple property (for all users) or -// something that only some paranoics will use. -// Ret Value [out] - ID of registered property. It must be -// used when accessing this property. -/////////////////////////////////////////////////////////////// -UINT CConfigManager::RegisterStringProperty(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault, DWORD dwFlags, char cDetailLevel) -{ - // create config entry - _CFGENTRY* pcfg=new _CFGENTRY; - pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(pcfg->pszSection, pszSection); - pcfg->pszKey=new TCHAR[_tcslen(pszKey)+1]; - _tcscpy(pcfg->pszKey, pszKey); - pcfg->cType=PT_STRING; - pcfg->def.pszValue=new TCHAR[_tcslen(pszDefault)+1]; - _tcscpy(pcfg->def.pszValue, pszDefault); - pcfg->bModified=false; - pcfg->cDetailLevel=cDetailLevel; - pcfg->dwFlags=dwFlags; - - // register - return RegisterProperty(pcfg); -} - -UINT CConfigManager::RegisterStringArrayProperty(LPCTSTR pszSection, char cDetailLevel) -{ - _CFGENTRY* pcfg=new _CFGENTRY; - pcfg->pszSection=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(pcfg->pszSection, pszSection); - pcfg->pszKey=NULL; - pcfg->cType=PT_ASTRING; - pcfg->bModified=false; - pcfg->cDetailLevel=cDetailLevel; - pcfg->val.pvszValue=new char_vector; - pcfg->dwFlags=RF_NONE; - - return RegisterProperty(pcfg); -} - -/////////////////////////////////////////////////////////////// -// Returns value of int property given property ID -// uiPropID [in] - property ID (returned by RegisterProperty..) -// Ret Value [out] - value of this property (either from file -// or the default one specified at registration) -/////////////////////////////////////////////////////////////// -int CConfigManager::GetIntValue(UINT uiPropID) -{ - EnterCriticalSection(&m_cs); - int iRet=m_vCfgData.at(uiPropID)->val.iValue; - LeaveCriticalSection(&m_cs); - return iRet; -} - -/////////////////////////////////////////////////////////////// -// Sets value of a given property (by it's ID) -// uiPropID [in] - property ID (returned by RegisterProperty..) -// iValue [in] - the new value of this property -/////////////////////////////////////////////////////////////// -void CConfigManager::SetIntValue(UINT uiPropID, int iValue) -{ - EnterCriticalSection(&m_cs); - m_vCfgData.at(uiPropID)->val.iValue=iValue; - m_vCfgData.at(uiPropID)->bModified=true; - LeaveCriticalSection(&m_cs); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); -} - -/////////////////////////////////////////////////////////////// -// Returns value of int64 property given property ID -// uiPropID [in] - property ID (returned by RegisterProperty..) -// Ret Value [out] - value of this property (either from file -// or the default one specified at registration) -/////////////////////////////////////////////////////////////// -__int64 CConfigManager::GetInt64Value(UINT uiPropID) -{ - EnterCriticalSection(&m_cs); - __int64 llRet=m_vCfgData.at(uiPropID)->val.llValue; - LeaveCriticalSection(&m_cs); - return llRet; -} - -/////////////////////////////////////////////////////////////// -// Sets value of a given property (by it's ID) -// uiPropID [in] - property ID (returned by RegisterProperty..) -// llValue [in] - the new value of this property -/////////////////////////////////////////////////////////////// -void CConfigManager::SetInt64Value(UINT uiPropID, __int64 llValue) -{ - EnterCriticalSection(&m_cs); - m_vCfgData.at(uiPropID)->val.llValue=llValue; - m_vCfgData.at(uiPropID)->bModified=true; - LeaveCriticalSection(&m_cs); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); -} - -/////////////////////////////////////////////////////////////// -// Returns value of bool property given property ID -// uiPropID [in] - property ID (returned by RegisterProperty..) -// Ret Value [out] - value of this property (either from file -// or the default one specified at registration) -/////////////////////////////////////////////////////////////// -bool CConfigManager::GetBoolValue(UINT uiPropID) -{ - EnterCriticalSection(&m_cs); - bool bRet=m_vCfgData.at(uiPropID)->val.bValue; - LeaveCriticalSection(&m_cs); - return bRet; -} - -/////////////////////////////////////////////////////////////// -// Sets value of a given property (by it's ID) -// uiPropID [in] - property ID (returned by RegisterProperty..) -// bValue [in] - the new value of this property -/////////////////////////////////////////////////////////////// -void CConfigManager::SetBoolValue(UINT uiPropID, bool bValue) -{ - EnterCriticalSection(&m_cs); - m_vCfgData.at(uiPropID)->val.bValue=bValue; - m_vCfgData.at(uiPropID)->bModified=true; - LeaveCriticalSection(&m_cs); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); -} - -/////////////////////////////////////////////////////////////// -// Returns value of string property given property ID -// uiPropID [in] - property ID (returned by RegisterProperty..) -// Ret Value [out] - value of this property (either from file -// or the default one specified at registration) -/////////////////////////////////////////////////////////////// -PCTSTR CConfigManager::GetStringValue(UINT uiPropID, PTSTR pszBuffer, int iSize) -{ - EnterCriticalSection(&m_cs); - -#ifndef DISABLE_CRYPT - if (m_vCfgData.at(uiPropID)->dwFlags & RF_ENCRYPTED) - { - // make sure password has been set already - _ASSERT(m_pszPassword); - - TCHAR szLine[8192]; - if (AES256DecipherString(m_vCfgData.at(uiPropID)->val.pszValue, m_pszPassword, szLine) <= 0) - { - // return - _tcscpy(pszBuffer, _T("")); - LeaveCriticalSection(&m_cs); - return pszBuffer; - } - - // copy the decrypted data - _tcsncpy(pszBuffer, szLine, iSize); - pszBuffer[iSize-1]=_T('\0'); - } - else -#endif - _tcsncpy(pszBuffer, m_vCfgData.at(uiPropID)->val.pszValue, iSize); - - if (m_vCfgData.at(uiPropID)->dwFlags & RF_PATH) - { - if (pszBuffer[_tcslen(pszBuffer)-1] != _T('\\')) - _tcscat(pszBuffer, _T("\\")); - } - - LeaveCriticalSection(&m_cs); - - return pszBuffer; -} - -/////////////////////////////////////////////////////////////// -// Sets value of a given property (by it's ID) -// uiPropID [in] - property ID (returned by RegisterProperty..) -// pszValue [in] - the new value of this property -/////////////////////////////////////////////////////////////// -void CConfigManager::SetStringValue(UINT uiPropID, LPCTSTR pszValue) -{ - EnterCriticalSection(&m_cs); -#ifndef DISABLE_CRYPT - // encrypt the data before setting the property text - if (m_vCfgData.at(uiPropID)->dwFlags & RF_ENCRYPTED) - { - // make sure password has been set already - _ASSERT(m_pszPassword); - - TCHAR szLine[8192]; - if (AES256CipherString(pszValue, m_pszPassword, szLine) < 0) - { - _ASSERT(false); - TRACE("Cannot cipher string - what to do ????\n"); - } - - // store encrypted value - delete [] m_vCfgData.at(uiPropID)->val.pszValue; // delete old value - m_vCfgData.at(uiPropID)->val.pszValue=new TCHAR[_tcslen(szLine)+1]; // create space for new - _tcscpy(m_vCfgData.at(uiPropID)->val.pszValue, szLine); // copy the new one - m_vCfgData.at(uiPropID)->bModified=true; // modified state - } - else - { -#endif - delete [] m_vCfgData.at(uiPropID)->val.pszValue; // delete old value - m_vCfgData.at(uiPropID)->val.pszValue=new TCHAR[_tcslen(pszValue)+1]; // create space for new - _tcscpy(m_vCfgData.at(uiPropID)->val.pszValue, pszValue); // copy the new one - m_vCfgData.at(uiPropID)->bModified=true; // modified state -#ifndef DISABLE_CRYPT - } -#endif - LeaveCriticalSection(&m_cs); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); -} - -void CConfigManager::GetStringArrayValue(UINT uiPropID, char_vector* pcVector) -{ - EnterCriticalSection(&m_cs); - _CFGENTRY* pentry=m_vCfgData.at(uiPropID); - pcVector->assign(pentry->val.pvszValue->begin(), pentry->val.pvszValue->end(), true, true); - LeaveCriticalSection(&m_cs); -} - -void CConfigManager::SetStringArrayValue(UINT uiPropID, char_vector* pcVector) -{ - EnterCriticalSection(&m_cs); - _CFGENTRY* pentry=m_vCfgData.at(uiPropID); - pentry->val.pvszValue->assign(pcVector->begin(), pcVector->end(), true, true); - LeaveCriticalSection(&m_cs); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROPERTYCHANGE, uiPropID); -} - -/////////////////////////////////////////////////////////////// -// Selects new profile -// pszCfgName [in] - new profile name -/////////////////////////////////////////////////////////////// -void CConfigManager::SelectProfile(LPCTSTR pszCfgName) -{ - // store config into ini file - vector<_CFGENTRY*>::const_iterator it=m_vCfgData.begin(); - while (it != m_vCfgData.end()) - WriteProperty(*it++); - - // change config - delete [] m_pszCurrentConfig; - m_pszCurrentConfig=new TCHAR[_tcslen(pszCfgName)+1]; - _tcscpy(m_pszCurrentConfig, pszCfgName); - - // read data from ini file - it=m_vCfgData.begin(); - while (it != m_vCfgData.end()) - ReadProperty(*it++); - - // set data in ini file - SetString(CFG_PROFILE, CFG_SECTION, CFG_KEY, pszCfgName); - - if (m_pfnCallback) - (*m_pfnCallback)(0, WM_CFGNOTIFY, CNFT_PROFILECHANGE, (LPARAM)pszCfgName); -} - -/////////////////////////////////////////////////////////////// -// (Internal) Frees one of the profile entries -// pEntry [in] - address of profile entry -/////////////////////////////////////////////////////////////// -void CConfigManager::FreeEntry(_CFGENTRY* pEntry) -{ - // free section and key - delete [] pEntry->pszSection; - delete [] pEntry->pszKey; - - // if this is a string property - free it - switch(pEntry->cType) - { - case PT_STRING: - delete [] pEntry->def.pszValue; - delete [] pEntry->val.pszValue; - break; - case PT_ASTRING: - { - pEntry->val.pvszValue->clear(true); - delete pEntry->val.pvszValue; - break; - } - } - - // last - delete object itself - delete pEntry; -} - -/////////////////////////////////////////////////////////////// -// Reads value of a given property entry from .ini file -// pEntry [in] - filled property entry structure -/////////////////////////////////////////////////////////////// -void CConfigManager::ReadProperty(_CFGENTRY* pEntry) -{ - // process each attribute - switch (pEntry->cType) - { - case PT_INT64: - { - pEntry->val.llValue=GetInt64(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.llValue, m_szBuffer); - break; - } - case PT_STRING: - { - GetString(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, m_szBuffer, pEntry->def.pszValue); - pEntry->val.pszValue=new TCHAR[_tcslen(m_szBuffer)+1]; - _tcscpy(pEntry->val.pszValue, m_szBuffer); - break; - } - case PT_BOOL: - { - pEntry->val.bValue=GetBool(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.bValue, m_szBuffer); - break; - } - case PT_INT: - { - pEntry->val.iValue=GetInt(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->def.iValue, m_szBuffer); - break; - } - case PT_ASTRING: - { - TCHAR szNum[8]; - for (int i=0;ipszSection, szNum, m_szBuffer, _T(""))) - pEntry->val.pvszValue->push_back(m_szBuffer, true); - else - break; - } - - break; - } - default: - _ASSERT(false); // unknown property type - } - - // set modified if this wasn't read from a file - pEntry->bModified=m_bDefault; // if this is a default value - store it when needed -} - -/////////////////////////////////////////////////////////////// -// Writes property to the .ini file -// pEntry [in] - filled property entry struct -/////////////////////////////////////////////////////////////// -void CConfigManager::WriteProperty(_CFGENTRY* pEntry) -{ - if (pEntry->bModified) - { - switch (pEntry->cType) - { - case PT_INT64: - { - SetInt64(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.llValue); - pEntry->bModified=false; - break; - } - case PT_STRING: - { - SetString(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.pszValue); - pEntry->bModified=false; - break; - } - case PT_BOOL: - { - SetBool(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.bValue); - pEntry->bModified=false; - break; - } - case PT_INT: - { - SetInt(m_pszCurrentConfig, pEntry->pszSection, pEntry->pszKey, pEntry->val.iValue); - pEntry->bModified=false; - break; - } - case PT_ASTRING: - { - TCHAR szNum[8]; - for (int i=0;ival.pvszValue->size()) - { - // add string - SetString(m_pszCurrentConfig, pEntry->pszSection, szNum, pEntry->val.pvszValue->at(i)); - } - else - { - // remove string - RemoveKey(m_pszCurrentConfig, pEntry->pszSection, szNum, true); - break; - } - } - pEntry->bModified=false; - - break; - } - } - } -} - -LRESULT CConfigManager::MsgRouter(UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uiMsg) - { - case CCMI_REGISTERPROPERTY: - return (LRESULT)RegisterProperty((_CFGENTRY*)lParam); - case CCMI_GETINTVALUE: - return (LRESULT)GetIntValue((UINT)wParam); - case CCMI_SETINTVALUE: - SetIntValue((UINT)wParam, (int)lParam); - return (LRESULT)0; - case CCMI_GETINT64VALUE: - { - if (lParam) - { - *((__int64*)lParam)=GetInt64Value((UINT)wParam); - return (LRESULT)0; - } - else - return (LRESULT)1; - } - case CCMI_SETINT64VALUE: - { - if (lParam) - { - SetInt64Value((UINT)wParam, *((__int64*)lParam)); - return (LRESULT)0; - } - else - return (LRESULT)1; - } - case CCMI_GETBOOLVALUE: - return (LRESULT)GetBoolValue((UINT)wParam); - case CCMI_SETBOOLVALUE: - SetBoolValue((UINT)wParam, lParam != 0); - return (LRESULT)0; - case CCMI_GETSTRINGVALUE: - GetStringValue((UINT)wParam, (LPTSTR)lParam, 1024); - return (LRESULT)0; - case CCMI_SETSTRINGVALUE: - SetStringValue((UINT)wParam, (LPCTSTR)lParam); - return (LRESULT)0; - case CCMI_SELECTPROFILE: - SelectProfile((LPCTSTR)lParam); - return (LRESULT)0; - } - return (LRESULT)1; -} Index: src/ch/ConfigManager.h =================================================================== diff -u -N --- src/ch/ConfigManager.h (revision 0) +++ src/ch/ConfigManager.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,186 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + File: ConfigManager.h + Version: 1.0 + Author: Ixen Gerthannes (ixen@interia.pl) + File description: + Contains structs/classes for handling configuration + settings in application. + Classes: + CConfigManager + - support access to properties by it's ID + - supports registering additional properties when + the program works. + - supports multiple levels of property detail + - special meaning - ; [Config]; + "Current configuration name=xxx" - specifies + current active profile (the one that will be used + as a source for getting data for properties). + Structures: + _CFGENTRY - contain information about one property. +*************************************************************************/ + +#ifndef __CONFIG_MANAGER_H__ +#define __CONFIG_MANAGER_H__ + +#include "IniFile.h" +#include "charvect.h" +#include "af_defs.h" + +using namespace std; + +// property types in CConfigEntry +#define PT_INT64 0 +#define PT_STRING 1 +#define PT_BOOL 2 +#define PT_INT 3 +#define PT_ASTRING 4 /* array of strings */ + +// flags when registering +#define RF_NONE 0x00 +#define RF_PATH 0x01 + +#ifndef DISABLE_CRYPT +#define RF_ENCRYPTED 0x02 +#endif + +// property detail level +// general properties - for everyone +#define PDL_GENERAL 0 +// advanced properties - for advanced users +#define PDL_ADVANCED 1 +// paranoid type - for only a few individuals who want to configure everything +#define PDL_PARANOID 2 + +// types of notifications (going out) +// CNFT_PROFILECHANGE - this notification is sent when something changes the current configuration profile +// LPARAM - address of new profile string +#define CNFT_PROFILECHANGE 0x0001 +// CNFT_PROPERTYCHANGE - tells about changing value of a property +// LPARAM - (UINT) property ID +#define CNFT_PROPERTYCHANGE 0x0002 + +// messages that goes into this class +#define CCMI_REGISTERPROPERTY 0x0001 +#define CCMI_GETINTVALUE 0x0002 +#define CCMI_SETINTVALUE 0x0003 +#define CCMI_GETINT64VALUE 0x0004 +#define CCMI_SETINT64VALUE 0x0005 +#define CCMI_GETBOOLVALUE 0x0006 +#define CCMI_SETBOOLVALUE 0x0007 +#define CCMI_GETSTRINGVALUE 0x0008 +#define CCMI_SETSTRINGVALUE 0x0009 +#define CCMI_SELECTPROFILE 0x000a + + +// defines one of the attributes +struct _CFGENTRY +{ + TCHAR* pszSection; // section name + TCHAR* pszKey; // key name + char cDetailLevel; // detail level of this property (GENERAL (for everyone), ADVANCED (for advanced users), PARANOID) + bool bModified; // if property is in modified state (it wasn't saved from last change) + char cType; // type of property + DWORD dwFlags; // if set and property is string then we need to append '\\' at the end + union DATA + { + __int64 llValue; // __int64 value type + TCHAR* pszValue; // string value type + int iValue; // int value type + bool bValue; // bool value type + char_vector* pvszValue; // compound string table + } val, def; +}; + + +class CConfigManager : public CIniFile +{ +public: + CConfigManager() : CIniFile() { m_pszCurrentConfig=NULL; m_pfnCallback=NULL; +#ifndef DISABLE_CRYPT + m_pszPassword=NULL; +#endif + InitializeCriticalSection(&m_cs); }; + ~CConfigManager() { Close(); +#ifndef DISABLE_CRYPT + delete [] m_pszPassword; +#endif + DeleteCriticalSection(&m_cs); }; + + void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; + + LRESULT MsgRouter(UINT uiMsg, WPARAM wParam, LPARAM lParam); + + // open/close funcs + void Open(LPCTSTR pszFilename); // reads all registered attributes from file + void Save(); // saves data to file + void Close(); // destroys everything + +#ifndef DISABLE_CRYPT + // encryption options + void SetPassword(PCTSTR pszPass); // sets the encrypt/decrypt password +#endif + + // properties registration funcs + UINT RegisterProperty(_CFGENTRY* pEntry); // just adds pointer to a vector + UINT RegisterInt64Property(LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, char cDetailLevel=PDL_GENERAL); + UINT RegisterIntProperty(LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, char cDetailLevel=PDL_GENERAL); + UINT RegisterBoolProperty(LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, char cDetailLevel=PDL_GENERAL); + UINT RegisterStringProperty(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault, DWORD dwFlags=RF_NONE, char cDetailLevel=PDL_GENERAL); + UINT RegisterStringArrayProperty(LPCTSTR pszSection, char cDetailLevel=PDL_GENERAL); + + // property get/set funcs + int GetIntValue(UINT uiPropID); + void SetIntValue(UINT uiPropID, int iValue); + __int64 GetInt64Value(UINT uiPropID); + void SetInt64Value(UINT uiPropID, __int64 llValue); + bool GetBoolValue(UINT uiPropID); + void SetBoolValue(UINT uiPropID, bool bValue); + PCTSTR GetStringValue(UINT uiPropID, PTSTR pszBuffer, int iSize); + void SetStringValue(UINT uiPropID, LPCTSTR pszValue); + void GetStringArrayValue(UINT uiPropID, char_vector* pcVector); + void SetStringArrayValue(UINT uiPropID, char_vector* pcVector); + + // config profiles management + void SelectProfile(LPCTSTR pszCfgName); + +protected: + void ReadProperty(_CFGENTRY* pEntry); // reads value from ini file... + void WriteProperty(_CFGENTRY* pEntry); // store value to ini file + void FreeEntry(_CFGENTRY* pEntry); // frees entry with data + + void Report(LPCTSTR /*pszReportString*/) { /* currently nothing */ }; // reports errors and others + +protected: + TCHAR* m_pszCurrentConfig; // name of current config + vector<_CFGENTRY*> m_vCfgData; // config data - all attributes + TCHAR m_szBuffer[1024]; // internal buffer + +#ifndef DISABLE_CRYPT + // passwd + TCHAR* m_pszPassword; // password for the encrypted properties +#endif + + PFNNOTIFYCALLBACK m_pfnCallback; // callback func for reporting some data + CRITICAL_SECTION m_cs; +}; + +#endif \ No newline at end of file Index: ch/ConfigManager.h =================================================================== diff -u -N --- ch/ConfigManager.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/ConfigManager.h (revision 0) @@ -1,186 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - File: ConfigManager.h - Version: 1.0 - Author: Ixen Gerthannes (ixen@interia.pl) - File description: - Contains structs/classes for handling configuration - settings in application. - Classes: - CConfigManager - - support access to properties by it's ID - - supports registering additional properties when - the program works. - - supports multiple levels of property detail - - special meaning - ; [Config]; - "Current configuration name=xxx" - specifies - current active profile (the one that will be used - as a source for getting data for properties). - Structures: - _CFGENTRY - contain information about one property. -*************************************************************************/ - -#ifndef __CONFIG_MANAGER_H__ -#define __CONFIG_MANAGER_H__ - -#include "IniFile.h" -#include "charvect.h" -#include "af_defs.h" - -using namespace std; - -// property types in CConfigEntry -#define PT_INT64 0 -#define PT_STRING 1 -#define PT_BOOL 2 -#define PT_INT 3 -#define PT_ASTRING 4 /* array of strings */ - -// flags when registering -#define RF_NONE 0x00 -#define RF_PATH 0x01 - -#ifndef DISABLE_CRYPT -#define RF_ENCRYPTED 0x02 -#endif - -// property detail level -// general properties - for everyone -#define PDL_GENERAL 0 -// advanced properties - for advanced users -#define PDL_ADVANCED 1 -// paranoid type - for only a few individuals who want to configure everything -#define PDL_PARANOID 2 - -// types of notifications (going out) -// CNFT_PROFILECHANGE - this notification is sent when something changes the current configuration profile -// LPARAM - address of new profile string -#define CNFT_PROFILECHANGE 0x0001 -// CNFT_PROPERTYCHANGE - tells about changing value of a property -// LPARAM - (UINT) property ID -#define CNFT_PROPERTYCHANGE 0x0002 - -// messages that goes into this class -#define CCMI_REGISTERPROPERTY 0x0001 -#define CCMI_GETINTVALUE 0x0002 -#define CCMI_SETINTVALUE 0x0003 -#define CCMI_GETINT64VALUE 0x0004 -#define CCMI_SETINT64VALUE 0x0005 -#define CCMI_GETBOOLVALUE 0x0006 -#define CCMI_SETBOOLVALUE 0x0007 -#define CCMI_GETSTRINGVALUE 0x0008 -#define CCMI_SETSTRINGVALUE 0x0009 -#define CCMI_SELECTPROFILE 0x000a - - -// defines one of the attributes -struct _CFGENTRY -{ - TCHAR* pszSection; // section name - TCHAR* pszKey; // key name - char cDetailLevel; // detail level of this property (GENERAL (for everyone), ADVANCED (for advanced users), PARANOID) - bool bModified; // if property is in modified state (it wasn't saved from last change) - char cType; // type of property - DWORD dwFlags; // if set and property is string then we need to append '\\' at the end - union DATA - { - __int64 llValue; // __int64 value type - TCHAR* pszValue; // string value type - int iValue; // int value type - bool bValue; // bool value type - char_vector* pvszValue; // compound string table - } val, def; -}; - - -class CConfigManager : public CIniFile -{ -public: - CConfigManager() : CIniFile() { m_pszCurrentConfig=NULL; m_pfnCallback=NULL; -#ifndef DISABLE_CRYPT - m_pszPassword=NULL; -#endif - InitializeCriticalSection(&m_cs); }; - ~CConfigManager() { Close(); -#ifndef DISABLE_CRYPT - delete [] m_pszPassword; -#endif - DeleteCriticalSection(&m_cs); }; - - void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; - - LRESULT MsgRouter(UINT uiMsg, WPARAM wParam, LPARAM lParam); - - // open/close funcs - void Open(LPCTSTR pszFilename); // reads all registered attributes from file - void Save(); // saves data to file - void Close(); // destroys everything - -#ifndef DISABLE_CRYPT - // encryption options - void SetPassword(PCTSTR pszPass); // sets the encrypt/decrypt password -#endif - - // properties registration funcs - UINT RegisterProperty(_CFGENTRY* pEntry); // just adds pointer to a vector - UINT RegisterInt64Property(LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, char cDetailLevel=PDL_GENERAL); - UINT RegisterIntProperty(LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, char cDetailLevel=PDL_GENERAL); - UINT RegisterBoolProperty(LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, char cDetailLevel=PDL_GENERAL); - UINT RegisterStringProperty(LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszDefault, DWORD dwFlags=RF_NONE, char cDetailLevel=PDL_GENERAL); - UINT RegisterStringArrayProperty(LPCTSTR pszSection, char cDetailLevel=PDL_GENERAL); - - // property get/set funcs - int GetIntValue(UINT uiPropID); - void SetIntValue(UINT uiPropID, int iValue); - __int64 GetInt64Value(UINT uiPropID); - void SetInt64Value(UINT uiPropID, __int64 llValue); - bool GetBoolValue(UINT uiPropID); - void SetBoolValue(UINT uiPropID, bool bValue); - PCTSTR GetStringValue(UINT uiPropID, PTSTR pszBuffer, int iSize); - void SetStringValue(UINT uiPropID, LPCTSTR pszValue); - void GetStringArrayValue(UINT uiPropID, char_vector* pcVector); - void SetStringArrayValue(UINT uiPropID, char_vector* pcVector); - - // config profiles management - void SelectProfile(LPCTSTR pszCfgName); - -protected: - void ReadProperty(_CFGENTRY* pEntry); // reads value from ini file... - void WriteProperty(_CFGENTRY* pEntry); // store value to ini file - void FreeEntry(_CFGENTRY* pEntry); // frees entry with data - - void Report(LPCTSTR /*pszReportString*/) { /* currently nothing */ }; // reports errors and others - -protected: - TCHAR* m_pszCurrentConfig; // name of current config - vector<_CFGENTRY*> m_vCfgData; // config data - all attributes - TCHAR m_szBuffer[1024]; // internal buffer - -#ifndef DISABLE_CRYPT - // passwd - TCHAR* m_pszPassword; // password for the encrypted properties -#endif - - PFNNOTIFYCALLBACK m_pfnCallback; // callback func for reporting some data - CRITICAL_SECTION m_cs; -}; - -#endif \ No newline at end of file Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -N --- src/ch/CustomCopyDlg.cpp (revision 0) +++ src/ch/CustomCopyDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,907 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "CustomCopyDlg.h" +#include "structs.h" +#include "dialogs.h" +#include "BufferSizeDlg.h" +#include "FilterDlg.h" +#include "StringHelpers.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CCustomCopyDlg dialog + + +CCustomCopyDlg::CCustomCopyDlg() : CHLanguageDialog(CCustomCopyDlg::IDD) +{ + //{{AFX_DATA_INIT(CCustomCopyDlg) + m_ucCount = 1; + m_bOnlyCreate = FALSE; + m_bIgnoreFolders = FALSE; + m_bFilters = FALSE; + m_bAdvanced = FALSE; + m_bForceDirectories = FALSE; + //}}AFX_DATA_INIT + +// m_ccData.m_astrPaths.RemoveAll(); // unneeded +// m_ccData.m_strDestPath.Empty(); + + m_ccData.m_iOperation=0; + m_ccData.m_iPriority=THREAD_PRIORITY_NORMAL; + m_ccData.m_ucCount=1; + + // m_ccData.m_bsSizes stays uninitialized + // m_ccData.m_afFilters - this too + + m_ccData.m_bIgnoreFolders=false; + m_ccData.m_bForceDirectories=false; + m_ccData.m_bCreateStructure=false; + + m_bActualisation=false; +} + +void CCustomCopyDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CCustomCopyDlg) + DDX_Control(pDX, IDC_DESTPATH_COMBOBOXEX, m_ctlDstPath); + DDX_Control(pDX, IDC_COUNT_SPIN, m_ctlCountSpin); + DDX_Control(pDX, IDC_FILTERS_LIST, m_ctlFilters); + DDX_Control(pDX, IDC_BUFFERSIZES_LIST, m_ctlBufferSizes); + DDX_Control(pDX, IDC_OPERATION_COMBO, m_ctlOperation); + DDX_Control(pDX, IDC_PRIORITY_COMBO, m_ctlPriority); + DDX_Control(pDX, IDC_FILES_LIST, m_ctlFiles); + DDX_Text(pDX, IDC_COUNT_EDIT, m_ucCount); + DDV_MinMaxByte(pDX, m_ucCount, 1, 255); + DDX_Check(pDX, IDC_ONLYSTRUCTURE_CHECK, m_bOnlyCreate); + DDX_Check(pDX, IDC_IGNOREFOLDERS_CHECK, m_bIgnoreFolders); + DDX_Check(pDX, IDC_FORCEDIRECTORIES_CHECK, m_bForceDirectories); + DDX_Check(pDX, IDC_FILTERS_CHECK, m_bFilters); + DDX_Check(pDX, IDC_ADVANCED_CHECK, m_bAdvanced); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CCustomCopyDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CCustomCopyDlg) + ON_BN_CLICKED(IDC_ADDDIR_BUTTON, OnAddDirectoryButton) + ON_BN_CLICKED(IDC_ADDFILE_BUTTON, OnAddFilesButton) + ON_BN_CLICKED(IDC_REMOVEFILEFOLDER_BUTTON, OnRemoveButton) + ON_BN_CLICKED(IDC_DESTBROWSE_BUTTON, OnBrowseButton) + ON_BN_CLICKED(IDC_BUFFERSIZES_BUTTON, OnChangebufferButton) + ON_BN_CLICKED(IDC_ADDFILTER_BUTTON, OnAddfilterButton) + ON_BN_CLICKED(IDC_REMOVEFILTER_BUTTON, OnRemovefilterButton) + ON_WM_DESTROY() + ON_BN_CLICKED(IDC_FILTERS_CHECK, OnFiltersCheck) + ON_BN_CLICKED(IDC_STANDARD_CHECK, OnStandardCheck) + ON_BN_CLICKED(IDC_ADVANCED_CHECK, OnAdvancedCheck) + ON_NOTIFY(NM_DBLCLK, IDC_FILTERS_LIST, OnDblclkFiltersList) + ON_LBN_DBLCLK(IDC_BUFFERSIZES_LIST, OnDblclkBuffersizesList) + ON_CBN_EDITCHANGE(IDC_DESTPATH_COMBOBOXEX, OnEditchangeDestpathComboboxex) + ON_BN_CLICKED(IDC_IMPORT_BUTTON, OnImportButton) + ON_BN_CLICKED(IDC_IGNOREFOLDERS_CHECK, OnIgnorefoldersCheck) + ON_BN_CLICKED(IDC_FORCEDIRECTORIES_CHECK, OnForcedirectoriesCheck) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CCustomCopyDlg message handlers +BOOL CCustomCopyDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // make this dialog on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + // paths' listbox - init images - system image list + SHFILEINFO sfi; + HIMAGELIST hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + + m_ilImages.Attach(hImageList); + m_ctlFiles.SetImageList(&m_ilImages, LVSIL_SMALL); + + // calc list width + CRect rc; + m_ctlFiles.GetWindowRect(&rc); + 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); + + // paths' listbox - add one column + LVCOLUMN lvc; + lvc.mask=LVCF_FMT | LVCF_WIDTH; + lvc.fmt=LVCFMT_LEFT; + lvc.cx=rc.Width(); + m_ctlFiles.InsertColumn(1, &lvc); + + // fill paths' listbox + for (int i=0;iLoadString(IDS_CCDCOPY_STRING)); + m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDMOVE_STRING)); + + // copying/moving + m_ctlOperation.SetCurSel(m_ccData.m_iOperation); + + // fill priority combo + for (i=0;i<7;i++) + { + m_ctlPriority.AddString(GetResManager()->LoadString(IDS_PRIORITY0_STRING+i)); + } + + m_ctlPriority.SetCurSel(PriorityToIndex(m_ccData.m_iPriority)); + + // count of copies + m_ucCount=m_ccData.m_ucCount; + m_ctlCountSpin.SetRange(1, 255); + + // fill buffer sizes listbox + SetBuffersizesString(); + + // list width + m_ctlFilters.GetWindowRect(&rc); + rc.right-=GetSystemMetrics(SM_CXEDGE)*2; + + // filter - some columns in a header + lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; + lvc.fmt=LVCFMT_LEFT; + + // mask + lvc.iSubItem=-1; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRMASK_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.15*rc.Width()); + m_ctlFilters.InsertColumn(1, &lvc); + + // exclude mask + lvc.iSubItem=0; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEMASK_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.15*rc.Width()); + m_ctlFilters.InsertColumn(2, &lvc); + + // size + lvc.iSubItem=1; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRSIZE_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.3*rc.Width()); + m_ctlFilters.InsertColumn(3, &lvc); + + // time + lvc.iSubItem=2; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRDATE_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.3*rc.Width()); + m_ctlFilters.InsertColumn(4, &lvc); + + // attributes + lvc.iSubItem=3; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRATTRIB_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.1*rc.Width()); + m_ctlFilters.InsertColumn(5, &lvc); + + // -attributes + lvc.iSubItem=4; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEATTRIB_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.1*rc.Width()); + m_ctlFilters.InsertColumn(6, &lvc); + + m_bFilters=!!m_ccData.m_afFilters.GetSize(); + + // other custom flags + m_bAdvanced=(m_ccData.m_bIgnoreFolders | m_ccData.m_bCreateStructure); + m_bIgnoreFolders=m_ccData.m_bIgnoreFolders; + m_bForceDirectories=m_ccData.m_bForceDirectories; + m_bOnlyCreate=m_ccData.m_bCreateStructure; + + UpdateData(FALSE); + + EnableControls(); + + return TRUE; +} + +void CCustomCopyDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + UpdateData(TRUE); + + // count the width of a list + 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); + + // operation + int iPos=m_ctlOperation.GetCurSel(); + m_ctlOperation.ResetContent(); + m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDCOPY_STRING)); + m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDMOVE_STRING)); + m_ctlOperation.SetCurSel(iPos); + + // priority combo + iPos=m_ctlPriority.GetCurSel(); + m_ctlPriority.ResetContent(); + for (int i=0;i<7;i++) + { + m_ctlPriority.AddString(GetResManager()->LoadString(IDS_PRIORITY0_STRING+i)); + } + m_ctlPriority.SetCurSel(iPos); + + // fill the listbox with buffers + SetBuffersizesString(); + + // filter section (filter, size, date, attributes) + while(m_ctlFilters.DeleteColumn(0)); // delete all columns + + lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; + lvc.fmt=LVCFMT_LEFT; + + // mask + lvc.iSubItem=-1; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRMASK_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.15*rc.Width()); + m_ctlFilters.InsertColumn(1, &lvc); + + // exclude mask + lvc.iSubItem=0; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEMASK_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.15*rc.Width()); + m_ctlFilters.InsertColumn(2, &lvc); + + // size + lvc.iSubItem=1; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRSIZE_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.3*rc.Width()); + m_ctlFilters.InsertColumn(3, &lvc); + + // time + lvc.iSubItem=2; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRDATE_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.3*rc.Width()); + m_ctlFilters.InsertColumn(4, &lvc); + + // attributes + lvc.iSubItem=3; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRATTRIB_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.1*rc.Width()); + m_ctlFilters.InsertColumn(5, &lvc); + + // -attributes + lvc.iSubItem=4; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEATTRIB_STRING); + lvc.cchTextMax=lstrlen(lvc.pszText); + lvc.cx=static_cast(0.1*rc.Width()); + m_ctlFilters.InsertColumn(6, &lvc); + + // refresh the entries in filters' list + m_ctlFilters.DeleteAllItems(); + for (i=0;iLoadString(IDS_BROWSE_STRING), &strPath)) + AddPath(strPath); +} + +void CCustomCopyDlg::OnAddFilesButton() +{ + CFileDialog dlg(TRUE, NULL, NULL, OFN_ALLOWMULTISELECT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager()->LoadString(IDS_FILEDLGALLFILTER_STRING), this); + + TCHAR *pszBuffer=new TCHAR[65535]; + memset(pszBuffer, 0, 65535*sizeof(TCHAR)); + dlg.m_ofn.lpstrFile=pszBuffer; + dlg.m_ofn.nMaxFile=65535; + + if (dlg.DoModal() == IDOK) + { + // first element is the path + CString strPath=pszBuffer; + + int iOffset=_tcslen(pszBuffer)+1; + + // get filenames + if (pszBuffer[iOffset] == _T('\0')) + AddPath(strPath); + else + { + if (strPath.Right(1) != _T("\\")) + strPath+=_T("\\"); + while (pszBuffer[iOffset] != _T('\0')) + { + AddPath(strPath+CString(pszBuffer+iOffset)); + iOffset+=_tcslen(pszBuffer+iOffset)+1; + } + } + } + + // delete buffer + delete [] pszBuffer; +} + +void CCustomCopyDlg::OnRemoveButton() +{ + POSITION pos; + int iItem; + while (true) + { + pos = m_ctlFiles.GetFirstSelectedItemPosition(); + if (pos == NULL) + break; + else + { + iItem=m_ctlFiles.GetNextSelectedItem(pos); + m_ctlFiles.DeleteItem(iItem); + } + } +} + +void CCustomCopyDlg::OnBrowseButton() +{ + CString strPath; + if (BrowseForFolder(GetResManager()->LoadString(IDS_DSTFOLDERBROWSE_STRING), &strPath)) + { + SetComboPath(strPath); +// m_strDest=strPath; //** + } +} + +void CCustomCopyDlg::OnOK() +{ + UpdateData(TRUE); + + // copy files from listctrl to an array + m_ccData.m_astrPaths.RemoveAll(); + CString strPath; + + for (int i=0;iLoadString(IDS_BSEDEFAULT_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiDefaultSize, szSize, true)); + m_ctlBufferSizes.AddString(szData); + + if (!m_ccData.m_bsSizes.m_bOnlyDefault) + { + _stprintf(szData, GetResManager()->LoadString(IDS_BSEONEDISK_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiOneDiskSize, szSize, true)); + m_ctlBufferSizes.AddString(szData); + + _stprintf(szData, GetResManager()->LoadString(IDS_BSETWODISKS_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiTwoDisksSize, szSize, true)); + m_ctlBufferSizes.AddString(szData); + + _stprintf(szData, GetResManager()->LoadString(IDS_BSECD_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiCDSize, szSize, true)); + m_ctlBufferSizes.AddString(szData); + + _stprintf(szData, GetResManager()->LoadString(IDS_BSELAN_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiLANSize, szSize, true)); + m_ctlBufferSizes.AddString(szData); + } +} + +void CCustomCopyDlg::OnChangebufferButton() +{ + CBufferSizeDlg dlg; + dlg.m_bsSizes=m_ccData.m_bsSizes; + if (dlg.DoModal() == IDOK) + { + m_ccData.m_bsSizes=dlg.m_bsSizes; + SetBuffersizesString(); + } +} + +void CCustomCopyDlg::AddPath(CString strPath) +{ + // fill listbox with paths + LVITEM lvi; + lvi.mask=LVIF_TEXT | LVIF_IMAGE; + lvi.iItem=m_ctlFiles.GetItemCount(); + lvi.iSubItem=0; + + // there's no need for a high speed so get the images + SHFILEINFO sfi; + SHGetFileInfo(strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON/* | SHGFI_USEFILEATTRIBUTES*/); + + // fill the list + lvi.pszText=strPath.GetBuffer(0); + strPath.ReleaseBuffer(); + lvi.cchTextMax=lstrlen(lvi.pszText); + lvi.iImage=sfi.iIcon; + m_ctlFiles.InsertItem(&lvi); +} + +void CCustomCopyDlg::OnAddfilterButton() +{ + CFilterDlg dlg; + CString strData; + for (int i=0;iLoadString(IDS_FILTERMASKEMPTY_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.InsertItem(&lvi); + + ///////////////////// + lvi.iSubItem=1; + + if (rFilter.m_bUseExcludeMask) + { + CString strData; + rFilter.GetCombinedExcludeMask(strData); + _tcscpy(szLoaded, strData); + } + else + _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERMASKEMPTY_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.SetItem(&lvi); + + ///////////////// + lvi.iSubItem=2; + + if (rFilter.m_bUseSize) + { + _stprintf(szLoaded, _T("%s %s"), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iSizeType1), GetSizeString(static_cast<__int64>(rFilter.m_ullSize1), szData, true)); + + if (rFilter.m_bUseSize2) + { + _tcscat(szLoaded, GetResManager()->LoadString(IDS_AND_STRING)); + CString strLoaded2; + strLoaded2.Format(_T("%s %s"), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iSizeType2), GetSizeString(static_cast<__int64>(rFilter.m_ullSize2), szData, true)); + _tcscat(szLoaded, strLoaded2); + } + } + else + _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERSIZE_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.SetItem(&lvi); + + /////////////////// + lvi.iSubItem=3; + + if (rFilter.m_bUseDate) + { + _stprintf(szLoaded, _T("%s %s"), GetResManager()->LoadString(IDS_DATECREATED_STRING+rFilter.m_iDateType), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iDateType1)); + if (rFilter.m_bDate1) + _tcscat(szLoaded, rFilter.m_tDate1.Format(_T(" %x"))); + if (rFilter.m_bTime1) + _tcscat(szLoaded, rFilter.m_tTime1.Format(_T(" %X"))); + + if (rFilter.m_bUseDate2) + { + _tcscat(szLoaded, GetResManager()->LoadString(IDS_AND_STRING)); + _tcscat(szLoaded, GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iDateType2)); + if (rFilter.m_bDate2) + _tcscat(szLoaded, rFilter.m_tDate2.Format(_T(" %x"))); + if (rFilter.m_bTime2) + _tcscat(szLoaded, rFilter.m_tTime2.Format(_T(" %X"))); + } + } + else + _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERDATE_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.SetItem(&lvi); + + ///////////////////// + lvi.iSubItem=4; + szLoaded[0]=_T('\0'); + if (rFilter.m_bUseAttributes) + { + if (rFilter.m_iArchive == 1) + _tcscat(szLoaded, _T("A")); + if (rFilter.m_iReadOnly == 1) + _tcscat(szLoaded, _T("R")); + if (rFilter.m_iHidden == 1) + _tcscat(szLoaded, _T("H")); + if (rFilter.m_iSystem == 1) + _tcscat(szLoaded, _T("S")); + if (rFilter.m_iDirectory == 1) + _tcscat(szLoaded, _T("D")); + } + + if (!rFilter.m_bUseAttributes || szLoaded[0] == _T('\0')) + _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERATTRIB_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.SetItem(&lvi); + + ///////////////////// + lvi.iSubItem=5; + szLoaded[0]=_T('\0'); + if (rFilter.m_bUseAttributes) + { + if (rFilter.m_iArchive == 0) + _tcscat(szLoaded, _T("A")); + if (rFilter.m_iReadOnly == 0) + _tcscat(szLoaded, _T("R")); + if (rFilter.m_iHidden == 0) + _tcscat(szLoaded, _T("H")); + if (rFilter.m_iSystem == 0) + _tcscat(szLoaded, _T("S")); + if (rFilter.m_iDirectory == 0) + _tcscat(szLoaded, _T("D")); + } + + if (!rFilter.m_bUseAttributes || szLoaded[0] == _T('0')) + _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERATTRIB_STRING)); + + lvi.pszText=szLoaded; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlFilters.SetItem(&lvi); +} + +void CCustomCopyDlg::OnRemovefilterButton() +{ + POSITION pos; + int iItem; + while (true) + { + pos=m_ctlFilters.GetFirstSelectedItemPosition(); + if (pos == NULL) + break; + else + { + iItem=m_ctlFilters.GetNextSelectedItem(pos); + m_ctlFilters.DeleteItem(iItem); + m_ccData.m_afFilters.RemoveAt(iItem); + } + } +} + +void CCustomCopyDlg::OnDestroy() +{ + m_ctlFiles.SetImageList(NULL, LVSIL_SMALL); + m_ilImages.Detach(); + + CHLanguageDialog::OnDestroy(); +} + +void CCustomCopyDlg::EnableControls() +{ + UpdateData(TRUE); + + m_ctlFilters.EnableWindow(m_bFilters); + GetDlgItem(IDC_ADDFILTER_BUTTON)->EnableWindow(m_bFilters); + GetDlgItem(IDC_REMOVEFILTER_BUTTON)->EnableWindow(m_bFilters); + + GetDlgItem(IDC_IGNOREFOLDERS_CHECK)->EnableWindow(m_bAdvanced && !m_bForceDirectories); + GetDlgItem(IDC_FORCEDIRECTORIES_CHECK)->EnableWindow(m_bAdvanced && !m_bIgnoreFolders); + GetDlgItem(IDC_ONLYSTRUCTURE_CHECK)->EnableWindow(m_bAdvanced); +} + +void CCustomCopyDlg::OnFiltersCheck() +{ + EnableControls(); +} + +void CCustomCopyDlg::OnStandardCheck() +{ + EnableControls(); +} + +void CCustomCopyDlg::OnAdvancedCheck() +{ + EnableControls(); +} + +void CCustomCopyDlg::OnDblclkFiltersList(NMHDR* /*pNMHDR*/, LRESULT* pResult) +{ + POSITION pos=m_ctlFilters.GetFirstSelectedItemPosition(); + if (pos != NULL) + { + int iItem=m_ctlFilters.GetNextSelectedItem(pos); + CFilterDlg dlg; + dlg.m_ffFilter=m_ccData.m_afFilters.GetAt(iItem); + + CString strData; + for (int i=0;iSetSel(-1, -1); +} + +void CCustomCopyDlg::OnEditchangeDestpathComboboxex() +{ + if (m_bActualisation) + return; + m_bActualisation=true; + UpdateComboIcon(); + m_bActualisation=false; +} + +void CCustomCopyDlg::OnImportButton() +{ + CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager()->LoadString(IDS_FLTALLFILTER_STRING)); + if (dlg.DoModal() == IDOK) + { + UINT uiCount=0; + CString strData; + try + { + CFile file(dlg.GetPathName(), CFile::modeRead); + CArchive ar(&file, CArchive::load); + + while (ar.ReadString(strData)) + { + strData.TrimLeft(_T("\" \t")); + strData.TrimRight(_T("\" \t")); + AddPath(strData); + uiCount++; + } + + ar.Close(); + file.Close(); + } + catch(CException* e) + { + e->Delete(); + } + + // report + CString strFmt; + strFmt.Format(GetResManager()->LoadString(IDS_IMPORTREPORT_STRING), uiCount); + AfxMessageBox(strFmt); + } +} + +void CCustomCopyDlg::OnForcedirectoriesCheck() +{ + UpdateData(TRUE); + + GetDlgItem(IDC_IGNOREFOLDERS_CHECK)->EnableWindow(!m_bForceDirectories); +} + +void CCustomCopyDlg::OnIgnorefoldersCheck() +{ + UpdateData(TRUE); + + GetDlgItem(IDC_FORCEDIRECTORIES_CHECK)->EnableWindow(!m_bIgnoreFolders); +} Index: ch/CustomCopyDlg.cpp =================================================================== diff -u -N --- ch/CustomCopyDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/CustomCopyDlg.cpp (revision 0) @@ -1,907 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "CustomCopyDlg.h" -#include "structs.h" -#include "dialogs.h" -#include "BufferSizeDlg.h" -#include "FilterDlg.h" -#include "StringHelpers.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCustomCopyDlg dialog - - -CCustomCopyDlg::CCustomCopyDlg() : CHLanguageDialog(CCustomCopyDlg::IDD) -{ - //{{AFX_DATA_INIT(CCustomCopyDlg) - m_ucCount = 1; - m_bOnlyCreate = FALSE; - m_bIgnoreFolders = FALSE; - m_bFilters = FALSE; - m_bAdvanced = FALSE; - m_bForceDirectories = FALSE; - //}}AFX_DATA_INIT - -// m_ccData.m_astrPaths.RemoveAll(); // unneeded -// m_ccData.m_strDestPath.Empty(); - - m_ccData.m_iOperation=0; - m_ccData.m_iPriority=THREAD_PRIORITY_NORMAL; - m_ccData.m_ucCount=1; - - // m_ccData.m_bsSizes stays uninitialized - // m_ccData.m_afFilters - this too - - m_ccData.m_bIgnoreFolders=false; - m_ccData.m_bForceDirectories=false; - m_ccData.m_bCreateStructure=false; - - m_bActualisation=false; -} - -void CCustomCopyDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CCustomCopyDlg) - DDX_Control(pDX, IDC_DESTPATH_COMBOBOXEX, m_ctlDstPath); - DDX_Control(pDX, IDC_COUNT_SPIN, m_ctlCountSpin); - DDX_Control(pDX, IDC_FILTERS_LIST, m_ctlFilters); - DDX_Control(pDX, IDC_BUFFERSIZES_LIST, m_ctlBufferSizes); - DDX_Control(pDX, IDC_OPERATION_COMBO, m_ctlOperation); - DDX_Control(pDX, IDC_PRIORITY_COMBO, m_ctlPriority); - DDX_Control(pDX, IDC_FILES_LIST, m_ctlFiles); - DDX_Text(pDX, IDC_COUNT_EDIT, m_ucCount); - DDV_MinMaxByte(pDX, m_ucCount, 1, 255); - DDX_Check(pDX, IDC_ONLYSTRUCTURE_CHECK, m_bOnlyCreate); - DDX_Check(pDX, IDC_IGNOREFOLDERS_CHECK, m_bIgnoreFolders); - DDX_Check(pDX, IDC_FORCEDIRECTORIES_CHECK, m_bForceDirectories); - DDX_Check(pDX, IDC_FILTERS_CHECK, m_bFilters); - DDX_Check(pDX, IDC_ADVANCED_CHECK, m_bAdvanced); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CCustomCopyDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CCustomCopyDlg) - ON_BN_CLICKED(IDC_ADDDIR_BUTTON, OnAddDirectoryButton) - ON_BN_CLICKED(IDC_ADDFILE_BUTTON, OnAddFilesButton) - ON_BN_CLICKED(IDC_REMOVEFILEFOLDER_BUTTON, OnRemoveButton) - ON_BN_CLICKED(IDC_DESTBROWSE_BUTTON, OnBrowseButton) - ON_BN_CLICKED(IDC_BUFFERSIZES_BUTTON, OnChangebufferButton) - ON_BN_CLICKED(IDC_ADDFILTER_BUTTON, OnAddfilterButton) - ON_BN_CLICKED(IDC_REMOVEFILTER_BUTTON, OnRemovefilterButton) - ON_WM_DESTROY() - ON_BN_CLICKED(IDC_FILTERS_CHECK, OnFiltersCheck) - ON_BN_CLICKED(IDC_STANDARD_CHECK, OnStandardCheck) - ON_BN_CLICKED(IDC_ADVANCED_CHECK, OnAdvancedCheck) - ON_NOTIFY(NM_DBLCLK, IDC_FILTERS_LIST, OnDblclkFiltersList) - ON_LBN_DBLCLK(IDC_BUFFERSIZES_LIST, OnDblclkBuffersizesList) - ON_CBN_EDITCHANGE(IDC_DESTPATH_COMBOBOXEX, OnEditchangeDestpathComboboxex) - ON_BN_CLICKED(IDC_IMPORT_BUTTON, OnImportButton) - ON_BN_CLICKED(IDC_IGNOREFOLDERS_CHECK, OnIgnorefoldersCheck) - ON_BN_CLICKED(IDC_FORCEDIRECTORIES_CHECK, OnForcedirectoriesCheck) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CCustomCopyDlg message handlers -BOOL CCustomCopyDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // make this dialog on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - // paths' listbox - init images - system image list - SHFILEINFO sfi; - HIMAGELIST hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - - m_ilImages.Attach(hImageList); - m_ctlFiles.SetImageList(&m_ilImages, LVSIL_SMALL); - - // calc list width - CRect rc; - m_ctlFiles.GetWindowRect(&rc); - 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); - - // paths' listbox - add one column - LVCOLUMN lvc; - lvc.mask=LVCF_FMT | LVCF_WIDTH; - lvc.fmt=LVCFMT_LEFT; - lvc.cx=rc.Width(); - m_ctlFiles.InsertColumn(1, &lvc); - - // fill paths' listbox - for (int i=0;iLoadString(IDS_CCDCOPY_STRING)); - m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDMOVE_STRING)); - - // copying/moving - m_ctlOperation.SetCurSel(m_ccData.m_iOperation); - - // fill priority combo - for (i=0;i<7;i++) - { - m_ctlPriority.AddString(GetResManager()->LoadString(IDS_PRIORITY0_STRING+i)); - } - - m_ctlPriority.SetCurSel(PriorityToIndex(m_ccData.m_iPriority)); - - // count of copies - m_ucCount=m_ccData.m_ucCount; - m_ctlCountSpin.SetRange(1, 255); - - // fill buffer sizes listbox - SetBuffersizesString(); - - // list width - m_ctlFilters.GetWindowRect(&rc); - rc.right-=GetSystemMetrics(SM_CXEDGE)*2; - - // filter - some columns in a header - lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; - lvc.fmt=LVCFMT_LEFT; - - // mask - lvc.iSubItem=-1; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRMASK_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.15*rc.Width()); - m_ctlFilters.InsertColumn(1, &lvc); - - // exclude mask - lvc.iSubItem=0; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEMASK_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.15*rc.Width()); - m_ctlFilters.InsertColumn(2, &lvc); - - // size - lvc.iSubItem=1; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRSIZE_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.3*rc.Width()); - m_ctlFilters.InsertColumn(3, &lvc); - - // time - lvc.iSubItem=2; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRDATE_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.3*rc.Width()); - m_ctlFilters.InsertColumn(4, &lvc); - - // attributes - lvc.iSubItem=3; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRATTRIB_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.1*rc.Width()); - m_ctlFilters.InsertColumn(5, &lvc); - - // -attributes - lvc.iSubItem=4; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEATTRIB_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.1*rc.Width()); - m_ctlFilters.InsertColumn(6, &lvc); - - m_bFilters=!!m_ccData.m_afFilters.GetSize(); - - // other custom flags - m_bAdvanced=(m_ccData.m_bIgnoreFolders | m_ccData.m_bCreateStructure); - m_bIgnoreFolders=m_ccData.m_bIgnoreFolders; - m_bForceDirectories=m_ccData.m_bForceDirectories; - m_bOnlyCreate=m_ccData.m_bCreateStructure; - - UpdateData(FALSE); - - EnableControls(); - - return TRUE; -} - -void CCustomCopyDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - UpdateData(TRUE); - - // count the width of a list - 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); - - // operation - int iPos=m_ctlOperation.GetCurSel(); - m_ctlOperation.ResetContent(); - m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDCOPY_STRING)); - m_ctlOperation.AddString(GetResManager()->LoadString(IDS_CCDMOVE_STRING)); - m_ctlOperation.SetCurSel(iPos); - - // priority combo - iPos=m_ctlPriority.GetCurSel(); - m_ctlPriority.ResetContent(); - for (int i=0;i<7;i++) - { - m_ctlPriority.AddString(GetResManager()->LoadString(IDS_PRIORITY0_STRING+i)); - } - m_ctlPriority.SetCurSel(iPos); - - // fill the listbox with buffers - SetBuffersizesString(); - - // filter section (filter, size, date, attributes) - while(m_ctlFilters.DeleteColumn(0)); // delete all columns - - lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; - lvc.fmt=LVCFMT_LEFT; - - // mask - lvc.iSubItem=-1; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRMASK_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.15*rc.Width()); - m_ctlFilters.InsertColumn(1, &lvc); - - // exclude mask - lvc.iSubItem=0; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEMASK_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.15*rc.Width()); - m_ctlFilters.InsertColumn(2, &lvc); - - // size - lvc.iSubItem=1; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRSIZE_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.3*rc.Width()); - m_ctlFilters.InsertColumn(3, &lvc); - - // time - lvc.iSubItem=2; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRDATE_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.3*rc.Width()); - m_ctlFilters.InsertColumn(4, &lvc); - - // attributes - lvc.iSubItem=3; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDRATTRIB_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.1*rc.Width()); - m_ctlFilters.InsertColumn(5, &lvc); - - // -attributes - lvc.iSubItem=4; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_HDREXCLUDEATTRIB_STRING); - lvc.cchTextMax=lstrlen(lvc.pszText); - lvc.cx=static_cast(0.1*rc.Width()); - m_ctlFilters.InsertColumn(6, &lvc); - - // refresh the entries in filters' list - m_ctlFilters.DeleteAllItems(); - for (i=0;iLoadString(IDS_BROWSE_STRING), &strPath)) - AddPath(strPath); -} - -void CCustomCopyDlg::OnAddFilesButton() -{ - CFileDialog dlg(TRUE, NULL, NULL, OFN_ALLOWMULTISELECT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NODEREFERENCELINKS | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager()->LoadString(IDS_FILEDLGALLFILTER_STRING), this); - - TCHAR *pszBuffer=new TCHAR[65535]; - memset(pszBuffer, 0, 65535*sizeof(TCHAR)); - dlg.m_ofn.lpstrFile=pszBuffer; - dlg.m_ofn.nMaxFile=65535; - - if (dlg.DoModal() == IDOK) - { - // first element is the path - CString strPath=pszBuffer; - - int iOffset=_tcslen(pszBuffer)+1; - - // get filenames - if (pszBuffer[iOffset] == _T('\0')) - AddPath(strPath); - else - { - if (strPath.Right(1) != _T("\\")) - strPath+=_T("\\"); - while (pszBuffer[iOffset] != _T('\0')) - { - AddPath(strPath+CString(pszBuffer+iOffset)); - iOffset+=_tcslen(pszBuffer+iOffset)+1; - } - } - } - - // delete buffer - delete [] pszBuffer; -} - -void CCustomCopyDlg::OnRemoveButton() -{ - POSITION pos; - int iItem; - while (true) - { - pos = m_ctlFiles.GetFirstSelectedItemPosition(); - if (pos == NULL) - break; - else - { - iItem=m_ctlFiles.GetNextSelectedItem(pos); - m_ctlFiles.DeleteItem(iItem); - } - } -} - -void CCustomCopyDlg::OnBrowseButton() -{ - CString strPath; - if (BrowseForFolder(GetResManager()->LoadString(IDS_DSTFOLDERBROWSE_STRING), &strPath)) - { - SetComboPath(strPath); -// m_strDest=strPath; //** - } -} - -void CCustomCopyDlg::OnOK() -{ - UpdateData(TRUE); - - // copy files from listctrl to an array - m_ccData.m_astrPaths.RemoveAll(); - CString strPath; - - for (int i=0;iLoadString(IDS_BSEDEFAULT_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiDefaultSize, szSize, true)); - m_ctlBufferSizes.AddString(szData); - - if (!m_ccData.m_bsSizes.m_bOnlyDefault) - { - _stprintf(szData, GetResManager()->LoadString(IDS_BSEONEDISK_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiOneDiskSize, szSize, true)); - m_ctlBufferSizes.AddString(szData); - - _stprintf(szData, GetResManager()->LoadString(IDS_BSETWODISKS_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiTwoDisksSize, szSize, true)); - m_ctlBufferSizes.AddString(szData); - - _stprintf(szData, GetResManager()->LoadString(IDS_BSECD_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiCDSize, szSize, true)); - m_ctlBufferSizes.AddString(szData); - - _stprintf(szData, GetResManager()->LoadString(IDS_BSELAN_STRING), GetSizeString(m_ccData.m_bsSizes.m_uiLANSize, szSize, true)); - m_ctlBufferSizes.AddString(szData); - } -} - -void CCustomCopyDlg::OnChangebufferButton() -{ - CBufferSizeDlg dlg; - dlg.m_bsSizes=m_ccData.m_bsSizes; - if (dlg.DoModal() == IDOK) - { - m_ccData.m_bsSizes=dlg.m_bsSizes; - SetBuffersizesString(); - } -} - -void CCustomCopyDlg::AddPath(CString strPath) -{ - // fill listbox with paths - LVITEM lvi; - lvi.mask=LVIF_TEXT | LVIF_IMAGE; - lvi.iItem=m_ctlFiles.GetItemCount(); - lvi.iSubItem=0; - - // there's no need for a high speed so get the images - SHFILEINFO sfi; - SHGetFileInfo(strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON/* | SHGFI_USEFILEATTRIBUTES*/); - - // fill the list - lvi.pszText=strPath.GetBuffer(0); - strPath.ReleaseBuffer(); - lvi.cchTextMax=lstrlen(lvi.pszText); - lvi.iImage=sfi.iIcon; - m_ctlFiles.InsertItem(&lvi); -} - -void CCustomCopyDlg::OnAddfilterButton() -{ - CFilterDlg dlg; - CString strData; - for (int i=0;iLoadString(IDS_FILTERMASKEMPTY_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.InsertItem(&lvi); - - ///////////////////// - lvi.iSubItem=1; - - if (rFilter.m_bUseExcludeMask) - { - CString strData; - rFilter.GetCombinedExcludeMask(strData); - _tcscpy(szLoaded, strData); - } - else - _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERMASKEMPTY_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.SetItem(&lvi); - - ///////////////// - lvi.iSubItem=2; - - if (rFilter.m_bUseSize) - { - _stprintf(szLoaded, _T("%s %s"), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iSizeType1), GetSizeString(static_cast<__int64>(rFilter.m_ullSize1), szData, true)); - - if (rFilter.m_bUseSize2) - { - _tcscat(szLoaded, GetResManager()->LoadString(IDS_AND_STRING)); - CString strLoaded2; - strLoaded2.Format(_T("%s %s"), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iSizeType2), GetSizeString(static_cast<__int64>(rFilter.m_ullSize2), szData, true)); - _tcscat(szLoaded, strLoaded2); - } - } - else - _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERSIZE_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.SetItem(&lvi); - - /////////////////// - lvi.iSubItem=3; - - if (rFilter.m_bUseDate) - { - _stprintf(szLoaded, _T("%s %s"), GetResManager()->LoadString(IDS_DATECREATED_STRING+rFilter.m_iDateType), GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iDateType1)); - if (rFilter.m_bDate1) - _tcscat(szLoaded, rFilter.m_tDate1.Format(_T(" %x"))); - if (rFilter.m_bTime1) - _tcscat(szLoaded, rFilter.m_tTime1.Format(_T(" %X"))); - - if (rFilter.m_bUseDate2) - { - _tcscat(szLoaded, GetResManager()->LoadString(IDS_AND_STRING)); - _tcscat(szLoaded, GetResManager()->LoadString(IDS_LT_STRING+rFilter.m_iDateType2)); - if (rFilter.m_bDate2) - _tcscat(szLoaded, rFilter.m_tDate2.Format(_T(" %x"))); - if (rFilter.m_bTime2) - _tcscat(szLoaded, rFilter.m_tTime2.Format(_T(" %X"))); - } - } - else - _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERDATE_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.SetItem(&lvi); - - ///////////////////// - lvi.iSubItem=4; - szLoaded[0]=_T('\0'); - if (rFilter.m_bUseAttributes) - { - if (rFilter.m_iArchive == 1) - _tcscat(szLoaded, _T("A")); - if (rFilter.m_iReadOnly == 1) - _tcscat(szLoaded, _T("R")); - if (rFilter.m_iHidden == 1) - _tcscat(szLoaded, _T("H")); - if (rFilter.m_iSystem == 1) - _tcscat(szLoaded, _T("S")); - if (rFilter.m_iDirectory == 1) - _tcscat(szLoaded, _T("D")); - } - - if (!rFilter.m_bUseAttributes || szLoaded[0] == _T('\0')) - _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERATTRIB_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.SetItem(&lvi); - - ///////////////////// - lvi.iSubItem=5; - szLoaded[0]=_T('\0'); - if (rFilter.m_bUseAttributes) - { - if (rFilter.m_iArchive == 0) - _tcscat(szLoaded, _T("A")); - if (rFilter.m_iReadOnly == 0) - _tcscat(szLoaded, _T("R")); - if (rFilter.m_iHidden == 0) - _tcscat(szLoaded, _T("H")); - if (rFilter.m_iSystem == 0) - _tcscat(szLoaded, _T("S")); - if (rFilter.m_iDirectory == 0) - _tcscat(szLoaded, _T("D")); - } - - if (!rFilter.m_bUseAttributes || szLoaded[0] == _T('0')) - _tcscpy(szLoaded, GetResManager()->LoadString(IDS_FILTERATTRIB_STRING)); - - lvi.pszText=szLoaded; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlFilters.SetItem(&lvi); -} - -void CCustomCopyDlg::OnRemovefilterButton() -{ - POSITION pos; - int iItem; - while (true) - { - pos=m_ctlFilters.GetFirstSelectedItemPosition(); - if (pos == NULL) - break; - else - { - iItem=m_ctlFilters.GetNextSelectedItem(pos); - m_ctlFilters.DeleteItem(iItem); - m_ccData.m_afFilters.RemoveAt(iItem); - } - } -} - -void CCustomCopyDlg::OnDestroy() -{ - m_ctlFiles.SetImageList(NULL, LVSIL_SMALL); - m_ilImages.Detach(); - - CHLanguageDialog::OnDestroy(); -} - -void CCustomCopyDlg::EnableControls() -{ - UpdateData(TRUE); - - m_ctlFilters.EnableWindow(m_bFilters); - GetDlgItem(IDC_ADDFILTER_BUTTON)->EnableWindow(m_bFilters); - GetDlgItem(IDC_REMOVEFILTER_BUTTON)->EnableWindow(m_bFilters); - - GetDlgItem(IDC_IGNOREFOLDERS_CHECK)->EnableWindow(m_bAdvanced && !m_bForceDirectories); - GetDlgItem(IDC_FORCEDIRECTORIES_CHECK)->EnableWindow(m_bAdvanced && !m_bIgnoreFolders); - GetDlgItem(IDC_ONLYSTRUCTURE_CHECK)->EnableWindow(m_bAdvanced); -} - -void CCustomCopyDlg::OnFiltersCheck() -{ - EnableControls(); -} - -void CCustomCopyDlg::OnStandardCheck() -{ - EnableControls(); -} - -void CCustomCopyDlg::OnAdvancedCheck() -{ - EnableControls(); -} - -void CCustomCopyDlg::OnDblclkFiltersList(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - POSITION pos=m_ctlFilters.GetFirstSelectedItemPosition(); - if (pos != NULL) - { - int iItem=m_ctlFilters.GetNextSelectedItem(pos); - CFilterDlg dlg; - dlg.m_ffFilter=m_ccData.m_afFilters.GetAt(iItem); - - CString strData; - for (int i=0;iSetSel(-1, -1); -} - -void CCustomCopyDlg::OnEditchangeDestpathComboboxex() -{ - if (m_bActualisation) - return; - m_bActualisation=true; - UpdateComboIcon(); - m_bActualisation=false; -} - -void CCustomCopyDlg::OnImportButton() -{ - CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, GetResManager()->LoadString(IDS_FLTALLFILTER_STRING)); - if (dlg.DoModal() == IDOK) - { - UINT uiCount=0; - CString strData; - try - { - CFile file(dlg.GetPathName(), CFile::modeRead); - CArchive ar(&file, CArchive::load); - - while (ar.ReadString(strData)) - { - strData.TrimLeft(_T("\" \t")); - strData.TrimRight(_T("\" \t")); - AddPath(strData); - uiCount++; - } - - ar.Close(); - file.Close(); - } - catch(CException* e) - { - e->Delete(); - } - - // report - CString strFmt; - strFmt.Format(GetResManager()->LoadString(IDS_IMPORTREPORT_STRING), uiCount); - AfxMessageBox(strFmt); - } -} - -void CCustomCopyDlg::OnForcedirectoriesCheck() -{ - UpdateData(TRUE); - - GetDlgItem(IDC_IGNOREFOLDERS_CHECK)->EnableWindow(!m_bForceDirectories); -} - -void CCustomCopyDlg::OnIgnorefoldersCheck() -{ - UpdateData(TRUE); - - GetDlgItem(IDC_FORCEDIRECTORIES_CHECK)->EnableWindow(!m_bIgnoreFolders); -} Index: src/ch/CustomCopyDlg.h =================================================================== diff -u -N --- src/ch/CustomCopyDlg.h (revision 0) +++ src/ch/CustomCopyDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,120 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __CUSTOMCOPYDLG_H__ +#define __CUSTOMCOPYDLG_H__ + +#include "DataBuffer.h" +#include "FileInfo.h" +#include "charvect.h" + +///////////////////////////////////////////////////////////////////////////// +// CCustomCopyDlg dialog + +class CCustomCopyDlg : public CHLanguageDialog +{ +// Construction +public: + CCustomCopyDlg(); // standard constructor + + void SetBuffersizesString(); + + struct _CCDATA + { + CStringArray m_astrPaths; // source paths to copy/move + CString m_strDestPath; // currently selected destination path + char_vector m_vRecent; // recently selected paths + int m_iOperation; // copy || move + int m_iPriority; // operation priority + BYTE m_ucCount; // count of copys + BUFFERSIZES m_bsSizes; // buffer sizes selected for this task + + CFiltersArray m_afFilters; // list of filters to select from combos + + bool m_bIgnoreFolders; + bool m_bForceDirectories; + bool m_bCreateStructure; + } m_ccData; + + bool m_bActualisation; // is this dialog processing the combo text changing ? +// Dialog Data + //{{AFX_DATA(CCustomCopyDlg) + enum { IDD = IDD_CUSTOM_COPY_DIALOG }; + CComboBoxEx m_ctlDstPath; + CSpinButtonCtrl m_ctlCountSpin; + CListCtrl m_ctlFilters; + CListBox m_ctlBufferSizes; + CComboBox m_ctlOperation; + CComboBox m_ctlPriority; + CListCtrl m_ctlFiles; + BYTE m_ucCount; + BOOL m_bOnlyCreate; + BOOL m_bIgnoreFolders; + BOOL m_bForceDirectories; + BOOL m_bFilters; + BOOL m_bAdvanced; + //}}AFX_DATA + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CCustomCopyDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + void UpdateDialog(); + void UpdateComboIcon(); + void SetComboPath(LPCTSTR lpszText); + void EnableControls(); + void AddFilter(const CFileFilter& rFilter, int iPos=-1); + void AddPath(CString strPath); + CImageList m_ilImages; + + // Generated message map functions + //{{AFX_MSG(CCustomCopyDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnAddDirectoryButton(); + afx_msg void OnAddFilesButton(); + afx_msg void OnRemoveButton(); + afx_msg void OnBrowseButton(); + virtual void OnOK(); + afx_msg void OnChangebufferButton(); + afx_msg void OnAddfilterButton(); + afx_msg void OnRemovefilterButton(); + afx_msg void OnDestroy(); + afx_msg void OnFiltersCheck(); + afx_msg void OnStandardCheck(); + afx_msg void OnAdvancedCheck(); + afx_msg void OnDblclkFiltersList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnDblclkBuffersizesList(); + afx_msg void OnEditchangeDestpathComboboxex(); + afx_msg void OnImportButton(); + afx_msg void OnIgnorefoldersCheck(); + afx_msg void OnForcedirectoriesCheck(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/CustomCopyDlg.h =================================================================== diff -u -N --- ch/CustomCopyDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/CustomCopyDlg.h (revision 0) @@ -1,120 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __CUSTOMCOPYDLG_H__ -#define __CUSTOMCOPYDLG_H__ - -#include "DataBuffer.h" -#include "FileInfo.h" -#include "charvect.h" - -///////////////////////////////////////////////////////////////////////////// -// CCustomCopyDlg dialog - -class CCustomCopyDlg : public CHLanguageDialog -{ -// Construction -public: - CCustomCopyDlg(); // standard constructor - - void SetBuffersizesString(); - - struct _CCDATA - { - CStringArray m_astrPaths; // source paths to copy/move - CString m_strDestPath; // currently selected destination path - char_vector m_vRecent; // recently selected paths - int m_iOperation; // copy || move - int m_iPriority; // operation priority - BYTE m_ucCount; // count of copys - BUFFERSIZES m_bsSizes; // buffer sizes selected for this task - - CFiltersArray m_afFilters; // list of filters to select from combos - - bool m_bIgnoreFolders; - bool m_bForceDirectories; - bool m_bCreateStructure; - } m_ccData; - - bool m_bActualisation; // is this dialog processing the combo text changing ? -// Dialog Data - //{{AFX_DATA(CCustomCopyDlg) - enum { IDD = IDD_CUSTOM_COPY_DIALOG }; - CComboBoxEx m_ctlDstPath; - CSpinButtonCtrl m_ctlCountSpin; - CListCtrl m_ctlFilters; - CListBox m_ctlBufferSizes; - CComboBox m_ctlOperation; - CComboBox m_ctlPriority; - CListCtrl m_ctlFiles; - BYTE m_ucCount; - BOOL m_bOnlyCreate; - BOOL m_bIgnoreFolders; - BOOL m_bForceDirectories; - BOOL m_bFilters; - BOOL m_bAdvanced; - //}}AFX_DATA - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CCustomCopyDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - void UpdateDialog(); - void UpdateComboIcon(); - void SetComboPath(LPCTSTR lpszText); - void EnableControls(); - void AddFilter(const CFileFilter& rFilter, int iPos=-1); - void AddPath(CString strPath); - CImageList m_ilImages; - - // Generated message map functions - //{{AFX_MSG(CCustomCopyDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnAddDirectoryButton(); - afx_msg void OnAddFilesButton(); - afx_msg void OnRemoveButton(); - afx_msg void OnBrowseButton(); - virtual void OnOK(); - afx_msg void OnChangebufferButton(); - afx_msg void OnAddfilterButton(); - afx_msg void OnRemovefilterButton(); - afx_msg void OnDestroy(); - afx_msg void OnFiltersCheck(); - afx_msg void OnStandardCheck(); - afx_msg void OnAdvancedCheck(); - afx_msg void OnDblclkFiltersList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDblclkBuffersizesList(); - afx_msg void OnEditchangeDestpathComboboxex(); - afx_msg void OnImportButton(); - afx_msg void OnIgnorefoldersCheck(); - afx_msg void OnForcedirectoriesCheck(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/DataBuffer.cpp =================================================================== diff -u -N --- src/ch/DataBuffer.cpp (revision 0) +++ src/ch/DataBuffer.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,162 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "DataBuffer.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +bool BUFFERSIZES::operator==(const BUFFERSIZES& bsSizes) const +{ + return (m_uiDefaultSize == bsSizes.m_uiDefaultSize + && m_uiOneDiskSize == bsSizes.m_uiOneDiskSize + && m_uiTwoDisksSize == bsSizes.m_uiTwoDisksSize + && m_uiCDSize == bsSizes.m_uiCDSize + && m_uiLANSize == bsSizes.m_uiLANSize); +} + +void BUFFERSIZES::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + ar<(m_bOnlyDefault); + } + else + { + ar>>m_uiDefaultSize; + ar>>m_uiOneDiskSize; + ar>>m_uiTwoDisksSize; + ar>>m_uiCDSize; + ar>>m_uiLANSize; + unsigned char ucTemp; + ar>>ucTemp; + m_bOnlyDefault=(ucTemp != 0); + } +} + +const BUFFERSIZES* CDataBuffer::Create(const BUFFERSIZES* pbsSizes) +{ + // if trying to set 0-size buffer + BUFFERSIZES bsSizes=*pbsSizes; // copy - not to mix in the def. param + + if (bsSizes.m_uiDefaultSize == 0) + bsSizes.m_uiDefaultSize=DEFAULT_SIZE; + if (bsSizes.m_uiOneDiskSize == 0) + bsSizes.m_uiOneDiskSize=DEFAULT_SIZE; + if (bsSizes.m_uiTwoDisksSize == 0) + bsSizes.m_uiTwoDisksSize=DEFAULT_SIZE; + if (bsSizes.m_uiCDSize == 0) + bsSizes.m_uiCDSize=DEFAULT_SIZE; + if (bsSizes.m_uiLANSize == 0) + bsSizes.m_uiLANSize=DEFAULT_SIZE; + + // max value from the all + UINT uiLargest; + if (bsSizes.m_bOnlyDefault) + uiLargest=bsSizes.m_uiDefaultSize; + else + { + uiLargest=(bsSizes.m_uiDefaultSize > bsSizes.m_uiOneDiskSize ? bsSizes.m_uiDefaultSize : bsSizes.m_uiOneDiskSize); + if (uiLargest < bsSizes.m_uiTwoDisksSize) + uiLargest=bsSizes.m_uiTwoDisksSize; + if (uiLargest < bsSizes.m_uiCDSize) + uiLargest=bsSizes.m_uiCDSize; + if (uiLargest < bsSizes.m_uiLANSize) + uiLargest=bsSizes.m_uiLANSize; + } + + // modify buffer size to the next 64k boundary + UINT uiRealSize=ROUNDTODS(uiLargest); + TRACE("Size: %lu, rounded: %lu\n", uiLargest, uiRealSize); + + if (m_uiRealSize == uiRealSize) + { + // real buffersize doesn't changed + m_bsSizes=bsSizes; + + return &m_bsSizes; + } + + // try to allocate + LPVOID pBuffer=VirtualAlloc(NULL, uiRealSize, MEM_COMMIT, PAGE_READWRITE); + if (pBuffer == NULL) + { + if (m_pBuffer == NULL) + { + // try safe buffesize + pBuffer=VirtualAlloc(NULL, DEFAULT_SIZE, MEM_COMMIT, PAGE_READWRITE); + if (pBuffer == NULL) + return &m_bsSizes; // do not change anything + + // delete old buffer + Delete(); + + // store data + m_pBuffer=static_cast(pBuffer); + m_uiRealSize=DEFAULT_SIZE; + m_bsSizes.m_bOnlyDefault=bsSizes.m_bOnlyDefault; + m_bsSizes.m_uiDefaultSize=DEFAULT_SIZE; + m_bsSizes.m_uiOneDiskSize=DEFAULT_SIZE; + m_bsSizes.m_uiTwoDisksSize=DEFAULT_SIZE; + m_bsSizes.m_uiCDSize=DEFAULT_SIZE; + m_bsSizes.m_uiLANSize=DEFAULT_SIZE; + + return &m_bsSizes; + } + else + { + // no new buffer could be created - leave the old one + return &m_bsSizes; + } + } + else + { + // succeeded + Delete(); // get rid of old buffer + + // store data + m_pBuffer=static_cast(pBuffer); + m_uiRealSize=uiRealSize; + m_bsSizes=bsSizes; + + return &m_bsSizes; + } +} + +void CDataBuffer::Delete() +{ + if (m_pBuffer != NULL) + { + VirtualFree(static_cast(m_pBuffer), m_uiRealSize, MEM_DECOMMIT); + m_pBuffer=NULL; + m_uiRealSize=0; + m_bsSizes.m_uiDefaultSize=0; + m_bsSizes.m_uiOneDiskSize=0; + m_bsSizes.m_uiTwoDisksSize=0; + m_bsSizes.m_uiCDSize=0; + m_bsSizes.m_uiLANSize=0; + } +} \ No newline at end of file Index: ch/DataBuffer.cpp =================================================================== diff -u -N --- ch/DataBuffer.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DataBuffer.cpp (revision 0) @@ -1,162 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "DataBuffer.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -bool BUFFERSIZES::operator==(const BUFFERSIZES& bsSizes) const -{ - return (m_uiDefaultSize == bsSizes.m_uiDefaultSize - && m_uiOneDiskSize == bsSizes.m_uiOneDiskSize - && m_uiTwoDisksSize == bsSizes.m_uiTwoDisksSize - && m_uiCDSize == bsSizes.m_uiCDSize - && m_uiLANSize == bsSizes.m_uiLANSize); -} - -void BUFFERSIZES::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - ar<(m_bOnlyDefault); - } - else - { - ar>>m_uiDefaultSize; - ar>>m_uiOneDiskSize; - ar>>m_uiTwoDisksSize; - ar>>m_uiCDSize; - ar>>m_uiLANSize; - unsigned char ucTemp; - ar>>ucTemp; - m_bOnlyDefault=(ucTemp != 0); - } -} - -const BUFFERSIZES* CDataBuffer::Create(const BUFFERSIZES* pbsSizes) -{ - // if trying to set 0-size buffer - BUFFERSIZES bsSizes=*pbsSizes; // copy - not to mix in the def. param - - if (bsSizes.m_uiDefaultSize == 0) - bsSizes.m_uiDefaultSize=DEFAULT_SIZE; - if (bsSizes.m_uiOneDiskSize == 0) - bsSizes.m_uiOneDiskSize=DEFAULT_SIZE; - if (bsSizes.m_uiTwoDisksSize == 0) - bsSizes.m_uiTwoDisksSize=DEFAULT_SIZE; - if (bsSizes.m_uiCDSize == 0) - bsSizes.m_uiCDSize=DEFAULT_SIZE; - if (bsSizes.m_uiLANSize == 0) - bsSizes.m_uiLANSize=DEFAULT_SIZE; - - // max value from the all - UINT uiLargest; - if (bsSizes.m_bOnlyDefault) - uiLargest=bsSizes.m_uiDefaultSize; - else - { - uiLargest=(bsSizes.m_uiDefaultSize > bsSizes.m_uiOneDiskSize ? bsSizes.m_uiDefaultSize : bsSizes.m_uiOneDiskSize); - if (uiLargest < bsSizes.m_uiTwoDisksSize) - uiLargest=bsSizes.m_uiTwoDisksSize; - if (uiLargest < bsSizes.m_uiCDSize) - uiLargest=bsSizes.m_uiCDSize; - if (uiLargest < bsSizes.m_uiLANSize) - uiLargest=bsSizes.m_uiLANSize; - } - - // modify buffer size to the next 64k boundary - UINT uiRealSize=ROUNDTODS(uiLargest); - TRACE("Size: %lu, rounded: %lu\n", uiLargest, uiRealSize); - - if (m_uiRealSize == uiRealSize) - { - // real buffersize doesn't changed - m_bsSizes=bsSizes; - - return &m_bsSizes; - } - - // try to allocate - LPVOID pBuffer=VirtualAlloc(NULL, uiRealSize, MEM_COMMIT, PAGE_READWRITE); - if (pBuffer == NULL) - { - if (m_pBuffer == NULL) - { - // try safe buffesize - pBuffer=VirtualAlloc(NULL, DEFAULT_SIZE, MEM_COMMIT, PAGE_READWRITE); - if (pBuffer == NULL) - return &m_bsSizes; // do not change anything - - // delete old buffer - Delete(); - - // store data - m_pBuffer=static_cast(pBuffer); - m_uiRealSize=DEFAULT_SIZE; - m_bsSizes.m_bOnlyDefault=bsSizes.m_bOnlyDefault; - m_bsSizes.m_uiDefaultSize=DEFAULT_SIZE; - m_bsSizes.m_uiOneDiskSize=DEFAULT_SIZE; - m_bsSizes.m_uiTwoDisksSize=DEFAULT_SIZE; - m_bsSizes.m_uiCDSize=DEFAULT_SIZE; - m_bsSizes.m_uiLANSize=DEFAULT_SIZE; - - return &m_bsSizes; - } - else - { - // no new buffer could be created - leave the old one - return &m_bsSizes; - } - } - else - { - // succeeded - Delete(); // get rid of old buffer - - // store data - m_pBuffer=static_cast(pBuffer); - m_uiRealSize=uiRealSize; - m_bsSizes=bsSizes; - - return &m_bsSizes; - } -} - -void CDataBuffer::Delete() -{ - if (m_pBuffer != NULL) - { - VirtualFree(static_cast(m_pBuffer), m_uiRealSize, MEM_DECOMMIT); - m_pBuffer=NULL; - m_uiRealSize=0; - m_bsSizes.m_uiDefaultSize=0; - m_bsSizes.m_uiOneDiskSize=0; - m_bsSizes.m_uiTwoDisksSize=0; - m_bsSizes.m_uiCDSize=0; - m_bsSizes.m_uiLANSize=0; - } -} \ No newline at end of file Index: src/ch/DataBuffer.h =================================================================== diff -u -N --- src/ch/DataBuffer.h (revision 0) +++ src/ch/DataBuffer.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,86 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __DATABUFFER_H__ +#define __DATABUFFER_H__ + +#define DEFAULT_SIZE 65536 + +#define ROUNDTODS(number)\ + ((number + DEFAULT_SIZE - 1) & ~(DEFAULT_SIZE-1)) + +#define ROUNDUP(number, to)\ + ((number + to - 1) & ~(to-1)) + +#define ROUNDDOWN(number, to)\ + (number & ~(to-1)) + +#define BI_DEFAULT 0 +#define BI_ONEDISK 1 +#define BI_TWODISKS 2 +#define BI_CD 3 +#define BI_LAN 4 + +#pragma warning (disable: 4201) +struct BUFFERSIZES +{ + void Serialize(CArchive& ar); + bool operator==(const BUFFERSIZES& bsSizes) const; + union + { + struct + { + UINT m_uiDefaultSize; // default buffer size + UINT m_uiOneDiskSize; // inside one disk boundary + UINT m_uiTwoDisksSize; // two disks + UINT m_uiCDSize; // CD<->anything + UINT m_uiLANSize; // LAN<->anything + }; + UINT m_auiSizes[5]; + }; + bool m_bOnlyDefault; +}; +#pragma warning (default: 4201) + +class CDataBuffer +{ +public: + CDataBuffer() { m_pBuffer=NULL; m_uiRealSize=0; m_bsSizes.m_uiDefaultSize=0; m_bsSizes.m_uiOneDiskSize=0; m_bsSizes.m_uiTwoDisksSize=0; m_bsSizes.m_uiCDSize=0; m_bsSizes.m_uiLANSize=0; m_bsSizes.m_bOnlyDefault=false; }; + ~CDataBuffer() { Delete(); }; + + const BUFFERSIZES* Create(const BUFFERSIZES* pbsSizes); // (re)allocates the buffer; if there's an error - restores previous buffer size + void Delete(); // deletes buffer + + UINT GetRealSize() { return m_uiRealSize; }; + UINT GetDefaultSize() { return m_bsSizes.m_uiDefaultSize; }; + UINT GetOneDiskSize() { return m_bsSizes.m_uiOneDiskSize; }; + UINT GetTwoDisksSize() { return m_bsSizes.m_uiTwoDisksSize; }; + UINT GetCDSize() { return m_bsSizes.m_uiCDSize; }; + UINT GetLANSize() { return m_bsSizes.m_uiLANSize; }; + const BUFFERSIZES* GetSizes() { return &m_bsSizes; }; + + // operators + operator unsigned char*() { return m_pBuffer; }; +protected: + unsigned char *m_pBuffer; // buffer address + UINT m_uiRealSize; // real buffer size + BUFFERSIZES m_bsSizes; +}; + +#endif \ No newline at end of file Index: ch/DataBuffer.h =================================================================== diff -u -N --- ch/DataBuffer.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DataBuffer.h (revision 0) @@ -1,86 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __DATABUFFER_H__ -#define __DATABUFFER_H__ - -#define DEFAULT_SIZE 65536 - -#define ROUNDTODS(number)\ - ((number + DEFAULT_SIZE - 1) & ~(DEFAULT_SIZE-1)) - -#define ROUNDUP(number, to)\ - ((number + to - 1) & ~(to-1)) - -#define ROUNDDOWN(number, to)\ - (number & ~(to-1)) - -#define BI_DEFAULT 0 -#define BI_ONEDISK 1 -#define BI_TWODISKS 2 -#define BI_CD 3 -#define BI_LAN 4 - -#pragma warning (disable: 4201) -struct BUFFERSIZES -{ - void Serialize(CArchive& ar); - bool operator==(const BUFFERSIZES& bsSizes) const; - union - { - struct - { - UINT m_uiDefaultSize; // default buffer size - UINT m_uiOneDiskSize; // inside one disk boundary - UINT m_uiTwoDisksSize; // two disks - UINT m_uiCDSize; // CD<->anything - UINT m_uiLANSize; // LAN<->anything - }; - UINT m_auiSizes[5]; - }; - bool m_bOnlyDefault; -}; -#pragma warning (default: 4201) - -class CDataBuffer -{ -public: - CDataBuffer() { m_pBuffer=NULL; m_uiRealSize=0; m_bsSizes.m_uiDefaultSize=0; m_bsSizes.m_uiOneDiskSize=0; m_bsSizes.m_uiTwoDisksSize=0; m_bsSizes.m_uiCDSize=0; m_bsSizes.m_uiLANSize=0; m_bsSizes.m_bOnlyDefault=false; }; - ~CDataBuffer() { Delete(); }; - - const BUFFERSIZES* Create(const BUFFERSIZES* pbsSizes); // (re)allocates the buffer; if there's an error - restores previous buffer size - void Delete(); // deletes buffer - - UINT GetRealSize() { return m_uiRealSize; }; - UINT GetDefaultSize() { return m_bsSizes.m_uiDefaultSize; }; - UINT GetOneDiskSize() { return m_bsSizes.m_uiOneDiskSize; }; - UINT GetTwoDisksSize() { return m_bsSizes.m_uiTwoDisksSize; }; - UINT GetCDSize() { return m_bsSizes.m_uiCDSize; }; - UINT GetLANSize() { return m_bsSizes.m_uiLANSize; }; - const BUFFERSIZES* GetSizes() { return &m_bsSizes; }; - - // operators - operator unsigned char*() { return m_pBuffer; }; -protected: - unsigned char *m_pBuffer; // buffer address - UINT m_uiRealSize; // real buffer size - BUFFERSIZES m_bsSizes; -}; - -#endif \ No newline at end of file Index: src/ch/DestPath.cpp =================================================================== diff -u -N --- src/ch/DestPath.cpp (revision 0) +++ src/ch/DestPath.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,92 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "DestPath.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +void GetDriveData(LPCTSTR lpszPath, int* piDrvNum, UINT* puiDrvType) +{ + TCHAR drv[_MAX_DRIVE+1]; + + _tsplitpath(lpszPath, drv, NULL, NULL, NULL); + if(lstrlen(drv) != 0) + { + // add '\\' + lstrcat(drv, _T("\\")); + _tcsupr(drv); + + // disk number + if (piDrvNum) + *piDrvNum=drv[0]-_T('A'); + + // disk type + if (puiDrvType) + { + *puiDrvType=GetDriveType(drv); + if (*puiDrvType == DRIVE_NO_ROOT_DIR) + *puiDrvType=DRIVE_UNKNOWN; + } + } + else + { + // there's no disk in a path + if (piDrvNum) + *piDrvNum=-1; + + if (puiDrvType) + { + // check for unc path + if (_tcsncmp(lpszPath, _T("\\\\"), 2) == 0) + *puiDrvType=DRIVE_REMOTE; + else + *puiDrvType=DRIVE_UNKNOWN; + } + } +} + +void CDestPath::SetPath(LPCTSTR lpszPath) +{ + m_strPath=lpszPath; + + // make sure '\\' has been added + if (m_strPath.Right(1) != _T('\\')) + m_strPath+=_T('\\'); + + GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); +} + +void CDestPath::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + ar<>m_strPath; + ar>>m_iDriveNumber; + ar>>m_uiDriveType; + } +} Index: ch/DestPath.cpp =================================================================== diff -u -N --- ch/DestPath.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DestPath.cpp (revision 0) @@ -1,92 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "DestPath.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -void GetDriveData(LPCTSTR lpszPath, int* piDrvNum, UINT* puiDrvType) -{ - TCHAR drv[_MAX_DRIVE+1]; - - _tsplitpath(lpszPath, drv, NULL, NULL, NULL); - if(lstrlen(drv) != 0) - { - // add '\\' - lstrcat(drv, _T("\\")); - _tcsupr(drv); - - // disk number - if (piDrvNum) - *piDrvNum=drv[0]-_T('A'); - - // disk type - if (puiDrvType) - { - *puiDrvType=GetDriveType(drv); - if (*puiDrvType == DRIVE_NO_ROOT_DIR) - *puiDrvType=DRIVE_UNKNOWN; - } - } - else - { - // there's no disk in a path - if (piDrvNum) - *piDrvNum=-1; - - if (puiDrvType) - { - // check for unc path - if (_tcsncmp(lpszPath, _T("\\\\"), 2) == 0) - *puiDrvType=DRIVE_REMOTE; - else - *puiDrvType=DRIVE_UNKNOWN; - } - } -} - -void CDestPath::SetPath(LPCTSTR lpszPath) -{ - m_strPath=lpszPath; - - // make sure '\\' has been added - if (m_strPath.Right(1) != _T('\\')) - m_strPath+=_T('\\'); - - GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); -} - -void CDestPath::Serialize(CArchive& ar) -{ - if (ar.IsStoring()) - { - ar<>m_strPath; - ar>>m_iDriveNumber; - ar>>m_uiDriveType; - } -} Index: src/ch/DestPath.h =================================================================== diff -u -N --- src/ch/DestPath.h (revision 0) +++ src/ch/DestPath.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,41 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __DESTPATH_H__ +#define __DESTPATH_H__ + +class CDestPath +{ +public: + CDestPath() { m_iDriveNumber=-1; m_uiDriveType=static_cast(-1); }; + void SetPath(LPCTSTR lpszPath); + const CString& GetPath() const { return m_strPath; }; + + int GetDriveNumber() const { return m_iDriveNumber; }; + UINT GetDriveType() const { return m_uiDriveType; }; + + void Serialize(CArchive& ar); + +protected: + CString m_strPath; // always with ending '\\' + int m_iDriveNumber; // initialized within setpath (std -1) + UINT m_uiDriveType; // disk type - -1 if none, the rest like in GetDriveType +}; + +#endif \ No newline at end of file Index: ch/DestPath.h =================================================================== diff -u -N --- ch/DestPath.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DestPath.h (revision 0) @@ -1,41 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __DESTPATH_H__ -#define __DESTPATH_H__ - -class CDestPath -{ -public: - CDestPath() { m_iDriveNumber=-1; m_uiDriveType=static_cast(-1); }; - void SetPath(LPCTSTR lpszPath); - const CString& GetPath() const { return m_strPath; }; - - int GetDriveNumber() const { return m_iDriveNumber; }; - UINT GetDriveType() const { return m_uiDriveType; }; - - void Serialize(CArchive& ar); - -protected: - CString m_strPath; // always with ending '\\' - int m_iDriveNumber; // initialized within setpath (std -1) - UINT m_uiDriveType; // disk type - -1 if none, the rest like in GetDriveType -}; - -#endif \ No newline at end of file Index: src/ch/Device IO.h =================================================================== diff -u -N --- src/ch/Device IO.h (revision 0) +++ src/ch/Device IO.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,179 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#define VWIN32_DIOC_DOS_IOCTL 1 + +typedef struct _DEVIOCTL_REGISTERS +{ + DWORD reg_EBX; + DWORD reg_EDX; + DWORD reg_ECX; + DWORD reg_EAX; + DWORD reg_EDI; + DWORD reg_ESI; + DWORD reg_Flags; +} DEVIOCTL_REGISTERS, *PDEVIOCTL_REGISTERS; + +#pragma pack(1) +typedef struct _DRIVE_MAP_INFO +{ + BYTE dmiAllocationLength; + BYTE dmiInfoLength; + BYTE dmiFlags; + BYTE dmiInt13Unit; + DWORD dmiAssociatedDriveMap; + ULONGLONG dmiPartitionStartRBA; +} DRIVE_MAP_INFO, *PDRIVE_MAP_INFO; +#pragma pack() + +// only 9x +BOOL GetDriveMapInfo(UINT nDrive, PDRIVE_MAP_INFO pdmi) +{ + DEVIOCTL_REGISTERS reg, *preg; + reg.reg_EAX = 0x440D; // IOCTL for block devices + reg.reg_EBX = nDrive; // zero-based drive ID + reg.reg_ECX = 0x086f; // Get Media ID command + reg.reg_EDX = (DWORD)pdmi; // receives media ID info + preg=® + + preg->reg_Flags = 0x8000; // assume error (carry flag set) + + HANDLE hDevice = CreateFile("\\\\.\\vwin32", + GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, + (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); + + if (hDevice == (HANDLE)INVALID_HANDLE_VALUE) + { + return FALSE; + } + else + { + DWORD cb; + BOOL fResult = DeviceIoControl(hDevice, VWIN32_DIOC_DOS_IOCTL, + preg, sizeof(*preg), preg, sizeof(*preg), &cb, 0); + + if (!fResult) + { + CloseHandle(hDevice); + return FALSE; + } + } + + CloseHandle(hDevice); + + return TRUE; +} + +// only NT +bool GetSignature(LPCTSTR lpszDrive, LPTSTR lpszBuffer, int iSize) +{ + TCHAR szMapping[1024], szQuery[16384], szSymbolic[1024]; + + // read mappings + if (QueryDosDevice(lpszDrive, szMapping, 1024) == 0) + return false; + + // search for all, to find out in which string is the signature + int iCount, iCount2; + if ((iCount=QueryDosDevice(NULL, szQuery, 16384)) == 0) + { + TRACE("Encountered error #%lu @QueryDosDevice\n", GetLastError()); + return false; + } + + int iOffset=0, iOffset2=0; + TCHAR *pszSignature, *pszOffset; + while (iOffset < iCount) + { + if ((iCount2=QueryDosDevice(szQuery+iOffset, szSymbolic, 1024)) == 0) + return false; + + // read values from szSymbolic and compare with szMapping + iOffset2=0; + while (iOffset2 < iCount2) + { + // compare szSymbolic+iOffset2 with szMapping + if (_tcscmp(szMapping, szSymbolic+iOffset2) == 0 + && _tcsncmp(szQuery+iOffset, _T("STORAGE#Volume#"), _tcslen("STORAGE#Volume#")) == 0) + { + // now search for 'Signature' and extract (from szQuery+iOffset) + pszSignature=_tcsstr(szQuery+iOffset, _T("Signature")); + if (pszSignature == NULL) + continue; + pszOffset=_tcsstr(pszSignature, _T("Offset")); + if (pszOffset == NULL) + continue; + + // for better string copying + pszOffset[0]=_T('\0'); + + // found Signature & Offset - copy + int iCnt=reinterpret_cast(pszOffset)-reinterpret_cast(pszSignature)+1; + _tcsncpy(lpszBuffer, pszSignature, (iCnt > iSize) ? iSize : iCnt); + return true; + } + + iOffset2+=_tcslen(szSymbolic)+1; + } + + iOffset+=_tcslen(szQuery+iOffset)+1; + } + + return false; +} + +// at 9x function checks int13h devices and at NT within symbolic links +bool IsSamePhysicalDisk(int iDrvNum1, int iDrvNum2) +{ + OSVERSIONINFO osvi; + osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); + + GetVersionEx(&osvi); + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + { + DRIVE_MAP_INFO dmi1, dmi2; + dmi1.dmiAllocationLength=sizeof(DRIVE_MAP_INFO); + dmi1.dmiInt13Unit=0xff; + dmi2.dmiAllocationLength=sizeof(DRIVE_MAP_INFO); + dmi2.dmiInt13Unit=0xff; + + // iDrvNum is 0-based, and we need 1-based + if (!GetDriveMapInfo(iDrvNum1+1, &dmi1) || !GetDriveMapInfo(iDrvNum2+1, &dmi2) || dmi1.dmiInt13Unit != dmi2.dmiInt13Unit || dmi1.dmiInt13Unit == 0xff) + return false; + else + return true; + } + else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) + { + TCHAR drv1[3], drv2[3]; + + drv1[0]=static_cast(iDrvNum1+_T('A')); + drv1[1]=_T(':'); + drv1[2]=_T('\0'); + drv2[0]=static_cast(iDrvNum2+_T('A')); + drv2[1]=_T(':'); + drv2[2]=_T('\0'); + + TCHAR szSign1[512], szSign2[512]; + return (GetSignature(drv1, szSign1, 512) && GetSignature(drv2, szSign2, 512) && _tcscmp(szSign1, szSign2) == 0); + } + + return false; +} Index: ch/Device IO.h =================================================================== diff -u -N --- ch/Device IO.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Device IO.h (revision 0) @@ -1,179 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#define VWIN32_DIOC_DOS_IOCTL 1 - -typedef struct _DEVIOCTL_REGISTERS -{ - DWORD reg_EBX; - DWORD reg_EDX; - DWORD reg_ECX; - DWORD reg_EAX; - DWORD reg_EDI; - DWORD reg_ESI; - DWORD reg_Flags; -} DEVIOCTL_REGISTERS, *PDEVIOCTL_REGISTERS; - -#pragma pack(1) -typedef struct _DRIVE_MAP_INFO -{ - BYTE dmiAllocationLength; - BYTE dmiInfoLength; - BYTE dmiFlags; - BYTE dmiInt13Unit; - DWORD dmiAssociatedDriveMap; - ULONGLONG dmiPartitionStartRBA; -} DRIVE_MAP_INFO, *PDRIVE_MAP_INFO; -#pragma pack() - -// only 9x -BOOL GetDriveMapInfo(UINT nDrive, PDRIVE_MAP_INFO pdmi) -{ - DEVIOCTL_REGISTERS reg, *preg; - reg.reg_EAX = 0x440D; // IOCTL for block devices - reg.reg_EBX = nDrive; // zero-based drive ID - reg.reg_ECX = 0x086f; // Get Media ID command - reg.reg_EDX = (DWORD)pdmi; // receives media ID info - preg=® - - preg->reg_Flags = 0x8000; // assume error (carry flag set) - - HANDLE hDevice = CreateFile("\\\\.\\vwin32", - GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, - (LPSECURITY_ATTRIBUTES) NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); - - if (hDevice == (HANDLE)INVALID_HANDLE_VALUE) - { - return FALSE; - } - else - { - DWORD cb; - BOOL fResult = DeviceIoControl(hDevice, VWIN32_DIOC_DOS_IOCTL, - preg, sizeof(*preg), preg, sizeof(*preg), &cb, 0); - - if (!fResult) - { - CloseHandle(hDevice); - return FALSE; - } - } - - CloseHandle(hDevice); - - return TRUE; -} - -// only NT -bool GetSignature(LPCTSTR lpszDrive, LPTSTR lpszBuffer, int iSize) -{ - TCHAR szMapping[1024], szQuery[16384], szSymbolic[1024]; - - // read mappings - if (QueryDosDevice(lpszDrive, szMapping, 1024) == 0) - return false; - - // search for all, to find out in which string is the signature - int iCount, iCount2; - if ((iCount=QueryDosDevice(NULL, szQuery, 16384)) == 0) - { - TRACE("Encountered error #%lu @QueryDosDevice\n", GetLastError()); - return false; - } - - int iOffset=0, iOffset2=0; - TCHAR *pszSignature, *pszOffset; - while (iOffset < iCount) - { - if ((iCount2=QueryDosDevice(szQuery+iOffset, szSymbolic, 1024)) == 0) - return false; - - // read values from szSymbolic and compare with szMapping - iOffset2=0; - while (iOffset2 < iCount2) - { - // compare szSymbolic+iOffset2 with szMapping - if (_tcscmp(szMapping, szSymbolic+iOffset2) == 0 - && _tcsncmp(szQuery+iOffset, _T("STORAGE#Volume#"), _tcslen("STORAGE#Volume#")) == 0) - { - // now search for 'Signature' and extract (from szQuery+iOffset) - pszSignature=_tcsstr(szQuery+iOffset, _T("Signature")); - if (pszSignature == NULL) - continue; - pszOffset=_tcsstr(pszSignature, _T("Offset")); - if (pszOffset == NULL) - continue; - - // for better string copying - pszOffset[0]=_T('\0'); - - // found Signature & Offset - copy - int iCnt=reinterpret_cast(pszOffset)-reinterpret_cast(pszSignature)+1; - _tcsncpy(lpszBuffer, pszSignature, (iCnt > iSize) ? iSize : iCnt); - return true; - } - - iOffset2+=_tcslen(szSymbolic)+1; - } - - iOffset+=_tcslen(szQuery+iOffset)+1; - } - - return false; -} - -// at 9x function checks int13h devices and at NT within symbolic links -bool IsSamePhysicalDisk(int iDrvNum1, int iDrvNum2) -{ - OSVERSIONINFO osvi; - osvi.dwOSVersionInfoSize=sizeof(OSVERSIONINFO); - - GetVersionEx(&osvi); - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - { - DRIVE_MAP_INFO dmi1, dmi2; - dmi1.dmiAllocationLength=sizeof(DRIVE_MAP_INFO); - dmi1.dmiInt13Unit=0xff; - dmi2.dmiAllocationLength=sizeof(DRIVE_MAP_INFO); - dmi2.dmiInt13Unit=0xff; - - // iDrvNum is 0-based, and we need 1-based - if (!GetDriveMapInfo(iDrvNum1+1, &dmi1) || !GetDriveMapInfo(iDrvNum2+1, &dmi2) || dmi1.dmiInt13Unit != dmi2.dmiInt13Unit || dmi1.dmiInt13Unit == 0xff) - return false; - else - return true; - } - else if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) - { - TCHAR drv1[3], drv2[3]; - - drv1[0]=static_cast(iDrvNum1+_T('A')); - drv1[1]=_T(':'); - drv1[2]=_T('\0'); - drv2[0]=static_cast(iDrvNum2+_T('A')); - drv2[1]=_T(':'); - drv2[2]=_T('\0'); - - TCHAR szSign1[512], szSign2[512]; - return (GetSignature(drv1, szSign1, 512) && GetSignature(drv2, szSign2, 512) && _tcscmp(szSign1, szSign2) == 0); - } - - return false; -} Index: src/ch/Dialogs.cpp =================================================================== diff -u -N --- src/ch/Dialogs.cpp (revision 0) +++ src/ch/Dialogs.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,67 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "dialogs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +bool BrowseForFolder(LPCTSTR lpszTitle, CString* pResult) +{ + // code allows browsing on all disks + LPMALLOC pMalloc; + TCHAR pszBuffer[MAX_PATH]; + sprintf(pszBuffer, "c:\\windows\\system"); + bool retval=false; + + /* Gets the Shell's default allocator */ + if (::SHGetMalloc(&pMalloc) == NOERROR) + { + BROWSEINFO bi; + LPITEMIDLIST pidl; + + // Get help on BROWSEINFO struct - it's got all the bit settings. + bi.hwndOwner = NULL; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszBuffer; + bi.lpszTitle = lpszTitle; + bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + bi.lpfn = NULL; + bi.lParam = 0; + + // This next call issues the dialog box. + if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) + { + if (::SHGetPathFromIDList(pidl, pszBuffer)) + { + *pResult=pszBuffer; + retval=true; + } + + // Free the PIDL allocated by SHBrowseForFolder. + pMalloc->Free(pidl); + } + // Release the shell's allocator. + pMalloc->Release(); + } + + return retval; +} Index: ch/Dialogs.cpp =================================================================== diff -u -N --- ch/Dialogs.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Dialogs.cpp (revision 0) @@ -1,67 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "dialogs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -bool BrowseForFolder(LPCTSTR lpszTitle, CString* pResult) -{ - // code allows browsing on all disks - LPMALLOC pMalloc; - TCHAR pszBuffer[MAX_PATH]; - sprintf(pszBuffer, "c:\\windows\\system"); - bool retval=false; - - /* Gets the Shell's default allocator */ - if (::SHGetMalloc(&pMalloc) == NOERROR) - { - BROWSEINFO bi; - LPITEMIDLIST pidl; - - // Get help on BROWSEINFO struct - it's got all the bit settings. - bi.hwndOwner = NULL; - bi.pidlRoot = NULL; - bi.pszDisplayName = pszBuffer; - bi.lpszTitle = lpszTitle; - bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - bi.lpfn = NULL; - bi.lParam = 0; - - // This next call issues the dialog box. - if ((pidl = ::SHBrowseForFolder(&bi)) != NULL) - { - if (::SHGetPathFromIDList(pidl, pszBuffer)) - { - *pResult=pszBuffer; - retval=true; - } - - // Free the PIDL allocated by SHBrowseForFolder. - pMalloc->Free(pidl); - } - // Release the shell's allocator. - pMalloc->Release(); - } - - return retval; -} Index: src/ch/Dialogs.h =================================================================== diff -u -N --- src/ch/Dialogs.h (revision 0) +++ src/ch/Dialogs.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,27 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __DIALOGS_H__ +#define __DIALOGS_H__ + +#include "shlobj.h" + +bool BrowseForFolder(LPCTSTR lpszTitle, CString* pResult); + +#endif \ No newline at end of file Index: ch/Dialogs.h =================================================================== diff -u -N --- ch/Dialogs.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Dialogs.h (revision 0) @@ -1,27 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __DIALOGS_H__ -#define __DIALOGS_H__ - -#include "shlobj.h" - -bool BrowseForFolder(LPCTSTR lpszTitle, CString* pResult); - -#endif \ No newline at end of file Index: src/ch/DirTreeCtrl.cpp =================================================================== diff -u -N --- src/ch/DirTreeCtrl.cpp (revision 0) +++ src/ch/DirTreeCtrl.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1141 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "DirTreeCtrl.h" +#include "afxtempl.h" +#include "memdc.h" +#include "shlobj.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define WM_INITCONTROL WM_USER+7 + +LPITEMIDLIST Next(LPCITEMIDLIST pidl) +{ + LPSTR lpMem=(LPSTR)pidl; + + lpMem+=pidl->mkid.cb; + + return (LPITEMIDLIST)lpMem; +} + +UINT GetSize(LPCITEMIDLIST pidl) +{ + UINT cbTotal = 0; + if (pidl) + { + cbTotal += sizeof(pidl->mkid.cb); // Null terminator + while (pidl->mkid.cb) + { + cbTotal += pidl->mkid.cb; + pidl = Next(pidl); + } + } + + return cbTotal; +} + +LPITEMIDLIST CreatePidl(UINT cbSize) +{ + LPMALLOC lpMalloc; + HRESULT hr; + LPITEMIDLIST pidl=NULL; + + hr=SHGetMalloc(&lpMalloc); + + if (FAILED(hr)) + return 0; + + pidl=(LPITEMIDLIST)lpMalloc->Alloc(cbSize); + + if (pidl) + memset(pidl, 0, cbSize); // zero-init for external task alloc + + if (lpMalloc) lpMalloc->Release(); + + return pidl; +} + +void FreePidl(LPITEMIDLIST lpiidl) +{ + LPMALLOC lpMalloc; + HRESULT hr; + + hr=SHGetMalloc(&lpMalloc); + + if (FAILED(hr)) + return; + + lpMalloc->Free(lpiidl); + + if (lpMalloc) lpMalloc->Release(); +} + +LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) +{ + LPITEMIDLIST pidlNew; + UINT cb1; + UINT cb2; + + if (pidl1) //May be NULL + cb1 = GetSize(pidl1) - sizeof(pidl1->mkid.cb); + else + cb1 = 0; + + cb2 = GetSize(pidl2); + + pidlNew = CreatePidl(cb1 + cb2); + if (pidlNew) + { + if (pidl1) + memcpy(pidlNew, pidl1, cb1); + memcpy(((LPSTR)pidlNew) + cb1, pidl2, cb2); + } + return pidlNew; +} + +LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi) +{ + LPITEMIDLIST lpiTemp; + + lpiTemp=(LPITEMIDLIST)lpMalloc->Alloc(lpi->mkid.cb+sizeof(lpi->mkid.cb)); + CopyMemory((PVOID)lpiTemp, (CONST VOID *)lpi, lpi->mkid.cb+sizeof(lpi->mkid.cb)); + + return lpiTemp; +} + +BOOL GetName(LPSHELLFOLDER lpsf, + LPITEMIDLIST lpi, + DWORD dwFlags, + LPSTR lpFriendlyName) +{ + BOOL bSuccess=TRUE; + STRRET str; + + if (NOERROR==lpsf->GetDisplayNameOf(lpi,dwFlags, &str)) + { + switch (str.uType) + { + case STRRET_WSTR: + + WideCharToMultiByte(CP_ACP, // CodePage + 0, // dwFlags + str.pOleStr, // lpWideCharStr + -1, // cchWideChar + lpFriendlyName, // lpMultiByteStr + MAX_PATH, + //sizeof(lpFriendlyName), // cchMultiByte, wrong. sizeof on a pointer, psk, psk + NULL, // lpDefaultChar, + NULL); // lpUsedDefaultChar + + break; + + case STRRET_OFFSET: + + lstrcpy(lpFriendlyName, (LPSTR)lpi+str.uOffset); + break; + + case STRRET_CSTR: + + lstrcpy(lpFriendlyName, (LPSTR)str.cStr); + break; + + default: + bSuccess = FALSE; + break; + } + } + else + bSuccess = FALSE; + + return bSuccess; +} + +LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi) +{ + char szBuff[MAX_PATH]; + OLECHAR szOleChar[MAX_PATH]; + LPSHELLFOLDER lpsfDeskTop; + LPITEMIDLIST lpifq; + ULONG ulEaten, ulAttribs; + HRESULT hr; + + if (!GetName(lpsf, lpi, SHGDN_FORPARSING, szBuff)) + return NULL; + + hr=SHGetDesktopFolder(&lpsfDeskTop); + + if (FAILED(hr)) + return NULL; + + MultiByteToWideChar(CP_ACP, + MB_PRECOMPOSED, + szBuff, + -1, + (USHORT *)szOleChar, + sizeof(szOleChar)); + + hr=lpsfDeskTop->ParseDisplayName(NULL, + NULL, + szOleChar, + &ulEaten, + &lpifq, + &ulAttribs); + + lpsfDeskTop->Release(); + + if (FAILED(hr)) + return NULL; + + return lpifq; +} + +///////////////////////////////////////////////////////////////////////////// +// CDirTreeCtrl + +CDirTreeCtrl::CDirTreeCtrl() +{ + m_hDrives=NULL; + m_hNetwork=NULL; + m_hImageList=NULL; + m_bIgnore=false; + m_iEditType=0; +// RegisterWindowClass(); +} +/* +bool CDirTreeCtrl::RegisterWindowClass() +{ + WNDCLASS wndcls; + HINSTANCE hInst = AfxGetInstanceHandle(); + + if (!(::GetClassInfo(hInst, DIRTREECTRL_CLASSNAME, &wndcls))) + { + // otherwise we need to register a new class + wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; + wndcls.lpfnWndProc = ::DefWindowProc; + wndcls.cbClsExtra = wndcls.cbWndExtra = 0; + wndcls.hInstance = hInst; + wndcls.hIcon = NULL; + wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); + wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1); + wndcls.lpszMenuName = NULL; + wndcls.lpszClassName = DIRTREECTRL_CLASSNAME; + + if (!AfxRegisterClass(&wndcls)) + { + AfxThrowResourceException(); + return false; + } + } + + return true; +} +*/ +CDirTreeCtrl::~CDirTreeCtrl() +{ +} + + +BEGIN_MESSAGE_MAP(CDirTreeCtrl, CTreeCtrl) + //{{AFX_MSG_MAP(CDirTreeCtrl) + ON_WM_DESTROY() + ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding) + ON_NOTIFY_REFLECT(TVN_DELETEITEM, OnDeleteitem) + ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, OnItemexpanded) + ON_NOTIFY_REFLECT(TVN_ENDLABELEDIT, OnEndlabeledit) + ON_NOTIFY_REFLECT(TVN_BEGINLABELEDIT, OnBeginLabelEdit) + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDirTreeCtrl message handlers + +///////////////////////////////////////////////////////////////////////////// +// inicjalizacja +void CDirTreeCtrl::PreSubclassWindow() +{ +// InitControl(); // here's not needed (strange ??) + CTreeCtrl::PreSubclassWindow(); +} + +int CDirTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CTreeCtrl::OnCreate(lpCreateStruct) == -1) + return -1; + + InitControl(); + + return 0; +} + +void CDirTreeCtrl::InitControl() +{ + // prepare image list + SHFILEINFO sfi; + m_hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + + TreeView_SetImageList(this->m_hWnd, m_hImageList, TVSIL_NORMAL); + + // insert desktop icon + InsertDesktopItem(); + + // expanding, ... + PostMessage(WM_INITCONTROL); +} + +///////////////////////////////////////////////////////////////////////////// +// wstawia ikon� pulpitu +HTREEITEM CDirTreeCtrl::InsertDesktopItem() +{ + // clear treectrl - it shouldn't be more than 1 desktop + if (!DeleteAllItems()) + return NULL; + + // clear vars + m_hDrives=NULL; + m_hNetwork=NULL; + + // fill with items + SHFILEINFO sfi; + LPSHELLFOLDER lpsfDesktop; + LPITEMIDLIST lpiidlDesktop; + if (FAILED(SHGetDesktopFolder(&lpsfDesktop))) + return NULL; + if (SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_DESKTOP, &lpiidlDesktop) != NOERROR) + return NULL; + + // add desktop + TVITEM tvi; + TVINSERTSTRUCT tvis; + TCHAR szText[_MAX_PATH]; + _SHELLITEMDATA *psid=new _SHELLITEMDATA; + psid->lpiidl=lpiidlDesktop; + psid->lpsf=lpsfDesktop; + psid->lpiidlRelative=NULL; + psid->lpsfParent=NULL; + + tvi.mask=TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM; + if (!GetName(lpsfDesktop, lpiidlDesktop, 0/*SHGDN_INCLUDE_NONFILESYS*/, szText)) + lstrcpy(szText, _T("???")); + tvi.pszText=szText; + sfi.iIcon=-1; + SHGetFileInfo((LPCTSTR)lpiidlDesktop, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + tvi.iImage=sfi.iIcon; + sfi.iIcon=-1; + SHGetFileInfo((LPCTSTR)lpiidlDesktop, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON); + tvi.iSelectedImage=sfi.iIcon; + tvi.cChildren=1; + tvi.lParam=reinterpret_cast(psid); + + tvis.hParent=TVI_ROOT; + tvis.item=tvi; + return InsertItem(&tvis); +} + +////////////////////////////////////////////////////////////////////////////// +// processes WM_INITCONTROL +LRESULT CDirTreeCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_INITCONTROL: + ExpandItem(GetRootItem(), TVE_EXPAND); + break; + case WM_SETPATH: + SetPath((LPCTSTR)lParam); + break; + } + + return CTreeCtrl::WindowProc(message, wParam, lParam); +} + +//////////////////////////////////////////////////////////////////////////// +// enables image list, ... +void CDirTreeCtrl::OnDestroy() +{ + SetImageList(NULL, LVSIL_SMALL); + CTreeCtrl::OnDestroy(); +} + +//////////////////////////////////////////////////////////////////////////// +// compares two items +int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM/* lParamSort*/) +{ + // je�li si� nie da + if (lParam1 == NULL || lParam2 == NULL) + return 0; + + // normalne przetwarzanie + SHELLITEMDATA* psidl1=(SHELLITEMDATA*)lParam1, *psidl2=(SHELLITEMDATA*)lParam2; + + LPSHELLFOLDER lpsf; + if (SHGetDesktopFolder(&lpsf) != NOERROR) + return 0; + + HRESULT hRes=lpsf->CompareIDs(0, psidl1->lpiidl, psidl2->lpiidl); + if (!SUCCEEDED(hRes)) + return 0; + + lpsf->Release(); + + return (short)SCODE_CODE(GetScode(hRes)); +} + +///////////////////////////////////////////////////////////////////////////// +// fills a hParent node with items starting with lpsf and lpdil for this item +bool CDirTreeCtrl::FillNode(HTREEITEM hParent, LPSHELLFOLDER lpsf, LPITEMIDLIST lpidl, bool bSilent) +{ + // get the global flag under consideration + if (m_bIgnoreShellDialogs) + bSilent=m_bIgnoreShellDialogs; + + // get the desktop interface and id's of list for net neigh. and my computer + LPSHELLFOLDER lpsfDesktop=NULL; + LPITEMIDLIST lpiidlDrives=NULL, lpiidlNetwork=NULL; + if (hParent == GetRootItem()) + { + SHGetDesktopFolder(&lpsfDesktop); + SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_DRIVES, &lpiidlDrives); + SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_NETWORK, &lpiidlNetwork); + } + + LPITEMIDLIST lpiidl; + SHFILEINFO sfi; + ULONG ulAttrib; + TVITEM tvi; + TVINSERTSTRUCT tvis; + _SHELLITEMDATA *psid; + TCHAR szText[_MAX_PATH]; + LPENUMIDLIST lpeid=NULL; + HTREEITEM hCurrent=NULL; + bool bFound=false; + + // shell allocator + LPMALLOC lpm; + if (SHGetMalloc(&lpm) != NOERROR) + return false; + + // enumerate child items for lpsf + if (lpsf->EnumObjects(bSilent ? NULL : GetParent()->GetSafeHwnd(), SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN, &lpeid) != NOERROR) + return false; + + while (lpeid->Next(1, &lpiidl, NULL) == NOERROR) + { + // filer what has been found + ulAttrib=SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM; + lpsf->GetAttributesOf(1, (const struct _ITEMIDLIST **)&lpiidl, &ulAttrib); + if (ulAttrib & SFGAO_FOLDER && (ulAttrib & SFGAO_FILESYSANCESTOR || ulAttrib & SFGAO_FILESYSTEM) ) + { + // there's something to add so set bFound + bFound=true; + + // it's time to add everything + psid=new _SHELLITEMDATA; + lpsf->BindToObject(lpiidl, NULL, IID_IShellFolder, (void**)&psid->lpsf); + psid->lpiidl=ConcatPidls(lpidl, lpiidl); + psid->lpiidlRelative=CopyITEMID(lpm, lpiidl); + psid->lpsfParent=lpsf; + + tvi.mask=TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM; + if (!GetName(lpsf, lpiidl, SHGDN_INFOLDER/* | SHGDN_INCLUDE_NONFILESYS*/, szText)) + lstrcpy(szText, _T("???")); + tvi.pszText=szText; + sfi.iIcon=-1; + SHGetFileInfo((LPCTSTR)psid->lpiidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + tvi.iImage=sfi.iIcon; + sfi.iIcon=-1; + SHGetFileInfo((LPCTSTR)psid->lpiidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON); + tvi.iSelectedImage=sfi.iIcon; + tvi.cChildren=(ulAttrib & SFGAO_HASSUBFOLDER); + tvi.lParam=reinterpret_cast(psid); + + tvis.hParent=hParent; + tvis.item=tvi; + hCurrent=InsertItem(&tvis); + + if (hParent == GetRootItem()) + { + // if this is My computer or net. neigh. - it's better to remember the handles + // compare psid->lpiidl and (lpiidlDrives & lpiidlNetwork) + if (SCODE_CODE(lpsfDesktop->CompareIDs(0, psid->lpiidl, lpiidlDrives)) == 0) + m_hDrives=hCurrent; + else if (SCODE_CODE(lpsfDesktop->CompareIDs(0, psid->lpiidl, lpiidlNetwork)) == 0) + m_hNetwork=hCurrent; + } + + FreePidl(lpiidl); // free found pidl - it was copied already + } + } + + if (lpeid) + lpeid->Release(); + + if (lpsfDesktop) + lpsfDesktop->Release(); + + lpm->Release(); + + // sortuj + if (bFound) + { + TVSORTCB tvscb; + tvscb.hParent=hParent; + tvscb.lpfnCompare=&CompareFunc; + tvscb.lParam=NULL; + if (!SortChildrenCB(&tvscb)) + TRACE("SortChildren failed\n"); + } + else + { + // some items has + and some not - correction + TVITEM tvi; + tvi.mask=TVIF_HANDLE | TVIF_CHILDREN; + tvi.hItem=hParent; + if (GetItem(&tvi) && tvi.cChildren == 1) + { + tvi.cChildren=0; + SetItem(&tvi); + } + } + + return bFound; +} + +//////////////////////////////////////////////////////////////////////////// +// alternate function for Expand(), makes additional processing +bool CDirTreeCtrl::ExpandItem(HTREEITEM hItem, UINT nCode) +{ + switch(nCode) + { + case TVE_EXPAND: + { + // get the item's data + TVITEM tvi; + tvi.mask=TVIF_PARAM | TVIF_STATE; + tvi.hItem=hItem; + tvi.stateMask=TVIS_EXPANDEDONCE | TVIS_SELECTED | TVIS_EXPANDED; + if (!GetItem(&tvi)) + return false; + + if (tvi.state & TVIS_EXPANDED) + return true; + + // Fill node before normal expanding + SHELLITEMDATA* psid; + if (GetItemStruct(hItem, &psid)) + { + if (!FillNode(hItem, psid->lpsf, psid->lpiidl, true)) + TRACE("FillNode in ExpandItem failed...\n"); + + // ignore fillnode in onitemexpanding + m_bIgnore=true; + } + + // normal expand + EnsureVisible(hItem); + SelectItem(hItem); + return Expand(hItem, TVE_EXPAND) != 0; + + break; + } + default: + return Expand(hItem, nCode) != 0; + } +} + +///////////////////////////////////////////////////////////////////////////// +// node expand handling - calls FillNode +void CDirTreeCtrl::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; + _SHELLITEMDATA* psid=reinterpret_cast<_SHELLITEMDATA*>(pNMTreeView->itemNew.lParam); + + switch (pNMTreeView->action) + { + case TVE_EXPAND: + if (!m_bIgnore) + { + // fill + if (!FillNode(pNMTreeView->itemNew.hItem, psid->lpsf, psid->lpiidl)) + TRACE("FillNode failed...\n"); + } + else + { + // now refresh normally + m_bIgnore=false; + } + break; + } + + *pResult = 0; +} + +//////////////////////////////////////////////////////////////////////////// +// deleting items after node collapses +void CDirTreeCtrl::OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; + + switch (pNMTreeView->action) + { + case TVE_COLLAPSE: + if (ItemHasChildren(pNMTreeView->itemNew.hItem)) + { + HTREEITEM hItem; + while ((hItem=GetChildItem(pNMTreeView->itemNew.hItem)) != NULL) + DeleteItem(hItem); + } + + break; + } + + *pResult = 0; +} + +////////////////////////////////////////////////////////////////////////////// +// deletes everything what has been allocated for an item +void CDirTreeCtrl::OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; + _SHELLITEMDATA *psid=reinterpret_cast<_SHELLITEMDATA*>(pNMTreeView->itemOld.lParam); + + if (psid) + { + psid->lpsf->Release(); + FreePidl(psid->lpiidl); + FreePidl(psid->lpiidlRelative); + delete psid; + } + + *pResult = 0; +} + +/////////////////////////////////////////////////////////////////////////// +// returns path associated with an item +bool CDirTreeCtrl::GetPath(HTREEITEM hItem, LPTSTR pszPath) +{ + TVITEM tvi; + tvi.mask=TVIF_HANDLE | TVIF_PARAM; + tvi.hItem=hItem; + + if (GetItem(&tvi)) + { + // item data + _SHELLITEMDATA* psid=reinterpret_cast<_SHELLITEMDATA*>(tvi.lParam); + if (psid == NULL) + return false; + + // desktop interface + LPSHELLFOLDER lpsf; + if (SHGetDesktopFolder(&lpsf) != NOERROR) + return false; + + if (!SHGetPathFromIDList(psid->lpiidl, pszPath)) + { + lpsf->Release(); + return false; + } + + lpsf->Release(); + return true; + } + else + return false; +} + +//////////////////////////////////////////////////////////////////////////// +// finds the item that is nearest to a given path - returns true if find +// even a part of a path +bool CDirTreeCtrl::SetPath(LPCTSTR lpszPath) +{ + ASSERT(lpszPath); + + // if path is empty + if (_tcscmp(lpszPath, _T("")) == 0) + return false; + + // type of path + bool bNetwork=_tcsncmp(lpszPath, _T("\\\\"), 2) == 0; + + if (!bNetwork) + return SetLocalPath(lpszPath); + else + { + // we don't look in net neighbourhood for speed reasons + EnsureVisible(m_hNetwork); +// SelectItem(m_hNetwork); +// ExpandItem(m_hNetwork, TVE_EXPAND); + return true; + } +} + + +/////////////////////////////////////////////////////////////////////////// +// sets the local path - not network +bool CDirTreeCtrl::SetLocalPath(LPCTSTR lpszPath) +{ + // expand desktop and my computer + HTREEITEM hItem=GetRootItem(); + ExpandItem(hItem, TVE_EXPAND); + ExpandItem(m_hDrives, TVE_EXPAND); + + HTREEITEM hFound=RegularSelect(m_hDrives, lpszPath); + if (hFound) + { + EnsureVisible(hFound); + SelectItem(hFound); + ExpandItem(hFound, TVE_EXPAND); + } + + return hFound != NULL; +} + +///////////////////////////////////////////////////////////////////////////// +// sets network path +/* +bool CDirTreeCtrl::SetRemotePath(LPCTSTR lpszPath) +{ + // expand desktop and net neigh + HTREEITEM hItem=GetRootItem(); + ExpandItem(hItem, TVE_EXPAND); + ExpandItem(m_hNetwork, TVE_EXPAND); + + // find root + TCHAR szBuffer[2048]; + NETRESOURCE* pnr; + CArray m_ahRoots; // root's list + bool bSkipRootChecks=false; + HTREEITEM hRoot=GetChildItem(m_hNetwork); + while(hRoot) + { + if (!GetItemShellData(hRoot, SHGDFIL_NETRESOURCE, szBuffer, 2048)) + { + // problem with NETRESOURCE - find next + hRoot=GetNextSiblingItem(hRoot); + continue; + } + + // got NETRESOURCE + pnr=(NETRESOURCE*)szBuffer; + if (pnr->dwDisplayType == RESOURCEDISPLAYTYPE_ROOT) + m_ahRoots.Add(hRoot); + else if (pnr->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) + { + if (ComparePaths(lpszPath, pnr->lpRemoteName)) + { + bSkipRootChecks=true; // skip II phase + break; // hRoot contains handle to an item from which we need to start searching from + } + } + + // next to check + hRoot=GetNextSiblingItem(hRoot); + } + + // II phase: net neigh tree traversation + if (!bSkipRootChecks) + { + hRoot=NULL; + HTREEITEM hNode; + TCHAR szBuffer[2048]; + for (int i=0;i(tvi.lParam); + + if (SHGetPathFromIDList(psid->lpiidl, szPath)) + { + if (ComparePaths(lpszPath, szPath)) + { + // it's contained - expand + ExpandItem(hItem, TVE_EXPAND); + hLast=hItem; // remember last that matches path + + hItem=GetChildItem(hItem); // another 'zoom' + continue; + } + } + } + + // next folder + hItem=GetNextSiblingItem(hItem); + } + + // return what has been found + return hLast; +} +//////////////////////////////////////////////////////////////////////////// +// helper - finds comp in a network that matches the path. Skips all the +// workgroups, network names, ... +/* +HTREEITEM CDirTreeCtrl::TraverseNetNode(HTREEITEM hItem, LPCTSTR lpszPath, LPTSTR lpszBuffer) +{ + // start with 1st chil item + HTREEITEM hNext=GetChildItem(hItem); + NETRESOURCE *pnet; + + while (hNext) + { + // get NETRESOURCE structure - is this a server ? + if (GetItemShellData(hNext, SHGDFIL_NETRESOURCE, lpszBuffer, 2048)) + { + // got NETRESOURCE + pnet=(NETRESOURCE*)lpszBuffer; + + // is the path contained + if (ComparePaths(lpszPath, pnet->lpRemoteName)) + return hNext; // found what's needed + + if (pnet->dwDisplayType != RESOURCEDISPLAYTYPE_SERVER) + { + // expand + if (!ExpandItem(hNext, TVE_EXPAND)) + return NULL; + + // recurse + HTREEITEM hFound; + if ( (hFound=TraverseNetNode(hNext, lpszPath, lpszBuffer)) != NULL) + return hFound; // if found - return, if not - continue search + } + } + + // next item to check. + hNext=GetNextSiblingItem(hNext); + } + + return NULL; // nothing has been found +} +*/ +//////////////////////////////////////////////////////////////////////////// +// compares two paths - if one is contained in another (to the first '\\' or '/' +bool CDirTreeCtrl::ComparePaths(LPCTSTR lpszFull, LPCTSTR lpszPartial) +{ + CString strSrc=lpszFull, strFnd=lpszPartial; + strFnd.MakeUpper(); + strFnd.TrimRight(_T("\\/")); + + // make uppercas the source string, cut before nearest \\ or / after strFnd.GetLength + strSrc.MakeUpper(); + + // find out the position of a nearest / lub '\\' + int iLen=strFnd.GetLength(), iPos; + if (strSrc.GetLength() >= iLen) + { + iPos=strSrc.Mid(iLen).FindOneOf(_T("\\/")); + if (iPos != -1) + strSrc=strSrc.Left(iPos+iLen); + + return strSrc == strFnd; + } + else + return false; +} + +//////////////////////////////////////////////////////////////////////////// +// returns shell description for an item (like in explorer). +bool CDirTreeCtrl::GetItemInfoTip(HTREEITEM hItem, CString* pTip) +{ + _SHELLITEMDATA* psid=(_SHELLITEMDATA*)GetItemData(hItem); + if (psid == NULL || psid->lpiidlRelative == NULL || psid->lpsfParent == NULL) + return false; + + // get interface + IQueryInfo *pqi; + if (psid->lpsfParent->GetUIObjectOf(this->GetSafeHwnd(), 1, (const struct _ITEMIDLIST**)&psid->lpiidlRelative, IID_IQueryInfo, 0, (void**)&pqi) != NOERROR) + return false; + + // get tip + WCHAR *pszTip; + if (pqi->GetInfoTip(0, &pszTip) != NOERROR) + { + pqi->Release(); + return false; + } + + // copy with a conversion + *pTip=(const WCHAR *)pszTip; + + // uwolnij pami�� skojarzon� z pszTip + LPMALLOC lpm; + if (SHGetMalloc(&lpm) == NOERROR) + { + lpm->Free(pszTip); + lpm->Release(); + } + + pqi->Release(); + + return true; +} + +//////////////////////////////////////////////////////////////////////////// +// better exchange for SHGetDataFromIDList +bool CDirTreeCtrl::GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize) +{ + PSHELLITEMDATA psid; + if (!GetItemStruct(hItem, &psid) || psid->lpsfParent == NULL || psid->lpiidlRelative == NULL) + return false; + + return SHGetDataFromIDList(psid->lpsfParent, psid->lpiidlRelative, nFormat, pBuffer, iSize) == NOERROR; +} + +///////////////////////////////////////////////////////////////////////////// +// returns SHELLITEMDATA associated with an item +bool CDirTreeCtrl::GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid) +{ + ASSERT(ppsid); + *ppsid=(PSHELLITEMDATA)GetItemData(hItem); + return *ppsid != NULL; +} + +HTREEITEM CDirTreeCtrl::InsertNewFolder(HTREEITEM hParent, LPCTSTR /*lpszNewFolder*/) +{ + // check if HTREEITEM has an associated path + TCHAR szPath[_MAX_PATH]; + if (!GetPath(hParent, szPath)) + return NULL; + + // focus + SetFocus(); + + // if has child items - enumerate + TVITEM tvi; + tvi.mask=TVIF_HANDLE | TVIF_STATE | TVIF_CHILDREN; + tvi.hItem=hParent; + tvi.stateMask=TVIS_EXPANDED; + if (GetItem(&tvi)) + { + if (!(tvi.state & TVIS_EXPANDED)) + TRACE("InsertNewFolder's expanditem returned %u\n", ExpandItem(hParent, TVE_EXPAND)); + TRACE("%lu child items\n", tvi.cChildren); + } + + // if hParent doesn't have any chilren - add + to make it look like it hastak, aby wydawa�o si�, �e ma + if (!ItemHasChildren(hParent)) + { + tvi.mask=TVIF_HANDLE | TVIF_CHILDREN; + tvi.hItem=hParent; + tvi.cChildren=1; + if (!SetItem(&tvi)) + TRACE("SetItem failed...\n"); + } + + // temp buffer for a name + TCHAR *pszPath=new TCHAR[1]; + pszPath[0]=_T('\0'); + + // insert new item with an empty lParam + TVINSERTSTRUCT tvis; + tvis.hParent=hParent; + tvis.hInsertAfter=TVI_SORT; + tvis.item.mask=TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; + tvis.item.iImage=-1; + tvis.item.iSelectedImage=-1; + tvis.item.pszText=pszPath; + tvis.item.cchTextMax=lstrlen(tvis.item.pszText); + tvis.item.lParam=NULL; + + HTREEITEM hRes=InsertItem(&tvis); + + delete [] pszPath; + + // now make sure hParent is expanded + Expand(hParent, TVE_EXPAND); + + // edit an item + if (hRes) + { + m_iEditType=1; + CEdit *pctlEdit=EditLabel(hRes); + if (pctlEdit == NULL) + return NULL; + } + + return hRes; +} + +void CDirTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMTVDISPINFO* pdi = (NMTVDISPINFO*)pNMHDR; + + if (m_iEditType == 1) // for a new folder + { + if (pdi->item.pszText && _tcslen(pdi->item.pszText) != 0) + { + // no success at beginning + int iResult=0; + + // item - parent + HTREEITEM hParent=GetParentItem(pdi->item.hItem); + + // get parent folder name + TCHAR szPath[_MAX_PATH]; + if (!GetPath(hParent, szPath)) + { + // there's no path - skip + *pResult=0; + m_iEditType=0; + + // delete item + DeleteItem(pdi->item.hItem); + GetParent()->SendMessage(WM_CREATEFOLDERRESULT, 0, iResult); + return; + } + + // try to create folder + CString strPath=szPath; + if (strPath.Right(1) != _T('\\')) + strPath+=_T('\\'); + + // full path to the new folder + strPath+=pdi->item.pszText; + + // new folder + if (CreateDirectory(strPath, NULL)) + iResult = 1; + + // refresh - delete all from hParent and fill node + HTREEITEM hChild; + while ((hChild=GetChildItem(hParent)) != NULL) + DeleteItem(hChild); + + // now fillnode + SHELLITEMDATA* psid; + if (GetItemStruct(hParent, &psid)) + { + if (!FillNode(hParent, psid->lpsf, psid->lpiidl)) + TRACE("FillNode in EndEditLabel failed...\n"); + } + + hChild=GetChildItem(hParent); + while(hChild) + { + if (!GetPath(hChild, szPath)) + { + hChild=GetNextSiblingItem(hChild); + continue; + } + + if (_tcscmp(strPath, szPath) == 0) + { + // zaznacz + ExpandItem(hChild, TVE_EXPAND); + break; + } + + hChild=GetNextSiblingItem(hChild); + } + + + // another members + *pResult=1; + m_iEditType=0; + + GetParent()->SendMessage(WM_CREATEFOLDERRESULT, 0, iResult); + } + else + { + // no path - skip + *pResult=0; + m_iEditType=0; + + // delete an item + DeleteItem(pdi->item.hItem); + } + } + + *pResult = 0; +} + +void CDirTreeCtrl::OnBeginLabelEdit(NMHDR* /*pNMHDR*/, LRESULT* pResult) +{ + if (m_iEditType == 1) + *pResult=0; + else + *pResult=1; +} + +BOOL CDirTreeCtrl::OnEraseBkgnd(CDC* /*pDC*/) +{ + return FALSE; +} + +void CDirTreeCtrl::OnPaint() +{ + CPaintDC dc(this); // device context for painting + CMemDC memdc(&dc, &dc.m_ps.rcPaint); + + DefWindowProc(WM_PAINT, (WPARAM)memdc.GetSafeHdc(), 0); +} + +void CDirTreeCtrl::SetIgnoreShellDialogs(bool bFlag) +{ + m_bIgnoreShellDialogs=bFlag; +} + +bool CDirTreeCtrl::GetIgnoreShellDialogs() +{ + return m_bIgnoreShellDialogs; +} Index: ch/DirTreeCtrl.cpp =================================================================== diff -u -N --- ch/DirTreeCtrl.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DirTreeCtrl.cpp (revision 0) @@ -1,1141 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "DirTreeCtrl.h" -#include "afxtempl.h" -#include "memdc.h" -#include "shlobj.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define WM_INITCONTROL WM_USER+7 - -LPITEMIDLIST Next(LPCITEMIDLIST pidl) -{ - LPSTR lpMem=(LPSTR)pidl; - - lpMem+=pidl->mkid.cb; - - return (LPITEMIDLIST)lpMem; -} - -UINT GetSize(LPCITEMIDLIST pidl) -{ - UINT cbTotal = 0; - if (pidl) - { - cbTotal += sizeof(pidl->mkid.cb); // Null terminator - while (pidl->mkid.cb) - { - cbTotal += pidl->mkid.cb; - pidl = Next(pidl); - } - } - - return cbTotal; -} - -LPITEMIDLIST CreatePidl(UINT cbSize) -{ - LPMALLOC lpMalloc; - HRESULT hr; - LPITEMIDLIST pidl=NULL; - - hr=SHGetMalloc(&lpMalloc); - - if (FAILED(hr)) - return 0; - - pidl=(LPITEMIDLIST)lpMalloc->Alloc(cbSize); - - if (pidl) - memset(pidl, 0, cbSize); // zero-init for external task alloc - - if (lpMalloc) lpMalloc->Release(); - - return pidl; -} - -void FreePidl(LPITEMIDLIST lpiidl) -{ - LPMALLOC lpMalloc; - HRESULT hr; - - hr=SHGetMalloc(&lpMalloc); - - if (FAILED(hr)) - return; - - lpMalloc->Free(lpiidl); - - if (lpMalloc) lpMalloc->Release(); -} - -LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - LPITEMIDLIST pidlNew; - UINT cb1; - UINT cb2; - - if (pidl1) //May be NULL - cb1 = GetSize(pidl1) - sizeof(pidl1->mkid.cb); - else - cb1 = 0; - - cb2 = GetSize(pidl2); - - pidlNew = CreatePidl(cb1 + cb2); - if (pidlNew) - { - if (pidl1) - memcpy(pidlNew, pidl1, cb1); - memcpy(((LPSTR)pidlNew) + cb1, pidl2, cb2); - } - return pidlNew; -} - -LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi) -{ - LPITEMIDLIST lpiTemp; - - lpiTemp=(LPITEMIDLIST)lpMalloc->Alloc(lpi->mkid.cb+sizeof(lpi->mkid.cb)); - CopyMemory((PVOID)lpiTemp, (CONST VOID *)lpi, lpi->mkid.cb+sizeof(lpi->mkid.cb)); - - return lpiTemp; -} - -BOOL GetName(LPSHELLFOLDER lpsf, - LPITEMIDLIST lpi, - DWORD dwFlags, - LPSTR lpFriendlyName) -{ - BOOL bSuccess=TRUE; - STRRET str; - - if (NOERROR==lpsf->GetDisplayNameOf(lpi,dwFlags, &str)) - { - switch (str.uType) - { - case STRRET_WSTR: - - WideCharToMultiByte(CP_ACP, // CodePage - 0, // dwFlags - str.pOleStr, // lpWideCharStr - -1, // cchWideChar - lpFriendlyName, // lpMultiByteStr - MAX_PATH, - //sizeof(lpFriendlyName), // cchMultiByte, wrong. sizeof on a pointer, psk, psk - NULL, // lpDefaultChar, - NULL); // lpUsedDefaultChar - - break; - - case STRRET_OFFSET: - - lstrcpy(lpFriendlyName, (LPSTR)lpi+str.uOffset); - break; - - case STRRET_CSTR: - - lstrcpy(lpFriendlyName, (LPSTR)str.cStr); - break; - - default: - bSuccess = FALSE; - break; - } - } - else - bSuccess = FALSE; - - return bSuccess; -} - -LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi) -{ - char szBuff[MAX_PATH]; - OLECHAR szOleChar[MAX_PATH]; - LPSHELLFOLDER lpsfDeskTop; - LPITEMIDLIST lpifq; - ULONG ulEaten, ulAttribs; - HRESULT hr; - - if (!GetName(lpsf, lpi, SHGDN_FORPARSING, szBuff)) - return NULL; - - hr=SHGetDesktopFolder(&lpsfDeskTop); - - if (FAILED(hr)) - return NULL; - - MultiByteToWideChar(CP_ACP, - MB_PRECOMPOSED, - szBuff, - -1, - (USHORT *)szOleChar, - sizeof(szOleChar)); - - hr=lpsfDeskTop->ParseDisplayName(NULL, - NULL, - szOleChar, - &ulEaten, - &lpifq, - &ulAttribs); - - lpsfDeskTop->Release(); - - if (FAILED(hr)) - return NULL; - - return lpifq; -} - -///////////////////////////////////////////////////////////////////////////// -// CDirTreeCtrl - -CDirTreeCtrl::CDirTreeCtrl() -{ - m_hDrives=NULL; - m_hNetwork=NULL; - m_hImageList=NULL; - m_bIgnore=false; - m_iEditType=0; -// RegisterWindowClass(); -} -/* -bool CDirTreeCtrl::RegisterWindowClass() -{ - WNDCLASS wndcls; - HINSTANCE hInst = AfxGetInstanceHandle(); - - if (!(::GetClassInfo(hInst, DIRTREECTRL_CLASSNAME, &wndcls))) - { - // otherwise we need to register a new class - wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; - wndcls.lpfnWndProc = ::DefWindowProc; - wndcls.cbClsExtra = wndcls.cbWndExtra = 0; - wndcls.hInstance = hInst; - wndcls.hIcon = NULL; - wndcls.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); - wndcls.hbrBackground = (HBRUSH) (COLOR_3DFACE + 1); - wndcls.lpszMenuName = NULL; - wndcls.lpszClassName = DIRTREECTRL_CLASSNAME; - - if (!AfxRegisterClass(&wndcls)) - { - AfxThrowResourceException(); - return false; - } - } - - return true; -} -*/ -CDirTreeCtrl::~CDirTreeCtrl() -{ -} - - -BEGIN_MESSAGE_MAP(CDirTreeCtrl, CTreeCtrl) - //{{AFX_MSG_MAP(CDirTreeCtrl) - ON_WM_DESTROY() - ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding) - ON_NOTIFY_REFLECT(TVN_DELETEITEM, OnDeleteitem) - ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, OnItemexpanded) - ON_NOTIFY_REFLECT(TVN_ENDLABELEDIT, OnEndlabeledit) - ON_NOTIFY_REFLECT(TVN_BEGINLABELEDIT, OnBeginLabelEdit) - ON_WM_ERASEBKGND() - ON_WM_PAINT() - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDirTreeCtrl message handlers - -///////////////////////////////////////////////////////////////////////////// -// inicjalizacja -void CDirTreeCtrl::PreSubclassWindow() -{ -// InitControl(); // here's not needed (strange ??) - CTreeCtrl::PreSubclassWindow(); -} - -int CDirTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CTreeCtrl::OnCreate(lpCreateStruct) == -1) - return -1; - - InitControl(); - - return 0; -} - -void CDirTreeCtrl::InitControl() -{ - // prepare image list - SHFILEINFO sfi; - m_hImageList = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - - TreeView_SetImageList(this->m_hWnd, m_hImageList, TVSIL_NORMAL); - - // insert desktop icon - InsertDesktopItem(); - - // expanding, ... - PostMessage(WM_INITCONTROL); -} - -///////////////////////////////////////////////////////////////////////////// -// wstawia ikon� pulpitu -HTREEITEM CDirTreeCtrl::InsertDesktopItem() -{ - // clear treectrl - it shouldn't be more than 1 desktop - if (!DeleteAllItems()) - return NULL; - - // clear vars - m_hDrives=NULL; - m_hNetwork=NULL; - - // fill with items - SHFILEINFO sfi; - LPSHELLFOLDER lpsfDesktop; - LPITEMIDLIST lpiidlDesktop; - if (FAILED(SHGetDesktopFolder(&lpsfDesktop))) - return NULL; - if (SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_DESKTOP, &lpiidlDesktop) != NOERROR) - return NULL; - - // add desktop - TVITEM tvi; - TVINSERTSTRUCT tvis; - TCHAR szText[_MAX_PATH]; - _SHELLITEMDATA *psid=new _SHELLITEMDATA; - psid->lpiidl=lpiidlDesktop; - psid->lpsf=lpsfDesktop; - psid->lpiidlRelative=NULL; - psid->lpsfParent=NULL; - - tvi.mask=TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM; - if (!GetName(lpsfDesktop, lpiidlDesktop, 0/*SHGDN_INCLUDE_NONFILESYS*/, szText)) - lstrcpy(szText, _T("???")); - tvi.pszText=szText; - sfi.iIcon=-1; - SHGetFileInfo((LPCTSTR)lpiidlDesktop, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - tvi.iImage=sfi.iIcon; - sfi.iIcon=-1; - SHGetFileInfo((LPCTSTR)lpiidlDesktop, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON); - tvi.iSelectedImage=sfi.iIcon; - tvi.cChildren=1; - tvi.lParam=reinterpret_cast(psid); - - tvis.hParent=TVI_ROOT; - tvis.item=tvi; - return InsertItem(&tvis); -} - -////////////////////////////////////////////////////////////////////////////// -// processes WM_INITCONTROL -LRESULT CDirTreeCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_INITCONTROL: - ExpandItem(GetRootItem(), TVE_EXPAND); - break; - case WM_SETPATH: - SetPath((LPCTSTR)lParam); - break; - } - - return CTreeCtrl::WindowProc(message, wParam, lParam); -} - -//////////////////////////////////////////////////////////////////////////// -// enables image list, ... -void CDirTreeCtrl::OnDestroy() -{ - SetImageList(NULL, LVSIL_SMALL); - CTreeCtrl::OnDestroy(); -} - -//////////////////////////////////////////////////////////////////////////// -// compares two items -int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM/* lParamSort*/) -{ - // je�li si� nie da - if (lParam1 == NULL || lParam2 == NULL) - return 0; - - // normalne przetwarzanie - SHELLITEMDATA* psidl1=(SHELLITEMDATA*)lParam1, *psidl2=(SHELLITEMDATA*)lParam2; - - LPSHELLFOLDER lpsf; - if (SHGetDesktopFolder(&lpsf) != NOERROR) - return 0; - - HRESULT hRes=lpsf->CompareIDs(0, psidl1->lpiidl, psidl2->lpiidl); - if (!SUCCEEDED(hRes)) - return 0; - - lpsf->Release(); - - return (short)SCODE_CODE(GetScode(hRes)); -} - -///////////////////////////////////////////////////////////////////////////// -// fills a hParent node with items starting with lpsf and lpdil for this item -bool CDirTreeCtrl::FillNode(HTREEITEM hParent, LPSHELLFOLDER lpsf, LPITEMIDLIST lpidl, bool bSilent) -{ - // get the global flag under consideration - if (m_bIgnoreShellDialogs) - bSilent=m_bIgnoreShellDialogs; - - // get the desktop interface and id's of list for net neigh. and my computer - LPSHELLFOLDER lpsfDesktop=NULL; - LPITEMIDLIST lpiidlDrives=NULL, lpiidlNetwork=NULL; - if (hParent == GetRootItem()) - { - SHGetDesktopFolder(&lpsfDesktop); - SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_DRIVES, &lpiidlDrives); - SHGetSpecialFolderLocation(this->GetSafeHwnd(), CSIDL_NETWORK, &lpiidlNetwork); - } - - LPITEMIDLIST lpiidl; - SHFILEINFO sfi; - ULONG ulAttrib; - TVITEM tvi; - TVINSERTSTRUCT tvis; - _SHELLITEMDATA *psid; - TCHAR szText[_MAX_PATH]; - LPENUMIDLIST lpeid=NULL; - HTREEITEM hCurrent=NULL; - bool bFound=false; - - // shell allocator - LPMALLOC lpm; - if (SHGetMalloc(&lpm) != NOERROR) - return false; - - // enumerate child items for lpsf - if (lpsf->EnumObjects(bSilent ? NULL : GetParent()->GetSafeHwnd(), SHCONTF_FOLDERS | SHCONTF_INCLUDEHIDDEN, &lpeid) != NOERROR) - return false; - - while (lpeid->Next(1, &lpiidl, NULL) == NOERROR) - { - // filer what has been found - ulAttrib=SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM; - lpsf->GetAttributesOf(1, (const struct _ITEMIDLIST **)&lpiidl, &ulAttrib); - if (ulAttrib & SFGAO_FOLDER && (ulAttrib & SFGAO_FILESYSANCESTOR || ulAttrib & SFGAO_FILESYSTEM) ) - { - // there's something to add so set bFound - bFound=true; - - // it's time to add everything - psid=new _SHELLITEMDATA; - lpsf->BindToObject(lpiidl, NULL, IID_IShellFolder, (void**)&psid->lpsf); - psid->lpiidl=ConcatPidls(lpidl, lpiidl); - psid->lpiidlRelative=CopyITEMID(lpm, lpiidl); - psid->lpsfParent=lpsf; - - tvi.mask=TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM; - if (!GetName(lpsf, lpiidl, SHGDN_INFOLDER/* | SHGDN_INCLUDE_NONFILESYS*/, szText)) - lstrcpy(szText, _T("???")); - tvi.pszText=szText; - sfi.iIcon=-1; - SHGetFileInfo((LPCTSTR)psid->lpiidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - tvi.iImage=sfi.iIcon; - sfi.iIcon=-1; - SHGetFileInfo((LPCTSTR)psid->lpiidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON); - tvi.iSelectedImage=sfi.iIcon; - tvi.cChildren=(ulAttrib & SFGAO_HASSUBFOLDER); - tvi.lParam=reinterpret_cast(psid); - - tvis.hParent=hParent; - tvis.item=tvi; - hCurrent=InsertItem(&tvis); - - if (hParent == GetRootItem()) - { - // if this is My computer or net. neigh. - it's better to remember the handles - // compare psid->lpiidl and (lpiidlDrives & lpiidlNetwork) - if (SCODE_CODE(lpsfDesktop->CompareIDs(0, psid->lpiidl, lpiidlDrives)) == 0) - m_hDrives=hCurrent; - else if (SCODE_CODE(lpsfDesktop->CompareIDs(0, psid->lpiidl, lpiidlNetwork)) == 0) - m_hNetwork=hCurrent; - } - - FreePidl(lpiidl); // free found pidl - it was copied already - } - } - - if (lpeid) - lpeid->Release(); - - if (lpsfDesktop) - lpsfDesktop->Release(); - - lpm->Release(); - - // sortuj - if (bFound) - { - TVSORTCB tvscb; - tvscb.hParent=hParent; - tvscb.lpfnCompare=&CompareFunc; - tvscb.lParam=NULL; - if (!SortChildrenCB(&tvscb)) - TRACE("SortChildren failed\n"); - } - else - { - // some items has + and some not - correction - TVITEM tvi; - tvi.mask=TVIF_HANDLE | TVIF_CHILDREN; - tvi.hItem=hParent; - if (GetItem(&tvi) && tvi.cChildren == 1) - { - tvi.cChildren=0; - SetItem(&tvi); - } - } - - return bFound; -} - -//////////////////////////////////////////////////////////////////////////// -// alternate function for Expand(), makes additional processing -bool CDirTreeCtrl::ExpandItem(HTREEITEM hItem, UINT nCode) -{ - switch(nCode) - { - case TVE_EXPAND: - { - // get the item's data - TVITEM tvi; - tvi.mask=TVIF_PARAM | TVIF_STATE; - tvi.hItem=hItem; - tvi.stateMask=TVIS_EXPANDEDONCE | TVIS_SELECTED | TVIS_EXPANDED; - if (!GetItem(&tvi)) - return false; - - if (tvi.state & TVIS_EXPANDED) - return true; - - // Fill node before normal expanding - SHELLITEMDATA* psid; - if (GetItemStruct(hItem, &psid)) - { - if (!FillNode(hItem, psid->lpsf, psid->lpiidl, true)) - TRACE("FillNode in ExpandItem failed...\n"); - - // ignore fillnode in onitemexpanding - m_bIgnore=true; - } - - // normal expand - EnsureVisible(hItem); - SelectItem(hItem); - return Expand(hItem, TVE_EXPAND) != 0; - - break; - } - default: - return Expand(hItem, nCode) != 0; - } -} - -///////////////////////////////////////////////////////////////////////////// -// node expand handling - calls FillNode -void CDirTreeCtrl::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - _SHELLITEMDATA* psid=reinterpret_cast<_SHELLITEMDATA*>(pNMTreeView->itemNew.lParam); - - switch (pNMTreeView->action) - { - case TVE_EXPAND: - if (!m_bIgnore) - { - // fill - if (!FillNode(pNMTreeView->itemNew.hItem, psid->lpsf, psid->lpiidl)) - TRACE("FillNode failed...\n"); - } - else - { - // now refresh normally - m_bIgnore=false; - } - break; - } - - *pResult = 0; -} - -//////////////////////////////////////////////////////////////////////////// -// deleting items after node collapses -void CDirTreeCtrl::OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - - switch (pNMTreeView->action) - { - case TVE_COLLAPSE: - if (ItemHasChildren(pNMTreeView->itemNew.hItem)) - { - HTREEITEM hItem; - while ((hItem=GetChildItem(pNMTreeView->itemNew.hItem)) != NULL) - DeleteItem(hItem); - } - - break; - } - - *pResult = 0; -} - -////////////////////////////////////////////////////////////////////////////// -// deletes everything what has been allocated for an item -void CDirTreeCtrl::OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - _SHELLITEMDATA *psid=reinterpret_cast<_SHELLITEMDATA*>(pNMTreeView->itemOld.lParam); - - if (psid) - { - psid->lpsf->Release(); - FreePidl(psid->lpiidl); - FreePidl(psid->lpiidlRelative); - delete psid; - } - - *pResult = 0; -} - -/////////////////////////////////////////////////////////////////////////// -// returns path associated with an item -bool CDirTreeCtrl::GetPath(HTREEITEM hItem, LPTSTR pszPath) -{ - TVITEM tvi; - tvi.mask=TVIF_HANDLE | TVIF_PARAM; - tvi.hItem=hItem; - - if (GetItem(&tvi)) - { - // item data - _SHELLITEMDATA* psid=reinterpret_cast<_SHELLITEMDATA*>(tvi.lParam); - if (psid == NULL) - return false; - - // desktop interface - LPSHELLFOLDER lpsf; - if (SHGetDesktopFolder(&lpsf) != NOERROR) - return false; - - if (!SHGetPathFromIDList(psid->lpiidl, pszPath)) - { - lpsf->Release(); - return false; - } - - lpsf->Release(); - return true; - } - else - return false; -} - -//////////////////////////////////////////////////////////////////////////// -// finds the item that is nearest to a given path - returns true if find -// even a part of a path -bool CDirTreeCtrl::SetPath(LPCTSTR lpszPath) -{ - ASSERT(lpszPath); - - // if path is empty - if (_tcscmp(lpszPath, _T("")) == 0) - return false; - - // type of path - bool bNetwork=_tcsncmp(lpszPath, _T("\\\\"), 2) == 0; - - if (!bNetwork) - return SetLocalPath(lpszPath); - else - { - // we don't look in net neighbourhood for speed reasons - EnsureVisible(m_hNetwork); -// SelectItem(m_hNetwork); -// ExpandItem(m_hNetwork, TVE_EXPAND); - return true; - } -} - - -/////////////////////////////////////////////////////////////////////////// -// sets the local path - not network -bool CDirTreeCtrl::SetLocalPath(LPCTSTR lpszPath) -{ - // expand desktop and my computer - HTREEITEM hItem=GetRootItem(); - ExpandItem(hItem, TVE_EXPAND); - ExpandItem(m_hDrives, TVE_EXPAND); - - HTREEITEM hFound=RegularSelect(m_hDrives, lpszPath); - if (hFound) - { - EnsureVisible(hFound); - SelectItem(hFound); - ExpandItem(hFound, TVE_EXPAND); - } - - return hFound != NULL; -} - -///////////////////////////////////////////////////////////////////////////// -// sets network path -/* -bool CDirTreeCtrl::SetRemotePath(LPCTSTR lpszPath) -{ - // expand desktop and net neigh - HTREEITEM hItem=GetRootItem(); - ExpandItem(hItem, TVE_EXPAND); - ExpandItem(m_hNetwork, TVE_EXPAND); - - // find root - TCHAR szBuffer[2048]; - NETRESOURCE* pnr; - CArray m_ahRoots; // root's list - bool bSkipRootChecks=false; - HTREEITEM hRoot=GetChildItem(m_hNetwork); - while(hRoot) - { - if (!GetItemShellData(hRoot, SHGDFIL_NETRESOURCE, szBuffer, 2048)) - { - // problem with NETRESOURCE - find next - hRoot=GetNextSiblingItem(hRoot); - continue; - } - - // got NETRESOURCE - pnr=(NETRESOURCE*)szBuffer; - if (pnr->dwDisplayType == RESOURCEDISPLAYTYPE_ROOT) - m_ahRoots.Add(hRoot); - else if (pnr->dwDisplayType == RESOURCEDISPLAYTYPE_SHARE) - { - if (ComparePaths(lpszPath, pnr->lpRemoteName)) - { - bSkipRootChecks=true; // skip II phase - break; // hRoot contains handle to an item from which we need to start searching from - } - } - - // next to check - hRoot=GetNextSiblingItem(hRoot); - } - - // II phase: net neigh tree traversation - if (!bSkipRootChecks) - { - hRoot=NULL; - HTREEITEM hNode; - TCHAR szBuffer[2048]; - for (int i=0;i(tvi.lParam); - - if (SHGetPathFromIDList(psid->lpiidl, szPath)) - { - if (ComparePaths(lpszPath, szPath)) - { - // it's contained - expand - ExpandItem(hItem, TVE_EXPAND); - hLast=hItem; // remember last that matches path - - hItem=GetChildItem(hItem); // another 'zoom' - continue; - } - } - } - - // next folder - hItem=GetNextSiblingItem(hItem); - } - - // return what has been found - return hLast; -} -//////////////////////////////////////////////////////////////////////////// -// helper - finds comp in a network that matches the path. Skips all the -// workgroups, network names, ... -/* -HTREEITEM CDirTreeCtrl::TraverseNetNode(HTREEITEM hItem, LPCTSTR lpszPath, LPTSTR lpszBuffer) -{ - // start with 1st chil item - HTREEITEM hNext=GetChildItem(hItem); - NETRESOURCE *pnet; - - while (hNext) - { - // get NETRESOURCE structure - is this a server ? - if (GetItemShellData(hNext, SHGDFIL_NETRESOURCE, lpszBuffer, 2048)) - { - // got NETRESOURCE - pnet=(NETRESOURCE*)lpszBuffer; - - // is the path contained - if (ComparePaths(lpszPath, pnet->lpRemoteName)) - return hNext; // found what's needed - - if (pnet->dwDisplayType != RESOURCEDISPLAYTYPE_SERVER) - { - // expand - if (!ExpandItem(hNext, TVE_EXPAND)) - return NULL; - - // recurse - HTREEITEM hFound; - if ( (hFound=TraverseNetNode(hNext, lpszPath, lpszBuffer)) != NULL) - return hFound; // if found - return, if not - continue search - } - } - - // next item to check. - hNext=GetNextSiblingItem(hNext); - } - - return NULL; // nothing has been found -} -*/ -//////////////////////////////////////////////////////////////////////////// -// compares two paths - if one is contained in another (to the first '\\' or '/' -bool CDirTreeCtrl::ComparePaths(LPCTSTR lpszFull, LPCTSTR lpszPartial) -{ - CString strSrc=lpszFull, strFnd=lpszPartial; - strFnd.MakeUpper(); - strFnd.TrimRight(_T("\\/")); - - // make uppercas the source string, cut before nearest \\ or / after strFnd.GetLength - strSrc.MakeUpper(); - - // find out the position of a nearest / lub '\\' - int iLen=strFnd.GetLength(), iPos; - if (strSrc.GetLength() >= iLen) - { - iPos=strSrc.Mid(iLen).FindOneOf(_T("\\/")); - if (iPos != -1) - strSrc=strSrc.Left(iPos+iLen); - - return strSrc == strFnd; - } - else - return false; -} - -//////////////////////////////////////////////////////////////////////////// -// returns shell description for an item (like in explorer). -bool CDirTreeCtrl::GetItemInfoTip(HTREEITEM hItem, CString* pTip) -{ - _SHELLITEMDATA* psid=(_SHELLITEMDATA*)GetItemData(hItem); - if (psid == NULL || psid->lpiidlRelative == NULL || psid->lpsfParent == NULL) - return false; - - // get interface - IQueryInfo *pqi; - if (psid->lpsfParent->GetUIObjectOf(this->GetSafeHwnd(), 1, (const struct _ITEMIDLIST**)&psid->lpiidlRelative, IID_IQueryInfo, 0, (void**)&pqi) != NOERROR) - return false; - - // get tip - WCHAR *pszTip; - if (pqi->GetInfoTip(0, &pszTip) != NOERROR) - { - pqi->Release(); - return false; - } - - // copy with a conversion - *pTip=(const WCHAR *)pszTip; - - // uwolnij pami�� skojarzon� z pszTip - LPMALLOC lpm; - if (SHGetMalloc(&lpm) == NOERROR) - { - lpm->Free(pszTip); - lpm->Release(); - } - - pqi->Release(); - - return true; -} - -//////////////////////////////////////////////////////////////////////////// -// better exchange for SHGetDataFromIDList -bool CDirTreeCtrl::GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize) -{ - PSHELLITEMDATA psid; - if (!GetItemStruct(hItem, &psid) || psid->lpsfParent == NULL || psid->lpiidlRelative == NULL) - return false; - - return SHGetDataFromIDList(psid->lpsfParent, psid->lpiidlRelative, nFormat, pBuffer, iSize) == NOERROR; -} - -///////////////////////////////////////////////////////////////////////////// -// returns SHELLITEMDATA associated with an item -bool CDirTreeCtrl::GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid) -{ - ASSERT(ppsid); - *ppsid=(PSHELLITEMDATA)GetItemData(hItem); - return *ppsid != NULL; -} - -HTREEITEM CDirTreeCtrl::InsertNewFolder(HTREEITEM hParent, LPCTSTR /*lpszNewFolder*/) -{ - // check if HTREEITEM has an associated path - TCHAR szPath[_MAX_PATH]; - if (!GetPath(hParent, szPath)) - return NULL; - - // focus - SetFocus(); - - // if has child items - enumerate - TVITEM tvi; - tvi.mask=TVIF_HANDLE | TVIF_STATE | TVIF_CHILDREN; - tvi.hItem=hParent; - tvi.stateMask=TVIS_EXPANDED; - if (GetItem(&tvi)) - { - if (!(tvi.state & TVIS_EXPANDED)) - TRACE("InsertNewFolder's expanditem returned %u\n", ExpandItem(hParent, TVE_EXPAND)); - TRACE("%lu child items\n", tvi.cChildren); - } - - // if hParent doesn't have any chilren - add + to make it look like it hastak, aby wydawa�o si�, �e ma - if (!ItemHasChildren(hParent)) - { - tvi.mask=TVIF_HANDLE | TVIF_CHILDREN; - tvi.hItem=hParent; - tvi.cChildren=1; - if (!SetItem(&tvi)) - TRACE("SetItem failed...\n"); - } - - // temp buffer for a name - TCHAR *pszPath=new TCHAR[1]; - pszPath[0]=_T('\0'); - - // insert new item with an empty lParam - TVINSERTSTRUCT tvis; - tvis.hParent=hParent; - tvis.hInsertAfter=TVI_SORT; - tvis.item.mask=TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE; - tvis.item.iImage=-1; - tvis.item.iSelectedImage=-1; - tvis.item.pszText=pszPath; - tvis.item.cchTextMax=lstrlen(tvis.item.pszText); - tvis.item.lParam=NULL; - - HTREEITEM hRes=InsertItem(&tvis); - - delete [] pszPath; - - // now make sure hParent is expanded - Expand(hParent, TVE_EXPAND); - - // edit an item - if (hRes) - { - m_iEditType=1; - CEdit *pctlEdit=EditLabel(hRes); - if (pctlEdit == NULL) - return NULL; - } - - return hRes; -} - -void CDirTreeCtrl::OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult) -{ - NMTVDISPINFO* pdi = (NMTVDISPINFO*)pNMHDR; - - if (m_iEditType == 1) // for a new folder - { - if (pdi->item.pszText && _tcslen(pdi->item.pszText) != 0) - { - // no success at beginning - int iResult=0; - - // item - parent - HTREEITEM hParent=GetParentItem(pdi->item.hItem); - - // get parent folder name - TCHAR szPath[_MAX_PATH]; - if (!GetPath(hParent, szPath)) - { - // there's no path - skip - *pResult=0; - m_iEditType=0; - - // delete item - DeleteItem(pdi->item.hItem); - GetParent()->SendMessage(WM_CREATEFOLDERRESULT, 0, iResult); - return; - } - - // try to create folder - CString strPath=szPath; - if (strPath.Right(1) != _T('\\')) - strPath+=_T('\\'); - - // full path to the new folder - strPath+=pdi->item.pszText; - - // new folder - if (CreateDirectory(strPath, NULL)) - iResult = 1; - - // refresh - delete all from hParent and fill node - HTREEITEM hChild; - while ((hChild=GetChildItem(hParent)) != NULL) - DeleteItem(hChild); - - // now fillnode - SHELLITEMDATA* psid; - if (GetItemStruct(hParent, &psid)) - { - if (!FillNode(hParent, psid->lpsf, psid->lpiidl)) - TRACE("FillNode in EndEditLabel failed...\n"); - } - - hChild=GetChildItem(hParent); - while(hChild) - { - if (!GetPath(hChild, szPath)) - { - hChild=GetNextSiblingItem(hChild); - continue; - } - - if (_tcscmp(strPath, szPath) == 0) - { - // zaznacz - ExpandItem(hChild, TVE_EXPAND); - break; - } - - hChild=GetNextSiblingItem(hChild); - } - - - // another members - *pResult=1; - m_iEditType=0; - - GetParent()->SendMessage(WM_CREATEFOLDERRESULT, 0, iResult); - } - else - { - // no path - skip - *pResult=0; - m_iEditType=0; - - // delete an item - DeleteItem(pdi->item.hItem); - } - } - - *pResult = 0; -} - -void CDirTreeCtrl::OnBeginLabelEdit(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - if (m_iEditType == 1) - *pResult=0; - else - *pResult=1; -} - -BOOL CDirTreeCtrl::OnEraseBkgnd(CDC* /*pDC*/) -{ - return FALSE; -} - -void CDirTreeCtrl::OnPaint() -{ - CPaintDC dc(this); // device context for painting - CMemDC memdc(&dc, &dc.m_ps.rcPaint); - - DefWindowProc(WM_PAINT, (WPARAM)memdc.GetSafeHdc(), 0); -} - -void CDirTreeCtrl::SetIgnoreShellDialogs(bool bFlag) -{ - m_bIgnoreShellDialogs=bFlag; -} - -bool CDirTreeCtrl::GetIgnoreShellDialogs() -{ - return m_bIgnoreShellDialogs; -} Index: src/ch/DirTreeCtrl.h =================================================================== diff -u -N --- src/ch/DirTreeCtrl.h (revision 0) +++ src/ch/DirTreeCtrl.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,173 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + CDirTreeCtrl tree control + + Files: DirTreeCtrl.h, DirTreeCtrl.cpp + Author: Ixen Gerthannes + Usage: + Use it just as normal controls - place tree ctrl on your dialog and + subclass it. + Members: + Functions: + HTREEITEM InsertDesktopItem(); - initialisation - deletes + all items in a list, and inserts desktop root icon + bool ExpandItem(HTREEITEM hItem, UINT nCode); - replacement + for function Expand - does more processing - better; + UINT nCode just as in Expand(...) + bool GetPath(HTREEITEM hItem, LPTSTR pszPath); - returns file + system path (into pszPath) given HTREEITEM. + bool SetPath(LPCTSTR lpszPath); - try to select given path in + a directory tree. Returns true if whole path or a part of it + was selected. + bool GetItemInfoTip(HTREEITEM hItem, CString* pTip); - try to + get an explorer's tool tip text for a given HTREEITEM. + It uses IQueryInfo interface on IShellFolder. Cannot use it + for top-level item (root). Note: function may return true + with empty *pTip. + bool GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize); + functions gets data as in SHGetDataFromIDList + bool GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid); + function returns address of struct associated whith a given + item (just as GetItemData, but type-casted to SHELLITEMDATA) + Structs: + SHELLITEMDATA - struct that is associated as lParam with every + item inserted into this tree control (with new operator). + Members: + LPSHELLFOLDER lpsf; - address of IShellFolder interface + associated with this item + LPITEMIDLIST lpiidl; - this's item id list relative to + desktop folder + LPSHELLFOLDER lpsfParent; - address of IShellFolder + associated with a parent's item of this item + LPITEMIDLIST lpiidlRelative; - this's item id list + relative to lpsfParent + +*************************************************************************/ + +#ifndef __DIRTREECTRL_H__ +#define __DIRTREECTRL_H__ + +#include "shlobj.h" + +// Functions that deal with PIDLs +LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); +LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi); +LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi); +BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, LPSTR lpFriendlyName); +LPITEMIDLIST CreatePidl(UINT cbSize); +void FreePidl(LPITEMIDLIST lpiidl); +UINT GetSize(LPCITEMIDLIST pidl); +LPITEMIDLIST Next(LPCITEMIDLIST pidl); + +///////////////////////////////////////////////////////////////////////////// +// CDirTreeCtrl window +#define WM_SETPATH WM_USER+8 +#define WM_CREATEFOLDERRESULT WM_USER+9 + +#define SHELLITEMDATA _SHELLITEMDATA +#define PSHELLITEMDATA _SHELLITEMDATA* + +struct _SHELLITEMDATA +{ + LPSHELLFOLDER lpsf; // this shell folder (always exists) + LPITEMIDLIST lpiidl; // this item id list relative to desktop (always exists) + + LPSHELLFOLDER lpsfParent; // parent shell folder (may be NULL) + LPITEMIDLIST lpiidlRelative; // this item id list relative to the parent's lpsf (may be NULL) +}; + +class CDirTreeCtrl : public CTreeCtrl +{ +// Construction +public: + CDirTreeCtrl(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDirTreeCtrl) + protected: + virtual void PreSubclassWindow(); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + + // Implementation +public: + void SetIgnoreShellDialogs(bool bFlag); + bool GetIgnoreShellDialogs(); + HTREEITEM InsertDesktopItem(); + HTREEITEM InsertNewFolder(HTREEITEM hParent, LPCTSTR lpszNewFolder); + bool ExpandItem(HTREEITEM hItem, UINT nCode); + bool GetPath(HTREEITEM hItem, LPTSTR pszPath); + bool SetPath(LPCTSTR lpszPath); + bool GetItemInfoTip(HTREEITEM hItem, CString* pTip); + bool GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize); + bool GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid); + bool IsEditing() const { return m_iEditType != 0; }; + virtual ~CDirTreeCtrl(); + + // Generated message map functions +protected: + bool RegisterWindowClass(); + friend int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM/* lParamSort*/); + + //{{AFX_MSG(CDirTreeCtrl) + afx_msg void OnDestroy(); + afx_msg void OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnPaint(); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() + +// members +protected: + void InitControl(); + HTREEITEM RegularSelect(HTREEITEM hStart, LPCTSTR lpszPath); +// HTREEITEM TraverseNetNode(HTREEITEM hItem, LPCTSTR lpszPath, LPTSTR lpszBuffer); + bool ComparePaths(LPCTSTR lpszFull, LPCTSTR lpszPartial); +// bool SetRemotePath(LPCTSTR lpszPath); + bool SetLocalPath(LPCTSTR lpszPath); + bool FillNode(HTREEITEM hParent, LPSHELLFOLDER lpsf, LPITEMIDLIST lpidl, bool bSilent=false); + + bool m_bIgnoreShellDialogs; // ignore dialogs of type 'insert floppy disk' + HIMAGELIST m_hImageList; // system img list + HTREEITEM m_hDrives, m_hNetwork; // my computer's and net neighbourhood's handles + bool m_bIgnore; // ignore the nearest adding of items in OnItemexpanding + int m_iEditType; // type of item editing (0-doesn't exist (nothing for edit), 1-new folder) +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/DirTreeCtrl.h =================================================================== diff -u -N --- ch/DirTreeCtrl.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DirTreeCtrl.h (revision 0) @@ -1,173 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - CDirTreeCtrl tree control - - Files: DirTreeCtrl.h, DirTreeCtrl.cpp - Author: Ixen Gerthannes - Usage: - Use it just as normal controls - place tree ctrl on your dialog and - subclass it. - Members: - Functions: - HTREEITEM InsertDesktopItem(); - initialisation - deletes - all items in a list, and inserts desktop root icon - bool ExpandItem(HTREEITEM hItem, UINT nCode); - replacement - for function Expand - does more processing - better; - UINT nCode just as in Expand(...) - bool GetPath(HTREEITEM hItem, LPTSTR pszPath); - returns file - system path (into pszPath) given HTREEITEM. - bool SetPath(LPCTSTR lpszPath); - try to select given path in - a directory tree. Returns true if whole path or a part of it - was selected. - bool GetItemInfoTip(HTREEITEM hItem, CString* pTip); - try to - get an explorer's tool tip text for a given HTREEITEM. - It uses IQueryInfo interface on IShellFolder. Cannot use it - for top-level item (root). Note: function may return true - with empty *pTip. - bool GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize); - functions gets data as in SHGetDataFromIDList - bool GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid); - function returns address of struct associated whith a given - item (just as GetItemData, but type-casted to SHELLITEMDATA) - Structs: - SHELLITEMDATA - struct that is associated as lParam with every - item inserted into this tree control (with new operator). - Members: - LPSHELLFOLDER lpsf; - address of IShellFolder interface - associated with this item - LPITEMIDLIST lpiidl; - this's item id list relative to - desktop folder - LPSHELLFOLDER lpsfParent; - address of IShellFolder - associated with a parent's item of this item - LPITEMIDLIST lpiidlRelative; - this's item id list - relative to lpsfParent - -*************************************************************************/ - -#ifndef __DIRTREECTRL_H__ -#define __DIRTREECTRL_H__ - -#include "shlobj.h" - -// Functions that deal with PIDLs -LPITEMIDLIST ConcatPidls(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2); -LPITEMIDLIST GetFullyQualPidl(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi); -LPITEMIDLIST CopyITEMID(LPMALLOC lpMalloc, LPITEMIDLIST lpi); -BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, LPSTR lpFriendlyName); -LPITEMIDLIST CreatePidl(UINT cbSize); -void FreePidl(LPITEMIDLIST lpiidl); -UINT GetSize(LPCITEMIDLIST pidl); -LPITEMIDLIST Next(LPCITEMIDLIST pidl); - -///////////////////////////////////////////////////////////////////////////// -// CDirTreeCtrl window -#define WM_SETPATH WM_USER+8 -#define WM_CREATEFOLDERRESULT WM_USER+9 - -#define SHELLITEMDATA _SHELLITEMDATA -#define PSHELLITEMDATA _SHELLITEMDATA* - -struct _SHELLITEMDATA -{ - LPSHELLFOLDER lpsf; // this shell folder (always exists) - LPITEMIDLIST lpiidl; // this item id list relative to desktop (always exists) - - LPSHELLFOLDER lpsfParent; // parent shell folder (may be NULL) - LPITEMIDLIST lpiidlRelative; // this item id list relative to the parent's lpsf (may be NULL) -}; - -class CDirTreeCtrl : public CTreeCtrl -{ -// Construction -public: - CDirTreeCtrl(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDirTreeCtrl) - protected: - virtual void PreSubclassWindow(); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - - // Implementation -public: - void SetIgnoreShellDialogs(bool bFlag); - bool GetIgnoreShellDialogs(); - HTREEITEM InsertDesktopItem(); - HTREEITEM InsertNewFolder(HTREEITEM hParent, LPCTSTR lpszNewFolder); - bool ExpandItem(HTREEITEM hItem, UINT nCode); - bool GetPath(HTREEITEM hItem, LPTSTR pszPath); - bool SetPath(LPCTSTR lpszPath); - bool GetItemInfoTip(HTREEITEM hItem, CString* pTip); - bool GetItemShellData(HTREEITEM hItem, int nFormat, PVOID pBuffer, int iSize); - bool GetItemStruct(HTREEITEM hItem, PSHELLITEMDATA *ppsid); - bool IsEditing() const { return m_iEditType != 0; }; - virtual ~CDirTreeCtrl(); - - // Generated message map functions -protected: - bool RegisterWindowClass(); - friend int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM/* lParamSort*/); - - //{{AFX_MSG(CDirTreeCtrl) - afx_msg void OnDestroy(); - afx_msg void OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnBeginLabelEdit(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnPaint(); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() - -// members -protected: - void InitControl(); - HTREEITEM RegularSelect(HTREEITEM hStart, LPCTSTR lpszPath); -// HTREEITEM TraverseNetNode(HTREEITEM hItem, LPCTSTR lpszPath, LPTSTR lpszBuffer); - bool ComparePaths(LPCTSTR lpszFull, LPCTSTR lpszPartial); -// bool SetRemotePath(LPCTSTR lpszPath); - bool SetLocalPath(LPCTSTR lpszPath); - bool FillNode(HTREEITEM hParent, LPSHELLFOLDER lpsf, LPITEMIDLIST lpidl, bool bSilent=false); - - bool m_bIgnoreShellDialogs; // ignore dialogs of type 'insert floppy disk' - HIMAGELIST m_hImageList; // system img list - HTREEITEM m_hDrives, m_hNetwork; // my computer's and net neighbourhood's handles - bool m_bIgnore; // ignore the nearest adding of items in OnItemexpanding - int m_iEditType; // type of item editing (0-doesn't exist (nothing for edit), 1-new folder) -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/DstFileErrorDlg.cpp =================================================================== diff -u -N --- src/ch/DstFileErrorDlg.cpp (revision 0) +++ src/ch/DstFileErrorDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,120 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "DstFileErrorDlg.h" +#include "btnIDs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDstFileErrorDlg dialog + +CDstFileErrorDlg::CDstFileErrorDlg() + : CHLanguageDialog(CDstFileErrorDlg::IDD) +{ + //{{AFX_DATA_INIT(CDstFileErrorDlg) + m_strMessage = _T(""); + m_strFilename = _T(""); + //}}AFX_DATA_INIT + m_bEnableTimer=false; + m_iDefaultOption=ID_RECOPY; + m_iTime=30000; +} + + +void CDstFileErrorDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDstFileErrorDlg) + DDX_Text(pDX, IDC_MESSAGE_EDIT, m_strMessage); + DDX_Text(pDX, IDC_FILENAME_EDIT, m_strFilename); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CDstFileErrorDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CDstFileErrorDlg) + ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) + ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) + ON_BN_CLICKED(IDC_WAIT_BUTTON, OnWaitButton) + ON_WM_TIMER() + ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CDstFileErrorDlg message handlers + +void CDstFileErrorDlg::OnRetryButton() +{ + EndDialog(ID_RETRY); +} + +void CDstFileErrorDlg::OnIgnoreButton() +{ + EndDialog(ID_IGNORE); +} + +void CDstFileErrorDlg::OnWaitButton() +{ + EndDialog(ID_WAIT); +} + +void CDstFileErrorDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 1601) + { + m_iTime-=1000; + if (m_iTime < 0) + EndDialog(m_iDefaultOption); + + TCHAR xx[16]; + SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} + +BOOL CDstFileErrorDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // make this dialog on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + // remember title + GetWindowText(m_strTitle); + + if (m_bEnableTimer) + SetTimer(1601, 1000, NULL); + + return TRUE; +} + +void CDstFileErrorDlg::OnIgnoreAllButton() +{ + EndDialog(ID_IGNOREALL); +} Index: ch/DstFileErrorDlg.cpp =================================================================== diff -u -N --- ch/DstFileErrorDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DstFileErrorDlg.cpp (revision 0) @@ -1,120 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "DstFileErrorDlg.h" -#include "btnIDs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDstFileErrorDlg dialog - -CDstFileErrorDlg::CDstFileErrorDlg() - : CHLanguageDialog(CDstFileErrorDlg::IDD) -{ - //{{AFX_DATA_INIT(CDstFileErrorDlg) - m_strMessage = _T(""); - m_strFilename = _T(""); - //}}AFX_DATA_INIT - m_bEnableTimer=false; - m_iDefaultOption=ID_RECOPY; - m_iTime=30000; -} - - -void CDstFileErrorDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDstFileErrorDlg) - DDX_Text(pDX, IDC_MESSAGE_EDIT, m_strMessage); - DDX_Text(pDX, IDC_FILENAME_EDIT, m_strFilename); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CDstFileErrorDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CDstFileErrorDlg) - ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) - ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) - ON_BN_CLICKED(IDC_WAIT_BUTTON, OnWaitButton) - ON_WM_TIMER() - ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CDstFileErrorDlg message handlers - -void CDstFileErrorDlg::OnRetryButton() -{ - EndDialog(ID_RETRY); -} - -void CDstFileErrorDlg::OnIgnoreButton() -{ - EndDialog(ID_IGNORE); -} - -void CDstFileErrorDlg::OnWaitButton() -{ - EndDialog(ID_WAIT); -} - -void CDstFileErrorDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 1601) - { - m_iTime-=1000; - if (m_iTime < 0) - EndDialog(m_iDefaultOption); - - TCHAR xx[16]; - SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} - -BOOL CDstFileErrorDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // make this dialog on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - // remember title - GetWindowText(m_strTitle); - - if (m_bEnableTimer) - SetTimer(1601, 1000, NULL); - - return TRUE; -} - -void CDstFileErrorDlg::OnIgnoreAllButton() -{ - EndDialog(ID_IGNOREALL); -} Index: src/ch/DstFileErrorDlg.h =================================================================== diff -u -N --- src/ch/DstFileErrorDlg.h (revision 0) +++ src/ch/DstFileErrorDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,70 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __DSTFILEERRORDLG_H__ +#define __DSTFILEERRORDLG_H__ + +///////////////////////////////////////////////////////////////////////////// +// CDstFileErrorDlg dialog + +class CDstFileErrorDlg : public CHLanguageDialog +{ +// Construction +public: + CDstFileErrorDlg(); // standard constructor + + CString m_strTitle; + bool m_bEnableTimer; + int m_iTime; + int m_iDefaultOption; + +// Dialog Data + //{{AFX_DATA(CDstFileErrorDlg) + enum { IDD = IDD_FEEDBACK_DSTFILE_DIALOG }; + CString m_strMessage; + CString m_strFilename; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDstFileErrorDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDstFileErrorDlg) + afx_msg void OnRetryButton(); + afx_msg void OnIgnoreButton(); + afx_msg void OnWaitButton(); + afx_msg void OnTimer(UINT nIDEvent); + virtual BOOL OnInitDialog(); + afx_msg void OnIgnoreAllButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/DstFileErrorDlg.h =================================================================== diff -u -N --- ch/DstFileErrorDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/DstFileErrorDlg.h (revision 0) @@ -1,70 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __DSTFILEERRORDLG_H__ -#define __DSTFILEERRORDLG_H__ - -///////////////////////////////////////////////////////////////////////////// -// CDstFileErrorDlg dialog - -class CDstFileErrorDlg : public CHLanguageDialog -{ -// Construction -public: - CDstFileErrorDlg(); // standard constructor - - CString m_strTitle; - bool m_bEnableTimer; - int m_iTime; - int m_iDefaultOption; - -// Dialog Data - //{{AFX_DATA(CDstFileErrorDlg) - enum { IDD = IDD_FEEDBACK_DSTFILE_DIALOG }; - CString m_strMessage; - CString m_strFilename; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDstFileErrorDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDstFileErrorDlg) - afx_msg void OnRetryButton(); - afx_msg void OnIgnoreButton(); - afx_msg void OnWaitButton(); - afx_msg void OnTimer(UINT nIDEvent); - virtual BOOL OnInitDialog(); - afx_msg void OnIgnoreAllButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ExceptionEx.h =================================================================== diff -u -N --- src/ch/ExceptionEx.h (revision 0) +++ src/ch/ExceptionEx.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,212 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + File: Exception.h + Version: 1.0 + Author: Ixen Gerthannes (ixen@interia.pl) + File description: + Contain CException class - a base for any other exception + types. + Classes: + CException + - provides basic exception functionality. + - when used with MFC class name is CExceptionEx (it's + not based on MFC CException!). +*************************************************************************/ +#ifndef __EXCEPTION_H__ +#define __EXCEPTION_H__ + +#include "stdio.h" + +#define THROW_EXCEPTIONEX(str_reason, app_code, last_error) throw new CExceptionEx(__FILE__, __LINE__, __FUNCTION__, str_reason, app_code, last_error) + +// not too specific - use specialised classes based on this one (this also could be used) +class CExceptionEx +{ +protected: + enum PropType { dtString, dtPtrToString, dtDword, dtSysError }; + + struct __EXCPROPINFO + { + TCHAR szName[64]; // name of the property (ie."Source file") + PropType eType; // type of the property (string, dword, bool, ...) + void* pData; // pointer to the value of the property + }; + +public: + CExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, PCTSTR pszReason, DWORD dwReason, DWORD dwLastError=0) + { + // init the object with a given values + _tcsncpy(m_szSourceFile, pszSrcFile, _MAX_PATH); + m_szSourceFile[_MAX_PATH-1]=_T('\0'); + m_dwSourceLine=dwLine; + _tcsncpy(m_szFunction, pszFunc, _MAX_PATH); + m_szFunction[_MAX_PATH-1]=_T('\0'); + SetReason(pszReason); + m_dwReason=dwReason; + m_dwError=dwLastError; + }; + CExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, TCHAR* pszReason, DWORD dwReason, DWORD dwLastError=0) + { + _tcsncpy(m_szSourceFile, pszSrcFile, _MAX_PATH); + m_szSourceFile[_MAX_PATH-1]=_T('\0'); + m_dwSourceLine=dwLine; + _tcsncpy(m_szFunction, pszFunc, _MAX_PATH); + m_szFunction[_MAX_PATH-1]=_T('\0'); + m_pszReason=pszReason; + m_dwReason=dwReason; + m_dwError=dwLastError; + }; + + virtual ~CExceptionEx() { delete [] m_pszReason; }; + + virtual int RegisterInfo(__EXCPROPINFO* pInfo) + { + // if the pInfo is null - return count of a needed props + if (pInfo == NULL) + return 6; // +baseClass::RegisterInfo + + // call base class RegisterInfo + + // function has to register the info to be displayed (called from within GetInfo) + RegisterProp(pInfo+0, _T("Source file"), PropType::dtString, &m_szSourceFile); + RegisterProp(pInfo+1, _T("Line"), PropType::dtDword, &m_dwSourceLine); + RegisterProp(pInfo+2, _T("Function"), PropType::dtString, &m_szFunction); + RegisterProp(pInfo+3, _T("Reason"), PropType::dtPtrToString, &m_pszReason); + RegisterProp(pInfo+4, _T("App error"), PropType::dtDword, &m_dwReason); + RegisterProp(pInfo+5, _T("System error"), PropType::dtSysError, &m_dwError); + + return 6; + }; + +public: + // helpers + static TCHAR* FormatReason(PCTSTR pszReason, ...) + { + TCHAR szBuf[1024]; + va_list marker; + va_start(marker, pszReason); + _vstprintf(szBuf, pszReason, marker); + va_end(marker); + TCHAR *pszData=new TCHAR[_tcslen(szBuf)+1]; + _tcscpy(pszData, szBuf); + return pszData; + }; + + // formats max info about this exception + virtual TCHAR* GetInfo(LPCTSTR pszDesc, TCHAR* pszStr, DWORD dwMaxLen) + { + // get the properties + int iCount=RegisterInfo(NULL); + __EXCPROPINFO *pepi=new __EXCPROPINFO[iCount]; + RegisterInfo(pepi); // register all the properties + + // add the desc to the out + if (pszDesc) + { + _tcsncpy(pszStr, pszDesc, dwMaxLen-1); + pszStr[dwMaxLen-1]=_T('\0'); + } + else + pszStr[0]=_T('\0'); + + size_t tIndex=_tcslen(pszStr); + + // format the info accordingly + TCHAR szData[1024]; + for (int i=0;iszName, pszName, 63); + pInfo->szName[63]=_T('\0'); + pInfo->eType=type; + pInfo->pData=pData; + }; + +public: + // exception information + TCHAR m_szSourceFile[_MAX_PATH]; // source file from where the exception is being thrown + DWORD m_dwSourceLine; // line in the source file from where exception has been thrown + TCHAR m_szFunction[_MAX_PATH]; // name of the function in which the exception occured + TCHAR *m_pszReason; // description of this error (in english - internal error code - description - human readable) + DWORD m_dwReason; // numerical value that states app-level error number + DWORD m_dwError; // in most cases GetLastError() when it has any sense +}; + +#endif \ No newline at end of file Index: ch/ExceptionEx.h =================================================================== diff -u -N --- ch/ExceptionEx.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/ExceptionEx.h (revision 0) @@ -1,212 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - File: Exception.h - Version: 1.0 - Author: Ixen Gerthannes (ixen@interia.pl) - File description: - Contain CException class - a base for any other exception - types. - Classes: - CException - - provides basic exception functionality. - - when used with MFC class name is CExceptionEx (it's - not based on MFC CException!). -*************************************************************************/ -#ifndef __EXCEPTION_H__ -#define __EXCEPTION_H__ - -#include "stdio.h" - -#define THROW_EXCEPTIONEX(str_reason, app_code, last_error) throw new CExceptionEx(__FILE__, __LINE__, __FUNCTION__, str_reason, app_code, last_error) - -// not too specific - use specialised classes based on this one (this also could be used) -class CExceptionEx -{ -protected: - enum PropType { dtString, dtPtrToString, dtDword, dtSysError }; - - struct __EXCPROPINFO - { - TCHAR szName[64]; // name of the property (ie."Source file") - PropType eType; // type of the property (string, dword, bool, ...) - void* pData; // pointer to the value of the property - }; - -public: - CExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, PCTSTR pszReason, DWORD dwReason, DWORD dwLastError=0) - { - // init the object with a given values - _tcsncpy(m_szSourceFile, pszSrcFile, _MAX_PATH); - m_szSourceFile[_MAX_PATH-1]=_T('\0'); - m_dwSourceLine=dwLine; - _tcsncpy(m_szFunction, pszFunc, _MAX_PATH); - m_szFunction[_MAX_PATH-1]=_T('\0'); - SetReason(pszReason); - m_dwReason=dwReason; - m_dwError=dwLastError; - }; - CExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, TCHAR* pszReason, DWORD dwReason, DWORD dwLastError=0) - { - _tcsncpy(m_szSourceFile, pszSrcFile, _MAX_PATH); - m_szSourceFile[_MAX_PATH-1]=_T('\0'); - m_dwSourceLine=dwLine; - _tcsncpy(m_szFunction, pszFunc, _MAX_PATH); - m_szFunction[_MAX_PATH-1]=_T('\0'); - m_pszReason=pszReason; - m_dwReason=dwReason; - m_dwError=dwLastError; - }; - - virtual ~CExceptionEx() { delete [] m_pszReason; }; - - virtual int RegisterInfo(__EXCPROPINFO* pInfo) - { - // if the pInfo is null - return count of a needed props - if (pInfo == NULL) - return 6; // +baseClass::RegisterInfo - - // call base class RegisterInfo - - // function has to register the info to be displayed (called from within GetInfo) - RegisterProp(pInfo+0, _T("Source file"), PropType::dtString, &m_szSourceFile); - RegisterProp(pInfo+1, _T("Line"), PropType::dtDword, &m_dwSourceLine); - RegisterProp(pInfo+2, _T("Function"), PropType::dtString, &m_szFunction); - RegisterProp(pInfo+3, _T("Reason"), PropType::dtPtrToString, &m_pszReason); - RegisterProp(pInfo+4, _T("App error"), PropType::dtDword, &m_dwReason); - RegisterProp(pInfo+5, _T("System error"), PropType::dtSysError, &m_dwError); - - return 6; - }; - -public: - // helpers - static TCHAR* FormatReason(PCTSTR pszReason, ...) - { - TCHAR szBuf[1024]; - va_list marker; - va_start(marker, pszReason); - _vstprintf(szBuf, pszReason, marker); - va_end(marker); - TCHAR *pszData=new TCHAR[_tcslen(szBuf)+1]; - _tcscpy(pszData, szBuf); - return pszData; - }; - - // formats max info about this exception - virtual TCHAR* GetInfo(LPCTSTR pszDesc, TCHAR* pszStr, DWORD dwMaxLen) - { - // get the properties - int iCount=RegisterInfo(NULL); - __EXCPROPINFO *pepi=new __EXCPROPINFO[iCount]; - RegisterInfo(pepi); // register all the properties - - // add the desc to the out - if (pszDesc) - { - _tcsncpy(pszStr, pszDesc, dwMaxLen-1); - pszStr[dwMaxLen-1]=_T('\0'); - } - else - pszStr[0]=_T('\0'); - - size_t tIndex=_tcslen(pszStr); - - // format the info accordingly - TCHAR szData[1024]; - for (int i=0;iszName, pszName, 63); - pInfo->szName[63]=_T('\0'); - pInfo->eType=type; - pInfo->pData=pData; - }; - -public: - // exception information - TCHAR m_szSourceFile[_MAX_PATH]; // source file from where the exception is being thrown - DWORD m_dwSourceLine; // line in the source file from where exception has been thrown - TCHAR m_szFunction[_MAX_PATH]; // name of the function in which the exception occured - TCHAR *m_pszReason; // description of this error (in english - internal error code - description - human readable) - DWORD m_dwReason; // numerical value that states app-level error number - DWORD m_dwError; // in most cases GetLastError() when it has any sense -}; - -#endif \ No newline at end of file Index: src/ch/FFListCtrl.cpp =================================================================== diff -u -N --- src/ch/FFListCtrl.cpp (revision 0) +++ src/ch/FFListCtrl.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,105 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "FFListCtrl.h" +#include "MemDC.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CFFListCtrl + +CFFListCtrl::CFFListCtrl() +{ +} + +CFFListCtrl::~CFFListCtrl() +{ +} + + +BEGIN_MESSAGE_MAP(CFFListCtrl, CListCtrl) + //{{AFX_MSG_MAP(CFFListCtrl) + ON_WM_ERASEBKGND() + ON_WM_PAINT() + ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemchanged) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CFFListCtrl message handlers + +BOOL CFFListCtrl::OnEraseBkgnd(CDC*) +{ + return FALSE;/*CListCtrl::OnEraseBkgnd(pDC);*/ +} + +void CFFListCtrl::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + CRect headerRect; + GetHeaderCtrl()->GetWindowRect(&headerRect); + ScreenToClient(&headerRect); + dc.ExcludeClipRect(&headerRect); + + CRect rect; + GetClientRect(&rect); + CMemDC memDC(&dc, rect); + + CRect clip; + memDC.GetClipBox(&clip); + memDC.FillSolidRect(clip, GetSysColor(COLOR_WINDOW)); + + DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, (LPARAM)0); +} + +void CFFListCtrl::LimitItems(int iLimit) +{ + if (GetItemCount() > iLimit) + { + while (GetItemCount() > iLimit) + DeleteItem(iLimit); + } +} + +void CFFListCtrl::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; + + if ( /*((pNMListView->uOldState & LVIS_SELECTED) && !(pNMListView->uNewState & LVIS_SELECTED)) + ||*/ (!(pNMListView->uOldState & LVIS_SELECTED) && (pNMListView->uNewState & LVIS_SELECTED)) ) + SendSelChangedToParent(); + + *pResult = 0; +} + +void CFFListCtrl::SendSelChangedToParent() +{ + NMHDR nmhdr; + nmhdr.hwndFrom=m_hWnd; + nmhdr.idFrom=GetDlgCtrlID(); + nmhdr.code=LVN_CHANGEDSELECTION; + GetParent()->SendMessage(WM_NOTIFY, static_cast(nmhdr.idFrom), reinterpret_cast(&nmhdr)); +} Index: ch/FFListCtrl.cpp =================================================================== diff -u -N --- ch/FFListCtrl.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FFListCtrl.cpp (revision 0) @@ -1,105 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "FFListCtrl.h" -#include "MemDC.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFFListCtrl - -CFFListCtrl::CFFListCtrl() -{ -} - -CFFListCtrl::~CFFListCtrl() -{ -} - - -BEGIN_MESSAGE_MAP(CFFListCtrl, CListCtrl) - //{{AFX_MSG_MAP(CFFListCtrl) - ON_WM_ERASEBKGND() - ON_WM_PAINT() - ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemchanged) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFFListCtrl message handlers - -BOOL CFFListCtrl::OnEraseBkgnd(CDC*) -{ - return FALSE;/*CListCtrl::OnEraseBkgnd(pDC);*/ -} - -void CFFListCtrl::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - CRect headerRect; - GetHeaderCtrl()->GetWindowRect(&headerRect); - ScreenToClient(&headerRect); - dc.ExcludeClipRect(&headerRect); - - CRect rect; - GetClientRect(&rect); - CMemDC memDC(&dc, rect); - - CRect clip; - memDC.GetClipBox(&clip); - memDC.FillSolidRect(clip, GetSysColor(COLOR_WINDOW)); - - DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, (LPARAM)0); -} - -void CFFListCtrl::LimitItems(int iLimit) -{ - if (GetItemCount() > iLimit) - { - while (GetItemCount() > iLimit) - DeleteItem(iLimit); - } -} - -void CFFListCtrl::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; - - if ( /*((pNMListView->uOldState & LVIS_SELECTED) && !(pNMListView->uNewState & LVIS_SELECTED)) - ||*/ (!(pNMListView->uOldState & LVIS_SELECTED) && (pNMListView->uNewState & LVIS_SELECTED)) ) - SendSelChangedToParent(); - - *pResult = 0; -} - -void CFFListCtrl::SendSelChangedToParent() -{ - NMHDR nmhdr; - nmhdr.hwndFrom=m_hWnd; - nmhdr.idFrom=GetDlgCtrlID(); - nmhdr.code=LVN_CHANGEDSELECTION; - GetParent()->SendMessage(WM_NOTIFY, static_cast(nmhdr.idFrom), reinterpret_cast(&nmhdr)); -} Index: src/ch/FFListCtrl.h =================================================================== diff -u -N --- src/ch/FFListCtrl.h (revision 0) +++ src/ch/FFListCtrl.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,66 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __FFLISTCTRL_H__ +#define __FFLISTCTRL_H__ + +///////////////////////////////////////////////////////////////////////////// +// CFFListCtrl window +#define LVN_CHANGEDSELECTION WM_USER+10 + +class CFFListCtrl : public CListCtrl +{ +// Construction +public: + CFFListCtrl(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFFListCtrl) + //}}AFX_VIRTUAL + +// Implementation +public: + void SendSelChangedToParent(); + void LimitItems(int iLimit); + virtual ~CFFListCtrl(); + + // Generated message map functions +protected: + //{{AFX_MSG(CFFListCtrl) + afx_msg BOOL OnEraseBkgnd(CDC*); + afx_msg void OnPaint(); + afx_msg void OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/FFListCtrl.h =================================================================== diff -u -N --- ch/FFListCtrl.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FFListCtrl.h (revision 0) @@ -1,66 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __FFLISTCTRL_H__ -#define __FFLISTCTRL_H__ - -///////////////////////////////////////////////////////////////////////////// -// CFFListCtrl window -#define LVN_CHANGEDSELECTION WM_USER+10 - -class CFFListCtrl : public CListCtrl -{ -// Construction -public: - CFFListCtrl(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFFListCtrl) - //}}AFX_VIRTUAL - -// Implementation -public: - void SendSelChangedToParent(); - void LimitItems(int iLimit); - virtual ~CFFListCtrl(); - - // Generated message map functions -protected: - //{{AFX_MSG(CFFListCtrl) - afx_msg BOOL OnEraseBkgnd(CDC*); - afx_msg void OnPaint(); - afx_msg void OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/FileEx.cpp =================================================================== diff -u -N --- src/ch/FileEx.cpp (revision 0) +++ src/ch/FileEx.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,917 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "FileEx.h" +#include "crc32.h" +#ifndef DISABLE_CRYPT +#include "crypt.h" +#endif + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#pragma warning( disable : 4127 ) + +// serialization buffer add on every reallocation +#define SERIALBUFFER_DELTA 4096UL + +/////////////////////////////////////////////////////////////// +// Opens file +// pszFilename [in] - name of the file to open +// dwAccess [in] - type of access to this file (R, W, RW, APPEND) +// dwBufferSize [in] - size of internal buffer when using buffered +// operations. +/////////////////////////////////////////////////////////////// +void CFileEx::Open(PCTSTR pszFilename, DWORD dwAccess, DWORD dwBufferSize) +{ + // check if this object is ready to open a file + if (m_hFile) + Close(); + + HANDLE hFile=NULL; + switch (dwAccess & FA_OPERATION) + { + case FA_READ: + hFile=CreateFile(pszFilename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + break; + case FA_WRITE: + hFile=CreateFile(pszFilename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + break; + case FA_RW: + case FA_APPEND: + hFile=CreateFile(pszFilename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + break; + default: + _ASSERT(false); // unknown File access value + } + + // check if operation succeeded + if (hFile == INVALID_HANDLE_VALUE) + THROW_FILEEXCEPTIONEX(_T("Cannot open the specified file (CreateFile failed)."), pszFilename, FERR_OPEN, GetLastError()); + else + { + // store hFile + m_hFile=hFile; + + // remember path of this file + m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; + _tcscpy(m_pszFilename, pszFilename); + + // remember the mode + m_dwMode=dwAccess; + + // is this buffered ? + SetBuffering((dwAccess & 0x8000) != 0, dwBufferSize); + } + + // if this is the "FA_APPEND" access mode - seek to end + if ((dwAccess & FA_OPERATION) == FA_APPEND) + InternalSeek(0, FILE_END); +} + +/////////////////////////////////////////////////////////////// +// Closes the file (could be used on non-opened files +/////////////////////////////////////////////////////////////// +void CFileEx::Close() +{ + // only if the file has been opened + if (m_hFile) + { + // flush all data + Flush(); + + // close da file + if (!CloseHandle(m_hFile)) + { + // error closing + THROW_FILEEXCEPTIONEX(_T("Cannot close the handle associated with a file (CloseHandle failed)."), m_pszFilename, FERR_CLOSE, GetLastError()); + } + else + m_hFile=NULL; + + // free strings and other data + delete [] m_pszFilename; + m_pszFilename=NULL; + delete [] m_pbyBuffer; + m_pbyBuffer=NULL; + } +} + +/////////////////////////////////////////////////////////////// +// Flushes internal buffers when using buffered operations +// may be used in non-buffered mode and for not opened files +// sets file pointer to the place resulting from position +// in internal buffer +/////////////////////////////////////////////////////////////// +void CFileEx::Flush() +{ + if (m_hFile && m_bBuffered && m_dwDataCount > 0) + { + if (m_bLastOperation) + { + // last operation - storing data + WritePacket(); + } + else + { + // last - reading data + // set file pointer to position current-(m_dwDataCount-m_dwCurrentPos) + InternalSeek(-(long)(m_dwDataCount-m_dwCurrentPos), FILE_CURRENT); + m_dwCurrentPos=0; + m_dwDataCount=0; + } + } +} + +/////////////////////////////////////////////////////////////// +// Reads some data from file (buffered or not) +// pBuffer [in/out] - buffer for data +// dwSize [in] - size of data to read +// Ret Value [out] - count of bytes read (could differ from +// dwSize) +/////////////////////////////////////////////////////////////// +DWORD CFileEx::ReadBuffer(void* pBuffer, DWORD dwSize) +{ + _ASSERT(m_hFile); // forgot to open the file ? + + // flush if needed + if (m_bLastOperation) + { + Flush(); + m_bLastOperation=false; + } + + if (!m_bBuffered) + { + // unbuffered operation (read what is needed) + DWORD dwRD=0; + if (!ReadFile(m_hFile, pBuffer, dwSize, &dwRD, NULL)) + THROW_FILEEXCEPTIONEX(_T("Cannot read data from file (ReadFile failed)."), m_pszFilename, FERR_READ, GetLastError()); + + return dwRD; // if 0 - eof (not treated as exception) + } + else + { + // reads must be done by packets + DWORD dwCurrPos=0; // position in external buffer + while (dwCurrPos 0); // couldn't use 0-sized internal buffer + + // flush + Flush(); + + // delete old buffer + if (m_bBuffered && (!bEnable || dwSize != m_dwBufferSize)) + { + delete [] m_pbyBuffer; + m_pbyBuffer=NULL; + } + + // alloc new buffer if needed + if (bEnable && (!m_bBuffered || dwSize != m_dwBufferSize)) + m_pbyBuffer=new BYTE[dwSize]; + + m_bBuffered=bEnable; + m_dwBufferSize=dwSize; +} + +/////////////////////////////////////////////////////////////// +// Changes current mode to unbuffered. If already unbuffered +// function returns doing nothing +/////////////////////////////////////////////////////////////// +void CFileEx::SwitchToUnbuffered() +{ + if (!m_bBuffered) + return; // it's already unbuffered - leave it as is + else + { + m_bRememberedState=true; // mark that we change state to a different one + SetBuffering(false, m_dwBufferSize); // do no change internal buffer size + } +} + +/////////////////////////////////////////////////////////////// +// Changes current mode to buffered. If already buffered +// function returns doing nothing +/////////////////////////////////////////////////////////////// +void CFileEx::SwitchToBuffered() +{ + if (m_bBuffered) + return; // already buffered + else + { + m_bRememberedState=true; + SetBuffering(true, m_dwBufferSize); + } +} + +/////////////////////////////////////////////////////////////// +// Function restores (un)buffered state previously remembered +// with SwitchToXXX. If SwitchToXXX doesn't change the state +// - this function also doesn't. +/////////////////////////////////////////////////////////////// +void CFileEx::RestoreState() +{ + // restore state only if changed + if (m_bRememberedState) + { + SetBuffering(!m_bBuffered, m_dwBufferSize); + m_bRememberedState=false; + } +} + +/////////////////////////////////////////////////////////////// +// (Internal) Reads next packet of data from file (when using +// buffered operations it cause next data of size of internal +// buffer to be read from file +// Ret Value [out] - Count of data that was read +/////////////////////////////////////////////////////////////// +DWORD CFileEx::ReadPacket() +{ + _ASSERT(m_hFile); + + // read data + DWORD dwRD=0; + if (!ReadFile(m_hFile, m_pbyBuffer, m_dwBufferSize, &dwRD, NULL)) + THROW_FILEEXCEPTIONEX(_T("Cannot read data from a file (ReadFile failed)."), m_pszFilename, FERR_READ, GetLastError()); + + // reset internal members + m_dwDataCount=dwRD; + m_dwCurrentPos=0; + + return dwRD; +} + +/////////////////////////////////////////////////////////////// +// (Internal) Function writes all data from internal buffer to +// a file. +// Ret Value [out] - count of bytes written +/////////////////////////////////////////////////////////////// +DWORD CFileEx::WritePacket() +{ + _ASSERT(m_hFile); + + DWORD dwWR=0; + if (!WriteFile(m_hFile, m_pbyBuffer, m_dwDataCount, &dwWR, NULL)) + THROW_FILEEXCEPTIONEX(_T("Cannot write data to a file (WriteFile failed)."), m_pszFilename, FERR_WRITE, GetLastError()); + + // reset internal members + m_dwDataCount=0; + m_dwCurrentPos=0; + + return dwWR; +} + +#ifndef DISABLE_CRYPT +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::SetPassword(PCTSTR pszPass) +{ + // delete the old password + if (m_pszPassword) + delete [] m_pszPassword; // delete old password + + // generate the SHA256 from this password + m_pszPassword=new TCHAR[64+1]; + StringToKey256(pszPass, m_pszPassword); +} + +#endif + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::BeginDataBlock(DWORD dwFlags) +{ + // do not call begin data block within another data block + _ASSERT(!m_bSerializing && m_pbySerialBuffer == NULL); + + // alloc the new buffer and insert there a header (a few bytes) + m_pbySerialBuffer=new BYTE[SERIALBUFFER_DELTA]; + m_dwSerialBufferSize=SERIALBUFFER_DELTA; + + // determine action from read or write flag + bool bWrite=false; + switch(m_dwMode & FA_OPERATION) + { + case FA_READ: + bWrite=false; + break; + case FA_WRITE: + bWrite=true; + break; + case FA_RW: + case FA_APPEND: + _ASSERT(FALSE); // cannot use serialization with files opened in rw mode + break; + } + + // action + if (bWrite) + { + // reserve some space for a header + m_dwSerialBufferPos=sizeof(SERIALIZEINFOHEADER); + } + else + { + // we need to read the block from a file + if (ReadBuffer(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)) != sizeof(SERIALIZEINFOHEADER)) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("Cannot read the specified amount of data from a file (reading serialization header)."), m_pszFilename, FERR_SERIALIZE, GetLastError()); + } + + // move forward + m_dwSerialBufferPos=sizeof(SERIALIZEINFOHEADER); + + // determine the size of the remaining data in file + SERIALIZEINFOHEADER* psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; + DWORD dwSize=psih->dwToRead-sizeof(SERIALIZEINFOHEADER); + + // check the header crc + DWORD dwhc=icpf::crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(DWORD)); + if (dwhc != psih->dwHeaderCRC32) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("Block corrupted. Header CRC check failed."), m_pszFilename, FERR_SERIALIZE, 0); + } + + // resize the buffer + ResizeSerialBuffer(psih->dwToRead); + + // refresh the psih + psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; + + // read the remaining data + if (ReadBuffer(m_pbySerialBuffer+m_dwSerialBufferPos, dwSize) != dwSize) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("Cannot read specified amount of data from file (reading the after-header data)."), m_pszFilename, FERR_SERIALIZE, GetLastError()); + } + +#ifndef DISABLE_CRYPT + // decrypt the data + if (dwFlags & BF_ENCRYPTED) + { + if (AES256Decrypt(m_pbySerialBuffer+m_dwSerialBufferPos, dwSize, m_pszPassword, m_pbySerialBuffer+m_dwSerialBufferPos) < 0) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("Cannot decrypt the data read from the serialization file."), m_pszFilename, FERR_CRYPT, 0); + } + } +#endif + // NOTE: do not update the position - we need ptr at the beginning of data + + // now we are almost ready to retrieve data - only the crc check for the data + DWORD dwCRC=icpf::crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), psih->dwDataSize-sizeof(SERIALIZEINFOHEADER)); + if (psih->dwCRC32 != dwCRC) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("CRC check of the data read from file failed."), m_pszFilename, FERR_SERIALIZE, GetLastError()); + } + } + + // make a mark + m_dwDataBlockFlags=dwFlags; + m_bSerializing=true; +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::EndDataBlock() +{ + // make sure everything is ok + _ASSERT(m_bSerializing && m_pbySerialBuffer != NULL); + + // type of operation + bool bWrite=false; + switch(m_dwMode & FA_OPERATION) + { + case FA_READ: + bWrite=false; + break; + case FA_WRITE: + bWrite=true; + break; + case FA_RW: + case FA_APPEND: + _ASSERT(FALSE); // cannot use serialization with files opened in rw mode + break; + } + + // when writing - make a header, ...; when reading - do nothing important + if (bWrite) + { + // check if there is any data + if (m_dwSerialBufferPos == sizeof(SERIALIZEINFOHEADER)) + return; // no data has been serialized + + // fill the header (real data information) + SERIALIZEINFOHEADER *psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; + psih->dwDataSize=m_dwSerialBufferPos; + psih->dwCRC32=icpf::crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_dwSerialBufferPos-sizeof(SERIALIZEINFOHEADER)); + +#ifndef DISABLE_CRYPT + // we could encrypt the data here if needed + if (m_dwDataBlockFlags & BF_ENCRYPTED) + { + int iRes=AES256Crypt(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_dwSerialBufferPos-sizeof(SERIALIZEINFOHEADER), m_pszPassword, m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER)); + if (iRes < 0) + { + ClearSerialization(); + THROW_FILEEXCEPTIONEX(_T("Cannot encrypt the data to store."), m_pszFilename, FERR_CRYPT, 0); + } + + // fill the header + psih->dwToRead=iRes+sizeof(SERIALIZEINFOHEADER); + } + else + { +#endif + // the rest of header + psih->dwToRead=m_dwSerialBufferPos; +#ifndef DISABLE_CRYPT + } +#endif + + // calc the header crc + psih->dwHeaderCRC32=icpf::crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(DWORD)); + + // write the buffer + WriteBuffer(m_pbySerialBuffer, psih->dwToRead); + } + + // remove all the traces of serializing + ClearSerialization(); +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::SWrite(void* pData, DWORD dwSize) +{ + InternalAppendSerialBuffer(pData, dwSize); +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::SRead(void* pData, DWORD dwSize) +{ + InternalReadSerialBuffer(pData, dwSize); +} + +#ifdef _MFC_VER + +CFileEx& CFileEx::operator<<(CString strData) +{ + DWORD dwLen=strData.GetLength(); + SWrite(&dwLen, sizeof(DWORD)); + SWrite(strData.GetBuffer(1), dwLen); + strData.ReleaseBuffer(); + return *this; +} + +CFileEx& CFileEx::operator>>(CString& strData) +{ + DWORD dwLen; + SRead(&dwLen, sizeof(DWORD)); + PTSTR pszData=strData.GetBuffer(dwLen+1); + try + { + SRead(pszData, dwLen); + } + catch(...) + { + pszData[dwLen]=_T('\0'); + strData.ReleaseBuffer(); + throw; + } + + pszData[dwLen]=_T('\0'); + strData.ReleaseBuffer(); + return *this; +} + +#endif + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::ClearSerialization() +{ + // remove all the traces of serializing + delete [] m_pbySerialBuffer; + m_pbySerialBuffer=NULL; + m_dwSerialBufferSize=0; + m_dwSerialBufferPos=0; + m_bSerializing=false; +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::InternalReadSerialBuffer(void* pData, DWORD dwLen) +{ + // check if we are reading + _ASSERT((m_dwMode & FA_OPERATION) == FA_READ); + + // check the ranges + if (m_dwSerialBufferPos+dwLen > m_dwSerialBufferSize) + { + // throw an exception - read beyond the data range in a given object + THROW_FILEEXCEPTIONEX(_T("Trying to read the serialization data beyond the range."), m_pszFilename, FERR_MEMORY, GetLastError()); + } + + // read the data + memcpy(pData, m_pbySerialBuffer+m_dwSerialBufferPos, dwLen); + m_dwSerialBufferPos+=dwLen; +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::InternalAppendSerialBuffer(void* pData, DWORD dwCount) +{ + // check if we are writing + _ASSERT((m_dwMode & FA_OPERATION) == FA_WRITE); + + // check serial buffer size (if there is enough room for the data) + if (m_dwSerialBufferPos+dwCount > m_dwSerialBufferSize) + { + // we need a buffer reallocation + DWORD dwDelta=((dwCount/SERIALBUFFER_DELTA)+1)*SERIALBUFFER_DELTA; + + // alloc the new buffer + ResizeSerialBuffer(m_dwSerialBufferSize+dwDelta); + } + + // real storage of the data + if (dwCount > 0) + { + memcpy(m_pbySerialBuffer+m_dwSerialBufferPos, pData, dwCount); + m_dwSerialBufferPos+=dwCount; + } +} + +/////////////////////////////////////////////////////////////// +// +/////////////////////////////////////////////////////////////// +void CFileEx::ResizeSerialBuffer(DWORD dwNewLen) +{ + // alloc the new buffer + BYTE* pbyNewBuffer=new BYTE[dwNewLen]; + + // copy the old data into the new one + DWORD dwCount=min(m_dwSerialBufferPos, dwNewLen); + if (m_dwSerialBufferPos > 0) + memcpy(pbyNewBuffer, m_pbySerialBuffer, dwCount); + + // delete the old buffer + delete [] m_pbySerialBuffer; + + // set the new buffer inplace and update the internal size + m_pbySerialBuffer=pbyNewBuffer; + m_dwSerialBufferSize=dwNewLen; +} + +/////////////////////////////////////////////////////////////// +// (Internal) Functions reads line of text from text file +// Only for buffered operation +// pszStr [out] - string that was read from file +// dwMaxLen [in] - size of the string buffer +/////////////////////////////////////////////////////////////// +bool CFileEx::InternalReadString(TCHAR* pszStr, DWORD dwMaxLen) +{ + _ASSERT(m_hFile != NULL); // file wasn't opened - error opening or you've forgotten to do so ? + + // last time was writing - free buffer + if (m_bLastOperation) + { + Flush(); + m_bLastOperation=false; + } + + // zero all the string + memset(pszStr, 0, dwMaxLen*sizeof(TCHAR)); + + // additional vars + DWORD dwStrPos=0; // current pos in external buffer + bool bSecondPass=false; // if there is need to check data for 0x0a char + + // copy each char into pszString + while(true) + { + // if buffer is empty - fill it + if (m_dwDataCount == 0 || m_dwCurrentPos == m_dwDataCount) + { + if (ReadPacket() == 0) + return _tcslen(pszStr) != 0; + } + + // skipping 0x0a in second pass + if (bSecondPass) + { + if (m_pbyBuffer[m_dwCurrentPos] == 0x0a) + m_dwCurrentPos++; + return true; + } + + // now process chars + while (m_dwCurrentPos < m_dwDataCount) + { + if (m_pbyBuffer[m_dwCurrentPos] == 0x0d) + { + bSecondPass=true; + m_dwCurrentPos++; + break; + } + else if (m_pbyBuffer[m_dwCurrentPos] == 0x0a) + { + m_dwCurrentPos++; + return true; + } + else + { + if (dwStrPos < dwMaxLen-1) + pszStr[dwStrPos++]=m_pbyBuffer[m_dwCurrentPos]; + m_dwCurrentPos++; + } + } + } + + return false; +} + +/////////////////////////////////////////////////////////////// +// (Internal) Sets file pointer in a file +// llOffset [in] - position to move to +// uiFrom [in] - type of moving (see Platform SDK on +// SetFilePointer) +/////////////////////////////////////////////////////////////// +LONGLONG CFileEx::InternalSeek(LONGLONG llOffset, UINT uiFrom) +{ + LARGE_INTEGER li; + li.QuadPart = llOffset; + li.LowPart = SetFilePointer (m_hFile, li.LowPart, &li.HighPart, uiFrom); + + if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) + { + // error seeking - throw an exception + THROW_FILEEXCEPTIONEX(_T("Seek error."), m_pszFilename, FERR_SEEK, GetLastError()); + } + + return li.QuadPart; +} Index: ch/FileEx.cpp =================================================================== diff -u -N --- ch/FileEx.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/FileEx.cpp (revision 0) @@ -1,917 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "FileEx.h" -#include "crc32.h" -#ifndef DISABLE_CRYPT -#include "crypt.h" -#endif - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#pragma warning( disable : 4127 ) - -// serialization buffer add on every reallocation -#define SERIALBUFFER_DELTA 4096UL - -/////////////////////////////////////////////////////////////// -// Opens file -// pszFilename [in] - name of the file to open -// dwAccess [in] - type of access to this file (R, W, RW, APPEND) -// dwBufferSize [in] - size of internal buffer when using buffered -// operations. -/////////////////////////////////////////////////////////////// -void CFileEx::Open(PCTSTR pszFilename, DWORD dwAccess, DWORD dwBufferSize) -{ - // check if this object is ready to open a file - if (m_hFile) - Close(); - - HANDLE hFile=NULL; - switch (dwAccess & FA_OPERATION) - { - case FA_READ: - hFile=CreateFile(pszFilename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - break; - case FA_WRITE: - hFile=CreateFile(pszFilename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - break; - case FA_RW: - case FA_APPEND: - hFile=CreateFile(pszFilename, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - break; - default: - _ASSERT(false); // unknown File access value - } - - // check if operation succeeded - if (hFile == INVALID_HANDLE_VALUE) - THROW_FILEEXCEPTIONEX(_T("Cannot open the specified file (CreateFile failed)."), pszFilename, FERR_OPEN, GetLastError()); - else - { - // store hFile - m_hFile=hFile; - - // remember path of this file - m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; - _tcscpy(m_pszFilename, pszFilename); - - // remember the mode - m_dwMode=dwAccess; - - // is this buffered ? - SetBuffering((dwAccess & 0x8000) != 0, dwBufferSize); - } - - // if this is the "FA_APPEND" access mode - seek to end - if ((dwAccess & FA_OPERATION) == FA_APPEND) - InternalSeek(0, FILE_END); -} - -/////////////////////////////////////////////////////////////// -// Closes the file (could be used on non-opened files -/////////////////////////////////////////////////////////////// -void CFileEx::Close() -{ - // only if the file has been opened - if (m_hFile) - { - // flush all data - Flush(); - - // close da file - if (!CloseHandle(m_hFile)) - { - // error closing - THROW_FILEEXCEPTIONEX(_T("Cannot close the handle associated with a file (CloseHandle failed)."), m_pszFilename, FERR_CLOSE, GetLastError()); - } - else - m_hFile=NULL; - - // free strings and other data - delete [] m_pszFilename; - m_pszFilename=NULL; - delete [] m_pbyBuffer; - m_pbyBuffer=NULL; - } -} - -/////////////////////////////////////////////////////////////// -// Flushes internal buffers when using buffered operations -// may be used in non-buffered mode and for not opened files -// sets file pointer to the place resulting from position -// in internal buffer -/////////////////////////////////////////////////////////////// -void CFileEx::Flush() -{ - if (m_hFile && m_bBuffered && m_dwDataCount > 0) - { - if (m_bLastOperation) - { - // last operation - storing data - WritePacket(); - } - else - { - // last - reading data - // set file pointer to position current-(m_dwDataCount-m_dwCurrentPos) - InternalSeek(-(long)(m_dwDataCount-m_dwCurrentPos), FILE_CURRENT); - m_dwCurrentPos=0; - m_dwDataCount=0; - } - } -} - -/////////////////////////////////////////////////////////////// -// Reads some data from file (buffered or not) -// pBuffer [in/out] - buffer for data -// dwSize [in] - size of data to read -// Ret Value [out] - count of bytes read (could differ from -// dwSize) -/////////////////////////////////////////////////////////////// -DWORD CFileEx::ReadBuffer(void* pBuffer, DWORD dwSize) -{ - _ASSERT(m_hFile); // forgot to open the file ? - - // flush if needed - if (m_bLastOperation) - { - Flush(); - m_bLastOperation=false; - } - - if (!m_bBuffered) - { - // unbuffered operation (read what is needed) - DWORD dwRD=0; - if (!ReadFile(m_hFile, pBuffer, dwSize, &dwRD, NULL)) - THROW_FILEEXCEPTIONEX(_T("Cannot read data from file (ReadFile failed)."), m_pszFilename, FERR_READ, GetLastError()); - - return dwRD; // if 0 - eof (not treated as exception) - } - else - { - // reads must be done by packets - DWORD dwCurrPos=0; // position in external buffer - while (dwCurrPos 0); // couldn't use 0-sized internal buffer - - // flush - Flush(); - - // delete old buffer - if (m_bBuffered && (!bEnable || dwSize != m_dwBufferSize)) - { - delete [] m_pbyBuffer; - m_pbyBuffer=NULL; - } - - // alloc new buffer if needed - if (bEnable && (!m_bBuffered || dwSize != m_dwBufferSize)) - m_pbyBuffer=new BYTE[dwSize]; - - m_bBuffered=bEnable; - m_dwBufferSize=dwSize; -} - -/////////////////////////////////////////////////////////////// -// Changes current mode to unbuffered. If already unbuffered -// function returns doing nothing -/////////////////////////////////////////////////////////////// -void CFileEx::SwitchToUnbuffered() -{ - if (!m_bBuffered) - return; // it's already unbuffered - leave it as is - else - { - m_bRememberedState=true; // mark that we change state to a different one - SetBuffering(false, m_dwBufferSize); // do no change internal buffer size - } -} - -/////////////////////////////////////////////////////////////// -// Changes current mode to buffered. If already buffered -// function returns doing nothing -/////////////////////////////////////////////////////////////// -void CFileEx::SwitchToBuffered() -{ - if (m_bBuffered) - return; // already buffered - else - { - m_bRememberedState=true; - SetBuffering(true, m_dwBufferSize); - } -} - -/////////////////////////////////////////////////////////////// -// Function restores (un)buffered state previously remembered -// with SwitchToXXX. If SwitchToXXX doesn't change the state -// - this function also doesn't. -/////////////////////////////////////////////////////////////// -void CFileEx::RestoreState() -{ - // restore state only if changed - if (m_bRememberedState) - { - SetBuffering(!m_bBuffered, m_dwBufferSize); - m_bRememberedState=false; - } -} - -/////////////////////////////////////////////////////////////// -// (Internal) Reads next packet of data from file (when using -// buffered operations it cause next data of size of internal -// buffer to be read from file -// Ret Value [out] - Count of data that was read -/////////////////////////////////////////////////////////////// -DWORD CFileEx::ReadPacket() -{ - _ASSERT(m_hFile); - - // read data - DWORD dwRD=0; - if (!ReadFile(m_hFile, m_pbyBuffer, m_dwBufferSize, &dwRD, NULL)) - THROW_FILEEXCEPTIONEX(_T("Cannot read data from a file (ReadFile failed)."), m_pszFilename, FERR_READ, GetLastError()); - - // reset internal members - m_dwDataCount=dwRD; - m_dwCurrentPos=0; - - return dwRD; -} - -/////////////////////////////////////////////////////////////// -// (Internal) Function writes all data from internal buffer to -// a file. -// Ret Value [out] - count of bytes written -/////////////////////////////////////////////////////////////// -DWORD CFileEx::WritePacket() -{ - _ASSERT(m_hFile); - - DWORD dwWR=0; - if (!WriteFile(m_hFile, m_pbyBuffer, m_dwDataCount, &dwWR, NULL)) - THROW_FILEEXCEPTIONEX(_T("Cannot write data to a file (WriteFile failed)."), m_pszFilename, FERR_WRITE, GetLastError()); - - // reset internal members - m_dwDataCount=0; - m_dwCurrentPos=0; - - return dwWR; -} - -#ifndef DISABLE_CRYPT -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::SetPassword(PCTSTR pszPass) -{ - // delete the old password - if (m_pszPassword) - delete [] m_pszPassword; // delete old password - - // generate the SHA256 from this password - m_pszPassword=new TCHAR[64+1]; - StringToKey256(pszPass, m_pszPassword); -} - -#endif - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::BeginDataBlock(DWORD dwFlags) -{ - // do not call begin data block within another data block - _ASSERT(!m_bSerializing && m_pbySerialBuffer == NULL); - - // alloc the new buffer and insert there a header (a few bytes) - m_pbySerialBuffer=new BYTE[SERIALBUFFER_DELTA]; - m_dwSerialBufferSize=SERIALBUFFER_DELTA; - - // determine action from read or write flag - bool bWrite=false; - switch(m_dwMode & FA_OPERATION) - { - case FA_READ: - bWrite=false; - break; - case FA_WRITE: - bWrite=true; - break; - case FA_RW: - case FA_APPEND: - _ASSERT(FALSE); // cannot use serialization with files opened in rw mode - break; - } - - // action - if (bWrite) - { - // reserve some space for a header - m_dwSerialBufferPos=sizeof(SERIALIZEINFOHEADER); - } - else - { - // we need to read the block from a file - if (ReadBuffer(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)) != sizeof(SERIALIZEINFOHEADER)) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("Cannot read the specified amount of data from a file (reading serialization header)."), m_pszFilename, FERR_SERIALIZE, GetLastError()); - } - - // move forward - m_dwSerialBufferPos=sizeof(SERIALIZEINFOHEADER); - - // determine the size of the remaining data in file - SERIALIZEINFOHEADER* psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; - DWORD dwSize=psih->dwToRead-sizeof(SERIALIZEINFOHEADER); - - // check the header crc - DWORD dwhc=icpf::crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(DWORD)); - if (dwhc != psih->dwHeaderCRC32) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("Block corrupted. Header CRC check failed."), m_pszFilename, FERR_SERIALIZE, 0); - } - - // resize the buffer - ResizeSerialBuffer(psih->dwToRead); - - // refresh the psih - psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; - - // read the remaining data - if (ReadBuffer(m_pbySerialBuffer+m_dwSerialBufferPos, dwSize) != dwSize) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("Cannot read specified amount of data from file (reading the after-header data)."), m_pszFilename, FERR_SERIALIZE, GetLastError()); - } - -#ifndef DISABLE_CRYPT - // decrypt the data - if (dwFlags & BF_ENCRYPTED) - { - if (AES256Decrypt(m_pbySerialBuffer+m_dwSerialBufferPos, dwSize, m_pszPassword, m_pbySerialBuffer+m_dwSerialBufferPos) < 0) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("Cannot decrypt the data read from the serialization file."), m_pszFilename, FERR_CRYPT, 0); - } - } -#endif - // NOTE: do not update the position - we need ptr at the beginning of data - - // now we are almost ready to retrieve data - only the crc check for the data - DWORD dwCRC=icpf::crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), psih->dwDataSize-sizeof(SERIALIZEINFOHEADER)); - if (psih->dwCRC32 != dwCRC) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("CRC check of the data read from file failed."), m_pszFilename, FERR_SERIALIZE, GetLastError()); - } - } - - // make a mark - m_dwDataBlockFlags=dwFlags; - m_bSerializing=true; -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::EndDataBlock() -{ - // make sure everything is ok - _ASSERT(m_bSerializing && m_pbySerialBuffer != NULL); - - // type of operation - bool bWrite=false; - switch(m_dwMode & FA_OPERATION) - { - case FA_READ: - bWrite=false; - break; - case FA_WRITE: - bWrite=true; - break; - case FA_RW: - case FA_APPEND: - _ASSERT(FALSE); // cannot use serialization with files opened in rw mode - break; - } - - // when writing - make a header, ...; when reading - do nothing important - if (bWrite) - { - // check if there is any data - if (m_dwSerialBufferPos == sizeof(SERIALIZEINFOHEADER)) - return; // no data has been serialized - - // fill the header (real data information) - SERIALIZEINFOHEADER *psih=(SERIALIZEINFOHEADER*)m_pbySerialBuffer; - psih->dwDataSize=m_dwSerialBufferPos; - psih->dwCRC32=icpf::crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_dwSerialBufferPos-sizeof(SERIALIZEINFOHEADER)); - -#ifndef DISABLE_CRYPT - // we could encrypt the data here if needed - if (m_dwDataBlockFlags & BF_ENCRYPTED) - { - int iRes=AES256Crypt(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_dwSerialBufferPos-sizeof(SERIALIZEINFOHEADER), m_pszPassword, m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER)); - if (iRes < 0) - { - ClearSerialization(); - THROW_FILEEXCEPTIONEX(_T("Cannot encrypt the data to store."), m_pszFilename, FERR_CRYPT, 0); - } - - // fill the header - psih->dwToRead=iRes+sizeof(SERIALIZEINFOHEADER); - } - else - { -#endif - // the rest of header - psih->dwToRead=m_dwSerialBufferPos; -#ifndef DISABLE_CRYPT - } -#endif - - // calc the header crc - psih->dwHeaderCRC32=icpf::crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(DWORD)); - - // write the buffer - WriteBuffer(m_pbySerialBuffer, psih->dwToRead); - } - - // remove all the traces of serializing - ClearSerialization(); -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::SWrite(void* pData, DWORD dwSize) -{ - InternalAppendSerialBuffer(pData, dwSize); -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::SRead(void* pData, DWORD dwSize) -{ - InternalReadSerialBuffer(pData, dwSize); -} - -#ifdef _MFC_VER - -CFileEx& CFileEx::operator<<(CString strData) -{ - DWORD dwLen=strData.GetLength(); - SWrite(&dwLen, sizeof(DWORD)); - SWrite(strData.GetBuffer(1), dwLen); - strData.ReleaseBuffer(); - return *this; -} - -CFileEx& CFileEx::operator>>(CString& strData) -{ - DWORD dwLen; - SRead(&dwLen, sizeof(DWORD)); - PTSTR pszData=strData.GetBuffer(dwLen+1); - try - { - SRead(pszData, dwLen); - } - catch(...) - { - pszData[dwLen]=_T('\0'); - strData.ReleaseBuffer(); - throw; - } - - pszData[dwLen]=_T('\0'); - strData.ReleaseBuffer(); - return *this; -} - -#endif - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::ClearSerialization() -{ - // remove all the traces of serializing - delete [] m_pbySerialBuffer; - m_pbySerialBuffer=NULL; - m_dwSerialBufferSize=0; - m_dwSerialBufferPos=0; - m_bSerializing=false; -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::InternalReadSerialBuffer(void* pData, DWORD dwLen) -{ - // check if we are reading - _ASSERT((m_dwMode & FA_OPERATION) == FA_READ); - - // check the ranges - if (m_dwSerialBufferPos+dwLen > m_dwSerialBufferSize) - { - // throw an exception - read beyond the data range in a given object - THROW_FILEEXCEPTIONEX(_T("Trying to read the serialization data beyond the range."), m_pszFilename, FERR_MEMORY, GetLastError()); - } - - // read the data - memcpy(pData, m_pbySerialBuffer+m_dwSerialBufferPos, dwLen); - m_dwSerialBufferPos+=dwLen; -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::InternalAppendSerialBuffer(void* pData, DWORD dwCount) -{ - // check if we are writing - _ASSERT((m_dwMode & FA_OPERATION) == FA_WRITE); - - // check serial buffer size (if there is enough room for the data) - if (m_dwSerialBufferPos+dwCount > m_dwSerialBufferSize) - { - // we need a buffer reallocation - DWORD dwDelta=((dwCount/SERIALBUFFER_DELTA)+1)*SERIALBUFFER_DELTA; - - // alloc the new buffer - ResizeSerialBuffer(m_dwSerialBufferSize+dwDelta); - } - - // real storage of the data - if (dwCount > 0) - { - memcpy(m_pbySerialBuffer+m_dwSerialBufferPos, pData, dwCount); - m_dwSerialBufferPos+=dwCount; - } -} - -/////////////////////////////////////////////////////////////// -// -/////////////////////////////////////////////////////////////// -void CFileEx::ResizeSerialBuffer(DWORD dwNewLen) -{ - // alloc the new buffer - BYTE* pbyNewBuffer=new BYTE[dwNewLen]; - - // copy the old data into the new one - DWORD dwCount=min(m_dwSerialBufferPos, dwNewLen); - if (m_dwSerialBufferPos > 0) - memcpy(pbyNewBuffer, m_pbySerialBuffer, dwCount); - - // delete the old buffer - delete [] m_pbySerialBuffer; - - // set the new buffer inplace and update the internal size - m_pbySerialBuffer=pbyNewBuffer; - m_dwSerialBufferSize=dwNewLen; -} - -/////////////////////////////////////////////////////////////// -// (Internal) Functions reads line of text from text file -// Only for buffered operation -// pszStr [out] - string that was read from file -// dwMaxLen [in] - size of the string buffer -/////////////////////////////////////////////////////////////// -bool CFileEx::InternalReadString(TCHAR* pszStr, DWORD dwMaxLen) -{ - _ASSERT(m_hFile != NULL); // file wasn't opened - error opening or you've forgotten to do so ? - - // last time was writing - free buffer - if (m_bLastOperation) - { - Flush(); - m_bLastOperation=false; - } - - // zero all the string - memset(pszStr, 0, dwMaxLen*sizeof(TCHAR)); - - // additional vars - DWORD dwStrPos=0; // current pos in external buffer - bool bSecondPass=false; // if there is need to check data for 0x0a char - - // copy each char into pszString - while(true) - { - // if buffer is empty - fill it - if (m_dwDataCount == 0 || m_dwCurrentPos == m_dwDataCount) - { - if (ReadPacket() == 0) - return _tcslen(pszStr) != 0; - } - - // skipping 0x0a in second pass - if (bSecondPass) - { - if (m_pbyBuffer[m_dwCurrentPos] == 0x0a) - m_dwCurrentPos++; - return true; - } - - // now process chars - while (m_dwCurrentPos < m_dwDataCount) - { - if (m_pbyBuffer[m_dwCurrentPos] == 0x0d) - { - bSecondPass=true; - m_dwCurrentPos++; - break; - } - else if (m_pbyBuffer[m_dwCurrentPos] == 0x0a) - { - m_dwCurrentPos++; - return true; - } - else - { - if (dwStrPos < dwMaxLen-1) - pszStr[dwStrPos++]=m_pbyBuffer[m_dwCurrentPos]; - m_dwCurrentPos++; - } - } - } - - return false; -} - -/////////////////////////////////////////////////////////////// -// (Internal) Sets file pointer in a file -// llOffset [in] - position to move to -// uiFrom [in] - type of moving (see Platform SDK on -// SetFilePointer) -/////////////////////////////////////////////////////////////// -LONGLONG CFileEx::InternalSeek(LONGLONG llOffset, UINT uiFrom) -{ - LARGE_INTEGER li; - li.QuadPart = llOffset; - li.LowPart = SetFilePointer (m_hFile, li.LowPart, &li.HighPart, uiFrom); - - if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR) - { - // error seeking - throw an exception - THROW_FILEEXCEPTIONEX(_T("Seek error."), m_pszFilename, FERR_SEEK, GetLastError()); - } - - return li.QuadPart; -} Index: src/ch/FileEx.h =================================================================== diff -u -N --- src/ch/FileEx.h (revision 0) +++ src/ch/FileEx.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,249 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + File: File.h + Version: 1.0 + Author: Ixen Gerthannes (ixen@interia.pl) + File description: + Contain class that handle buffered and unbuffered access to + file. Primarily designed to work without mfc. Possible use + with ms foundation classes. + Classes: + CFileException (based on CException) + - exception class designed for usage with class CFile + (not MFC based). + - when used with MFC class name is CFileExException + CFile + - handles file-based operations (buffered and + unbuffered): + - reading/writing of data buffers + - reading/writing of text lines (for text files) + - reading/writing values of internal types (int, + ...) + - when used with MFC class name is CFileEx +*************************************************************************/ +#ifndef __FILE_H__ +#define __FILE_H__ + +#pragma warning (disable : 4786) + +#include "ExceptionEx.h" + +#ifndef __FUNCTION__ + #define __FUNCTION__ "" +#endif + +#define THROW_FILEEXCEPTIONEX(str_reason, filename, app_code, last_error) throw new CFileExceptionEx(__FILE__, __LINE__, __FUNCTION__, str_reason, filename, app_code, last_error) + +// File exception errors +#define FERR_UNKNOWN 0 +#define FERR_OPEN 1 +#define FERR_CLOSE 2 +#define FERR_READ 3 +#define FERR_WRITE 4 +#define FERR_SEEK 5 +#define FERR_EOF 6 /* eof encountered - currently unused*/ +#define FERR_SETEOF 7 /* error while setting an eof in file */ +#define FERR_GETSIZE 8 /* error getting file size */ +#define FERR_SERIALIZE 9 /* serialization error */ +#define FERR_MEMORY 10 /* trying to read the data beyond the index */ +#define FERR_CRYPT 11 /* encryption/decryption error */ + +class CFileExceptionEx : public CExceptionEx +{ +public: + CFileExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, PCTSTR pszReason, PCTSTR pszFilename, DWORD dwReason=FERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; + CFileExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, TCHAR* pszReason, PCTSTR pszFilename, DWORD dwReason=FERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; + virtual ~CFileExceptionEx() { delete [] m_pszFilename; }; + + virtual int RegisterInfo(__EXCPROPINFO* pInfo) + { + // if the pInfo is null - return count of a needed props + if (pInfo == NULL) + return 1+CExceptionEx::RegisterInfo(NULL); + + // call base class RegisterInfo + size_t tIndex=CExceptionEx::RegisterInfo(pInfo); + + // function has to register the info to be displayed (called from within GetInfo) + RegisterProp(pInfo+tIndex+0, _T("Filename"), PropType::dtPtrToString, &m_pszFilename); + + return 1; + }; + +protected: + void SetFilename(PCTSTR pszFilename) { if (pszFilename) { m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; _tcscpy(m_pszFilename, pszFilename); } else m_pszFilename=NULL; }; + +public: + TCHAR* m_pszFilename; +}; + +// header information for serialziation block +struct SERIALIZEINFOHEADER +{ + // main header + DWORD dwDataSize; // size of the meaningful data (with the header size) + DWORD dwToRead; // count of data to read at once (may be greater than dwDataSize) + DWORD dwCRC32; // crc32 of the data (only the data part) + + // helper + DWORD dwHeaderCRC32; // the above's header crc +}; + +// file access modes +#define FA_OPERATION 0x7fff +#define FA_READ 0 +#define FA_WRITE 1 +#define FA_RW 2 +#define FA_APPEND 3 /* second rw access but with seek to end */ + +// additional mode mods +#define FA_BUFFERED 0x8000 /* if this is buffered */ + +// begin data block flags +#define BF_NONE 0x00 +#define BF_ENCRYPTED 0x01 + +// currently CSerializer will be the same as CFileEx (later it may change) +#define CSerializer CFileEx + +// real file class +class CFileEx +{ +public: + // construction/destruction + CFileEx() { m_hFile=NULL; m_pszFilename=NULL; m_dwMode=0; + m_dwBufferSize=0; m_pbyBuffer=NULL; m_dwCurrentPos=0; + m_dwDataCount=0; m_bBuffered=false; m_bLastOperation=false; m_bRememberedState=false; + m_pbySerialBuffer=NULL; m_dwSerialBufferSize=NULL; m_dwSerialBufferPos=0; m_bSerializing=0; +#ifndef DISABLE_CRYPT + m_pszPassword=NULL; +#endif + }; + ~CFileEx() { Close(); +#ifndef DISABLE_CRYPT + delete [] m_pszPassword; +#endif + }; + + // opening/closing file + void Open(PCTSTR pszFilename, DWORD dwAccess, DWORD dwBufferSize=4096); + void Close(); + + // flushing (flushes all the internal's buffer data to the external file) + void Flush(); + + // reads or writes the data from/to a file (uses buffering for this if enabled) + DWORD ReadBuffer(void* pBuffer, DWORD dwSize); + DWORD WriteBuffer(void* pBuffer, DWORD dwSize); + + // handling the lines of text in a file (autodetecting the windows/unix style of line ending) + bool ReadLine(TCHAR* pszStr, DWORD dwMaxLen); + void WriteLine(TCHAR* pszString); + + // position related functions + void Seek(LONGLONG llOffset, UINT uiFrom); // seeks in a file - flushes buffers before + LONGLONG GetPos(); // returns the current position of a file pointer (corrected by a pos in the internal buffer) + + // size related functions + void SetEndOfFile(); // sets the end of file in the current file pointer place + LONGLONG GetSize(); // retrieves the size of this file + + // buffered/unbuffered state managing + void SetBuffering(bool bEnable=true, DWORD dwSize=4096); // on-the-fly changing operation types + bool IsBuffered() { return m_bBuffered; }; + DWORD GetBufferSize() { return m_dwBufferSize; }; + + void SwitchToUnbuffered(); // remembers current state and changes to unbuffered + void SwitchToBuffered(); // remembers current state and changes to buffered + void RestoreState(); // restores (un)buffered last state + + // serialization (block operation) + void BeginDataBlock(DWORD dwFlags=BF_NONE); + void EndDataBlock(); + +#ifndef DISABLE_CRYPT + void SetPassword(PCTSTR pszPass); +#endif + // serialization stuff + void SWrite(void* pData, DWORD dwSize); + void SRead(void* pData, DWORD dwSize); + + bool IsStoring() { return (m_dwMode & FA_OPERATION) == FA_WRITE; }; + bool IsLoading() { return (m_dwMode & FA_OPERATION) == FA_READ; }; + + // storing data + template CFileEx& operator<<(T tData) { SWrite(&tData, sizeof(T)); return *this; }; + +#ifdef _MFC_VER + CFileEx& operator<<(CString strData); +#endif + + // reading data + template CFileEx& operator>>(T& tData) { SRead(&tData, sizeof(T)); return *this; }; + +#ifdef _MFC_VER + CFileEx& operator>>(CString& strData); +#endif + +protected: + // serialization related internal functions + void InternalAppendSerialBuffer(void* pData, DWORD dwCount); + void ResizeSerialBuffer(DWORD dwNewLen); + void InternalReadSerialBuffer(void* pData, DWORD dwLen); + void ClearSerialization(); + + // file-buffering related operations + DWORD ReadPacket(); // reads next packet of data - for buffered operations + DWORD WritePacket(); // writes next packet of data - buffered only + + bool InternalReadString(TCHAR* pszStr, DWORD dwMaxLen); + LONGLONG InternalSeek(LONGLONG llOffset, UINT uiFrom); // real seek-w/o any flushing + +protected: + HANDLE m_hFile; // handle to file + TCHAR* m_pszFilename; // path to this file + DWORD m_dwMode; // mode in which this file has been opened + + bool m_bLastOperation; // false=>READ, true=>WRITE + + // read/write buffering + bool m_bBuffered; // is this file additionally buffered ? + DWORD m_dwBufferSize; // specifies internal buffer size + BYTE* m_pbyBuffer; // internal buffer address + DWORD m_dwCurrentPos; // current position in above buffer + DWORD m_dwDataCount; // count of data in buffer (counting from beginning) + + // serialization stuff + bool m_bSerializing; // are we currently serializing (between BeginDataBlock and EndDataBlock) ? + BYTE* m_pbySerialBuffer; // buffer used for serialization + DWORD m_dwSerialBufferSize; // current size of the serialization buffer + DWORD m_dwSerialBufferPos; // current position in the serialization buffer + DWORD m_dwDataBlockFlags; // flags used in begin data block + +#ifndef DISABLE_CRYPT + // encryption related + TCHAR *m_pszPassword; +#endif + // state + bool m_bRememberedState; // was state remembered (it means also that last state was different) ? +}; + +#endif Index: ch/FileEx.h =================================================================== diff -u -N --- ch/FileEx.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/FileEx.h (revision 0) @@ -1,249 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - File: File.h - Version: 1.0 - Author: Ixen Gerthannes (ixen@interia.pl) - File description: - Contain class that handle buffered and unbuffered access to - file. Primarily designed to work without mfc. Possible use - with ms foundation classes. - Classes: - CFileException (based on CException) - - exception class designed for usage with class CFile - (not MFC based). - - when used with MFC class name is CFileExException - CFile - - handles file-based operations (buffered and - unbuffered): - - reading/writing of data buffers - - reading/writing of text lines (for text files) - - reading/writing values of internal types (int, - ...) - - when used with MFC class name is CFileEx -*************************************************************************/ -#ifndef __FILE_H__ -#define __FILE_H__ - -#pragma warning (disable : 4786) - -#include "ExceptionEx.h" - -#ifndef __FUNCTION__ - #define __FUNCTION__ "" -#endif - -#define THROW_FILEEXCEPTIONEX(str_reason, filename, app_code, last_error) throw new CFileExceptionEx(__FILE__, __LINE__, __FUNCTION__, str_reason, filename, app_code, last_error) - -// File exception errors -#define FERR_UNKNOWN 0 -#define FERR_OPEN 1 -#define FERR_CLOSE 2 -#define FERR_READ 3 -#define FERR_WRITE 4 -#define FERR_SEEK 5 -#define FERR_EOF 6 /* eof encountered - currently unused*/ -#define FERR_SETEOF 7 /* error while setting an eof in file */ -#define FERR_GETSIZE 8 /* error getting file size */ -#define FERR_SERIALIZE 9 /* serialization error */ -#define FERR_MEMORY 10 /* trying to read the data beyond the index */ -#define FERR_CRYPT 11 /* encryption/decryption error */ - -class CFileExceptionEx : public CExceptionEx -{ -public: - CFileExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, PCTSTR pszReason, PCTSTR pszFilename, DWORD dwReason=FERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; - CFileExceptionEx(PCTSTR pszSrcFile, DWORD dwLine, PCTSTR pszFunc, TCHAR* pszReason, PCTSTR pszFilename, DWORD dwReason=FERR_UNKNOWN, DWORD dwLastError=0) : CExceptionEx(pszSrcFile, dwLine, pszFunc, pszReason, dwReason, dwLastError) { SetFilename(pszFilename); }; - virtual ~CFileExceptionEx() { delete [] m_pszFilename; }; - - virtual int RegisterInfo(__EXCPROPINFO* pInfo) - { - // if the pInfo is null - return count of a needed props - if (pInfo == NULL) - return 1+CExceptionEx::RegisterInfo(NULL); - - // call base class RegisterInfo - size_t tIndex=CExceptionEx::RegisterInfo(pInfo); - - // function has to register the info to be displayed (called from within GetInfo) - RegisterProp(pInfo+tIndex+0, _T("Filename"), PropType::dtPtrToString, &m_pszFilename); - - return 1; - }; - -protected: - void SetFilename(PCTSTR pszFilename) { if (pszFilename) { m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; _tcscpy(m_pszFilename, pszFilename); } else m_pszFilename=NULL; }; - -public: - TCHAR* m_pszFilename; -}; - -// header information for serialziation block -struct SERIALIZEINFOHEADER -{ - // main header - DWORD dwDataSize; // size of the meaningful data (with the header size) - DWORD dwToRead; // count of data to read at once (may be greater than dwDataSize) - DWORD dwCRC32; // crc32 of the data (only the data part) - - // helper - DWORD dwHeaderCRC32; // the above's header crc -}; - -// file access modes -#define FA_OPERATION 0x7fff -#define FA_READ 0 -#define FA_WRITE 1 -#define FA_RW 2 -#define FA_APPEND 3 /* second rw access but with seek to end */ - -// additional mode mods -#define FA_BUFFERED 0x8000 /* if this is buffered */ - -// begin data block flags -#define BF_NONE 0x00 -#define BF_ENCRYPTED 0x01 - -// currently CSerializer will be the same as CFileEx (later it may change) -#define CSerializer CFileEx - -// real file class -class CFileEx -{ -public: - // construction/destruction - CFileEx() { m_hFile=NULL; m_pszFilename=NULL; m_dwMode=0; - m_dwBufferSize=0; m_pbyBuffer=NULL; m_dwCurrentPos=0; - m_dwDataCount=0; m_bBuffered=false; m_bLastOperation=false; m_bRememberedState=false; - m_pbySerialBuffer=NULL; m_dwSerialBufferSize=NULL; m_dwSerialBufferPos=0; m_bSerializing=0; -#ifndef DISABLE_CRYPT - m_pszPassword=NULL; -#endif - }; - ~CFileEx() { Close(); -#ifndef DISABLE_CRYPT - delete [] m_pszPassword; -#endif - }; - - // opening/closing file - void Open(PCTSTR pszFilename, DWORD dwAccess, DWORD dwBufferSize=4096); - void Close(); - - // flushing (flushes all the internal's buffer data to the external file) - void Flush(); - - // reads or writes the data from/to a file (uses buffering for this if enabled) - DWORD ReadBuffer(void* pBuffer, DWORD dwSize); - DWORD WriteBuffer(void* pBuffer, DWORD dwSize); - - // handling the lines of text in a file (autodetecting the windows/unix style of line ending) - bool ReadLine(TCHAR* pszStr, DWORD dwMaxLen); - void WriteLine(TCHAR* pszString); - - // position related functions - void Seek(LONGLONG llOffset, UINT uiFrom); // seeks in a file - flushes buffers before - LONGLONG GetPos(); // returns the current position of a file pointer (corrected by a pos in the internal buffer) - - // size related functions - void SetEndOfFile(); // sets the end of file in the current file pointer place - LONGLONG GetSize(); // retrieves the size of this file - - // buffered/unbuffered state managing - void SetBuffering(bool bEnable=true, DWORD dwSize=4096); // on-the-fly changing operation types - bool IsBuffered() { return m_bBuffered; }; - DWORD GetBufferSize() { return m_dwBufferSize; }; - - void SwitchToUnbuffered(); // remembers current state and changes to unbuffered - void SwitchToBuffered(); // remembers current state and changes to buffered - void RestoreState(); // restores (un)buffered last state - - // serialization (block operation) - void BeginDataBlock(DWORD dwFlags=BF_NONE); - void EndDataBlock(); - -#ifndef DISABLE_CRYPT - void SetPassword(PCTSTR pszPass); -#endif - // serialization stuff - void SWrite(void* pData, DWORD dwSize); - void SRead(void* pData, DWORD dwSize); - - bool IsStoring() { return (m_dwMode & FA_OPERATION) == FA_WRITE; }; - bool IsLoading() { return (m_dwMode & FA_OPERATION) == FA_READ; }; - - // storing data - template CFileEx& operator<<(T tData) { SWrite(&tData, sizeof(T)); return *this; }; - -#ifdef _MFC_VER - CFileEx& operator<<(CString strData); -#endif - - // reading data - template CFileEx& operator>>(T& tData) { SRead(&tData, sizeof(T)); return *this; }; - -#ifdef _MFC_VER - CFileEx& operator>>(CString& strData); -#endif - -protected: - // serialization related internal functions - void InternalAppendSerialBuffer(void* pData, DWORD dwCount); - void ResizeSerialBuffer(DWORD dwNewLen); - void InternalReadSerialBuffer(void* pData, DWORD dwLen); - void ClearSerialization(); - - // file-buffering related operations - DWORD ReadPacket(); // reads next packet of data - for buffered operations - DWORD WritePacket(); // writes next packet of data - buffered only - - bool InternalReadString(TCHAR* pszStr, DWORD dwMaxLen); - LONGLONG InternalSeek(LONGLONG llOffset, UINT uiFrom); // real seek-w/o any flushing - -protected: - HANDLE m_hFile; // handle to file - TCHAR* m_pszFilename; // path to this file - DWORD m_dwMode; // mode in which this file has been opened - - bool m_bLastOperation; // false=>READ, true=>WRITE - - // read/write buffering - bool m_bBuffered; // is this file additionally buffered ? - DWORD m_dwBufferSize; // specifies internal buffer size - BYTE* m_pbyBuffer; // internal buffer address - DWORD m_dwCurrentPos; // current position in above buffer - DWORD m_dwDataCount; // count of data in buffer (counting from beginning) - - // serialization stuff - bool m_bSerializing; // are we currently serializing (between BeginDataBlock and EndDataBlock) ? - BYTE* m_pbySerialBuffer; // buffer used for serialization - DWORD m_dwSerialBufferSize; // current size of the serialization buffer - DWORD m_dwSerialBufferPos; // current position in the serialization buffer - DWORD m_dwDataBlockFlags; // flags used in begin data block - -#ifndef DISABLE_CRYPT - // encryption related - TCHAR *m_pszPassword; -#endif - // state - bool m_bRememberedState; // was state remembered (it means also that last state was different) ? -}; - -#endif Index: src/ch/FileInfo.cpp =================================================================== diff -u -N --- src/ch/FileInfo.cpp (revision 0) +++ src/ch/FileInfo.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1089 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + FileInfo.cpp: implementation of the CFileInfo class. + (c) Codeguru & friends + Coded by Antonio Tejada Lacaci. 1999, modified by Ixen Gerthannes + atejada@espanet.com +*************************************************************************/ + +#include "stdafx.h" +#include "FileInfo.h" +#include "resource.h" +#include "DataBuffer.h" +#include "Device IO.h" +#include "imagehlp.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#undef THIS_FILE +static char THIS_FILE[]=__FILE__; +#define new DEBUG_NEW +#endif + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// +// finds another name for a copy of src file(folder) in dest location +void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult) +{ + // get the name from srcpath + if (strSrcPath.Right(1) == _T("\\")) + strSrcPath=strSrcPath.Left(strSrcPath.GetLength()-1); + + int iBarPos=strSrcPath.ReverseFind(_T('\\')); + CString strFolderName; + if (iBarPos != -1) + strFolderName=strSrcPath.Mid(iBarPos+1); + else + strFolderName=strSrcPath; // it shouldn't happen at all + + if (strDstPath.Right(1) != _T("\\")) + strDstPath+=_T("\\"); + + // set the dest path + CString strCheckPath; + strCheckPath.Format(GetResManager()->LoadString(IDS_FIRSTCOPY_STRING), strFolderName); + if (strCheckPath.GetLength() > _MAX_PATH) + strCheckPath=strCheckPath.Left(_MAX_PATH); // max - 260 chars + + // when adding to strDstPath check if the path already exists - if so - try again + int iCounter=1; + while (CFileInfo::Exist(strDstPath+strCheckPath)) + strCheckPath.Format(GetResManager()->LoadString(IDS_NEXTCOPY_STRING), ++iCounter, strFolderName); + + *pstrResult=strCheckPath; +} + +bool _tcicmp(TCHAR c1, TCHAR c2) +{ + TCHAR ch1[2]={c1, 0}, ch2[2]={c2, 0}; + return (_tcsicmp(ch1, ch2) == 0); +} + +//////////////////////////////////////////////////////////////////////////// +CFileFilter::CFileFilter() +{ + // files mask + m_bUseMask=false; + m_astrMask.RemoveAll(); + + m_bUseExcludeMask=false; + m_astrExcludeMask.RemoveAll(); + + // size filtering + m_bUseSize=false; + m_iSizeType1=GT; + m_ullSize1=0; + m_bUseSize2=false; + m_iSizeType2=LT; + m_ullSize2=0; + + // date filtering + m_bUseDate=false; + m_iDateType=DATE_CREATED; + m_iDateType1=GT; + m_bDate1=false; + m_tDate1=CTime::GetCurrentTime(); + m_bTime1=false; + m_tTime1=CTime::GetCurrentTime(); + + m_bUseDate2=false; + m_iDateType2=LT; + m_bDate2=false; + m_tDate2=CTime::GetCurrentTime(); + m_bTime2=false; + m_tTime2=CTime::GetCurrentTime(); + + // attribute filtering + m_bUseAttributes=false; + m_iArchive=2; + m_iReadOnly=2; + m_iHidden=2; + m_iSystem=2; + m_iDirectory=2; +} + +CFileFilter::CFileFilter(const CFileFilter& rFilter) +{ + *this=rFilter; +} + +CFileFilter& CFileFilter::operator=(const CFileFilter& rFilter) +{ + // files mask + m_bUseMask=rFilter.m_bUseMask; + m_astrMask.Copy(rFilter.m_astrMask); + + m_bUseExcludeMask=rFilter.m_bUseExcludeMask; + m_astrExcludeMask.Copy(rFilter.m_astrExcludeMask); + + // size filtering + m_bUseSize=rFilter.m_bUseSize; + m_iSizeType1=rFilter.m_iSizeType1; + m_ullSize1=rFilter.m_ullSize1; + m_bUseSize2=rFilter.m_bUseSize2; + m_iSizeType2=rFilter.m_iSizeType2; + m_ullSize2=rFilter.m_ullSize2; + + // date filtering + m_bUseDate=rFilter.m_bUseDate; + m_iDateType=rFilter.m_iDateType; + m_iDateType1=rFilter.m_iDateType1; + m_bDate1=rFilter.m_bDate1; + m_tDate1=rFilter.m_tDate1; + m_bTime1=rFilter.m_bTime1; + m_tTime1=rFilter.m_tTime1; + + m_bUseDate2=rFilter.m_bUseDate2; + m_iDateType2=rFilter.m_iDateType2; + m_bDate2=rFilter.m_bDate2; + m_tDate2=rFilter.m_tDate2; + m_bTime2=rFilter.m_bTime2; + m_tTime2=rFilter.m_tTime2; + + // attribute filtering + m_bUseAttributes=rFilter.m_bUseAttributes; + m_iArchive=rFilter.m_iArchive; + m_iReadOnly=rFilter.m_iReadOnly; + m_iHidden=rFilter.m_iHidden; + m_iSystem=rFilter.m_iSystem; + m_iDirectory=rFilter.m_iDirectory; + + return *this; +} + +void CFileFilter::Serialize(CArchive& ar) +{ + ULARGE_INTEGER li; + if (ar.IsStoring()) + { + // store + // files mask + ar<(m_bUseMask); + m_astrMask.Serialize(ar); + + ar<(m_bUseExcludeMask); + m_astrExcludeMask.Serialize(ar); + + // size filtering + ar<(m_bUseSize); + ar<(m_bUseSize2); + ar<(m_bUseDate); + ar<(m_bDate1); + ar<(m_bTime1); + ar<(m_bUseDate2); + ar<(m_bDate2); + ar<(m_bTime2); + ar<(m_bUseAttributes); + ar<>tmp; + m_bUseMask=(tmp != 0); + m_astrMask.Serialize(ar); + + ar>>tmp; + m_bUseExcludeMask=(tmp != 0); + m_astrExcludeMask.Serialize(ar); + + // size + ar>>tmp; + m_bUseSize=(tmp != 0); + ar>>m_iSizeType1; + ar>>li.LowPart; + ar>>li.HighPart; + m_ullSize1=li.QuadPart; + ar>>tmp; + m_bUseSize2=(tmp != 0); + ar>>m_iSizeType2; + ar>>li.LowPart; + ar>>li.HighPart; + m_ullSize2=li.QuadPart; + + // date + ar>>tmp; + m_bUseDate=(tmp != 0); + ar>>m_iDateType; + ar>>m_iDateType1; + ar>>tmp; + m_bDate1=(tmp != 0); + ar>>m_tDate1; + ar>>tmp; + m_bTime1=(tmp != 0); + ar>>m_tTime1; + + ar>>tmp; + m_bUseDate2=(tmp != 0); + ar>>m_iDateType2; + ar>>tmp; + m_bDate2=(tmp != 0); + ar>>m_tDate2; + ar>>tmp; + m_bTime2=(tmp != 0); + ar>>m_tTime2; + + // attributes + ar>>tmp; + m_bUseAttributes=(tmp != 0); + ar>>m_iArchive; + ar>>m_iReadOnly; + ar>>m_iHidden; + ar>>m_iSystem; + ar>>m_iDirectory; + } +} + +CString& CFileFilter::GetCombinedMask(CString& pMask) const +{ + pMask.Empty(); + if (m_astrMask.GetSize() > 0) + { + pMask=m_astrMask.GetAt(0); + for (int i=1;i 0) + { + pMask=m_astrExcludeMask.GetAt(0); + for (int i=1;i rInfo.GetLength64()) + return false; + break; + case GT: + if (m_ullSize1 >= rInfo.GetLength64()) + return false; + break; + } + + // second part + if (m_bUseSize2) + { + switch (m_iSizeType2) + { + case LT: + if (m_ullSize2 <= rInfo.GetLength64()) + return false; + break; + case LE: + if (m_ullSize2 < rInfo.GetLength64()) + return false; + break; + case EQ: + if (m_ullSize2 != rInfo.GetLength64()) + return false; + break; + case GE: + if (m_ullSize2 > rInfo.GetLength64()) + return false; + break; + case GT: + if (m_ullSize2 >= rInfo.GetLength64()) + return false; + break; + } + } + } + + // date - get the time from rInfo + if (m_bUseDate) + { + COleDateTime tm; + switch (m_iDateType) + { + case DATE_CREATED: + tm=rInfo.GetCreationTime(); + break; + case DATE_MODIFIED: + tm=rInfo.GetLastWriteTime(); + break; + case DATE_LASTACCESSED: + tm=rInfo.GetLastAccessTime(); + break; + } + + // counting... + unsigned long ulInfo=0, ulCheck=0; + if (m_bDate1) + { + ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; + ulCheck=(m_tDate1.GetYear()-1970)*32140800+m_tDate1.GetMonth()*2678400+m_tDate1.GetDay()*86400; + } + + if (m_bTime1) + { + ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); + ulCheck+=m_tTime1.GetHour()*3600+m_tTime1.GetMinute()*60+m_tTime1.GetSecond(); + } + + // ... and comparing + switch (m_iDateType1) + { + case LT: + if (ulInfo >= ulCheck) + return false; + break; + case LE: + if (ulInfo > ulCheck) + return false; + break; + case EQ: + if (ulInfo != ulCheck) + return false; + break; + case GE: + if (ulInfo < ulCheck) + return false; + break; + case GT: + if (ulInfo <= ulCheck) + return false; + break; + } + + if (m_bUseDate2) + { + // counting... + ulInfo=0, ulCheck=0; + if (m_bDate2) + { + ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; + ulCheck=(m_tDate2.GetYear()-1970)*32140800+m_tDate2.GetMonth()*2678400+m_tDate2.GetDay()*86400; + } + + if (m_bTime2) + { + ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); + ulCheck+=m_tTime2.GetHour()*3600+m_tTime2.GetMinute()*60+m_tTime2.GetSecond(); + } + + // ... comparing + switch (m_iDateType2) + { + case LT: + if (ulInfo >= ulCheck) + return false; + break; + case LE: + if (ulInfo > ulCheck) + return false; + break; + case EQ: + if (ulInfo != ulCheck) + return false; + break; + case GE: + if (ulInfo < ulCheck) + return false; + break; + case GT: + if (ulInfo <= ulCheck) + return false; + break; + } + } + } // of m_bUseDate + + // attributes + if (m_bUseAttributes) + { + if ( (m_iArchive == 1 && !rInfo.IsArchived()) || (m_iArchive == 0 && rInfo.IsArchived())) + return false; + if ( (m_iReadOnly == 1 && !rInfo.IsReadOnly()) || (m_iReadOnly == 0 && rInfo.IsReadOnly())) + return false; + if ( (m_iHidden == 1 && !rInfo.IsHidden()) || (m_iHidden == 0 && rInfo.IsHidden())) + return false; + if ( (m_iSystem == 1 && !rInfo.IsSystem()) || (m_iSystem == 0 && rInfo.IsSystem())) + return false; + if ( (m_iDirectory == 1 && !rInfo.IsDirectory()) || (m_iDirectory == 0 && rInfo.IsDirectory())) + return false; + } + + return true; +} + +bool CFileFilter::MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const +{ + bool bMatch = 1; + + //iterate and delete '?' and '*' one by one + while(*lpszMask != _T('\0') && bMatch && *lpszString != _T('\0')) + { + if (*lpszMask == _T('?')) lpszString++; + else if (*lpszMask == _T('*')) + { + bMatch = Scan(lpszMask, lpszString); + lpszMask--; + } + else + { + bMatch = _tcicmp(*lpszMask, *lpszString); + lpszString++; + } + lpszMask++; + } + while (*lpszMask == _T('*') && bMatch) lpszMask++; + + return bMatch && *lpszString == _T('\0') && *lpszMask == _T('\0'); +} + +// scan '?' and '*' +bool CFileFilter::Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const +{ + // remove the '?' and '*' + for(lpszMask++; *lpszString != _T('\0') && (*lpszMask == _T('?') || *lpszMask == _T('*')); lpszMask++) + if (*lpszMask == _T('?')) lpszString++; + while ( *lpszMask == _T('*')) lpszMask++; + + // if lpszString is empty and lpszMask has more characters or, + // lpszMask is empty, return + if (*lpszString == _T('\0') && *lpszMask != _T('\0')) return false; + if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; + // else search substring + else + { + LPCTSTR wdsCopy = lpszMask; + LPCTSTR lpszStringCopy = lpszString; + bool bMatch = true; + do + { + if (!MatchMask(lpszMask, lpszString)) lpszStringCopy++; + lpszMask = wdsCopy; + lpszString = lpszStringCopy; + while (!(_tcicmp(*lpszMask, *lpszString)) && (*lpszString != '\0')) lpszString++; + wdsCopy = lpszMask; + lpszStringCopy = lpszString; + } + while ((*lpszString != _T('\0')) ? !MatchMask(lpszMask, lpszString) : (bMatch = false) != false); + + if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; + + return bMatch; + } +} + +bool CFiltersArray::Match(const CFileInfo& rInfo) const +{ + if (GetSize() == 0) + return true; + + // if only one of the filters matches - return true + for (int i=0;i>iSize; + SetSize(iSize); + for (int i=0;icFileName; + + // if proper index has been passed - reduce the path + if (iSrcIndex >= 0) + m_strFilePath=m_strFilePath.Mid(m_pClipboard->GetAt(iSrcIndex)->GetPath().GetLength()); // wytnij �cie�k� z clipboarda + + m_iSrcIndex=iSrcIndex; + m_dwAttributes = pwfd->dwFileAttributes; + m_uhFileSize = (((ULONGLONG) pwfd->nFileSizeHigh) << 32) + pwfd->nFileSizeLow; + m_timCreation = pwfd->ftCreationTime; + m_timLastAccess = pwfd->ftLastAccessTime; + m_timLastWrite = pwfd->ftLastWriteTime; +} + +bool CFileInfo::Create(CString strFilePath, int iSrcIndex) +{ + WIN32_FIND_DATA wfd; + HANDLE hFind; + int nBarPos; + + hFind = FindFirstFile(strFilePath, &wfd); + if (hFind != INVALID_HANDLE_VALUE) + { + FindClose(hFind); + + // add data to members + nBarPos = strFilePath.ReverseFind(TCHAR('\\')); + Create(&wfd, strFilePath.Left(nBarPos+1), iSrcIndex); + + return true; + } + else + { + m_strFilePath=GetResManager()->LoadString(IDS_NOTFOUND_STRING); + m_iSrcIndex=-1; + m_dwAttributes = (DWORD)-1; + m_uhFileSize = (unsigned __int64)-1; + m_timCreation.SetDateTime(100, 1, 1, 0, 0, 0); + m_timLastAccess.SetDateTime(100, 1, 1, 0, 0, 0); + m_timLastWrite.SetDateTime(100, 1, 1, 0, 0, 0); + return false; + } +} + +CString CFileInfo::GetFileDrive(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + TCHAR szDrive[_MAX_DRIVE]; + _tsplitpath(strPath, szDrive, NULL, NULL, NULL); + return CString(szDrive); +} + +int CFileInfo::GetDriveNumber() const +{ + ASSERT(m_pClipboard); + + if (m_iSrcIndex != -1) + { + // read data stored in CClipboardEntry + return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveNumber(); + } + else + { + // manually + int iNum; + GetDriveData(m_strFilePath, &iNum, NULL); + return iNum; + } +} + +UINT CFileInfo::GetDriveType() const +{ + ASSERT(m_pClipboard); + + if (m_iSrcIndex != -1) + { + // read data contained in CClipboardEntry + return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveType(); + } + else + { + // manually + UINT uiType; + GetDriveData(m_strFilePath, NULL, &uiType); + return uiType; + } +} + +CString CFileInfo::GetFileDir(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + TCHAR szDir[_MAX_DIR]; + _tsplitpath(strPath, NULL, szDir,NULL, NULL); + return CString(szDir); +} + +CString CFileInfo::GetFileTitle(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + TCHAR szName[_MAX_FNAME]; + _tsplitpath(strPath, NULL, NULL, szName, NULL); + return CString(szName); +} + +CString CFileInfo::GetFileExt(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + TCHAR szExt[_MAX_EXT]; + _tsplitpath(strPath, NULL, NULL, NULL, szExt); + return CString(szExt); +} + +CString CFileInfo::GetFileRoot(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + + TCHAR szDrive[_MAX_DRIVE]; + TCHAR szDir[_MAX_DIR]; + _tsplitpath(strPath, szDrive, szDir, NULL, NULL); + return CString(szDrive)+szDir; +} + +CString CFileInfo::GetFileName(void) const +{ + ASSERT(m_pClipboard); + + CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; + + TCHAR szName[_MAX_FNAME]; + TCHAR szExt[_MAX_EXT]; + _tsplitpath(strPath, NULL, NULL, szName, szExt); + return CString(szName)+szExt; +} + +void CFileInfo::Store(CArchive& ar) +{ + ar<((m_uhFileSize & 0xFFFFFFFF00000000) >> 32); + ar<(m_uhFileSize & 0x00000000FFFFFFFF); + ar<>m_strFilePath; + ar>>m_iSrcIndex; + ar>>m_dwAttributes; + unsigned long part; + ar>>part; + m_uhFileSize=(static_cast(part) << 32); + ar>>part; + m_uhFileSize+=part; + ar>>m_timCreation; + ar>>m_timLastAccess; + ar>>m_timLastWrite; +} + +bool CFileInfo::operator==(const CFileInfo& rInfo) +{ + return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_timCreation == m_timCreation + && rInfo.m_timLastWrite == m_timLastWrite && rInfo.m_uhFileSize == m_uhFileSize); +} + +CString CFileInfo::GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags) +{ + // add '\\' + if (strPath.Right(1) != _T("\\")) + strPath+=_T("\\"); + + // iFlags: bit 0-ignore folders; bit 1-force creating directories + if (iFlags & 0x02) + { + // force create directories + TCHAR dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _tsplitpath(GetFullFilePath(), NULL, dir, fname, ext); + + CString str=dir; + str.TrimLeft(_T("\\")); + + // force create directory +// AfxMessageBox("Created multiple level of paths for %s"+strPath+str); + MakeSureDirectoryPathExists(strPath+str); + +// AfxMessageBox(strPath+str+fname+CString(ext)); + return strPath+str+fname+CString(ext); + } + else + { + if (!(iFlags & 0x01) && m_iSrcIndex != -1) + { + // generate new dest name + while (ucCopyNumber >= m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.GetSize()) + { + CString strNewPath; + FindFreeSubstituteName(GetFullFilePath(), strPath, &strNewPath); + m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.Add(strNewPath); + } + + return strPath+m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.GetAt(ucCopyNumber)+m_strFilePath; + } + else + return strPath+GetFileName(); + } +} + +CString CFileInfo::GetFullFilePath() const +{ + CString strPath; + if (m_iSrcIndex >= 0) + { + ASSERT(m_pClipboard); + strPath+=m_pClipboard->GetAt(m_iSrcIndex)->GetPath(); + } + strPath+=m_strFilePath; + + return strPath; +} + +int CFileInfo::GetBufferIndex() const +{ + if (m_iSrcIndex != -1) + return m_pClipboard->GetAt(m_iSrcIndex)->GetBufferIndex(); + else + return BI_DEFAULT; +} + +/////////////////////////////////////////////////////////////////////// +// Array + +void CFileInfoArray::AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, + const bool bRecurse, const bool bIncludeDirs, + const volatile bool* pbAbort) +{ + WIN32_FIND_DATA wfd; + CString strText; + + // init CFileInfo + CFileInfo finf; + finf.SetClipboard(m_pClipboard); // this is the link table (CClipboardArray) + + // append '\\' at the end of path if needed + if (strDirName.Right(1) != _T("\\")) + strDirName+=_T("\\"); + + strText = strDirName + _T("*"); + // Iterate through dirs & files + HANDLE hFind = FindFirstFile(strText, &wfd); + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + if ( !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) + { + finf.Create(&wfd, strDirName, iSrcIndex); + if (pFilters->Match(finf)) + Add(finf); + } + else if ( strcmp(wfd.cFileName, _T(".")) != 0 && strcmp(wfd.cFileName, _T("..")) != 0) + { + if (bIncludeDirs) + { + // Add directory itself + finf.Create(&wfd, strDirName, iSrcIndex); + Add(finf); + } + if (bRecurse) + { + strText = strDirName + wfd.cFileName+_T("\\"); + // Recurse Dirs + AddDir(strText, pFilters, iSrcIndex, bRecurse, bIncludeDirs, pbAbort); + } + } + } + while (((pbAbort == NULL) || (!*pbAbort)) && (FindNextFile(hFind, &wfd))); + + FindClose(hFind); + } +} + +int CFileInfoArray::AddFile(CString strFilePath, int iSrcIndex) +{ + CFileInfo finf; + + // CUSTOMIZATION3 - cut '\\' at the end of strFilePath, set relative path + if (strFilePath.Right(1) == _T("\\")) + strFilePath=strFilePath.Left(strFilePath.GetLength()-1); + + finf.Create(strFilePath, iSrcIndex); + return Add(finf); +} + + +////////////////////////////////////////////////////////////////////////////// +// CClipboardArray + +void CClipboardArray::Serialize(CArchive& ar, bool bData) +{ + if (ar.IsStoring()) + { + // write data + int iSize=GetSize(); + ar<Serialize(ar, bData); + } + else + { + int iSize; + ar>>iSize; + + CClipboardEntry* pEntry; + for (int i=0;iSerialize(ar, bData); + } + } +} + +///////////////////////////////////////////////////////////////////////////// +// CClipboardEntry + +void CClipboardEntry::SetPath(const CString& strPath) +{ + m_strPath=strPath; // guaranteed without ending '\\' + if (m_strPath.Right(1) == _T('\\')) + m_strPath=m_strPath.Left(m_strPath.GetLength()-1); + + GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); +} + +void CClipboardEntry::CalcBufferIndex(const CDestPath& dpDestPath) +{ + // what kind of buffer + if (m_uiDriveType == DRIVE_REMOTE || dpDestPath.GetDriveType() == DRIVE_REMOTE) + m_iBufferIndex=BI_LAN; + else if (m_uiDriveType == DRIVE_CDROM || dpDestPath.GetDriveType() == DRIVE_CDROM) + m_iBufferIndex=BI_CD; + else if (m_uiDriveType == DRIVE_FIXED && dpDestPath.GetDriveType() == DRIVE_FIXED) + { + // two hdd's - is this the same physical disk ? + if (m_iDriveNumber == dpDestPath.GetDriveNumber() || IsSamePhysicalDisk(m_iDriveNumber, dpDestPath.GetDriveNumber())) + m_iBufferIndex=BI_ONEDISK; + else + m_iBufferIndex=BI_TWODISKS; + } + else + m_iBufferIndex=BI_DEFAULT; +} + +void CClipboardEntry::Serialize(CArchive& ar, bool bData) +{ + if (bData) + { + if (ar.IsStoring()) + { + ar<(m_bMove); + ar<>m_strPath; + unsigned char ucData; + ar>>ucData; + m_bMove=ucData != 0; + ar>>m_iDriveNumber; + ar>>m_uiDriveType; + ar>>m_iBufferIndex; + } + } + else + m_astrDstPaths.Serialize(ar); +} Index: ch/FileInfo.cpp =================================================================== diff -u -N --- ch/FileInfo.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FileInfo.cpp (revision 0) @@ -1,1089 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - FileInfo.cpp: implementation of the CFileInfo class. - (c) Codeguru & friends - Coded by Antonio Tejada Lacaci. 1999, modified by Ixen Gerthannes - atejada@espanet.com -*************************************************************************/ - -#include "stdafx.h" -#include "FileInfo.h" -#include "resource.h" -#include "DataBuffer.h" -#include "Device IO.h" -#include "imagehlp.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -// finds another name for a copy of src file(folder) in dest location -void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult) -{ - // get the name from srcpath - if (strSrcPath.Right(1) == _T("\\")) - strSrcPath=strSrcPath.Left(strSrcPath.GetLength()-1); - - int iBarPos=strSrcPath.ReverseFind(_T('\\')); - CString strFolderName; - if (iBarPos != -1) - strFolderName=strSrcPath.Mid(iBarPos+1); - else - strFolderName=strSrcPath; // it shouldn't happen at all - - if (strDstPath.Right(1) != _T("\\")) - strDstPath+=_T("\\"); - - // set the dest path - CString strCheckPath; - strCheckPath.Format(GetResManager()->LoadString(IDS_FIRSTCOPY_STRING), strFolderName); - if (strCheckPath.GetLength() > _MAX_PATH) - strCheckPath=strCheckPath.Left(_MAX_PATH); // max - 260 chars - - // when adding to strDstPath check if the path already exists - if so - try again - int iCounter=1; - while (CFileInfo::Exist(strDstPath+strCheckPath)) - strCheckPath.Format(GetResManager()->LoadString(IDS_NEXTCOPY_STRING), ++iCounter, strFolderName); - - *pstrResult=strCheckPath; -} - -bool _tcicmp(TCHAR c1, TCHAR c2) -{ - TCHAR ch1[2]={c1, 0}, ch2[2]={c2, 0}; - return (_tcsicmp(ch1, ch2) == 0); -} - -//////////////////////////////////////////////////////////////////////////// -CFileFilter::CFileFilter() -{ - // files mask - m_bUseMask=false; - m_astrMask.RemoveAll(); - - m_bUseExcludeMask=false; - m_astrExcludeMask.RemoveAll(); - - // size filtering - m_bUseSize=false; - m_iSizeType1=GT; - m_ullSize1=0; - m_bUseSize2=false; - m_iSizeType2=LT; - m_ullSize2=0; - - // date filtering - m_bUseDate=false; - m_iDateType=DATE_CREATED; - m_iDateType1=GT; - m_bDate1=false; - m_tDate1=CTime::GetCurrentTime(); - m_bTime1=false; - m_tTime1=CTime::GetCurrentTime(); - - m_bUseDate2=false; - m_iDateType2=LT; - m_bDate2=false; - m_tDate2=CTime::GetCurrentTime(); - m_bTime2=false; - m_tTime2=CTime::GetCurrentTime(); - - // attribute filtering - m_bUseAttributes=false; - m_iArchive=2; - m_iReadOnly=2; - m_iHidden=2; - m_iSystem=2; - m_iDirectory=2; -} - -CFileFilter::CFileFilter(const CFileFilter& rFilter) -{ - *this=rFilter; -} - -CFileFilter& CFileFilter::operator=(const CFileFilter& rFilter) -{ - // files mask - m_bUseMask=rFilter.m_bUseMask; - m_astrMask.Copy(rFilter.m_astrMask); - - m_bUseExcludeMask=rFilter.m_bUseExcludeMask; - m_astrExcludeMask.Copy(rFilter.m_astrExcludeMask); - - // size filtering - m_bUseSize=rFilter.m_bUseSize; - m_iSizeType1=rFilter.m_iSizeType1; - m_ullSize1=rFilter.m_ullSize1; - m_bUseSize2=rFilter.m_bUseSize2; - m_iSizeType2=rFilter.m_iSizeType2; - m_ullSize2=rFilter.m_ullSize2; - - // date filtering - m_bUseDate=rFilter.m_bUseDate; - m_iDateType=rFilter.m_iDateType; - m_iDateType1=rFilter.m_iDateType1; - m_bDate1=rFilter.m_bDate1; - m_tDate1=rFilter.m_tDate1; - m_bTime1=rFilter.m_bTime1; - m_tTime1=rFilter.m_tTime1; - - m_bUseDate2=rFilter.m_bUseDate2; - m_iDateType2=rFilter.m_iDateType2; - m_bDate2=rFilter.m_bDate2; - m_tDate2=rFilter.m_tDate2; - m_bTime2=rFilter.m_bTime2; - m_tTime2=rFilter.m_tTime2; - - // attribute filtering - m_bUseAttributes=rFilter.m_bUseAttributes; - m_iArchive=rFilter.m_iArchive; - m_iReadOnly=rFilter.m_iReadOnly; - m_iHidden=rFilter.m_iHidden; - m_iSystem=rFilter.m_iSystem; - m_iDirectory=rFilter.m_iDirectory; - - return *this; -} - -void CFileFilter::Serialize(CArchive& ar) -{ - ULARGE_INTEGER li; - if (ar.IsStoring()) - { - // store - // files mask - ar<(m_bUseMask); - m_astrMask.Serialize(ar); - - ar<(m_bUseExcludeMask); - m_astrExcludeMask.Serialize(ar); - - // size filtering - ar<(m_bUseSize); - ar<(m_bUseSize2); - ar<(m_bUseDate); - ar<(m_bDate1); - ar<(m_bTime1); - ar<(m_bUseDate2); - ar<(m_bDate2); - ar<(m_bTime2); - ar<(m_bUseAttributes); - ar<>tmp; - m_bUseMask=(tmp != 0); - m_astrMask.Serialize(ar); - - ar>>tmp; - m_bUseExcludeMask=(tmp != 0); - m_astrExcludeMask.Serialize(ar); - - // size - ar>>tmp; - m_bUseSize=(tmp != 0); - ar>>m_iSizeType1; - ar>>li.LowPart; - ar>>li.HighPart; - m_ullSize1=li.QuadPart; - ar>>tmp; - m_bUseSize2=(tmp != 0); - ar>>m_iSizeType2; - ar>>li.LowPart; - ar>>li.HighPart; - m_ullSize2=li.QuadPart; - - // date - ar>>tmp; - m_bUseDate=(tmp != 0); - ar>>m_iDateType; - ar>>m_iDateType1; - ar>>tmp; - m_bDate1=(tmp != 0); - ar>>m_tDate1; - ar>>tmp; - m_bTime1=(tmp != 0); - ar>>m_tTime1; - - ar>>tmp; - m_bUseDate2=(tmp != 0); - ar>>m_iDateType2; - ar>>tmp; - m_bDate2=(tmp != 0); - ar>>m_tDate2; - ar>>tmp; - m_bTime2=(tmp != 0); - ar>>m_tTime2; - - // attributes - ar>>tmp; - m_bUseAttributes=(tmp != 0); - ar>>m_iArchive; - ar>>m_iReadOnly; - ar>>m_iHidden; - ar>>m_iSystem; - ar>>m_iDirectory; - } -} - -CString& CFileFilter::GetCombinedMask(CString& pMask) const -{ - pMask.Empty(); - if (m_astrMask.GetSize() > 0) - { - pMask=m_astrMask.GetAt(0); - for (int i=1;i 0) - { - pMask=m_astrExcludeMask.GetAt(0); - for (int i=1;i rInfo.GetLength64()) - return false; - break; - case GT: - if (m_ullSize1 >= rInfo.GetLength64()) - return false; - break; - } - - // second part - if (m_bUseSize2) - { - switch (m_iSizeType2) - { - case LT: - if (m_ullSize2 <= rInfo.GetLength64()) - return false; - break; - case LE: - if (m_ullSize2 < rInfo.GetLength64()) - return false; - break; - case EQ: - if (m_ullSize2 != rInfo.GetLength64()) - return false; - break; - case GE: - if (m_ullSize2 > rInfo.GetLength64()) - return false; - break; - case GT: - if (m_ullSize2 >= rInfo.GetLength64()) - return false; - break; - } - } - } - - // date - get the time from rInfo - if (m_bUseDate) - { - COleDateTime tm; - switch (m_iDateType) - { - case DATE_CREATED: - tm=rInfo.GetCreationTime(); - break; - case DATE_MODIFIED: - tm=rInfo.GetLastWriteTime(); - break; - case DATE_LASTACCESSED: - tm=rInfo.GetLastAccessTime(); - break; - } - - // counting... - unsigned long ulInfo=0, ulCheck=0; - if (m_bDate1) - { - ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; - ulCheck=(m_tDate1.GetYear()-1970)*32140800+m_tDate1.GetMonth()*2678400+m_tDate1.GetDay()*86400; - } - - if (m_bTime1) - { - ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); - ulCheck+=m_tTime1.GetHour()*3600+m_tTime1.GetMinute()*60+m_tTime1.GetSecond(); - } - - // ... and comparing - switch (m_iDateType1) - { - case LT: - if (ulInfo >= ulCheck) - return false; - break; - case LE: - if (ulInfo > ulCheck) - return false; - break; - case EQ: - if (ulInfo != ulCheck) - return false; - break; - case GE: - if (ulInfo < ulCheck) - return false; - break; - case GT: - if (ulInfo <= ulCheck) - return false; - break; - } - - if (m_bUseDate2) - { - // counting... - ulInfo=0, ulCheck=0; - if (m_bDate2) - { - ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; - ulCheck=(m_tDate2.GetYear()-1970)*32140800+m_tDate2.GetMonth()*2678400+m_tDate2.GetDay()*86400; - } - - if (m_bTime2) - { - ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); - ulCheck+=m_tTime2.GetHour()*3600+m_tTime2.GetMinute()*60+m_tTime2.GetSecond(); - } - - // ... comparing - switch (m_iDateType2) - { - case LT: - if (ulInfo >= ulCheck) - return false; - break; - case LE: - if (ulInfo > ulCheck) - return false; - break; - case EQ: - if (ulInfo != ulCheck) - return false; - break; - case GE: - if (ulInfo < ulCheck) - return false; - break; - case GT: - if (ulInfo <= ulCheck) - return false; - break; - } - } - } // of m_bUseDate - - // attributes - if (m_bUseAttributes) - { - if ( (m_iArchive == 1 && !rInfo.IsArchived()) || (m_iArchive == 0 && rInfo.IsArchived())) - return false; - if ( (m_iReadOnly == 1 && !rInfo.IsReadOnly()) || (m_iReadOnly == 0 && rInfo.IsReadOnly())) - return false; - if ( (m_iHidden == 1 && !rInfo.IsHidden()) || (m_iHidden == 0 && rInfo.IsHidden())) - return false; - if ( (m_iSystem == 1 && !rInfo.IsSystem()) || (m_iSystem == 0 && rInfo.IsSystem())) - return false; - if ( (m_iDirectory == 1 && !rInfo.IsDirectory()) || (m_iDirectory == 0 && rInfo.IsDirectory())) - return false; - } - - return true; -} - -bool CFileFilter::MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const -{ - bool bMatch = 1; - - //iterate and delete '?' and '*' one by one - while(*lpszMask != _T('\0') && bMatch && *lpszString != _T('\0')) - { - if (*lpszMask == _T('?')) lpszString++; - else if (*lpszMask == _T('*')) - { - bMatch = Scan(lpszMask, lpszString); - lpszMask--; - } - else - { - bMatch = _tcicmp(*lpszMask, *lpszString); - lpszString++; - } - lpszMask++; - } - while (*lpszMask == _T('*') && bMatch) lpszMask++; - - return bMatch && *lpszString == _T('\0') && *lpszMask == _T('\0'); -} - -// scan '?' and '*' -bool CFileFilter::Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const -{ - // remove the '?' and '*' - for(lpszMask++; *lpszString != _T('\0') && (*lpszMask == _T('?') || *lpszMask == _T('*')); lpszMask++) - if (*lpszMask == _T('?')) lpszString++; - while ( *lpszMask == _T('*')) lpszMask++; - - // if lpszString is empty and lpszMask has more characters or, - // lpszMask is empty, return - if (*lpszString == _T('\0') && *lpszMask != _T('\0')) return false; - if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; - // else search substring - else - { - LPCTSTR wdsCopy = lpszMask; - LPCTSTR lpszStringCopy = lpszString; - bool bMatch = true; - do - { - if (!MatchMask(lpszMask, lpszString)) lpszStringCopy++; - lpszMask = wdsCopy; - lpszString = lpszStringCopy; - while (!(_tcicmp(*lpszMask, *lpszString)) && (*lpszString != '\0')) lpszString++; - wdsCopy = lpszMask; - lpszStringCopy = lpszString; - } - while ((*lpszString != _T('\0')) ? !MatchMask(lpszMask, lpszString) : (bMatch = false) != false); - - if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; - - return bMatch; - } -} - -bool CFiltersArray::Match(const CFileInfo& rInfo) const -{ - if (GetSize() == 0) - return true; - - // if only one of the filters matches - return true - for (int i=0;i>iSize; - SetSize(iSize); - for (int i=0;icFileName; - - // if proper index has been passed - reduce the path - if (iSrcIndex >= 0) - m_strFilePath=m_strFilePath.Mid(m_pClipboard->GetAt(iSrcIndex)->GetPath().GetLength()); // wytnij �cie�k� z clipboarda - - m_iSrcIndex=iSrcIndex; - m_dwAttributes = pwfd->dwFileAttributes; - m_uhFileSize = (((ULONGLONG) pwfd->nFileSizeHigh) << 32) + pwfd->nFileSizeLow; - m_timCreation = pwfd->ftCreationTime; - m_timLastAccess = pwfd->ftLastAccessTime; - m_timLastWrite = pwfd->ftLastWriteTime; -} - -bool CFileInfo::Create(CString strFilePath, int iSrcIndex) -{ - WIN32_FIND_DATA wfd; - HANDLE hFind; - int nBarPos; - - hFind = FindFirstFile(strFilePath, &wfd); - if (hFind != INVALID_HANDLE_VALUE) - { - FindClose(hFind); - - // add data to members - nBarPos = strFilePath.ReverseFind(TCHAR('\\')); - Create(&wfd, strFilePath.Left(nBarPos+1), iSrcIndex); - - return true; - } - else - { - m_strFilePath=GetResManager()->LoadString(IDS_NOTFOUND_STRING); - m_iSrcIndex=-1; - m_dwAttributes = (DWORD)-1; - m_uhFileSize = (unsigned __int64)-1; - m_timCreation.SetDateTime(100, 1, 1, 0, 0, 0); - m_timLastAccess.SetDateTime(100, 1, 1, 0, 0, 0); - m_timLastWrite.SetDateTime(100, 1, 1, 0, 0, 0); - return false; - } -} - -CString CFileInfo::GetFileDrive(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - TCHAR szDrive[_MAX_DRIVE]; - _tsplitpath(strPath, szDrive, NULL, NULL, NULL); - return CString(szDrive); -} - -int CFileInfo::GetDriveNumber() const -{ - ASSERT(m_pClipboard); - - if (m_iSrcIndex != -1) - { - // read data stored in CClipboardEntry - return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveNumber(); - } - else - { - // manually - int iNum; - GetDriveData(m_strFilePath, &iNum, NULL); - return iNum; - } -} - -UINT CFileInfo::GetDriveType() const -{ - ASSERT(m_pClipboard); - - if (m_iSrcIndex != -1) - { - // read data contained in CClipboardEntry - return m_pClipboard->GetAt(m_iSrcIndex)->GetDriveType(); - } - else - { - // manually - UINT uiType; - GetDriveData(m_strFilePath, NULL, &uiType); - return uiType; - } -} - -CString CFileInfo::GetFileDir(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - TCHAR szDir[_MAX_DIR]; - _tsplitpath(strPath, NULL, szDir,NULL, NULL); - return CString(szDir); -} - -CString CFileInfo::GetFileTitle(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - TCHAR szName[_MAX_FNAME]; - _tsplitpath(strPath, NULL, NULL, szName, NULL); - return CString(szName); -} - -CString CFileInfo::GetFileExt(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - TCHAR szExt[_MAX_EXT]; - _tsplitpath(strPath, NULL, NULL, NULL, szExt); - return CString(szExt); -} - -CString CFileInfo::GetFileRoot(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - - TCHAR szDrive[_MAX_DRIVE]; - TCHAR szDir[_MAX_DIR]; - _tsplitpath(strPath, szDrive, szDir, NULL, NULL); - return CString(szDrive)+szDir; -} - -CString CFileInfo::GetFileName(void) const -{ - ASSERT(m_pClipboard); - - CString strPath=(m_iSrcIndex != -1) ? m_pClipboard->GetAt(m_iSrcIndex)->GetPath()+m_strFilePath : m_strFilePath; - - TCHAR szName[_MAX_FNAME]; - TCHAR szExt[_MAX_EXT]; - _tsplitpath(strPath, NULL, NULL, szName, szExt); - return CString(szName)+szExt; -} - -void CFileInfo::Store(CArchive& ar) -{ - ar<((m_uhFileSize & 0xFFFFFFFF00000000) >> 32); - ar<(m_uhFileSize & 0x00000000FFFFFFFF); - ar<>m_strFilePath; - ar>>m_iSrcIndex; - ar>>m_dwAttributes; - unsigned long part; - ar>>part; - m_uhFileSize=(static_cast(part) << 32); - ar>>part; - m_uhFileSize+=part; - ar>>m_timCreation; - ar>>m_timLastAccess; - ar>>m_timLastWrite; -} - -bool CFileInfo::operator==(const CFileInfo& rInfo) -{ - return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_timCreation == m_timCreation - && rInfo.m_timLastWrite == m_timLastWrite && rInfo.m_uhFileSize == m_uhFileSize); -} - -CString CFileInfo::GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags) -{ - // add '\\' - if (strPath.Right(1) != _T("\\")) - strPath+=_T("\\"); - - // iFlags: bit 0-ignore folders; bit 1-force creating directories - if (iFlags & 0x02) - { - // force create directories - TCHAR dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _tsplitpath(GetFullFilePath(), NULL, dir, fname, ext); - - CString str=dir; - str.TrimLeft(_T("\\")); - - // force create directory -// AfxMessageBox("Created multiple level of paths for %s"+strPath+str); - MakeSureDirectoryPathExists(strPath+str); - -// AfxMessageBox(strPath+str+fname+CString(ext)); - return strPath+str+fname+CString(ext); - } - else - { - if (!(iFlags & 0x01) && m_iSrcIndex != -1) - { - // generate new dest name - while (ucCopyNumber >= m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.GetSize()) - { - CString strNewPath; - FindFreeSubstituteName(GetFullFilePath(), strPath, &strNewPath); - m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.Add(strNewPath); - } - - return strPath+m_pClipboard->GetAt(m_iSrcIndex)->m_astrDstPaths.GetAt(ucCopyNumber)+m_strFilePath; - } - else - return strPath+GetFileName(); - } -} - -CString CFileInfo::GetFullFilePath() const -{ - CString strPath; - if (m_iSrcIndex >= 0) - { - ASSERT(m_pClipboard); - strPath+=m_pClipboard->GetAt(m_iSrcIndex)->GetPath(); - } - strPath+=m_strFilePath; - - return strPath; -} - -int CFileInfo::GetBufferIndex() const -{ - if (m_iSrcIndex != -1) - return m_pClipboard->GetAt(m_iSrcIndex)->GetBufferIndex(); - else - return BI_DEFAULT; -} - -/////////////////////////////////////////////////////////////////////// -// Array - -void CFileInfoArray::AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs, - const volatile bool* pbAbort) -{ - WIN32_FIND_DATA wfd; - CString strText; - - // init CFileInfo - CFileInfo finf; - finf.SetClipboard(m_pClipboard); // this is the link table (CClipboardArray) - - // append '\\' at the end of path if needed - if (strDirName.Right(1) != _T("\\")) - strDirName+=_T("\\"); - - strText = strDirName + _T("*"); - // Iterate through dirs & files - HANDLE hFind = FindFirstFile(strText, &wfd); - if (hFind != INVALID_HANDLE_VALUE) - { - do - { - if ( !(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) - { - finf.Create(&wfd, strDirName, iSrcIndex); - if (pFilters->Match(finf)) - Add(finf); - } - else if ( strcmp(wfd.cFileName, _T(".")) != 0 && strcmp(wfd.cFileName, _T("..")) != 0) - { - if (bIncludeDirs) - { - // Add directory itself - finf.Create(&wfd, strDirName, iSrcIndex); - Add(finf); - } - if (bRecurse) - { - strText = strDirName + wfd.cFileName+_T("\\"); - // Recurse Dirs - AddDir(strText, pFilters, iSrcIndex, bRecurse, bIncludeDirs, pbAbort); - } - } - } - while (((pbAbort == NULL) || (!*pbAbort)) && (FindNextFile(hFind, &wfd))); - - FindClose(hFind); - } -} - -int CFileInfoArray::AddFile(CString strFilePath, int iSrcIndex) -{ - CFileInfo finf; - - // CUSTOMIZATION3 - cut '\\' at the end of strFilePath, set relative path - if (strFilePath.Right(1) == _T("\\")) - strFilePath=strFilePath.Left(strFilePath.GetLength()-1); - - finf.Create(strFilePath, iSrcIndex); - return Add(finf); -} - - -////////////////////////////////////////////////////////////////////////////// -// CClipboardArray - -void CClipboardArray::Serialize(CArchive& ar, bool bData) -{ - if (ar.IsStoring()) - { - // write data - int iSize=GetSize(); - ar<Serialize(ar, bData); - } - else - { - int iSize; - ar>>iSize; - - CClipboardEntry* pEntry; - for (int i=0;iSerialize(ar, bData); - } - } -} - -///////////////////////////////////////////////////////////////////////////// -// CClipboardEntry - -void CClipboardEntry::SetPath(const CString& strPath) -{ - m_strPath=strPath; // guaranteed without ending '\\' - if (m_strPath.Right(1) == _T('\\')) - m_strPath=m_strPath.Left(m_strPath.GetLength()-1); - - GetDriveData(m_strPath, &m_iDriveNumber, &m_uiDriveType); -} - -void CClipboardEntry::CalcBufferIndex(const CDestPath& dpDestPath) -{ - // what kind of buffer - if (m_uiDriveType == DRIVE_REMOTE || dpDestPath.GetDriveType() == DRIVE_REMOTE) - m_iBufferIndex=BI_LAN; - else if (m_uiDriveType == DRIVE_CDROM || dpDestPath.GetDriveType() == DRIVE_CDROM) - m_iBufferIndex=BI_CD; - else if (m_uiDriveType == DRIVE_FIXED && dpDestPath.GetDriveType() == DRIVE_FIXED) - { - // two hdd's - is this the same physical disk ? - if (m_iDriveNumber == dpDestPath.GetDriveNumber() || IsSamePhysicalDisk(m_iDriveNumber, dpDestPath.GetDriveNumber())) - m_iBufferIndex=BI_ONEDISK; - else - m_iBufferIndex=BI_TWODISKS; - } - else - m_iBufferIndex=BI_DEFAULT; -} - -void CClipboardEntry::Serialize(CArchive& ar, bool bData) -{ - if (bData) - { - if (ar.IsStoring()) - { - ar<(m_bMove); - ar<>m_strPath; - unsigned char ucData; - ar>>ucData; - m_bMove=ucData != 0; - ar>>m_iDriveNumber; - ar>>m_uiDriveType; - ar>>m_iBufferIndex; - } - } - else - m_astrDstPaths.Serialize(ar); -} Index: src/ch/FileInfo.h =================================================================== diff -u -N --- src/ch/FileInfo.h (revision 0) +++ src/ch/FileInfo.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,382 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/** + * @doc FILEINFO + * @module FileInfo.h 1.3 - Interface for the CFileInfo and CFileInfoArray classes | + * The classes contained in this file allow to gather recursively file information + * through directories. + * + * Codeguru & friends + * Coded by Antonio Tejada Lacaci. 1999 + * atejada@espanet.com + * CRC32 code by Floor A.C. Naaijkens + * + * Updates (aaaa-mm-dd): + * MANY CHANGES by Ixen Gerthannes... + * 1999-9-23 ATL: Opensource works! Again, Mr. Szucs (rszucs@cygron.hu) gets another bug: + * Missing "4-(dwRead & 0x3)" in the same lines as before, when calc'ing the padding mask. + * 1999-9-16 ATL: Corrected bug in GetCRC and GetChecksum as suggested by R�bert Szucs (rszucs@cygron.hu): + * There was a buffer overflow and checksum and crc for last dword +1 was calc'ed instead + * of the ones for last dword. Instead accessing buffer[dwRead +3...] it ought to access + * buffer[dwRead...] (shame on me! :'(). + * 1999-9-2 ATL: Corrected bug in AddFile(CString, LPARAM) as suggested by Nhycoh (Nhycoh44@yahoo.com): + * There was some weird stuff at CFileInfo::Create(strFilePath) + * stating strFilePath.GetLength()-nBarPos instead of nBarPos+1 + * (I'm quite sure I left my head on my pillow the day I did that %-#). + * 1999-6-27 ATL: Updated GetCRC & GetChecksum to avoid some bug cases + * 1999-4-7 ATL: Updated source code doc to conform Autoduck 2.0 standard + * 1999-4-7 ATL: Corrected bug in AddDir as suggested by Zhuang Yuyao (zhuangyy@koal.com): + * bIncludeDirs wasn't used if bRecurse was false. + * + * Keep this comment if you redistribute this file. And credit where credit's due! + */ + +#ifndef __FILEINFO_H__ +#define __FILEINFO_H__ + +#include +#include "afxdisp.h" +#include "DestPath.h" + +void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult); +extern void GetDriveData(LPCTSTR lpszPath, int *piDrvNum, UINT *puiDrvType); + +// definitions for comparing sizes and dates +#define LT 0 +#define LE 1 +#define EQ 2 +#define GE 3 +#define GT 4 + +// date type defs +#define DATE_CREATED 0 +#define DATE_MODIFIED 1 +#define DATE_LASTACCESSED 2 + +class CFileInfo; + +class CFileFilter +{ +public: + CFileFilter(); + CFileFilter(const CFileFilter& rFilter); + CFileFilter& operator=(const CFileFilter& rFilter); + + bool Match(const CFileInfo& rInfo) const; + + CString& GetCombinedMask(CString& pMask) const; + void SetCombinedMask(const CString& pMask); + + CString& GetCombinedExcludeMask(CString& pMask) const; + void SetCombinedExcludeMask(const CString& pMask); + + void Serialize(CArchive& ar); + +protected: + bool MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const; + bool Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const; + +public: + // files mask + bool m_bUseMask; + CStringArray m_astrMask; + + // files mask- + bool m_bUseExcludeMask; + CStringArray m_astrExcludeMask; + + // size filtering + bool m_bUseSize; + int m_iSizeType1; + unsigned __int64 m_ullSize1; + bool m_bUseSize2; + int m_iSizeType2; + unsigned __int64 m_ullSize2; + + // date filtering + bool m_bUseDate; + int m_iDateType; // created/last modified/last accessed + int m_iDateType1; // before/after + bool m_bDate1; + CTime m_tDate1; + bool m_bTime1; + CTime m_tTime1; + + bool m_bUseDate2; + int m_iDateType2; + bool m_bDate2; + CTime m_tDate2; + bool m_bTime2; + CTime m_tTime2; + + // attribute filtering + bool m_bUseAttributes; + int m_iArchive; + int m_iReadOnly; + int m_iHidden; + int m_iSystem; + int m_iDirectory; +}; + +class CFiltersArray : public CArray +{ +public: + bool Match(const CFileInfo& rInfo) const; + void Serialize(CArchive& ar); +}; + +///////////////////////////////////////////////////////////////////////////// +// CClipboardEntry + +class CClipboardEntry +{ +public: + CClipboardEntry() { m_bMove=true; m_iDriveNumber=-1; m_uiDriveType=static_cast(-1); m_iBufferIndex=0; }; + CClipboardEntry(const CClipboardEntry& rEntry) { m_strPath=rEntry.m_strPath; m_bMove=rEntry.m_bMove; m_iDriveNumber=rEntry.m_iDriveNumber; m_uiDriveType=rEntry.m_uiDriveType; m_astrDstPaths.Copy(rEntry.m_astrDstPaths); }; + + void SetPath(const CString& strPath); + void CalcBufferIndex(const CDestPath& dpDestPath); + const CString& GetPath() const { return m_strPath; }; + + void SetMove(bool bValue) { m_bMove=bValue; }; + bool GetMove() { return m_bMove; }; + + int GetDriveNumber() const { return m_iDriveNumber; }; + UINT GetDriveType() const { return m_uiDriveType; }; + + int GetBufferIndex() const { return m_iBufferIndex; }; + + void Serialize(CArchive& ar, bool bData); + +private: + CString m_strPath; // path (ie. c:\\windows\\) - always with ending '\\' + bool m_bMove; // specifies if we can use MoveFile (if will be moved) + + int m_iDriveNumber; // disk number (-1 - none) + UINT m_uiDriveType; // path type + + int m_iBufferIndex; // buffer number, with which we'll copy this data + +public: + CStringArray m_astrDstPaths; // dest paths table for this group of paths +}; + +////////////////////////////////////////////////////////////////////////// +// CClipboardArray + +class CClipboardArray : public CArray +{ +public: + ~CClipboardArray() { RemoveAll(); }; + + void Serialize(CArchive& ar, bool bData); + + void SetAt(int nIndex, CClipboardEntry* pEntry) { delete [] GetAt(nIndex); SetAt(nIndex, pEntry); }; + void RemoveAt(int nIndex, int nCount = 1) { while (nCount--) { delete GetAt(nIndex); static_cast*>(this)->RemoveAt(nIndex, 1); } }; + void RemoveAll() { for (int i=0;i*>(this)->RemoveAll(); }; +}; + +class CFileInfo +{ +public: + CFileInfo(); + CFileInfo(const CFileInfo& finf); + ~CFileInfo(); + + // static member + static bool Exist(CString strPath); // check for file or folder existence + + void Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, int iSrcIndex); + bool Create(CString strFilePath, int iSrcIndex); + + DWORD GetLength(void) const { return (DWORD) m_uhFileSize; }; + ULONGLONG GetLength64(void) const { return m_uhFileSize; }; + void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; }; + + // disk - path and disk number (-1 if none - ie. net disk) + CString GetFileDrive(void) const; // returns string with src disk + int GetDriveNumber() const; // disk number A - 0, b-1, c-2, ... + UINT GetDriveType() const; // drive type + + CString GetFileDir(void) const; // @rdesc Returns \WINDOWS\ for C:\WINDOWS\WIN.INI + CString GetFileTitle(void) const; // @cmember returns WIN for C:\WINDOWS\WIN.INI + CString GetFileExt(void) const; /** @cmember returns INI for C:\WINDOWS\WIN.INI */ + CString GetFileRoot(void) const; /** @cmember returns C:\WINDOWS\ for C:\WINDOWS\WIN.INI */ + CString GetFileName(void) const; /** @cmember returns WIN.INI for C:\WINDOWS\WIN.INI */ + + const CString& GetFilePath(void) const { return m_strFilePath; } // returns path with m_strFilePath (probably not full) + CString GetFullFilePath() const; /** @cmember returns C:\WINDOWS\WIN.INI for C:\WINDOWS\WIN.INI */ + void SetFilePath(LPCTSTR lpszPath) { m_strFilePath=lpszPath; }; + + /* Get File times info (equivalent to CFindFile members) */ + const COleDateTime& GetCreationTime(void) const { return m_timCreation; }; /** @cmember returns creation time */ + const COleDateTime& GetLastAccessTime(void) const { return m_timLastAccess; }; /** @cmember returns last access time */ + const COleDateTime& GetLastWriteTime(void) const { return m_timLastWrite; }; /** @cmember returns las write time */ + + /* Get File attributes info (equivalent to CFindFile members) */ + DWORD GetAttributes(void) const { return m_dwAttributes; }; /** @cmember returns file attributes */ + bool IsDirectory(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }; /** @cmember returns TRUE if the file is a directory */ + bool IsArchived(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }; /** @cmember Returns TRUE if the file has archive bit set */ + bool IsReadOnly(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; }; /** @cmember Returns TRUE if the file is read-only */ + bool IsCompressed(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }; /** @cmember Returns TRUE if the file is compressed */ + bool IsSystem(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; }; /** @cmember Returns TRUE if the file is a system file */ + bool IsHidden(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; }; /** @cmember Returns TRUE if the file is hidden */ + bool IsTemporary(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; }; /** @cmember Returns TRUE if the file is temporary */ + bool IsNormal(void) const { return m_dwAttributes == 0; }; /** @cmember Returns TRUE if the file is a normal file */ + + // operations + void SetClipboard(CClipboardArray *pClipboard) { m_pClipboard=pClipboard; }; + CString GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags); + + void SetSrcIndex(int iIndex) { m_iSrcIndex=iIndex; }; + int GetSrcIndex() const { return m_iSrcIndex; }; + + bool GetMove() { if (m_iSrcIndex != -1) return m_pClipboard->GetAt(m_iSrcIndex)->GetMove(); else return true; }; + + int GetBufferIndex() const; + + // operators + bool operator==(const CFileInfo& rInfo); + + // (re)/store data + void Store(CArchive& ar); + void Load(CArchive& ar); +private: + CString m_strFilePath; // contains relative path (first path is in CClipboardArray) + int m_iSrcIndex; // index in CClipboardArray table (which contains the first part of the path) + + DWORD m_dwAttributes; // attributes + ULONGLONG m_uhFileSize; /** @cmember File of size. (COM states LONGLONG as hyper, so "uh" means unsigned hyper) */ + COleDateTime m_timCreation; /** @cmember Creation time */ + COleDateTime m_timLastAccess; /** @cmember Last Access time */ + COleDateTime m_timLastWrite; /** @cmember Last write time */ + + // ptrs to elements providing data + CClipboardArray *m_pClipboard; +}; + +/** +* @class Allows to retrieve s from files/directories in a directory +*/ +class CFileInfoArray : public CArray +{ +public: + /** @access Public members */ + + /** + * @cmember Default constructor + */ + CFileInfoArray() { m_pClipboard=NULL; SetSize(0, 5000); }; + void Init(CClipboardArray* pClipboard) { m_pClipboard=pClipboard; }; + + /** + * @cmember Adds a file or all contained in a directory to the CFileInfoArray + * Only "static" data for CFileInfo is filled (by default CRC and checksum are NOT + * calculated when inserting CFileInfos). Returns the number of s added to the array + * @parm Name of the directory, ended in backslash. + * @parm Mask of files to add in case that strDirName is a directory + * @parm Wether to recurse or not subdirectories + * @parmopt Parameter to pass to protected member function AddFileInfo + * @parmopt Wether to add or not CFileInfos for directories + * @parmopt Pointer to a variable to signal abort of directory retrieval + * (multithreaded apps). + * @parmopt pulCount Pointer to a variable incremented each time a CFileInfo is added to the + * array (multithreaded apps). + * @xref + */ + void AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, + const bool bRecurse, const bool bIncludeDirs, const volatile bool* pbAbort=NULL); + + /** + * @cmember Adds a single file or directory to the CFileInfoArray. In case of directory, files + * contained in the directory are NOT added to the array. + * Returns the position in the array where the was added (-1 if + * wasn't added) + * @parm Name of the file or directory to add. NOT ended with backslash. + * @parm Parameter to pass to protected member function AddFileInfo. + * @xref + */ + int AddFile(CString strFilePath, int iSrcIndex); + + // store/restore + void Store(CArchive& ar) { int iSize=GetSize(); ar<>iSize; SetSize(iSize, 5000); CFileInfo fi; fi.SetClipboard(m_pClipboard); + for (int i=0;i Codeguru & friends - * Coded by Antonio Tejada Lacaci. 1999 - * atejada@espanet.com - * CRC32 code by Floor A.C. Naaijkens - * - * Updates (aaaa-mm-dd): - * MANY CHANGES by Ixen Gerthannes... - * 1999-9-23 ATL: Opensource works! Again, Mr. Szucs (rszucs@cygron.hu) gets another bug: - * Missing "4-(dwRead & 0x3)" in the same lines as before, when calc'ing the padding mask. - * 1999-9-16 ATL: Corrected bug in GetCRC and GetChecksum as suggested by R�bert Szucs (rszucs@cygron.hu): - * There was a buffer overflow and checksum and crc for last dword +1 was calc'ed instead - * of the ones for last dword. Instead accessing buffer[dwRead +3...] it ought to access - * buffer[dwRead...] (shame on me! :'(). - * 1999-9-2 ATL: Corrected bug in AddFile(CString, LPARAM) as suggested by Nhycoh (Nhycoh44@yahoo.com): - * There was some weird stuff at CFileInfo::Create(strFilePath) - * stating strFilePath.GetLength()-nBarPos instead of nBarPos+1 - * (I'm quite sure I left my head on my pillow the day I did that %-#). - * 1999-6-27 ATL: Updated GetCRC & GetChecksum to avoid some bug cases - * 1999-4-7 ATL: Updated source code doc to conform Autoduck 2.0 standard - * 1999-4-7 ATL: Corrected bug in AddDir as suggested by Zhuang Yuyao (zhuangyy@koal.com): - * bIncludeDirs wasn't used if bRecurse was false. - * - * Keep this comment if you redistribute this file. And credit where credit's due! - */ - -#ifndef __FILEINFO_H__ -#define __FILEINFO_H__ - -#include -#include "afxdisp.h" -#include "DestPath.h" - -void FindFreeSubstituteName(CString strSrcPath, CString strDstPath, CString* pstrResult); -extern void GetDriveData(LPCTSTR lpszPath, int *piDrvNum, UINT *puiDrvType); - -// definitions for comparing sizes and dates -#define LT 0 -#define LE 1 -#define EQ 2 -#define GE 3 -#define GT 4 - -// date type defs -#define DATE_CREATED 0 -#define DATE_MODIFIED 1 -#define DATE_LASTACCESSED 2 - -class CFileInfo; - -class CFileFilter -{ -public: - CFileFilter(); - CFileFilter(const CFileFilter& rFilter); - CFileFilter& operator=(const CFileFilter& rFilter); - - bool Match(const CFileInfo& rInfo) const; - - CString& GetCombinedMask(CString& pMask) const; - void SetCombinedMask(const CString& pMask); - - CString& GetCombinedExcludeMask(CString& pMask) const; - void SetCombinedExcludeMask(const CString& pMask); - - void Serialize(CArchive& ar); - -protected: - bool MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const; - bool Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const; - -public: - // files mask - bool m_bUseMask; - CStringArray m_astrMask; - - // files mask- - bool m_bUseExcludeMask; - CStringArray m_astrExcludeMask; - - // size filtering - bool m_bUseSize; - int m_iSizeType1; - unsigned __int64 m_ullSize1; - bool m_bUseSize2; - int m_iSizeType2; - unsigned __int64 m_ullSize2; - - // date filtering - bool m_bUseDate; - int m_iDateType; // created/last modified/last accessed - int m_iDateType1; // before/after - bool m_bDate1; - CTime m_tDate1; - bool m_bTime1; - CTime m_tTime1; - - bool m_bUseDate2; - int m_iDateType2; - bool m_bDate2; - CTime m_tDate2; - bool m_bTime2; - CTime m_tTime2; - - // attribute filtering - bool m_bUseAttributes; - int m_iArchive; - int m_iReadOnly; - int m_iHidden; - int m_iSystem; - int m_iDirectory; -}; - -class CFiltersArray : public CArray -{ -public: - bool Match(const CFileInfo& rInfo) const; - void Serialize(CArchive& ar); -}; - -///////////////////////////////////////////////////////////////////////////// -// CClipboardEntry - -class CClipboardEntry -{ -public: - CClipboardEntry() { m_bMove=true; m_iDriveNumber=-1; m_uiDriveType=static_cast(-1); m_iBufferIndex=0; }; - CClipboardEntry(const CClipboardEntry& rEntry) { m_strPath=rEntry.m_strPath; m_bMove=rEntry.m_bMove; m_iDriveNumber=rEntry.m_iDriveNumber; m_uiDriveType=rEntry.m_uiDriveType; m_astrDstPaths.Copy(rEntry.m_astrDstPaths); }; - - void SetPath(const CString& strPath); - void CalcBufferIndex(const CDestPath& dpDestPath); - const CString& GetPath() const { return m_strPath; }; - - void SetMove(bool bValue) { m_bMove=bValue; }; - bool GetMove() { return m_bMove; }; - - int GetDriveNumber() const { return m_iDriveNumber; }; - UINT GetDriveType() const { return m_uiDriveType; }; - - int GetBufferIndex() const { return m_iBufferIndex; }; - - void Serialize(CArchive& ar, bool bData); - -private: - CString m_strPath; // path (ie. c:\\windows\\) - always with ending '\\' - bool m_bMove; // specifies if we can use MoveFile (if will be moved) - - int m_iDriveNumber; // disk number (-1 - none) - UINT m_uiDriveType; // path type - - int m_iBufferIndex; // buffer number, with which we'll copy this data - -public: - CStringArray m_astrDstPaths; // dest paths table for this group of paths -}; - -////////////////////////////////////////////////////////////////////////// -// CClipboardArray - -class CClipboardArray : public CArray -{ -public: - ~CClipboardArray() { RemoveAll(); }; - - void Serialize(CArchive& ar, bool bData); - - void SetAt(int nIndex, CClipboardEntry* pEntry) { delete [] GetAt(nIndex); SetAt(nIndex, pEntry); }; - void RemoveAt(int nIndex, int nCount = 1) { while (nCount--) { delete GetAt(nIndex); static_cast*>(this)->RemoveAt(nIndex, 1); } }; - void RemoveAll() { for (int i=0;i*>(this)->RemoveAll(); }; -}; - -class CFileInfo -{ -public: - CFileInfo(); - CFileInfo(const CFileInfo& finf); - ~CFileInfo(); - - // static member - static bool Exist(CString strPath); // check for file or folder existence - - void Create(const WIN32_FIND_DATA* pwfd, LPCTSTR pszFilePath, int iSrcIndex); - bool Create(CString strFilePath, int iSrcIndex); - - DWORD GetLength(void) const { return (DWORD) m_uhFileSize; }; - ULONGLONG GetLength64(void) const { return m_uhFileSize; }; - void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; }; - - // disk - path and disk number (-1 if none - ie. net disk) - CString GetFileDrive(void) const; // returns string with src disk - int GetDriveNumber() const; // disk number A - 0, b-1, c-2, ... - UINT GetDriveType() const; // drive type - - CString GetFileDir(void) const; // @rdesc Returns \WINDOWS\ for C:\WINDOWS\WIN.INI - CString GetFileTitle(void) const; // @cmember returns WIN for C:\WINDOWS\WIN.INI - CString GetFileExt(void) const; /** @cmember returns INI for C:\WINDOWS\WIN.INI */ - CString GetFileRoot(void) const; /** @cmember returns C:\WINDOWS\ for C:\WINDOWS\WIN.INI */ - CString GetFileName(void) const; /** @cmember returns WIN.INI for C:\WINDOWS\WIN.INI */ - - const CString& GetFilePath(void) const { return m_strFilePath; } // returns path with m_strFilePath (probably not full) - CString GetFullFilePath() const; /** @cmember returns C:\WINDOWS\WIN.INI for C:\WINDOWS\WIN.INI */ - void SetFilePath(LPCTSTR lpszPath) { m_strFilePath=lpszPath; }; - - /* Get File times info (equivalent to CFindFile members) */ - const COleDateTime& GetCreationTime(void) const { return m_timCreation; }; /** @cmember returns creation time */ - const COleDateTime& GetLastAccessTime(void) const { return m_timLastAccess; }; /** @cmember returns last access time */ - const COleDateTime& GetLastWriteTime(void) const { return m_timLastWrite; }; /** @cmember returns las write time */ - - /* Get File attributes info (equivalent to CFindFile members) */ - DWORD GetAttributes(void) const { return m_dwAttributes; }; /** @cmember returns file attributes */ - bool IsDirectory(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }; /** @cmember returns TRUE if the file is a directory */ - bool IsArchived(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; }; /** @cmember Returns TRUE if the file has archive bit set */ - bool IsReadOnly(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; }; /** @cmember Returns TRUE if the file is read-only */ - bool IsCompressed(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; }; /** @cmember Returns TRUE if the file is compressed */ - bool IsSystem(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; }; /** @cmember Returns TRUE if the file is a system file */ - bool IsHidden(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; }; /** @cmember Returns TRUE if the file is hidden */ - bool IsTemporary(void) const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; }; /** @cmember Returns TRUE if the file is temporary */ - bool IsNormal(void) const { return m_dwAttributes == 0; }; /** @cmember Returns TRUE if the file is a normal file */ - - // operations - void SetClipboard(CClipboardArray *pClipboard) { m_pClipboard=pClipboard; }; - CString GetDestinationPath(CString strPath, unsigned char ucCopyNumber, int iFlags); - - void SetSrcIndex(int iIndex) { m_iSrcIndex=iIndex; }; - int GetSrcIndex() const { return m_iSrcIndex; }; - - bool GetMove() { if (m_iSrcIndex != -1) return m_pClipboard->GetAt(m_iSrcIndex)->GetMove(); else return true; }; - - int GetBufferIndex() const; - - // operators - bool operator==(const CFileInfo& rInfo); - - // (re)/store data - void Store(CArchive& ar); - void Load(CArchive& ar); -private: - CString m_strFilePath; // contains relative path (first path is in CClipboardArray) - int m_iSrcIndex; // index in CClipboardArray table (which contains the first part of the path) - - DWORD m_dwAttributes; // attributes - ULONGLONG m_uhFileSize; /** @cmember File of size. (COM states LONGLONG as hyper, so "uh" means unsigned hyper) */ - COleDateTime m_timCreation; /** @cmember Creation time */ - COleDateTime m_timLastAccess; /** @cmember Last Access time */ - COleDateTime m_timLastWrite; /** @cmember Last write time */ - - // ptrs to elements providing data - CClipboardArray *m_pClipboard; -}; - -/** -* @class Allows to retrieve s from files/directories in a directory -*/ -class CFileInfoArray : public CArray -{ -public: - /** @access Public members */ - - /** - * @cmember Default constructor - */ - CFileInfoArray() { m_pClipboard=NULL; SetSize(0, 5000); }; - void Init(CClipboardArray* pClipboard) { m_pClipboard=pClipboard; }; - - /** - * @cmember Adds a file or all contained in a directory to the CFileInfoArray - * Only "static" data for CFileInfo is filled (by default CRC and checksum are NOT - * calculated when inserting CFileInfos). Returns the number of s added to the array - * @parm Name of the directory, ended in backslash. - * @parm Mask of files to add in case that strDirName is a directory - * @parm Wether to recurse or not subdirectories - * @parmopt Parameter to pass to protected member function AddFileInfo - * @parmopt Wether to add or not CFileInfos for directories - * @parmopt Pointer to a variable to signal abort of directory retrieval - * (multithreaded apps). - * @parmopt pulCount Pointer to a variable incremented each time a CFileInfo is added to the - * array (multithreaded apps). - * @xref - */ - void AddDir(CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs, const volatile bool* pbAbort=NULL); - - /** - * @cmember Adds a single file or directory to the CFileInfoArray. In case of directory, files - * contained in the directory are NOT added to the array. - * Returns the position in the array where the was added (-1 if - * wasn't added) - * @parm Name of the file or directory to add. NOT ended with backslash. - * @parm Parameter to pass to protected member function AddFileInfo. - * @xref - */ - int AddFile(CString strFilePath, int iSrcIndex); - - // store/restore - void Store(CArchive& ar) { int iSize=GetSize(); ar<>iSize; SetSize(iSize, 5000); CFileInfo fi; fi.SetClipboard(m_pClipboard); - for (int i=0;iLoadString(IDS_BYTE_STRING+i); + m_ctlSize1Multi.AddString(pszData); + m_ctlSize2Multi.AddString(pszData); + } + + // strings <, <=, ... + for (i=0;i<5;i++) + { + pszData=GetResManager()->LoadString(IDS_LT_STRING+i); + m_ctlSizeType1.AddString(pszData); + m_ctlSizeType2.AddString(pszData); + m_ctlDateType1.AddString(pszData); + m_ctlDateType2.AddString(pszData); + } + + for (i=0;i<3;i++) + { + m_ctlDateType.AddString(GetResManager()->LoadString(IDS_DATECREATED_STRING+i)); + } + + // copy data from CFileFilter to a dialog - mask + m_bFilter=m_ffFilter.m_bUseMask; + + CString strData; + m_ctlFilter.SetCurSel(m_ctlFilter.AddString(m_ffFilter.GetCombinedMask(strData))); + for (i=0;iLoadString(IDS_BYTE_STRING+i); + m_ctlSize1Multi.AddString(pszData); + m_ctlSize2Multi.AddString(pszData); + } + + // selection + m_ctlSize1Multi.SetCurSel(iPos[0]); + m_ctlSize2Multi.SetCurSel(iPos[1]); + + iPos[0]=m_ctlSizeType1.GetCurSel(); + iPos[1]=m_ctlSizeType2.GetCurSel(); + iPos[2]=m_ctlDateType1.GetCurSel(); + iPos[3]=m_ctlDateType2.GetCurSel(); + + m_ctlSizeType1.ResetContent(); + m_ctlSizeType2.ResetContent(); + m_ctlDateType1.ResetContent(); + m_ctlDateType2.ResetContent(); + + // strings <, <=, ... + for (i=0;i<5;i++) + { + pszData=GetResManager()->LoadString(IDS_LT_STRING+i); + m_ctlSizeType1.AddString(pszData); + m_ctlSizeType2.AddString(pszData); + m_ctlDateType1.AddString(pszData); + m_ctlDateType2.AddString(pszData); + } + + m_ctlSizeType1.SetCurSel(iPos[0]); + m_ctlSizeType2.SetCurSel(iPos[1]); + m_ctlDateType1.SetCurSel(iPos[2]); + m_ctlDateType2.SetCurSel(iPos[3]); + + iPos[0]=m_ctlDateType.GetCurSel(); + m_ctlDateType.ResetContent(); + for (i=0;i<3;i++) + { + m_ctlDateType.AddString(GetResManager()->LoadString(IDS_DATECREATED_STRING+i)); + } + m_ctlDateType.SetCurSel(iPos[0]); +} + +void CFilterDlg::SetSize1(unsigned __int64 ullSize) +{ + if ((ullSize % 1048576) == 0 && ullSize != 0) + { + m_uiSize1=static_cast(ullSize/1048576); + m_ctlSize1Multi.SetCurSel(2); + } + else if ((ullSize % 1024) == 0 && ullSize != 0) + { + m_uiSize1=static_cast(ullSize/1024); + m_ctlSize1Multi.SetCurSel(1); + } + else + { + m_uiSize1=static_cast(ullSize); + m_ctlSize1Multi.SetCurSel(0); + } +} + +void CFilterDlg::SetSize2(unsigned __int64 ullSize) +{ + if ((ullSize % 1048576) == 0 && ullSize != 0) + { + m_uiSize2=static_cast(ullSize/1048576); + m_ctlSize2Multi.SetCurSel(2); + } + else if ((ullSize % 1024) == 0 && ullSize != 0) + { + m_uiSize2=static_cast(ullSize/1024); + m_ctlSize2Multi.SetCurSel(1); + } + else + { + m_uiSize2=static_cast(ullSize); + m_ctlSize2Multi.SetCurSel(0); + } +} + +void CFilterDlg::EnableControls() +{ + UpdateData(TRUE); + // mask + m_ctlFilter.EnableWindow(m_bFilter); + + m_ctlExcludeMask.EnableWindow(m_bExclude); + + // size + m_ctlSizeType1.EnableWindow(m_bSize); + m_ctlSizeType2.EnableWindow(m_bSize && m_bSize2); + GetDlgItem(IDC_SIZE1_EDIT)->EnableWindow(m_bSize); + GetDlgItem(IDC_SIZE2_EDIT)->EnableWindow(m_bSize && m_bSize2); + GetDlgItem(IDC_SIZE1_SPIN)->EnableWindow(m_bSize); + GetDlgItem(IDC_SIZE2_SPIN)->EnableWindow(m_bSize && m_bSize2); + GetDlgItem(IDC_SIZE2_CHECK)->EnableWindow(m_bSize); + m_ctlSize1Multi.EnableWindow(m_bSize); + m_ctlSize2Multi.EnableWindow(m_bSize && m_bSize2); + + // date + CTime tmTemp; + bool bSecond=((m_ctlDate1.GetTime(tmTemp) == GDT_VALID) || (m_ctlTime1.GetTime(tmTemp) == GDT_VALID)); + m_ctlDateType.EnableWindow(m_bDate); + GetDlgItem(IDC_DATE2_CHECK)->EnableWindow(m_bDate && bSecond); + m_ctlDateType1.EnableWindow(m_bDate); + m_ctlDateType2.EnableWindow(m_bDate && m_bDate2 && bSecond); + m_ctlDate1.EnableWindow(m_bDate); + m_ctlDate2.EnableWindow(m_bDate && m_bDate2 && bSecond); + m_ctlTime1.EnableWindow(m_bDate); + m_ctlTime2.EnableWindow(m_bDate && m_bDate2 && bSecond); + + // attrib + GetDlgItem(IDC_ARCHIVE_CHECK)->EnableWindow(m_bAttributes); + GetDlgItem(IDC_READONLY_CHECK)->EnableWindow(m_bAttributes); + GetDlgItem(IDC_HIDDEN_CHECK)->EnableWindow(m_bAttributes); + GetDlgItem(IDC_SYSTEM_CHECK)->EnableWindow(m_bAttributes); + GetDlgItem(IDC_DIRECTORY_CHECK)->EnableWindow(m_bAttributes); +} + +void CFilterDlg::OnOK() +{ + UpdateData(TRUE); + + // CFileFilter --> dialogu - mask + CString strText; + m_ctlFilter.GetWindowText(strText); + m_ffFilter.m_bUseMask=((m_bFilter != 0) && !strText.IsEmpty()); + m_ffFilter.SetCombinedMask(strText); + + m_ctlExcludeMask.GetWindowText(strText); + m_ffFilter.m_bUseExcludeMask=(m_bExclude != 0) && !strText.IsEmpty(); + m_ffFilter.SetCombinedExcludeMask(strText); + + // size + m_ffFilter.m_bUseSize=(m_bSize != 0); + m_ffFilter.m_bUseSize2=(m_bSize2 != 0); + + m_ffFilter.m_iSizeType1=m_ctlSizeType1.GetCurSel(); + m_ffFilter.m_iSizeType2=m_ctlSizeType2.GetCurSel(); + + m_ffFilter.m_ullSize1=static_cast(m_uiSize1)*static_cast(GetMultiplier(m_ctlSize1Multi.GetCurSel())); + m_ffFilter.m_ullSize2=static_cast(m_uiSize2)*static_cast(GetMultiplier(m_ctlSize2Multi.GetCurSel())); + + // date + m_ffFilter.m_iDateType=m_ctlDateType.GetCurSel(); + + m_ffFilter.m_iDateType1=m_ctlDateType1.GetCurSel(); + m_ffFilter.m_iDateType2=m_ctlDateType2.GetCurSel(); + + m_ffFilter.m_bDate1=m_ctlDate1.GetTime(m_ffFilter.m_tDate1) == GDT_VALID; + m_ffFilter.m_bDate2=m_ctlDate2.GetTime(m_ffFilter.m_tDate2) == GDT_VALID; + m_ffFilter.m_bTime1=m_ctlTime1.GetTime(m_ffFilter.m_tTime1) == GDT_VALID; + m_ffFilter.m_bTime2=m_ctlTime2.GetTime(m_ffFilter.m_tTime2) == GDT_VALID; + + m_ffFilter.m_bUseDate=(m_bDate != 0) && (m_ffFilter.m_bDate1 || m_ffFilter.m_bTime1); + m_ffFilter.m_bUseDate2=(m_bDate2 != 0) && (m_ffFilter.m_bDate2 || m_ffFilter.m_bTime2); + + // attributes + m_ffFilter.m_bUseAttributes=(m_bAttributes != 0); + m_ffFilter.m_iArchive=m_iArchive; + m_ffFilter.m_iReadOnly=m_iReadOnly; + m_ffFilter.m_iHidden=m_iHidden; + m_ffFilter.m_iSystem=m_iSystem; + m_ffFilter.m_iDirectory=m_iDirectory; + + CHLanguageDialog::OnOK(); +} + +int CFilterDlg::GetMultiplier(int iIndex) +{ + switch (iIndex) + { + case 0: + return 1; + case 1: + return 1024; + case 2: + return 1048576; + default: + ASSERT(true); // bad index + return 1; + } +} + +void CFilterDlg::OnAttributesCheck() +{ + EnableControls(); +} + +void CFilterDlg::OnDateCheck() +{ + EnableControls(); +} + +void CFilterDlg::OnDate2Check() +{ + EnableControls(); +} + +void CFilterDlg::OnFilterCheck() +{ + EnableControls(); +} + +void CFilterDlg::OnSizeCheck() +{ + EnableControls(); +} + +void CFilterDlg::OnSize2Check() +{ + EnableControls(); +} + +void CFilterDlg::OnExcludemaskCheck() +{ + EnableControls(); +} + +void CFilterDlg::OnDatetimechangeTime1Datetimepicker(NMHDR* /*pNMHDR*/, LRESULT* pResult) +{ + EnableControls(); + + *pResult = 0; +} + +void CFilterDlg::OnDatetimechangeDate1Datetimepicker(NMHDR* /*pNMHDR*/, LRESULT* pResult) +{ + EnableControls(); + + *pResult = 0; +} Index: ch/FilterDlg.cpp =================================================================== diff -u -N --- ch/FilterDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FilterDlg.cpp (revision 0) @@ -1,443 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "copy handler.h" -#include "FilterDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CFilterDlg dialog - -CFilterDlg::CFilterDlg() - : CHLanguageDialog(CFilterDlg::IDD) -{ - //{{AFX_DATA_INIT(CFilterDlg) - m_iArchive = FALSE; - m_bAttributes = FALSE; - m_bDate = FALSE; - m_bDate2 = FALSE; - m_iDirectory = FALSE; - m_bFilter = FALSE; - m_iHidden = FALSE; - m_iReadOnly = FALSE; - m_bSize = FALSE; - m_uiSize1 = 0; - m_bSize2 = FALSE; - m_uiSize2 = 0; - m_iSystem = FALSE; - m_bExclude = FALSE; - //}}AFX_DATA_INIT -} - - -void CFilterDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CFilterDlg) - DDX_Control(pDX, IDC_FILTEREXCLUDE_COMBO, m_ctlExcludeMask); - DDX_Control(pDX, IDC_SIZE2_SPIN, m_ctlSpin2); - DDX_Control(pDX, IDC_SIZE1_SPIN, m_ctlSpin1); - DDX_Control(pDX, IDC_TIME2_DATETIMEPICKER, m_ctlTime2); - DDX_Control(pDX, IDC_TIME1_DATETIMEPICKER, m_ctlTime1); - DDX_Control(pDX, IDC_SIZETYPE2_COMBO, m_ctlSizeType2); - DDX_Control(pDX, IDC_SIZETYPE1_COMBO, m_ctlSizeType1); - DDX_Control(pDX, IDC_SIZE2MULTI_COMBO, m_ctlSize2Multi); - DDX_Control(pDX, IDC_SIZE1MULTI_COMBO, m_ctlSize1Multi); - DDX_Control(pDX, IDC_FILTER_COMBO, m_ctlFilter); - DDX_Control(pDX, IDC_DATETYPE_COMBO, m_ctlDateType); - DDX_Control(pDX, IDC_DATE2TYPE_COMBO, m_ctlDateType2); - DDX_Control(pDX, IDC_DATE2_DATETIMEPICKER, m_ctlDate2); - DDX_Control(pDX, IDC_DATE1TYPE_COMBO, m_ctlDateType1); - DDX_Control(pDX, IDC_DATE1_DATETIMEPICKER, m_ctlDate1); - DDX_Check(pDX, IDC_ARCHIVE_CHECK, m_iArchive); - DDX_Check(pDX, IDC_ATTRIBUTES_CHECK, m_bAttributes); - DDX_Check(pDX, IDC_DATE_CHECK, m_bDate); - DDX_Check(pDX, IDC_DATE2_CHECK, m_bDate2); - DDX_Check(pDX, IDC_DIRECTORY_CHECK, m_iDirectory); - DDX_Check(pDX, IDC_FILTER_CHECK, m_bFilter); - DDX_Check(pDX, IDC_HIDDEN_CHECK, m_iHidden); - DDX_Check(pDX, IDC_READONLY_CHECK, m_iReadOnly); - DDX_Check(pDX, IDC_SIZE_CHECK, m_bSize); - DDX_Text(pDX, IDC_SIZE1_EDIT, m_uiSize1); - DDX_Check(pDX, IDC_SIZE2_CHECK, m_bSize2); - DDX_Text(pDX, IDC_SIZE2_EDIT, m_uiSize2); - DDX_Check(pDX, IDC_SYSTEM_CHECK, m_iSystem); - DDX_Check(pDX, IDC_EXCLUDEMASK_CHECK, m_bExclude); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CFilterDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CFilterDlg) - ON_BN_CLICKED(IDC_ATTRIBUTES_CHECK, OnAttributesCheck) - ON_BN_CLICKED(IDC_DATE_CHECK, OnDateCheck) - ON_BN_CLICKED(IDC_DATE2_CHECK, OnDate2Check) - ON_BN_CLICKED(IDC_FILTER_CHECK, OnFilterCheck) - ON_BN_CLICKED(IDC_SIZE_CHECK, OnSizeCheck) - ON_BN_CLICKED(IDC_SIZE2_CHECK, OnSize2Check) - ON_BN_CLICKED(IDC_EXCLUDEMASK_CHECK, OnExcludemaskCheck) - ON_NOTIFY(DTN_DATETIMECHANGE, IDC_TIME1_DATETIMEPICKER, OnDatetimechangeTime1Datetimepicker) - ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATE1_DATETIMEPICKER, OnDatetimechangeDate1Datetimepicker) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFilterDlg message handlers - -BOOL CFilterDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // fill the combos with data - const TCHAR *pszData; - for (int i=0;i<3;i++) - { - pszData=GetResManager()->LoadString(IDS_BYTE_STRING+i); - m_ctlSize1Multi.AddString(pszData); - m_ctlSize2Multi.AddString(pszData); - } - - // strings <, <=, ... - for (i=0;i<5;i++) - { - pszData=GetResManager()->LoadString(IDS_LT_STRING+i); - m_ctlSizeType1.AddString(pszData); - m_ctlSizeType2.AddString(pszData); - m_ctlDateType1.AddString(pszData); - m_ctlDateType2.AddString(pszData); - } - - for (i=0;i<3;i++) - { - m_ctlDateType.AddString(GetResManager()->LoadString(IDS_DATECREATED_STRING+i)); - } - - // copy data from CFileFilter to a dialog - mask - m_bFilter=m_ffFilter.m_bUseMask; - - CString strData; - m_ctlFilter.SetCurSel(m_ctlFilter.AddString(m_ffFilter.GetCombinedMask(strData))); - for (i=0;iLoadString(IDS_BYTE_STRING+i); - m_ctlSize1Multi.AddString(pszData); - m_ctlSize2Multi.AddString(pszData); - } - - // selection - m_ctlSize1Multi.SetCurSel(iPos[0]); - m_ctlSize2Multi.SetCurSel(iPos[1]); - - iPos[0]=m_ctlSizeType1.GetCurSel(); - iPos[1]=m_ctlSizeType2.GetCurSel(); - iPos[2]=m_ctlDateType1.GetCurSel(); - iPos[3]=m_ctlDateType2.GetCurSel(); - - m_ctlSizeType1.ResetContent(); - m_ctlSizeType2.ResetContent(); - m_ctlDateType1.ResetContent(); - m_ctlDateType2.ResetContent(); - - // strings <, <=, ... - for (i=0;i<5;i++) - { - pszData=GetResManager()->LoadString(IDS_LT_STRING+i); - m_ctlSizeType1.AddString(pszData); - m_ctlSizeType2.AddString(pszData); - m_ctlDateType1.AddString(pszData); - m_ctlDateType2.AddString(pszData); - } - - m_ctlSizeType1.SetCurSel(iPos[0]); - m_ctlSizeType2.SetCurSel(iPos[1]); - m_ctlDateType1.SetCurSel(iPos[2]); - m_ctlDateType2.SetCurSel(iPos[3]); - - iPos[0]=m_ctlDateType.GetCurSel(); - m_ctlDateType.ResetContent(); - for (i=0;i<3;i++) - { - m_ctlDateType.AddString(GetResManager()->LoadString(IDS_DATECREATED_STRING+i)); - } - m_ctlDateType.SetCurSel(iPos[0]); -} - -void CFilterDlg::SetSize1(unsigned __int64 ullSize) -{ - if ((ullSize % 1048576) == 0 && ullSize != 0) - { - m_uiSize1=static_cast(ullSize/1048576); - m_ctlSize1Multi.SetCurSel(2); - } - else if ((ullSize % 1024) == 0 && ullSize != 0) - { - m_uiSize1=static_cast(ullSize/1024); - m_ctlSize1Multi.SetCurSel(1); - } - else - { - m_uiSize1=static_cast(ullSize); - m_ctlSize1Multi.SetCurSel(0); - } -} - -void CFilterDlg::SetSize2(unsigned __int64 ullSize) -{ - if ((ullSize % 1048576) == 0 && ullSize != 0) - { - m_uiSize2=static_cast(ullSize/1048576); - m_ctlSize2Multi.SetCurSel(2); - } - else if ((ullSize % 1024) == 0 && ullSize != 0) - { - m_uiSize2=static_cast(ullSize/1024); - m_ctlSize2Multi.SetCurSel(1); - } - else - { - m_uiSize2=static_cast(ullSize); - m_ctlSize2Multi.SetCurSel(0); - } -} - -void CFilterDlg::EnableControls() -{ - UpdateData(TRUE); - // mask - m_ctlFilter.EnableWindow(m_bFilter); - - m_ctlExcludeMask.EnableWindow(m_bExclude); - - // size - m_ctlSizeType1.EnableWindow(m_bSize); - m_ctlSizeType2.EnableWindow(m_bSize && m_bSize2); - GetDlgItem(IDC_SIZE1_EDIT)->EnableWindow(m_bSize); - GetDlgItem(IDC_SIZE2_EDIT)->EnableWindow(m_bSize && m_bSize2); - GetDlgItem(IDC_SIZE1_SPIN)->EnableWindow(m_bSize); - GetDlgItem(IDC_SIZE2_SPIN)->EnableWindow(m_bSize && m_bSize2); - GetDlgItem(IDC_SIZE2_CHECK)->EnableWindow(m_bSize); - m_ctlSize1Multi.EnableWindow(m_bSize); - m_ctlSize2Multi.EnableWindow(m_bSize && m_bSize2); - - // date - CTime tmTemp; - bool bSecond=((m_ctlDate1.GetTime(tmTemp) == GDT_VALID) || (m_ctlTime1.GetTime(tmTemp) == GDT_VALID)); - m_ctlDateType.EnableWindow(m_bDate); - GetDlgItem(IDC_DATE2_CHECK)->EnableWindow(m_bDate && bSecond); - m_ctlDateType1.EnableWindow(m_bDate); - m_ctlDateType2.EnableWindow(m_bDate && m_bDate2 && bSecond); - m_ctlDate1.EnableWindow(m_bDate); - m_ctlDate2.EnableWindow(m_bDate && m_bDate2 && bSecond); - m_ctlTime1.EnableWindow(m_bDate); - m_ctlTime2.EnableWindow(m_bDate && m_bDate2 && bSecond); - - // attrib - GetDlgItem(IDC_ARCHIVE_CHECK)->EnableWindow(m_bAttributes); - GetDlgItem(IDC_READONLY_CHECK)->EnableWindow(m_bAttributes); - GetDlgItem(IDC_HIDDEN_CHECK)->EnableWindow(m_bAttributes); - GetDlgItem(IDC_SYSTEM_CHECK)->EnableWindow(m_bAttributes); - GetDlgItem(IDC_DIRECTORY_CHECK)->EnableWindow(m_bAttributes); -} - -void CFilterDlg::OnOK() -{ - UpdateData(TRUE); - - // CFileFilter --> dialogu - mask - CString strText; - m_ctlFilter.GetWindowText(strText); - m_ffFilter.m_bUseMask=((m_bFilter != 0) && !strText.IsEmpty()); - m_ffFilter.SetCombinedMask(strText); - - m_ctlExcludeMask.GetWindowText(strText); - m_ffFilter.m_bUseExcludeMask=(m_bExclude != 0) && !strText.IsEmpty(); - m_ffFilter.SetCombinedExcludeMask(strText); - - // size - m_ffFilter.m_bUseSize=(m_bSize != 0); - m_ffFilter.m_bUseSize2=(m_bSize2 != 0); - - m_ffFilter.m_iSizeType1=m_ctlSizeType1.GetCurSel(); - m_ffFilter.m_iSizeType2=m_ctlSizeType2.GetCurSel(); - - m_ffFilter.m_ullSize1=static_cast(m_uiSize1)*static_cast(GetMultiplier(m_ctlSize1Multi.GetCurSel())); - m_ffFilter.m_ullSize2=static_cast(m_uiSize2)*static_cast(GetMultiplier(m_ctlSize2Multi.GetCurSel())); - - // date - m_ffFilter.m_iDateType=m_ctlDateType.GetCurSel(); - - m_ffFilter.m_iDateType1=m_ctlDateType1.GetCurSel(); - m_ffFilter.m_iDateType2=m_ctlDateType2.GetCurSel(); - - m_ffFilter.m_bDate1=m_ctlDate1.GetTime(m_ffFilter.m_tDate1) == GDT_VALID; - m_ffFilter.m_bDate2=m_ctlDate2.GetTime(m_ffFilter.m_tDate2) == GDT_VALID; - m_ffFilter.m_bTime1=m_ctlTime1.GetTime(m_ffFilter.m_tTime1) == GDT_VALID; - m_ffFilter.m_bTime2=m_ctlTime2.GetTime(m_ffFilter.m_tTime2) == GDT_VALID; - - m_ffFilter.m_bUseDate=(m_bDate != 0) && (m_ffFilter.m_bDate1 || m_ffFilter.m_bTime1); - m_ffFilter.m_bUseDate2=(m_bDate2 != 0) && (m_ffFilter.m_bDate2 || m_ffFilter.m_bTime2); - - // attributes - m_ffFilter.m_bUseAttributes=(m_bAttributes != 0); - m_ffFilter.m_iArchive=m_iArchive; - m_ffFilter.m_iReadOnly=m_iReadOnly; - m_ffFilter.m_iHidden=m_iHidden; - m_ffFilter.m_iSystem=m_iSystem; - m_ffFilter.m_iDirectory=m_iDirectory; - - CHLanguageDialog::OnOK(); -} - -int CFilterDlg::GetMultiplier(int iIndex) -{ - switch (iIndex) - { - case 0: - return 1; - case 1: - return 1024; - case 2: - return 1048576; - default: - ASSERT(true); // bad index - return 1; - } -} - -void CFilterDlg::OnAttributesCheck() -{ - EnableControls(); -} - -void CFilterDlg::OnDateCheck() -{ - EnableControls(); -} - -void CFilterDlg::OnDate2Check() -{ - EnableControls(); -} - -void CFilterDlg::OnFilterCheck() -{ - EnableControls(); -} - -void CFilterDlg::OnSizeCheck() -{ - EnableControls(); -} - -void CFilterDlg::OnSize2Check() -{ - EnableControls(); -} - -void CFilterDlg::OnExcludemaskCheck() -{ - EnableControls(); -} - -void CFilterDlg::OnDatetimechangeTime1Datetimepicker(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - EnableControls(); - - *pResult = 0; -} - -void CFilterDlg::OnDatetimechangeDate1Datetimepicker(NMHDR* /*pNMHDR*/, LRESULT* pResult) -{ - EnableControls(); - - *pResult = 0; -} Index: src/ch/FilterDlg.h =================================================================== diff -u -N --- src/ch/FilterDlg.h (revision 0) +++ src/ch/FilterDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,110 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __FILTERDLG_H__ +#define __FILTERDLG_H__ + +#include "FileInfo.h" +#include + +///////////////////////////////////////////////////////////////////////////// +// CFilterDlg dialog + +class CFilterDlg : public CHLanguageDialog +{ +// Construction +public: + CFilterDlg(); // standard constructor + +// Dialog Data + //{{AFX_DATA(CFilterDlg) + enum { IDD = IDD_FILTER_DIALOG }; + CComboBox m_ctlExcludeMask; + CSpinButtonCtrl m_ctlSpin2; + CSpinButtonCtrl m_ctlSpin1; + CDateTimeCtrl m_ctlTime2; + CDateTimeCtrl m_ctlTime1; + CComboBox m_ctlSizeType2; + CComboBox m_ctlSizeType1; + CComboBox m_ctlSize2Multi; + CComboBox m_ctlSize1Multi; + CComboBox m_ctlFilter; + CComboBox m_ctlDateType; + CComboBox m_ctlDateType2; + CDateTimeCtrl m_ctlDate2; + CComboBox m_ctlDateType1; + CDateTimeCtrl m_ctlDate1; + int m_iArchive; + BOOL m_bAttributes; + BOOL m_bDate; + BOOL m_bDate2; + int m_iDirectory; + BOOL m_bFilter; + int m_iHidden; + int m_iReadOnly; + BOOL m_bSize; + UINT m_uiSize1; + BOOL m_bSize2; + UINT m_uiSize2; + int m_iSystem; + BOOL m_bExclude; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFilterDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +public: + void SetSize2(unsigned __int64 ullSize); + CFileFilter m_ffFilter; + CStringArray m_astrAddMask; + CStringArray m_astrAddExcludeMask; + +protected: + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + int GetMultiplier(int iIndex); + void EnableControls(); + void SetSize1(unsigned __int64 ullSize); + + // Generated message map functions + //{{AFX_MSG(CFilterDlg) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + afx_msg void OnAttributesCheck(); + afx_msg void OnDateCheck(); + afx_msg void OnDate2Check(); + afx_msg void OnFilterCheck(); + afx_msg void OnSizeCheck(); + afx_msg void OnSize2Check(); + afx_msg void OnExcludemaskCheck(); + afx_msg void OnDatetimechangeTime1Datetimepicker(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnDatetimechangeDate1Datetimepicker(NMHDR* pNMHDR, LRESULT* pResult); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/FilterDlg.h =================================================================== diff -u -N --- ch/FilterDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FilterDlg.h (revision 0) @@ -1,110 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __FILTERDLG_H__ -#define __FILTERDLG_H__ - -#include "FileInfo.h" -#include - -///////////////////////////////////////////////////////////////////////////// -// CFilterDlg dialog - -class CFilterDlg : public CHLanguageDialog -{ -// Construction -public: - CFilterDlg(); // standard constructor - -// Dialog Data - //{{AFX_DATA(CFilterDlg) - enum { IDD = IDD_FILTER_DIALOG }; - CComboBox m_ctlExcludeMask; - CSpinButtonCtrl m_ctlSpin2; - CSpinButtonCtrl m_ctlSpin1; - CDateTimeCtrl m_ctlTime2; - CDateTimeCtrl m_ctlTime1; - CComboBox m_ctlSizeType2; - CComboBox m_ctlSizeType1; - CComboBox m_ctlSize2Multi; - CComboBox m_ctlSize1Multi; - CComboBox m_ctlFilter; - CComboBox m_ctlDateType; - CComboBox m_ctlDateType2; - CDateTimeCtrl m_ctlDate2; - CComboBox m_ctlDateType1; - CDateTimeCtrl m_ctlDate1; - int m_iArchive; - BOOL m_bAttributes; - BOOL m_bDate; - BOOL m_bDate2; - int m_iDirectory; - BOOL m_bFilter; - int m_iHidden; - int m_iReadOnly; - BOOL m_bSize; - UINT m_uiSize1; - BOOL m_bSize2; - UINT m_uiSize2; - int m_iSystem; - BOOL m_bExclude; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFilterDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - void SetSize2(unsigned __int64 ullSize); - CFileFilter m_ffFilter; - CStringArray m_astrAddMask; - CStringArray m_astrAddExcludeMask; - -protected: - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - int GetMultiplier(int iIndex); - void EnableControls(); - void SetSize1(unsigned __int64 ullSize); - - // Generated message map functions - //{{AFX_MSG(CFilterDlg) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnAttributesCheck(); - afx_msg void OnDateCheck(); - afx_msg void OnDate2Check(); - afx_msg void OnFilterCheck(); - afx_msg void OnSizeCheck(); - afx_msg void OnSize2Check(); - afx_msg void OnExcludemaskCheck(); - afx_msg void OnDatetimechangeTime1Datetimepicker(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnDatetimechangeDate1Datetimepicker(NMHDR* pNMHDR, LRESULT* pResult); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/FolderDialog.cpp =================================================================== diff -u -N --- src/ch/FolderDialog.cpp (revision 0) +++ src/ch/FolderDialog.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1295 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" +#include "DirTreeCtrl.h" +#include "FolderDialog.h" +#include "memdc.h" +#include "Theme Helpers.h" +#include "shlobj.h" +#include "..\Common\FileSupport.h" +#include "StringHelpers.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +// dialog jako taki +const unsigned long __g_DlgTemplate[]={ + 0x82cf0040, 0x00000000, 0x00000000, 0x011b0000, 0x000000b4, 0x00000000, 0x00540008, 0x00680061, + 0x006d006f, 0x00000061 }; + +///////////////////////////////////////////////////////////////////////////// +// additional messages +#ifndef WM_THEMECHANGED +#define WM_THEMECHANGED 0x031A +#endif + +///////////////////////////////////////////////////////////////////////////// +// widow procedures - group subclassing for flicker free drawing +WNDPROC __g_pfButton; +WNDPROC __g_pfStatic; +WNDPROC __g_pfList; +WNDPROC __g_pfCombo; +WNDPROC __g_pfBaseCombo; +WNDPROC __g_pfEdit; + +///////////////////////////////////////////////////////////////////////////// +// Draws and calls the old window proc +LRESULT CALLBACK InternalWindowProc(WNDPROC pfWndProc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) + { + case WM_ERASEBKGND: + return (LRESULT)0; + break; + case WM_PAINT: + CWnd* pWnd=CWnd::FromHandle(hwnd); + CPaintDC dc(pWnd); + + // exclude header from update rect (only in report view) + int iID=GetDlgCtrlID(hwnd); + if (iID == IDC_SHORTCUT_LIST) + { + DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE); + if ((dwStyle & LVS_TYPEMASK) == LVS_REPORT) + { + CRect headerRect; + HWND hHeader=ListView_GetHeader(hwnd); + GetWindowRect(hHeader, &headerRect); + CPoint pt=headerRect.TopLeft(); + ScreenToClient(hwnd, &pt); + headerRect.left=pt.x; + headerRect.top=pt.y; + pt=headerRect.BottomRight(); + ScreenToClient(hwnd, &pt); + headerRect.right=pt.x; + headerRect.bottom=pt.y; + dc.ExcludeClipRect(&headerRect); + } + } + + CMemDC memdc(&dc, &dc.m_ps.rcPaint); + + if (dc.m_ps.fErase) + memdc.FillSolidRect(&dc.m_ps.rcPaint, GetSysColor(COLOR_WINDOW)); + + CallWindowProc(pfWndProc, hwnd, WM_PAINT, (WPARAM)memdc.GetSafeHdc(), 0); + return 0; + break; + } + + return CallWindowProc(pfWndProc, hwnd, uMsg, wParam, lParam); +} + +//////////////////////////////////////////////////////////////////////////// +// window proc for edit ctrl contained in combo +LRESULT CALLBACK EditWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + return InternalWindowProc(__g_pfEdit, hwnd, uMsg, wParam, lParam); +}; + +//////////////////////////////////////////////////////////////////////////// +// procedure for combo box contained in comboboxex +LRESULT CALLBACK ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + return InternalWindowProc(__g_pfBaseCombo, hwnd, uMsg, wParam, lParam); +}; + +//////////////////////////////////////////////////////////////////////////// +// other visual elements' window proc +LRESULT CALLBACK CustomWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + int iID=GetDlgCtrlID(hwnd); + WNDPROC pfOld=NULL; + switch(iID) + { + case IDC_TOGGLE_BUTTON: + case IDOK: + case IDCANCEL: + pfOld=__g_pfButton; + break; + case IDC_TITLE_STATIC: + pfOld=__g_pfStatic; + break; + case IDC_PATH_COMBOBOXEX: + pfOld=__g_pfCombo; + break; + case IDC_SHORTCUT_LIST: + pfOld=__g_pfList; + break; + default: + ASSERT(false); // used CustomWindowProc, but no ID has been recognized + } + + return InternalWindowProc(pfOld, hwnd, uMsg, wParam, lParam); +} + +///////////////////////////////////////////////////////////////////////////// +// CFolderDialog dialog + +CFolderDialog::CFolderDialog(CWnd* /*pParent*/ /*=NULL*/) + : CHLanguageDialog() +{ + //{{AFX_DATA_INIT(CFolderDialog) + //}}AFX_DATA_INIT + m_hImages=NULL; + m_hLargeImages=NULL; + m_bIgnoreUpdate=false; + m_bIgnoreTreeRefresh=false; +} + +CFolderDialog::~CFolderDialog() +{ +} + +BEGIN_MESSAGE_MAP(CFolderDialog, CHLanguageDialog) + //{{AFX_MSG_MAP(CFolderDialog) + ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SHORTCUT_LIST, OnEndLabelEditShortcutList) + ON_BN_CLICKED(IDC_ADDSHORTCUT_BUTTON, OnAddShortcut) + ON_BN_CLICKED(IDC_REMOVESHORTCUT_BUTTON, OnRemoveShortcut) + ON_BN_CLICKED(IDC_TOGGLE_BUTTON, OnToggleButton) + ON_NOTIFY(TVN_SELCHANGED, IDC_FOLDER_TREE, OnSelchangedFolderTree) + ON_NOTIFY(TVN_GETINFOTIP, IDC_FOLDER_TREE, OnGetInfoTipFolderTree) + ON_BN_CLICKED(IDC_NEWFOLDER_BUTTON, OnNewfolderButton) + ON_CBN_EDITCHANGE(IDC_PATH_COMBOBOXEX, OnPathChanging) + ON_BN_CLICKED(IDC_LARGEICONS_BUTTON, OnIconsRadio) + ON_BN_CLICKED(IDC_SMALLICONS_BUTTON, OnSmalliconsRadio) + ON_BN_CLICKED(IDC_LIST_BUTTON, OnListRadio) + ON_BN_CLICKED(IDC_REPORT_BUTTON, OnReportRadio) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_SHORTCUT_LIST, OnItemchangedShortcutList) + ON_NOTIFY(LVN_GETINFOTIP, IDC_SHORTCUT_LIST, OnGetShortcutInfoTip) + ON_NOTIFY(LVN_KEYDOWN, IDC_SHORTCUT_LIST, OnShortcutKeyDown) + ON_WM_PAINT() + ON_WM_NCHITTEST() + ON_WM_SIZE() + ON_WM_GETMINMAXINFO() + ON_WM_SYSCOLORCHANGE() + ON_WM_CREATE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CFolderDialog message handlers + +///////////////////////////////////////////////////////////////////////////// +// creating all needed controls + +int CFolderDialog::CreateControls() +{ + // std rect - size doesn't matter for now + CRect rc(0, 0, 0, 0); + + if (!m_ctlTitle.Create(_T(""), WS_CHILD | WS_VISIBLE, rc, this, IDC_TITLE_STATIC) || + (__g_pfStatic=(WNDPROC)SetWindowLong(m_ctlTitle.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlTitle.SetFont(GetFont()); + + // buttons - small with bitmaps + if (!m_ctlLargeIcons.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_LARGEICONS_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlLargeIcons.SetImage(&m_ilList, 0); + + if (!m_ctlSmallIcons.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_SMALLICONS_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlSmallIcons.SetImage(&m_ilList, 1); + + if (!m_ctlList.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_LIST_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlList.SetImage(&m_ilList, 2); + + if (!m_ctlReport.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_REPORT_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlReport.SetImage(&m_ilList, 3); + + if (!m_ctlNewFolder.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_NEWFOLDER_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlNewFolder.SetImage(&m_ilList, 4); + + // listview + if (!m_ctlShortcuts.Create(WS_CHILD | WS_VISIBLE | LVS_SINGLESEL | LVS_SHAREIMAGELISTS | LVS_EDITLABELS | WS_TABSTOP | LVS_SMALLICON | LVS_SHOWSELALWAYS, rc, this, IDC_SHORTCUT_LIST) || + (__g_pfList=(WNDPROC)SetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlShortcuts.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); + m_ctlShortcuts.ModifyStyleEx(0, WS_EX_CLIENTEDGE); + + // dir tree ctrl + if (!m_ctlTree.Create(WS_CHILD | WS_VISIBLE | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS + | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | TVS_SINGLEEXPAND | TVS_INFOTIP | + WS_TABSTOP | WS_VSCROLL, rc, this, IDC_FOLDER_TREE) + || !m_ctlTree.ModifyStyleEx(0, WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE)) + { + TRACE("Error creating control..."); + return -1; + } + + // combobox + rc.bottom=rc.top+200; + if (!m_ctlPath.Create(WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_OWNERDRAWFIXED | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rc, this, IDC_PATH_COMBOBOXEX) || + (__g_pfCombo=(WNDPROC)SetWindowLong(m_ctlPath.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) + { + TRACE("Error creating control..."); + return -1; + } + HWND hCombo=(HWND)m_ctlPath.SendMessage(CBEM_GETCOMBOCONTROL, 0, 0); + if ((__g_pfBaseCombo=(WNDPROC)SetWindowLong(hCombo, GWL_WNDPROC, (LONG)ComboWindowProc)) == 0) + return -1; + HWND hEdit=(HWND)m_ctlPath.SendMessage(CBEM_GETEDITCONTROL, 0, 0); + if ((__g_pfEdit=(WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (LONG)EditWindowProc)) == 0) + return -1; + + // buttons OK & Cancel + rc.bottom=rc.top; + if (!m_ctlOk.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, rc, this, IDOK) || + (__g_pfButton=(WNDPROC)SetWindowLong(m_ctlOk.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlOk.SetFont(GetFont()); + + if (!m_ctlCancel.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rc, this, IDCANCEL) || + !((WNDPROC)SetWindowLong(m_ctlCancel.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc))) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlCancel.SetFont(GetFont()); + + if (!m_ctlToggle.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rc, this, IDC_TOGGLE_BUTTON) || + !((WNDPROC)SetWindowLong(m_ctlToggle.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc))) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlToggle.SetFont(GetFont()); + + // add&remove shortcut + if (!m_ctlRemoveShortcut.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_REMOVESHORTCUT_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlRemoveShortcut.SetImage(&m_ilList, 6); + + if (!m_ctlAddShortcut.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_ADDSHORTCUT_BUTTON)) + { + TRACE("Error creating control..."); + return -1; + } + m_ctlAddShortcut.SetImage(&m_ilList, 5); + + return 0; +} + +/////////////////////////////////////////////////////////////////////////// +// tworzy image list� z wszystkimi potrzebnymi ikonami +void CFolderDialog::InitImageList() +{ + m_ilList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1); + + HICON hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_LARGEICONS_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_SMALLICONS_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_LIST_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_REPORT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_NEWFOLDER_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_ADDSHORTCUT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); + + hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_DELETESHORTCUT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); + m_ilList.Add(hIcon); +} + +//////////////////////////////////////////////////////////////////////////// +// applies showing/hiding shortcuts list +void CFolderDialog::ApplyExpandState(bool bExpand) +{ + // change button text and hide/show needed elements + m_ctlToggle.SetWindowText(GetResManager()->LoadString(bExpand ? IDS_BDRIGHT_STRING : IDS_BDLEFT_STRING)); + m_ctlShortcuts.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlLargeIcons.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlSmallIcons.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlList.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlReport.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlAddShortcut.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); + m_ctlRemoveShortcut.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); +} + +//////////////////////////////////////////////////////////////////////////// +// toggle extended view +void CFolderDialog::OnToggleButton() +{ + m_bdData.bExtended=!m_bdData.bExtended; + ApplyExpandState(m_bdData.bExtended); + + CRect rcDialog; + GetClientRect(&rcDialog); + ResizeControls(rcDialog.Width(), rcDialog.Height()); +} + +///////////////////////////////////////////////////////////////////////////// +// initialization of most important params - reading text, bitmaps +BOOL CFolderDialog::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // image list + InitImageList(); + + if (CreateControls() == -1) + EndDialog(-1); + + // size of a dialog + CRect rcDialog; + GetClientRect(&rcDialog); + if (m_bdData.cx != 0) + rcDialog.right=rcDialog.left+m_bdData.cx; + if (m_bdData.cy != 0) + rcDialog.bottom=rcDialog.top+m_bdData.cy; + if (m_bdData.cy != 0 || m_bdData.cx != 0) + SetWindowPos(&wndTop, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOMOVE); + + // show needed text + SetWindowText(m_bdData.strCaption); + m_ctlTitle.SetWindowText(m_bdData.strText); + m_ctlTree.SetIgnoreShellDialogs(m_bdData.bIgnoreDialogs); + m_ctlTree.PostMessage(WM_SETPATH, 0, (LPARAM)((LPCTSTR)m_bdData.strInitialDir)); + + // buttons text + m_ctlOk.SetWindowText(GetResManager()->LoadString(IDS_BDOK_STRING)); + m_ctlCancel.SetWindowText(GetResManager()->LoadString(IDS_BDCANCEL_STRING)); + ApplyExpandState(m_bdData.bExtended); + + // sys img list + SHFILEINFO sfi; + m_hImages = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + m_hLargeImages=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX); + m_ctlPath.SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)m_hImages); + m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_hImages); + m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hLargeImages); + + // add all the paths from m_bdData.astrRecent + COMBOBOXEXITEM cbi; + CString strText; + cbi.mask=CBEIF_IMAGE | CBEIF_TEXT; + + for (int i=0;i<(int)m_bdData.cvRecent.size();i++) + { + cbi.iItem=i; + cbi.pszText=m_bdData.cvRecent.at(i); + sfi.iIcon=-1; + SHGetFileInfo(m_bdData.cvRecent.at(i), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + cbi.iImage=sfi.iIcon; + + m_ctlPath.InsertItem(&cbi); + } + + // additional columns in a list + LVCOLUMN lvc; + lvc.mask=LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT; + lvc.iSubItem=-1; + lvc.cx=80; + lvc.pszText=(LPTSTR)GetResManager()->LoadString(IDS_BDNAME_STRING); + m_ctlShortcuts.InsertColumn(0, &lvc); + lvc.iSubItem=0; + lvc.cx=110; + lvc.pszText=(LPTSTR)GetResManager()->LoadString(IDS_BDPATH_STRING); + m_ctlShortcuts.InsertColumn(1, &lvc); + + // select view-style button + SetView(m_bdData.iView); + + // update shortcuts' list + CShortcut sc; + for (i=0;i<(int)m_bdData.cvShortcuts.size();i++) + { + sc=CString(m_bdData.cvShortcuts.at(i)); + sfi.iIcon=-1; + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.InsertItem(i, sc.m_strName, sfi.iIcon); + m_ctlShortcuts.SetItem(i, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + } + + // now resize and ok. + GetClientRect(&rcDialog); + ResizeControls(rcDialog.Width(), rcDialog.Height()); + + // set to top - the strange way + SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + SetFocus(); + SetForegroundWindow(); + + return TRUE; +} + +//////////////////////////////////////////////////////////////////////////// +// tooltip handling for controls in this dialog +BOOL CFolderDialog::OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip) +{ + switch (uiID) + { + case IDC_NEWFOLDER_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDNEWFOLDER_STRING); + break; + case IDC_LARGEICONS_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDLARGEICONS_STRING); + break; + case IDC_SMALLICONS_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDSMALLICONS_STRING); + break; + case IDC_LIST_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDLIST_STRING); + break; + case IDC_REPORT_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDREPORT_STRING); + break; + case IDC_TOGGLE_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDDETAILS_STRING); + break; + case IDC_ADDSHORTCUT_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDADDSHORTCUT_STRING); + break; + case IDC_REMOVESHORTCUT_BUTTON: + pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDREMOVESHORTCUT_STRING); + break; + default: + return FALSE; + } + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// cancels the dialog or cancels editing of an item +void CFolderDialog::OnCancel() +{ + if (m_ctlTree.IsEditing()) + { + TreeView_EndEditLabelNow(m_ctlTree.GetSafeHwnd(), TRUE); + return; + } + + CRect rcDlg; + GetWindowRect(&rcDlg); + m_bdData.cx=rcDlg.Width(); + m_bdData.cy=rcDlg.Height(); + + CHLanguageDialog::OnCancel(); +} + +/////////////////////////////////////////////////////////////////////////// +// finishes dialog's work or finished editing of an item +void CFolderDialog::OnOK() +{ + // if we edit an item in m_ctlTree + if (m_ctlTree.IsEditing()) + { + TreeView_EndEditLabelNow(m_ctlTree.GetSafeHwnd(), FALSE); + return; + } + + // update path, get rid of '\\' + m_ctlPath.GetWindowText(m_strPath); + if (m_strPath.Right(1) == _T('\\') || m_strPath.Right(1) == _T('/')) + m_strPath=m_strPath.Left(m_strPath.GetLength()-1); + + // does it exist as a folder ? +/* CFileFind fnd; + BOOL bExist=fnd.FindFile(m_strPath+_T("\\*")); + fnd.Close();*/ +// WIN32_FIND_DATA wfd; +// HANDLE hFind; + +// if (!bExist) + if ( GetFileAttributes(m_strPath) == INVALID_FILE_ATTRIBUTES) + { + MsgBox(IDS_BDPATHDOESNTEXIST_STRING, MB_OK | MB_ICONERROR); + return; + } + + m_bdData.cvRecent.insert(m_bdData.cvRecent.begin(), (const PTSTR)(LPCTSTR)(m_strPath+_T('\\')), true); + + CRect rcDlg; + GetWindowRect(&rcDlg); + m_bdData.cx=rcDlg.Width(); + m_bdData.cy=rcDlg.Height(); + + CHLanguageDialog::OnOK(); +} + +/////////////////////////////////////////////////////////////////////////// +// Displays dialog from __g_DlgTemplate +int CFolderDialog::DoModal() +{ + if (!InitModalIndirect((LPCDLGTEMPLATE)__g_DlgTemplate)) + return -1; + else + return CHLanguageDialog::DoModal(); +} + +/////////////////////////////////////////////////////////////////////////// +// handles creation of a new folder +void CFolderDialog::OnNewfolderButton() +{ + // currently selected item + HTREEITEM hItem=m_ctlTree.GetSelectedItem(); + if (hItem == NULL) + return; + + // insert child item + m_ctlTree.InsertNewFolder(hItem, _T("")); +} + +///////////////////////////////////////////////////////////////////////////// +// other messages +LRESULT CFolderDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_CREATEFOLDERRESULT: + if (((int)lParam) != 1) + MsgBox(IDS_BDCANNOTCREATEFOLDER_STRING); + break; + case WM_THEMECHANGED: + CRect rcDialog; + GetClientRect(&rcDialog); + ResizeControls(rcDialog.Width(), rcDialog.Height()); + break; + } + + return CHLanguageDialog::WindowProc(message, wParam, lParam); +} + +////////////////////////////////////////////////////////////////////////////// +// tooltips for folder tree +void CFolderDialog::OnGetInfoTipFolderTree(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMTVGETINFOTIP* pit = (NMTVGETINFOTIP*)pNMHDR; + *pResult = 0; + + // get rid of old tip + m_strTip.Empty(); + + // get type of an item - for floppy skip + SHDESCRIPTIONID shdi; + bool bSkipFreeSpace=false; + if (m_ctlTree.GetItemShellData(pit->hItem, SHGDFIL_DESCRIPTIONID, &shdi, sizeof(SHDESCRIPTIONID)) + && ( shdi.dwDescriptionId == SHDID_COMPUTER_DRIVE35 + || shdi.dwDescriptionId == SHDID_COMPUTER_DRIVE525 ) ) + bSkipFreeSpace=true; + + + // some about network + bool bNet; + CString strData; + NETRESOURCE* pnet=(NETRESOURCE*)m_szBuffer; + if ( (bNet=m_ctlTree.GetItemShellData(pit->hItem, SHGDFIL_NETRESOURCE, pnet, 2048)) == true) + { + if (pnet->lpRemoteName && _tcscmp(pnet->lpRemoteName, _T("")) != 0) + m_strTip+=GetResManager()->LoadString(IDS_BDREMOTENAME_STRING)+CString(pnet->lpRemoteName)+_T("\n"); + if ( pnet->lpLocalName && _tcscmp(pnet->lpLocalName, _T("")) != 0) + m_strTip+=GetResManager()->LoadString(IDS_BDLOCALNAME_STRING)+CString(pnet->lpLocalName)+_T("\n"); + if ( pnet->dwDisplayType != 0) + m_strTip+=GetResManager()->LoadString(IDS_BDTYPE_STRING)+CString(GetResManager()->LoadString(IDS_BDDOMAIN_STRING+pnet->dwDisplayType))+_T("\n"); + if ( pnet->lpProvider && _tcscmp(pnet->lpProvider, _T("")) != 0) + m_strTip+=GetResManager()->LoadString(IDS_BDNETTYPE_STRING)+CString(pnet->lpProvider)+_T("\n"); + if ( pnet->lpComment && _tcscmp(pnet->lpComment, _T("")) != 0) + m_strTip+=GetResManager()->LoadString(IDS_BDDESCRIPTION_STRING)+CString(pnet->lpComment)+_T("\n"); + } + + // try to get path + CString strPath, strMask; + TCHAR szSizeFree[32], szSizeTotal[32]; + bool bPath; + if ( (bPath=m_ctlTree.GetPath(pit->hItem, strPath.GetBuffer(_MAX_PATH))) == true ) + { + strPath.ReleaseBuffer(); + if (!bNet && !strPath.IsEmpty()) + m_strTip+=strPath+_T("\n"); + + if (!bSkipFreeSpace) + { + // get disk free space + __int64 llFree, llTotal; + if (GetDynamicFreeSpace(strPath, &llFree, &llTotal)) + { + m_strTip+=GetResManager()->LoadString(IDS_BDFREESPACE_STRING)+CString(GetSizeString(llFree, szSizeFree, false))+_T("\n"); + m_strTip+=GetResManager()->LoadString(IDS_BDCAPACITY_STRING)+CString(GetSizeString(llTotal, szSizeTotal, false))+_T("\n"); + } + } + } + + if (!bNet && !bPath) + { + // get std shell msg + m_ctlTree.GetItemInfoTip(pit->hItem, &m_strTip); + } + else + { + // get rid of '\n' + m_strTip=m_strTip.Left(m_strTip.GetLength()-1); + } + + // set + pit->pszText=m_strTip.GetBuffer(1); // tip doesn't change - skip RelaseBuffer + pit->cchTextMax=lstrlen(pit->pszText); +} + +///////////////////////////////////////////////////////////////////////////// +// tooltip support for shortcuts list +void CFolderDialog::OnGetShortcutInfoTip(NMHDR* pNMHDR, LRESULT* /*pResult*/) +{ + NMLVGETINFOTIP* pit=(NMLVGETINFOTIP*)pNMHDR; + m_strTip.Empty(); + + if (pit->iItem < 0 || pit->iItem >= (int)m_bdData.cvShortcuts.size()) + return; // out of range + + CShortcut sc=CString(m_bdData.cvShortcuts.at(pit->iItem)); + m_strTip=sc.m_strName+_T("\r\n")+CString(GetResManager()->LoadString(IDS_BDPATH2_STRING))+sc.m_strPath; + + // get disk free space + __int64 llFree, llTotal; + if (GetDynamicFreeSpace(sc.m_strPath, &llFree, &llTotal)) + { + m_strTip+=CString(_T("\r\n"))+GetResManager()->LoadString(IDS_BDFREESPACE_STRING)+CString(GetSizeString(llFree, m_szBuffer, false))+_T("\n"); + m_strTip+=GetResManager()->LoadString(IDS_BDCAPACITY_STRING)+CString(GetSizeString(llTotal, m_szBuffer, false)); + } + + pit->pszText=(LPTSTR)(LPCTSTR)m_strTip; + pit->cchTextMax=m_strTip.GetLength()+1; +} + +//////////////////////////////////////////////////////////////////////////// +// updates text in combo when the selection in a tree changes +void CFolderDialog::OnSelchangedFolderTree(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; + TCHAR szPath[_MAX_PATH]; + + if (m_bIgnoreUpdate) + return; + + if (m_ctlTree.GetPath(pNMTreeView->itemNew.hItem, szPath)) + SetComboPath(szPath); + + *pResult = 0; +} + +//////////////////////////////////////////////////////////////////////////// +// updates folder tree when combo text changes +void CFolderDialog::OnPathChanging() +{ + if (m_bIgnoreTreeRefresh) + return; + + COMBOBOXEXITEM cbi; + cbi.mask=CBEIF_TEXT; + cbi.iItem=-1; + cbi.pszText=m_szBuffer; + cbi.cchTextMax=_MAX_PATH; + + if (!m_ctlPath.GetItem(&cbi)) + return; + + UpdateComboIcon(); + + m_bIgnoreUpdate=true; + m_ctlTree.SetPath(cbi.pszText); + m_bIgnoreUpdate=false; +} + +///////////////////////////////////////////////////////////////////////// +// sets text in comboboxex edit and updates icon +void CFolderDialog::SetComboPath(LPCTSTR lpszPath) +{ + // set current select to -1 + m_bIgnoreTreeRefresh=true; + m_ctlPath.SetCurSel(-1); + m_bIgnoreTreeRefresh=false; + + SHFILEINFO sfi; + sfi.iIcon=-1; + + COMBOBOXEXITEM cbi; + + cbi.mask=CBEIF_TEXT | CBEIF_IMAGE; + cbi.iItem=-1; + _tcscpy(m_szBuffer, lpszPath); + cbi.pszText=m_szBuffer; + SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + cbi.iImage=sfi.iIcon; + m_bIgnoreTreeRefresh=true; + m_ctlPath.SetItem(&cbi); + m_bIgnoreTreeRefresh=false; +} + +////////////////////////////////////////////////////////////////////////// +// updates icon in comboex +void CFolderDialog::UpdateComboIcon() +{ + // get text from combo + COMBOBOXEXITEM cbi; + cbi.mask=CBEIF_TEXT; + cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; + cbi.pszText=m_szBuffer; + cbi.cchTextMax=_MAX_PATH; + + if (!m_ctlPath.GetItem(&cbi)) + return; + + // select no item + m_bIgnoreTreeRefresh=true; + m_ctlPath.SetCurSel(-1); + m_bIgnoreTreeRefresh=false; + + // icon update + SHFILEINFO sfi; + sfi.iIcon=-1; + + cbi.mask |= CBEIF_IMAGE; + cbi.iItem=-1; + + CString str=(LPCTSTR)m_szBuffer; + if (str.Left(2) != _T("\\\\") || str.Find(_T('\\'), 2) != -1) + SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + + cbi.iImage=sfi.iIcon; + + m_bIgnoreTreeRefresh=true; + m_ctlPath.SetItem(&cbi); + m_bIgnoreTreeRefresh=false; + + // unselect text in combo's edit + CEdit* pEdit=m_ctlPath.GetEditCtrl(); + if (!pEdit) + return; + + pEdit->SetSel(-1, -1); +} + +///////////////////////////////////////////////////////////////////////////// +// combo and treeview update +void CFolderDialog::OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMLISTVIEW* plv=(NMLISTVIEW*)pNMHDR; + + // current selection + if (plv->iItem >= 0 && plv->iItem < (int)m_bdData.cvShortcuts.size()) + { + CShortcut sc=CString(m_bdData.cvShortcuts.at(plv->iItem)); + m_ctlTree.SetPath(sc.m_strPath); + SetComboPath(sc.m_strPath); + } + + *pResult = 0; +} + +///////////////////////////////////////////////////////////////////////////// +// adding shortcut +void CFolderDialog::OnAddShortcut() +{ + // get current text + COMBOBOXEXITEM cbi; + cbi.mask=CBEIF_TEXT; + cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; + cbi.pszText=m_szBuffer; + cbi.cchTextMax=_MAX_PATH; + + if (!m_ctlPath.GetItem(&cbi)) + { + MsgBox(IDS_BDNOSHORTCUTPATH_STRING); + return; + } + + // create new item - update shortcut list + CShortcut sc; + sc.m_strPath=cbi.pszText; + SHFILEINFO sfi; + sfi.iIcon=-1; + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + + // add to an array and to shortcuts list + m_bdData.cvShortcuts.push_back((const PTSTR)(LPCTSTR)(CString)(sc), true); + int iIndex=m_bdData.cvShortcuts.size()-1; + m_ctlShortcuts.InsertItem(iIndex, sc.m_strName, sfi.iIcon); + m_ctlShortcuts.SetItem(iIndex, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + + // edit item + m_ctlShortcuts.SetFocus(); + if (m_ctlShortcuts.EditLabel(iIndex) == NULL) + { + TRACE("Couldn't edit shortcut list's item label\n"); + return; + } +} + +//////////////////////////////////////////////////////////////////////////// +// keyboard's delete button handling +void CFolderDialog::OnShortcutKeyDown(NMHDR* pNMHDR, LRESULT* /*pResult*/) +{ + LPNMLVKEYDOWN lpkd=(LPNMLVKEYDOWN)pNMHDR; + if (lpkd->wVKey == VK_DELETE) + OnRemoveShortcut(); +} + +//////////////////////////////////////////////////////////////////////////// +// deleting shortcut from list +void CFolderDialog::OnRemoveShortcut() +{ + POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); + if (pos) + { + int iSel=m_ctlShortcuts.GetNextSelectedItem(pos); + m_ctlShortcuts.DeleteItem(iSel); + m_bdData.cvShortcuts.erase(m_bdData.cvShortcuts.begin()+iSel, true); + + m_ctlShortcuts.Arrange(LVA_DEFAULT); + } +} + +/////////////////////////////////////////////////////////////////////////// +// finishing editing shortcut name +void CFolderDialog::OnEndLabelEditShortcutList(NMHDR* pNMHDR, LRESULT* pResult) +{ + NMLVDISPINFO* pdi = (NMLVDISPINFO*)pNMHDR; + + // editing has been cancelled - delete item + if (pdi->item.pszText == NULL) + { + m_ctlShortcuts.DeleteItem(pdi->item.iItem); + m_bdData.cvShortcuts.erase(m_bdData.cvShortcuts.begin()+pdi->item.iItem, true); + + *pResult=0; + return; + } + + // std editing - success + CShortcut sc=CString(m_bdData.cvShortcuts.at(pdi->item.iItem)); + sc.m_strName=pdi->item.pszText; + + m_bdData.cvShortcuts.replace(m_bdData.cvShortcuts.begin()+pdi->item.iItem, (const PTSTR)(LPCTSTR)(CString)sc, true, true); + + *pResult=1; +} + +//////////////////////////////////////////////////////////////////////////// +// sets the style of a shortcuts list +void CFolderDialog::SetView(int iView) +{ + DWORD dwView=0; + switch (iView) + { + case 0: + dwView=LVS_ICON; + break; + case 2: + dwView=LVS_SMALLICON; + break; + case 3: + dwView=LVS_REPORT; + break; + default: + dwView=LVS_LIST; + break; + } + + DWORD dwStyle = GetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_STYLE); + + // Only set the window style if the view bits have changed. + if ((dwStyle & LVS_TYPEMASK) != dwView) + SetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_STYLE, (dwStyle & ~LVS_TYPEMASK) | dwView); + m_ctlShortcuts.Arrange(LVA_ALIGNTOP); +} + +/////////////////////////////////////////////////////////////////////////// +// large icons +void CFolderDialog::OnIconsRadio() +{ + m_bdData.iView=0; + SetView(0); + m_ctlLargeIcons.Invalidate(); + m_ctlSmallIcons.Invalidate(); + m_ctlList.Invalidate(); + m_ctlReport.Invalidate(); +} + +/////////////////////////////////////////////////////////////////////////// +// small icons +void CFolderDialog::OnSmalliconsRadio() +{ + m_bdData.iView=1; + SetView(1); + m_ctlLargeIcons.Invalidate(); + m_ctlSmallIcons.Invalidate(); + m_ctlList.Invalidate(); + m_ctlReport.Invalidate(); +} + +/////////////////////////////////////////////////////////////////////////// +// list button +void CFolderDialog::OnListRadio() +{ + m_bdData.iView=2; + SetView(2); + m_ctlLargeIcons.Invalidate(); + m_ctlSmallIcons.Invalidate(); + m_ctlList.Invalidate(); + m_ctlReport.Invalidate(); +} + +/////////////////////////////////////////////////////////////////////////// +// report button +void CFolderDialog::OnReportRadio() +{ + m_bdData.iView=3; + SetView(3); + m_ctlLargeIcons.Invalidate(); + m_ctlSmallIcons.Invalidate(); + m_ctlList.Invalidate(); + m_ctlReport.Invalidate(); +} + +//////////////////////////////////////////////////////////////////////////// +// resize handling +void CFolderDialog::OnSize(UINT nType, int cx, int cy) +{ + CHLanguageDialog::OnSize(nType, cx, cy); + + ResizeControls(cx, cy); + InvalidateRect(&m_rcGripper); +} + +//////////////////////////////////////////////////////////////////////////// +// repositions controls within the dialog +void CFolderDialog::ResizeControls(int cx, int cy) +{ + // is app themed ? + CUxThemeSupport uxt; + bool bThemed=uxt.IsThemeSupported() && uxt.IsAppThemed(); + + // settings + const int iMargin=7; // dialog units + const int iTextCount=3; // ilo�� linii textu w staticu + + // small buttons + const int iBmpMargin=1; // margin between button and a bitmap within + const int iButtonWidth=(bThemed ? 20 : 16)+2*GetSystemMetrics(SM_CXEDGE)+2*iBmpMargin; // fixed size + const int iButtonHeight=(bThemed ? 20 : 16)+2*GetSystemMetrics(SM_CYEDGE)+2*iBmpMargin; + + // large buttons + const int iLargeButtonHeight=14; // OK&Cancel buttons (dialog units) + const int iLargeButtonWidth=50; // width in DU + const int iToggleButtonWidth=18; // toggle size + + // combo + const int iComboHeight=12; + const int iComboExpandedHeight=100; + + // static text at the top of dialog + CRect rcStatic( iMargin, iMargin, 0, iMargin+iTextCount*8 ); + MapDialogRect(&rcStatic); + rcStatic.right=cx-rcStatic.left; + + CWnd* pWnd=GetDlgItem(IDC_TITLE_STATIC); + if (pWnd) + { + pWnd->MoveWindow(&rcStatic); + pWnd->Invalidate(); + } + + // 4*button (**********) + CRect rcButton(iMargin, iMargin+iTextCount*8+5, 0, 0); + MapDialogRect(&rcButton); + rcButton.right=rcButton.left+iButtonWidth; + rcButton.bottom=rcButton.top+iButtonHeight; + pWnd=GetDlgItem(IDC_LARGEICONS_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + rcButton.left+=iButtonWidth; + rcButton.right+=iButtonWidth; + pWnd=GetDlgItem(IDC_SMALLICONS_BUTTON); + if (pWnd) + pWnd->MoveWindow(&rcButton); + + rcButton.left+=iButtonWidth; + rcButton.right+=iButtonWidth; + pWnd=GetDlgItem(IDC_LIST_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + rcButton.left+=iButtonWidth; + rcButton.right+=iButtonWidth; + pWnd=GetDlgItem(IDC_REPORT_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + // new folder button + rcButton=CRect(iMargin, iMargin+iTextCount*8+5, iMargin, 0); + MapDialogRect(&rcButton); + rcButton.left=cx-rcButton.left-iButtonWidth-1; // off by 1 - better looks + rcButton.right=cx-rcButton.right-1; + rcButton.bottom=rcButton.top+iButtonHeight; + pWnd=GetDlgItem(IDC_NEWFOLDER_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + // shortcuts list (**********) + CRect rcShortcuts(iMargin, iMargin+iTextCount*8+5+1, 2*iMargin+5, iMargin+iLargeButtonHeight+5+iComboHeight+3); + MapDialogRect(&rcShortcuts); + rcShortcuts.top+=iButtonHeight; // small button size + rcShortcuts.right=MulDiv((cx-rcShortcuts.right), 35, 120); + rcShortcuts.bottom=cy-rcShortcuts.bottom; + pWnd=GetDlgItem(IDC_SHORTCUT_LIST); + if (pWnd) + { + pWnd->MoveWindow(&rcShortcuts); + pWnd->Invalidate(); + } + + // button toggle + rcButton=CRect(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iTextCount*8+5, iToggleButtonWidth, iLargeButtonHeight); + MapDialogRect(&rcButton); + if (m_bdData.bExtended) + rcButton.left+=rcShortcuts.Width()+1; + rcButton.right+=rcButton.left; + rcButton.bottom+=rcButton.top; + pWnd=GetDlgItem(IDC_TOGGLE_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + // tree ctrl + CRect rcTree(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iTextCount*8+5+1, iMargin, iMargin+iLargeButtonHeight+5+iComboHeight+3 ); + MapDialogRect(&rcTree); + rcTree.top+=iButtonHeight; + rcTree.bottom=cy-rcTree.bottom; + rcTree.right=cx-rcTree.right; + if (m_bdData.bExtended) + rcTree.left+=rcShortcuts.Width(); + pWnd=GetDlgItem(IDC_FOLDER_TREE); + if (pWnd) + { + pWnd->MoveWindow(&rcTree); + pWnd->Invalidate(); + } + + // combo + CRect rcCombo(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iLargeButtonHeight+5+iComboHeight, iMargin, iComboExpandedHeight/*iMargin+iLargeButtonHeight+5*/); + MapDialogRect(&rcCombo); + if (m_bdData.bExtended) + rcCombo.left+=rcShortcuts.Width(); + rcCombo.top=cy-rcCombo.top; + rcCombo.right=cx-rcCombo.right; + rcCombo.bottom+=rcCombo.top; + pWnd=GetDlgItem(IDC_PATH_COMBOBOXEX); + if (pWnd) + { + pWnd->MoveWindow(&rcCombo); + pWnd->Invalidate(); + } + + // button - add shortcut/remove shortcut + rcButton=CRect(0, iMargin+iLargeButtonHeight+5+iComboHeight, 0, 0); + MapDialogRect(&rcButton); + rcButton.top=cy-rcButton.top; + rcButton.left=rcShortcuts.right-iButtonWidth; + rcButton.right=rcButton.left+iButtonWidth; + rcButton.bottom=rcButton.top+iButtonHeight; + pWnd=GetDlgItem(IDC_ADDSHORTCUT_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + rcButton.left-=iButtonWidth; + rcButton.right-=iButtonWidth; + pWnd=GetDlgItem(IDC_REMOVESHORTCUT_BUTTON); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + // buttony - ok & cancel + rcButton=CRect(iMargin+2*iLargeButtonWidth+3, iMargin+iLargeButtonHeight, iMargin+iLargeButtonWidth+3, iMargin); + MapDialogRect(&rcButton); + rcButton.left=cx-rcButton.left; + rcButton.top=cy-rcButton.top; + rcButton.right=cx-rcButton.right; + rcButton.bottom=cy-rcButton.bottom; + pWnd=GetDlgItem(IDOK); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } + + rcButton=CRect(iMargin+iLargeButtonWidth, iMargin+iLargeButtonHeight, iMargin, iMargin); + MapDialogRect(&rcButton); + rcButton.left=cx-rcButton.left; + rcButton.top=cy-rcButton.top; + rcButton.right=cx-rcButton.right; + rcButton.bottom=cy-rcButton.bottom; + pWnd=GetDlgItem(IDCANCEL); + if (pWnd) + { + pWnd->MoveWindow(&rcButton); + pWnd->Invalidate(); + } +} + +/////////////////////////////////////////////////////////////////////////// +// minimum size of a window +void CFolderDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) +{ + CRect rcMin(0, 0, 200, 160); + MapDialogRect(&rcMin); + lpMMI->ptMinTrackSize=rcMin.BottomRight(); +} + +///////////////////////////////////////////////////////////////////////////// +// paints a gripper +void CFolderDialog::OnPaint() +{ + if (!IsZoomed()) + { + CPaintDC dc(this); // device context for painting + + CRect rc; + GetClientRect(rc); + + rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); + rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); + m_rcGripper=rc; + dc.DrawFrameControl(rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); + } + else + { + CPaintDC dc(this); + DefWindowProc(WM_PAINT, (WPARAM)dc.GetSafeHdc(), 0); + } +} + +//////////////////////////////////////////////////////////////////////////// +// hit testing in a gripper cause +UINT CFolderDialog::OnNcHitTest(CPoint point) +{ + UINT uiRes=CHLanguageDialog::OnNcHitTest(point); + if (uiRes == HTCLIENT) + { + CRect rc; + GetWindowRect(&rc); + rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); + rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); + if (rc.PtInRect(point)) + uiRes = HTBOTTOMRIGHT; + } + + return uiRes; +} + +//////////////////////////////////////////////////////////////////////////// +// returns combo's path after dialog finishes +void CFolderDialog::GetPath(LPTSTR pszPath) +{ + _tcscpy(pszPath, m_strPath); +} + +//////////////////////////////////////////////////////////////////////////// +// returns combo's path after dialog finishes +void CFolderDialog::GetPath(CString &rstrPath) +{ + rstrPath=m_strPath; +} + +//////////////////////////////////////////////////////////////////////////// +// opens choose folder dialog +int BrowseForFolder(CFolderDialog::BROWSEDATA* pData, LPTSTR pszPath) +{ + ASSERT(pData); + ASSERT(pszPath); + CFolderDialog dlg; + dlg.m_bdData=*pData; + + int iResult=dlg.DoModal(); + if (iResult == IDOK) + { + dlg.GetPath(pszPath); // returned path + *pData=dlg.m_bdData; // future + } + else + _tcscpy(pszPath, _T("")); + + return iResult; +} Index: ch/FolderDialog.cpp =================================================================== diff -u -N --- ch/FolderDialog.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FolderDialog.cpp (revision 0) @@ -1,1295 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" -#include "DirTreeCtrl.h" -#include "FolderDialog.h" -#include "memdc.h" -#include "Theme Helpers.h" -#include "shlobj.h" -#include "..\Common\FileSupport.h" -#include "StringHelpers.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -// dialog jako taki -const unsigned long __g_DlgTemplate[]={ - 0x82cf0040, 0x00000000, 0x00000000, 0x011b0000, 0x000000b4, 0x00000000, 0x00540008, 0x00680061, - 0x006d006f, 0x00000061 }; - -///////////////////////////////////////////////////////////////////////////// -// additional messages -#ifndef WM_THEMECHANGED -#define WM_THEMECHANGED 0x031A -#endif - -///////////////////////////////////////////////////////////////////////////// -// widow procedures - group subclassing for flicker free drawing -WNDPROC __g_pfButton; -WNDPROC __g_pfStatic; -WNDPROC __g_pfList; -WNDPROC __g_pfCombo; -WNDPROC __g_pfBaseCombo; -WNDPROC __g_pfEdit; - -///////////////////////////////////////////////////////////////////////////// -// Draws and calls the old window proc -LRESULT CALLBACK InternalWindowProc(WNDPROC pfWndProc, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_ERASEBKGND: - return (LRESULT)0; - break; - case WM_PAINT: - CWnd* pWnd=CWnd::FromHandle(hwnd); - CPaintDC dc(pWnd); - - // exclude header from update rect (only in report view) - int iID=GetDlgCtrlID(hwnd); - if (iID == IDC_SHORTCUT_LIST) - { - DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE); - if ((dwStyle & LVS_TYPEMASK) == LVS_REPORT) - { - CRect headerRect; - HWND hHeader=ListView_GetHeader(hwnd); - GetWindowRect(hHeader, &headerRect); - CPoint pt=headerRect.TopLeft(); - ScreenToClient(hwnd, &pt); - headerRect.left=pt.x; - headerRect.top=pt.y; - pt=headerRect.BottomRight(); - ScreenToClient(hwnd, &pt); - headerRect.right=pt.x; - headerRect.bottom=pt.y; - dc.ExcludeClipRect(&headerRect); - } - } - - CMemDC memdc(&dc, &dc.m_ps.rcPaint); - - if (dc.m_ps.fErase) - memdc.FillSolidRect(&dc.m_ps.rcPaint, GetSysColor(COLOR_WINDOW)); - - CallWindowProc(pfWndProc, hwnd, WM_PAINT, (WPARAM)memdc.GetSafeHdc(), 0); - return 0; - break; - } - - return CallWindowProc(pfWndProc, hwnd, uMsg, wParam, lParam); -} - -//////////////////////////////////////////////////////////////////////////// -// window proc for edit ctrl contained in combo -LRESULT CALLBACK EditWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - return InternalWindowProc(__g_pfEdit, hwnd, uMsg, wParam, lParam); -}; - -//////////////////////////////////////////////////////////////////////////// -// procedure for combo box contained in comboboxex -LRESULT CALLBACK ComboWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - return InternalWindowProc(__g_pfBaseCombo, hwnd, uMsg, wParam, lParam); -}; - -//////////////////////////////////////////////////////////////////////////// -// other visual elements' window proc -LRESULT CALLBACK CustomWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - int iID=GetDlgCtrlID(hwnd); - WNDPROC pfOld=NULL; - switch(iID) - { - case IDC_TOGGLE_BUTTON: - case IDOK: - case IDCANCEL: - pfOld=__g_pfButton; - break; - case IDC_TITLE_STATIC: - pfOld=__g_pfStatic; - break; - case IDC_PATH_COMBOBOXEX: - pfOld=__g_pfCombo; - break; - case IDC_SHORTCUT_LIST: - pfOld=__g_pfList; - break; - default: - ASSERT(false); // used CustomWindowProc, but no ID has been recognized - } - - return InternalWindowProc(pfOld, hwnd, uMsg, wParam, lParam); -} - -///////////////////////////////////////////////////////////////////////////// -// CFolderDialog dialog - -CFolderDialog::CFolderDialog(CWnd* /*pParent*/ /*=NULL*/) - : CHLanguageDialog() -{ - //{{AFX_DATA_INIT(CFolderDialog) - //}}AFX_DATA_INIT - m_hImages=NULL; - m_hLargeImages=NULL; - m_bIgnoreUpdate=false; - m_bIgnoreTreeRefresh=false; -} - -CFolderDialog::~CFolderDialog() -{ -} - -BEGIN_MESSAGE_MAP(CFolderDialog, CHLanguageDialog) - //{{AFX_MSG_MAP(CFolderDialog) - ON_NOTIFY(LVN_ENDLABELEDIT, IDC_SHORTCUT_LIST, OnEndLabelEditShortcutList) - ON_BN_CLICKED(IDC_ADDSHORTCUT_BUTTON, OnAddShortcut) - ON_BN_CLICKED(IDC_REMOVESHORTCUT_BUTTON, OnRemoveShortcut) - ON_BN_CLICKED(IDC_TOGGLE_BUTTON, OnToggleButton) - ON_NOTIFY(TVN_SELCHANGED, IDC_FOLDER_TREE, OnSelchangedFolderTree) - ON_NOTIFY(TVN_GETINFOTIP, IDC_FOLDER_TREE, OnGetInfoTipFolderTree) - ON_BN_CLICKED(IDC_NEWFOLDER_BUTTON, OnNewfolderButton) - ON_CBN_EDITCHANGE(IDC_PATH_COMBOBOXEX, OnPathChanging) - ON_BN_CLICKED(IDC_LARGEICONS_BUTTON, OnIconsRadio) - ON_BN_CLICKED(IDC_SMALLICONS_BUTTON, OnSmalliconsRadio) - ON_BN_CLICKED(IDC_LIST_BUTTON, OnListRadio) - ON_BN_CLICKED(IDC_REPORT_BUTTON, OnReportRadio) - ON_NOTIFY(LVN_ITEMCHANGED, IDC_SHORTCUT_LIST, OnItemchangedShortcutList) - ON_NOTIFY(LVN_GETINFOTIP, IDC_SHORTCUT_LIST, OnGetShortcutInfoTip) - ON_NOTIFY(LVN_KEYDOWN, IDC_SHORTCUT_LIST, OnShortcutKeyDown) - ON_WM_PAINT() - ON_WM_NCHITTEST() - ON_WM_SIZE() - ON_WM_GETMINMAXINFO() - ON_WM_SYSCOLORCHANGE() - ON_WM_CREATE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFolderDialog message handlers - -///////////////////////////////////////////////////////////////////////////// -// creating all needed controls - -int CFolderDialog::CreateControls() -{ - // std rect - size doesn't matter for now - CRect rc(0, 0, 0, 0); - - if (!m_ctlTitle.Create(_T(""), WS_CHILD | WS_VISIBLE, rc, this, IDC_TITLE_STATIC) || - (__g_pfStatic=(WNDPROC)SetWindowLong(m_ctlTitle.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlTitle.SetFont(GetFont()); - - // buttons - small with bitmaps - if (!m_ctlLargeIcons.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_LARGEICONS_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlLargeIcons.SetImage(&m_ilList, 0); - - if (!m_ctlSmallIcons.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_SMALLICONS_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlSmallIcons.SetImage(&m_ilList, 1); - - if (!m_ctlList.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_LIST_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlList.SetImage(&m_ilList, 2); - - if (!m_ctlReport.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_REPORT_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlReport.SetImage(&m_ilList, 3); - - if (!m_ctlNewFolder.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_NEWFOLDER_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlNewFolder.SetImage(&m_ilList, 4); - - // listview - if (!m_ctlShortcuts.Create(WS_CHILD | WS_VISIBLE | LVS_SINGLESEL | LVS_SHAREIMAGELISTS | LVS_EDITLABELS | WS_TABSTOP | LVS_SMALLICON | LVS_SHOWSELALWAYS, rc, this, IDC_SHORTCUT_LIST) || - (__g_pfList=(WNDPROC)SetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlShortcuts.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); - m_ctlShortcuts.ModifyStyleEx(0, WS_EX_CLIENTEDGE); - - // dir tree ctrl - if (!m_ctlTree.Create(WS_CHILD | WS_VISIBLE | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_EDITLABELS - | TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | TVS_TRACKSELECT | TVS_SINGLEEXPAND | TVS_INFOTIP | - WS_TABSTOP | WS_VSCROLL, rc, this, IDC_FOLDER_TREE) - || !m_ctlTree.ModifyStyleEx(0, WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE)) - { - TRACE("Error creating control..."); - return -1; - } - - // combobox - rc.bottom=rc.top+200; - if (!m_ctlPath.Create(WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_DROPDOWN | CBS_SORT | CBS_OWNERDRAWFIXED | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rc, this, IDC_PATH_COMBOBOXEX) || - (__g_pfCombo=(WNDPROC)SetWindowLong(m_ctlPath.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) - { - TRACE("Error creating control..."); - return -1; - } - HWND hCombo=(HWND)m_ctlPath.SendMessage(CBEM_GETCOMBOCONTROL, 0, 0); - if ((__g_pfBaseCombo=(WNDPROC)SetWindowLong(hCombo, GWL_WNDPROC, (LONG)ComboWindowProc)) == 0) - return -1; - HWND hEdit=(HWND)m_ctlPath.SendMessage(CBEM_GETEDITCONTROL, 0, 0); - if ((__g_pfEdit=(WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (LONG)EditWindowProc)) == 0) - return -1; - - // buttons OK & Cancel - rc.bottom=rc.top; - if (!m_ctlOk.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, rc, this, IDOK) || - (__g_pfButton=(WNDPROC)SetWindowLong(m_ctlOk.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc)) == 0) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlOk.SetFont(GetFont()); - - if (!m_ctlCancel.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rc, this, IDCANCEL) || - !((WNDPROC)SetWindowLong(m_ctlCancel.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc))) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlCancel.SetFont(GetFont()); - - if (!m_ctlToggle.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, rc, this, IDC_TOGGLE_BUTTON) || - !((WNDPROC)SetWindowLong(m_ctlToggle.GetSafeHwnd(), GWL_WNDPROC, (LONG)CustomWindowProc))) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlToggle.SetFont(GetFont()); - - // add&remove shortcut - if (!m_ctlRemoveShortcut.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_REMOVESHORTCUT_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlRemoveShortcut.SetImage(&m_ilList, 6); - - if (!m_ctlAddShortcut.Create(_T(""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, rc, this, IDC_ADDSHORTCUT_BUTTON)) - { - TRACE("Error creating control..."); - return -1; - } - m_ctlAddShortcut.SetImage(&m_ilList, 5); - - return 0; -} - -/////////////////////////////////////////////////////////////////////////// -// tworzy image list� z wszystkimi potrzebnymi ikonami -void CFolderDialog::InitImageList() -{ - m_ilList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 1); - - HICON hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_LARGEICONS_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_SMALLICONS_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_LIST_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_REPORT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_NEWFOLDER_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_ADDSHORTCUT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); - - hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDI_DELETESHORTCUT_ICON), IMAGE_ICON, 16, 16, LR_VGACOLOR); - m_ilList.Add(hIcon); -} - -//////////////////////////////////////////////////////////////////////////// -// applies showing/hiding shortcuts list -void CFolderDialog::ApplyExpandState(bool bExpand) -{ - // change button text and hide/show needed elements - m_ctlToggle.SetWindowText(GetResManager()->LoadString(bExpand ? IDS_BDRIGHT_STRING : IDS_BDLEFT_STRING)); - m_ctlShortcuts.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlLargeIcons.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlSmallIcons.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlList.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlReport.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlAddShortcut.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); - m_ctlRemoveShortcut.ShowWindow(bExpand ? SW_SHOW : SW_HIDE); -} - -//////////////////////////////////////////////////////////////////////////// -// toggle extended view -void CFolderDialog::OnToggleButton() -{ - m_bdData.bExtended=!m_bdData.bExtended; - ApplyExpandState(m_bdData.bExtended); - - CRect rcDialog; - GetClientRect(&rcDialog); - ResizeControls(rcDialog.Width(), rcDialog.Height()); -} - -///////////////////////////////////////////////////////////////////////////// -// initialization of most important params - reading text, bitmaps -BOOL CFolderDialog::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // image list - InitImageList(); - - if (CreateControls() == -1) - EndDialog(-1); - - // size of a dialog - CRect rcDialog; - GetClientRect(&rcDialog); - if (m_bdData.cx != 0) - rcDialog.right=rcDialog.left+m_bdData.cx; - if (m_bdData.cy != 0) - rcDialog.bottom=rcDialog.top+m_bdData.cy; - if (m_bdData.cy != 0 || m_bdData.cx != 0) - SetWindowPos(&wndTop, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOMOVE); - - // show needed text - SetWindowText(m_bdData.strCaption); - m_ctlTitle.SetWindowText(m_bdData.strText); - m_ctlTree.SetIgnoreShellDialogs(m_bdData.bIgnoreDialogs); - m_ctlTree.PostMessage(WM_SETPATH, 0, (LPARAM)((LPCTSTR)m_bdData.strInitialDir)); - - // buttons text - m_ctlOk.SetWindowText(GetResManager()->LoadString(IDS_BDOK_STRING)); - m_ctlCancel.SetWindowText(GetResManager()->LoadString(IDS_BDCANCEL_STRING)); - ApplyExpandState(m_bdData.bExtended); - - // sys img list - SHFILEINFO sfi; - m_hImages = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - m_hLargeImages=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX); - m_ctlPath.SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)m_hImages); - m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_hImages); - m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hLargeImages); - - // add all the paths from m_bdData.astrRecent - COMBOBOXEXITEM cbi; - CString strText; - cbi.mask=CBEIF_IMAGE | CBEIF_TEXT; - - for (int i=0;i<(int)m_bdData.cvRecent.size();i++) - { - cbi.iItem=i; - cbi.pszText=m_bdData.cvRecent.at(i); - sfi.iIcon=-1; - SHGetFileInfo(m_bdData.cvRecent.at(i), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - cbi.iImage=sfi.iIcon; - - m_ctlPath.InsertItem(&cbi); - } - - // additional columns in a list - LVCOLUMN lvc; - lvc.mask=LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT; - lvc.iSubItem=-1; - lvc.cx=80; - lvc.pszText=(LPTSTR)GetResManager()->LoadString(IDS_BDNAME_STRING); - m_ctlShortcuts.InsertColumn(0, &lvc); - lvc.iSubItem=0; - lvc.cx=110; - lvc.pszText=(LPTSTR)GetResManager()->LoadString(IDS_BDPATH_STRING); - m_ctlShortcuts.InsertColumn(1, &lvc); - - // select view-style button - SetView(m_bdData.iView); - - // update shortcuts' list - CShortcut sc; - for (i=0;i<(int)m_bdData.cvShortcuts.size();i++) - { - sc=CString(m_bdData.cvShortcuts.at(i)); - sfi.iIcon=-1; - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.InsertItem(i, sc.m_strName, sfi.iIcon); - m_ctlShortcuts.SetItem(i, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - } - - // now resize and ok. - GetClientRect(&rcDialog); - ResizeControls(rcDialog.Width(), rcDialog.Height()); - - // set to top - the strange way - SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - SetFocus(); - SetForegroundWindow(); - - return TRUE; -} - -//////////////////////////////////////////////////////////////////////////// -// tooltip handling for controls in this dialog -BOOL CFolderDialog::OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip) -{ - switch (uiID) - { - case IDC_NEWFOLDER_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDNEWFOLDER_STRING); - break; - case IDC_LARGEICONS_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDLARGEICONS_STRING); - break; - case IDC_SMALLICONS_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDSMALLICONS_STRING); - break; - case IDC_LIST_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDLIST_STRING); - break; - case IDC_REPORT_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDREPORT_STRING); - break; - case IDC_TOGGLE_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDDETAILS_STRING); - break; - case IDC_ADDSHORTCUT_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDADDSHORTCUT_STRING); - break; - case IDC_REMOVESHORTCUT_BUTTON: - pTip->lpszText=(LPTSTR)GetResManager()->LoadString(IDS_BDREMOVESHORTCUT_STRING); - break; - default: - return FALSE; - } - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// cancels the dialog or cancels editing of an item -void CFolderDialog::OnCancel() -{ - if (m_ctlTree.IsEditing()) - { - TreeView_EndEditLabelNow(m_ctlTree.GetSafeHwnd(), TRUE); - return; - } - - CRect rcDlg; - GetWindowRect(&rcDlg); - m_bdData.cx=rcDlg.Width(); - m_bdData.cy=rcDlg.Height(); - - CHLanguageDialog::OnCancel(); -} - -/////////////////////////////////////////////////////////////////////////// -// finishes dialog's work or finished editing of an item -void CFolderDialog::OnOK() -{ - // if we edit an item in m_ctlTree - if (m_ctlTree.IsEditing()) - { - TreeView_EndEditLabelNow(m_ctlTree.GetSafeHwnd(), FALSE); - return; - } - - // update path, get rid of '\\' - m_ctlPath.GetWindowText(m_strPath); - if (m_strPath.Right(1) == _T('\\') || m_strPath.Right(1) == _T('/')) - m_strPath=m_strPath.Left(m_strPath.GetLength()-1); - - // does it exist as a folder ? -/* CFileFind fnd; - BOOL bExist=fnd.FindFile(m_strPath+_T("\\*")); - fnd.Close();*/ -// WIN32_FIND_DATA wfd; -// HANDLE hFind; - -// if (!bExist) - if ( GetFileAttributes(m_strPath) == INVALID_FILE_ATTRIBUTES) - { - MsgBox(IDS_BDPATHDOESNTEXIST_STRING, MB_OK | MB_ICONERROR); - return; - } - - m_bdData.cvRecent.insert(m_bdData.cvRecent.begin(), (const PTSTR)(LPCTSTR)(m_strPath+_T('\\')), true); - - CRect rcDlg; - GetWindowRect(&rcDlg); - m_bdData.cx=rcDlg.Width(); - m_bdData.cy=rcDlg.Height(); - - CHLanguageDialog::OnOK(); -} - -/////////////////////////////////////////////////////////////////////////// -// Displays dialog from __g_DlgTemplate -int CFolderDialog::DoModal() -{ - if (!InitModalIndirect((LPCDLGTEMPLATE)__g_DlgTemplate)) - return -1; - else - return CHLanguageDialog::DoModal(); -} - -/////////////////////////////////////////////////////////////////////////// -// handles creation of a new folder -void CFolderDialog::OnNewfolderButton() -{ - // currently selected item - HTREEITEM hItem=m_ctlTree.GetSelectedItem(); - if (hItem == NULL) - return; - - // insert child item - m_ctlTree.InsertNewFolder(hItem, _T("")); -} - -///////////////////////////////////////////////////////////////////////////// -// other messages -LRESULT CFolderDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_CREATEFOLDERRESULT: - if (((int)lParam) != 1) - MsgBox(IDS_BDCANNOTCREATEFOLDER_STRING); - break; - case WM_THEMECHANGED: - CRect rcDialog; - GetClientRect(&rcDialog); - ResizeControls(rcDialog.Width(), rcDialog.Height()); - break; - } - - return CHLanguageDialog::WindowProc(message, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// -// tooltips for folder tree -void CFolderDialog::OnGetInfoTipFolderTree(NMHDR* pNMHDR, LRESULT* pResult) -{ - NMTVGETINFOTIP* pit = (NMTVGETINFOTIP*)pNMHDR; - *pResult = 0; - - // get rid of old tip - m_strTip.Empty(); - - // get type of an item - for floppy skip - SHDESCRIPTIONID shdi; - bool bSkipFreeSpace=false; - if (m_ctlTree.GetItemShellData(pit->hItem, SHGDFIL_DESCRIPTIONID, &shdi, sizeof(SHDESCRIPTIONID)) - && ( shdi.dwDescriptionId == SHDID_COMPUTER_DRIVE35 - || shdi.dwDescriptionId == SHDID_COMPUTER_DRIVE525 ) ) - bSkipFreeSpace=true; - - - // some about network - bool bNet; - CString strData; - NETRESOURCE* pnet=(NETRESOURCE*)m_szBuffer; - if ( (bNet=m_ctlTree.GetItemShellData(pit->hItem, SHGDFIL_NETRESOURCE, pnet, 2048)) == true) - { - if (pnet->lpRemoteName && _tcscmp(pnet->lpRemoteName, _T("")) != 0) - m_strTip+=GetResManager()->LoadString(IDS_BDREMOTENAME_STRING)+CString(pnet->lpRemoteName)+_T("\n"); - if ( pnet->lpLocalName && _tcscmp(pnet->lpLocalName, _T("")) != 0) - m_strTip+=GetResManager()->LoadString(IDS_BDLOCALNAME_STRING)+CString(pnet->lpLocalName)+_T("\n"); - if ( pnet->dwDisplayType != 0) - m_strTip+=GetResManager()->LoadString(IDS_BDTYPE_STRING)+CString(GetResManager()->LoadString(IDS_BDDOMAIN_STRING+pnet->dwDisplayType))+_T("\n"); - if ( pnet->lpProvider && _tcscmp(pnet->lpProvider, _T("")) != 0) - m_strTip+=GetResManager()->LoadString(IDS_BDNETTYPE_STRING)+CString(pnet->lpProvider)+_T("\n"); - if ( pnet->lpComment && _tcscmp(pnet->lpComment, _T("")) != 0) - m_strTip+=GetResManager()->LoadString(IDS_BDDESCRIPTION_STRING)+CString(pnet->lpComment)+_T("\n"); - } - - // try to get path - CString strPath, strMask; - TCHAR szSizeFree[32], szSizeTotal[32]; - bool bPath; - if ( (bPath=m_ctlTree.GetPath(pit->hItem, strPath.GetBuffer(_MAX_PATH))) == true ) - { - strPath.ReleaseBuffer(); - if (!bNet && !strPath.IsEmpty()) - m_strTip+=strPath+_T("\n"); - - if (!bSkipFreeSpace) - { - // get disk free space - __int64 llFree, llTotal; - if (GetDynamicFreeSpace(strPath, &llFree, &llTotal)) - { - m_strTip+=GetResManager()->LoadString(IDS_BDFREESPACE_STRING)+CString(GetSizeString(llFree, szSizeFree, false))+_T("\n"); - m_strTip+=GetResManager()->LoadString(IDS_BDCAPACITY_STRING)+CString(GetSizeString(llTotal, szSizeTotal, false))+_T("\n"); - } - } - } - - if (!bNet && !bPath) - { - // get std shell msg - m_ctlTree.GetItemInfoTip(pit->hItem, &m_strTip); - } - else - { - // get rid of '\n' - m_strTip=m_strTip.Left(m_strTip.GetLength()-1); - } - - // set - pit->pszText=m_strTip.GetBuffer(1); // tip doesn't change - skip RelaseBuffer - pit->cchTextMax=lstrlen(pit->pszText); -} - -///////////////////////////////////////////////////////////////////////////// -// tooltip support for shortcuts list -void CFolderDialog::OnGetShortcutInfoTip(NMHDR* pNMHDR, LRESULT* /*pResult*/) -{ - NMLVGETINFOTIP* pit=(NMLVGETINFOTIP*)pNMHDR; - m_strTip.Empty(); - - if (pit->iItem < 0 || pit->iItem >= (int)m_bdData.cvShortcuts.size()) - return; // out of range - - CShortcut sc=CString(m_bdData.cvShortcuts.at(pit->iItem)); - m_strTip=sc.m_strName+_T("\r\n")+CString(GetResManager()->LoadString(IDS_BDPATH2_STRING))+sc.m_strPath; - - // get disk free space - __int64 llFree, llTotal; - if (GetDynamicFreeSpace(sc.m_strPath, &llFree, &llTotal)) - { - m_strTip+=CString(_T("\r\n"))+GetResManager()->LoadString(IDS_BDFREESPACE_STRING)+CString(GetSizeString(llFree, m_szBuffer, false))+_T("\n"); - m_strTip+=GetResManager()->LoadString(IDS_BDCAPACITY_STRING)+CString(GetSizeString(llTotal, m_szBuffer, false)); - } - - pit->pszText=(LPTSTR)(LPCTSTR)m_strTip; - pit->cchTextMax=m_strTip.GetLength()+1; -} - -//////////////////////////////////////////////////////////////////////////// -// updates text in combo when the selection in a tree changes -void CFolderDialog::OnSelchangedFolderTree(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; - TCHAR szPath[_MAX_PATH]; - - if (m_bIgnoreUpdate) - return; - - if (m_ctlTree.GetPath(pNMTreeView->itemNew.hItem, szPath)) - SetComboPath(szPath); - - *pResult = 0; -} - -//////////////////////////////////////////////////////////////////////////// -// updates folder tree when combo text changes -void CFolderDialog::OnPathChanging() -{ - if (m_bIgnoreTreeRefresh) - return; - - COMBOBOXEXITEM cbi; - cbi.mask=CBEIF_TEXT; - cbi.iItem=-1; - cbi.pszText=m_szBuffer; - cbi.cchTextMax=_MAX_PATH; - - if (!m_ctlPath.GetItem(&cbi)) - return; - - UpdateComboIcon(); - - m_bIgnoreUpdate=true; - m_ctlTree.SetPath(cbi.pszText); - m_bIgnoreUpdate=false; -} - -///////////////////////////////////////////////////////////////////////// -// sets text in comboboxex edit and updates icon -void CFolderDialog::SetComboPath(LPCTSTR lpszPath) -{ - // set current select to -1 - m_bIgnoreTreeRefresh=true; - m_ctlPath.SetCurSel(-1); - m_bIgnoreTreeRefresh=false; - - SHFILEINFO sfi; - sfi.iIcon=-1; - - COMBOBOXEXITEM cbi; - - cbi.mask=CBEIF_TEXT | CBEIF_IMAGE; - cbi.iItem=-1; - _tcscpy(m_szBuffer, lpszPath); - cbi.pszText=m_szBuffer; - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - cbi.iImage=sfi.iIcon; - m_bIgnoreTreeRefresh=true; - m_ctlPath.SetItem(&cbi); - m_bIgnoreTreeRefresh=false; -} - -////////////////////////////////////////////////////////////////////////// -// updates icon in comboex -void CFolderDialog::UpdateComboIcon() -{ - // get text from combo - COMBOBOXEXITEM cbi; - cbi.mask=CBEIF_TEXT; - cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; - cbi.pszText=m_szBuffer; - cbi.cchTextMax=_MAX_PATH; - - if (!m_ctlPath.GetItem(&cbi)) - return; - - // select no item - m_bIgnoreTreeRefresh=true; - m_ctlPath.SetCurSel(-1); - m_bIgnoreTreeRefresh=false; - - // icon update - SHFILEINFO sfi; - sfi.iIcon=-1; - - cbi.mask |= CBEIF_IMAGE; - cbi.iItem=-1; - - CString str=(LPCTSTR)m_szBuffer; - if (str.Left(2) != _T("\\\\") || str.Find(_T('\\'), 2) != -1) - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - - cbi.iImage=sfi.iIcon; - - m_bIgnoreTreeRefresh=true; - m_ctlPath.SetItem(&cbi); - m_bIgnoreTreeRefresh=false; - - // unselect text in combo's edit - CEdit* pEdit=m_ctlPath.GetEditCtrl(); - if (!pEdit) - return; - - pEdit->SetSel(-1, -1); -} - -///////////////////////////////////////////////////////////////////////////// -// combo and treeview update -void CFolderDialog::OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult) -{ - NMLISTVIEW* plv=(NMLISTVIEW*)pNMHDR; - - // current selection - if (plv->iItem >= 0 && plv->iItem < (int)m_bdData.cvShortcuts.size()) - { - CShortcut sc=CString(m_bdData.cvShortcuts.at(plv->iItem)); - m_ctlTree.SetPath(sc.m_strPath); - SetComboPath(sc.m_strPath); - } - - *pResult = 0; -} - -///////////////////////////////////////////////////////////////////////////// -// adding shortcut -void CFolderDialog::OnAddShortcut() -{ - // get current text - COMBOBOXEXITEM cbi; - cbi.mask=CBEIF_TEXT; - cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; - cbi.pszText=m_szBuffer; - cbi.cchTextMax=_MAX_PATH; - - if (!m_ctlPath.GetItem(&cbi)) - { - MsgBox(IDS_BDNOSHORTCUTPATH_STRING); - return; - } - - // create new item - update shortcut list - CShortcut sc; - sc.m_strPath=cbi.pszText; - SHFILEINFO sfi; - sfi.iIcon=-1; - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - - // add to an array and to shortcuts list - m_bdData.cvShortcuts.push_back((const PTSTR)(LPCTSTR)(CString)(sc), true); - int iIndex=m_bdData.cvShortcuts.size()-1; - m_ctlShortcuts.InsertItem(iIndex, sc.m_strName, sfi.iIcon); - m_ctlShortcuts.SetItem(iIndex, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - - // edit item - m_ctlShortcuts.SetFocus(); - if (m_ctlShortcuts.EditLabel(iIndex) == NULL) - { - TRACE("Couldn't edit shortcut list's item label\n"); - return; - } -} - -//////////////////////////////////////////////////////////////////////////// -// keyboard's delete button handling -void CFolderDialog::OnShortcutKeyDown(NMHDR* pNMHDR, LRESULT* /*pResult*/) -{ - LPNMLVKEYDOWN lpkd=(LPNMLVKEYDOWN)pNMHDR; - if (lpkd->wVKey == VK_DELETE) - OnRemoveShortcut(); -} - -//////////////////////////////////////////////////////////////////////////// -// deleting shortcut from list -void CFolderDialog::OnRemoveShortcut() -{ - POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); - if (pos) - { - int iSel=m_ctlShortcuts.GetNextSelectedItem(pos); - m_ctlShortcuts.DeleteItem(iSel); - m_bdData.cvShortcuts.erase(m_bdData.cvShortcuts.begin()+iSel, true); - - m_ctlShortcuts.Arrange(LVA_DEFAULT); - } -} - -/////////////////////////////////////////////////////////////////////////// -// finishing editing shortcut name -void CFolderDialog::OnEndLabelEditShortcutList(NMHDR* pNMHDR, LRESULT* pResult) -{ - NMLVDISPINFO* pdi = (NMLVDISPINFO*)pNMHDR; - - // editing has been cancelled - delete item - if (pdi->item.pszText == NULL) - { - m_ctlShortcuts.DeleteItem(pdi->item.iItem); - m_bdData.cvShortcuts.erase(m_bdData.cvShortcuts.begin()+pdi->item.iItem, true); - - *pResult=0; - return; - } - - // std editing - success - CShortcut sc=CString(m_bdData.cvShortcuts.at(pdi->item.iItem)); - sc.m_strName=pdi->item.pszText; - - m_bdData.cvShortcuts.replace(m_bdData.cvShortcuts.begin()+pdi->item.iItem, (const PTSTR)(LPCTSTR)(CString)sc, true, true); - - *pResult=1; -} - -//////////////////////////////////////////////////////////////////////////// -// sets the style of a shortcuts list -void CFolderDialog::SetView(int iView) -{ - DWORD dwView=0; - switch (iView) - { - case 0: - dwView=LVS_ICON; - break; - case 2: - dwView=LVS_SMALLICON; - break; - case 3: - dwView=LVS_REPORT; - break; - default: - dwView=LVS_LIST; - break; - } - - DWORD dwStyle = GetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_STYLE); - - // Only set the window style if the view bits have changed. - if ((dwStyle & LVS_TYPEMASK) != dwView) - SetWindowLong(m_ctlShortcuts.GetSafeHwnd(), GWL_STYLE, (dwStyle & ~LVS_TYPEMASK) | dwView); - m_ctlShortcuts.Arrange(LVA_ALIGNTOP); -} - -/////////////////////////////////////////////////////////////////////////// -// large icons -void CFolderDialog::OnIconsRadio() -{ - m_bdData.iView=0; - SetView(0); - m_ctlLargeIcons.Invalidate(); - m_ctlSmallIcons.Invalidate(); - m_ctlList.Invalidate(); - m_ctlReport.Invalidate(); -} - -/////////////////////////////////////////////////////////////////////////// -// small icons -void CFolderDialog::OnSmalliconsRadio() -{ - m_bdData.iView=1; - SetView(1); - m_ctlLargeIcons.Invalidate(); - m_ctlSmallIcons.Invalidate(); - m_ctlList.Invalidate(); - m_ctlReport.Invalidate(); -} - -/////////////////////////////////////////////////////////////////////////// -// list button -void CFolderDialog::OnListRadio() -{ - m_bdData.iView=2; - SetView(2); - m_ctlLargeIcons.Invalidate(); - m_ctlSmallIcons.Invalidate(); - m_ctlList.Invalidate(); - m_ctlReport.Invalidate(); -} - -/////////////////////////////////////////////////////////////////////////// -// report button -void CFolderDialog::OnReportRadio() -{ - m_bdData.iView=3; - SetView(3); - m_ctlLargeIcons.Invalidate(); - m_ctlSmallIcons.Invalidate(); - m_ctlList.Invalidate(); - m_ctlReport.Invalidate(); -} - -//////////////////////////////////////////////////////////////////////////// -// resize handling -void CFolderDialog::OnSize(UINT nType, int cx, int cy) -{ - CHLanguageDialog::OnSize(nType, cx, cy); - - ResizeControls(cx, cy); - InvalidateRect(&m_rcGripper); -} - -//////////////////////////////////////////////////////////////////////////// -// repositions controls within the dialog -void CFolderDialog::ResizeControls(int cx, int cy) -{ - // is app themed ? - CUxThemeSupport uxt; - bool bThemed=uxt.IsThemeSupported() && uxt.IsAppThemed(); - - // settings - const int iMargin=7; // dialog units - const int iTextCount=3; // ilo�� linii textu w staticu - - // small buttons - const int iBmpMargin=1; // margin between button and a bitmap within - const int iButtonWidth=(bThemed ? 20 : 16)+2*GetSystemMetrics(SM_CXEDGE)+2*iBmpMargin; // fixed size - const int iButtonHeight=(bThemed ? 20 : 16)+2*GetSystemMetrics(SM_CYEDGE)+2*iBmpMargin; - - // large buttons - const int iLargeButtonHeight=14; // OK&Cancel buttons (dialog units) - const int iLargeButtonWidth=50; // width in DU - const int iToggleButtonWidth=18; // toggle size - - // combo - const int iComboHeight=12; - const int iComboExpandedHeight=100; - - // static text at the top of dialog - CRect rcStatic( iMargin, iMargin, 0, iMargin+iTextCount*8 ); - MapDialogRect(&rcStatic); - rcStatic.right=cx-rcStatic.left; - - CWnd* pWnd=GetDlgItem(IDC_TITLE_STATIC); - if (pWnd) - { - pWnd->MoveWindow(&rcStatic); - pWnd->Invalidate(); - } - - // 4*button (**********) - CRect rcButton(iMargin, iMargin+iTextCount*8+5, 0, 0); - MapDialogRect(&rcButton); - rcButton.right=rcButton.left+iButtonWidth; - rcButton.bottom=rcButton.top+iButtonHeight; - pWnd=GetDlgItem(IDC_LARGEICONS_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - rcButton.left+=iButtonWidth; - rcButton.right+=iButtonWidth; - pWnd=GetDlgItem(IDC_SMALLICONS_BUTTON); - if (pWnd) - pWnd->MoveWindow(&rcButton); - - rcButton.left+=iButtonWidth; - rcButton.right+=iButtonWidth; - pWnd=GetDlgItem(IDC_LIST_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - rcButton.left+=iButtonWidth; - rcButton.right+=iButtonWidth; - pWnd=GetDlgItem(IDC_REPORT_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - // new folder button - rcButton=CRect(iMargin, iMargin+iTextCount*8+5, iMargin, 0); - MapDialogRect(&rcButton); - rcButton.left=cx-rcButton.left-iButtonWidth-1; // off by 1 - better looks - rcButton.right=cx-rcButton.right-1; - rcButton.bottom=rcButton.top+iButtonHeight; - pWnd=GetDlgItem(IDC_NEWFOLDER_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - // shortcuts list (**********) - CRect rcShortcuts(iMargin, iMargin+iTextCount*8+5+1, 2*iMargin+5, iMargin+iLargeButtonHeight+5+iComboHeight+3); - MapDialogRect(&rcShortcuts); - rcShortcuts.top+=iButtonHeight; // small button size - rcShortcuts.right=MulDiv((cx-rcShortcuts.right), 35, 120); - rcShortcuts.bottom=cy-rcShortcuts.bottom; - pWnd=GetDlgItem(IDC_SHORTCUT_LIST); - if (pWnd) - { - pWnd->MoveWindow(&rcShortcuts); - pWnd->Invalidate(); - } - - // button toggle - rcButton=CRect(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iTextCount*8+5, iToggleButtonWidth, iLargeButtonHeight); - MapDialogRect(&rcButton); - if (m_bdData.bExtended) - rcButton.left+=rcShortcuts.Width()+1; - rcButton.right+=rcButton.left; - rcButton.bottom+=rcButton.top; - pWnd=GetDlgItem(IDC_TOGGLE_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - // tree ctrl - CRect rcTree(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iTextCount*8+5+1, iMargin, iMargin+iLargeButtonHeight+5+iComboHeight+3 ); - MapDialogRect(&rcTree); - rcTree.top+=iButtonHeight; - rcTree.bottom=cy-rcTree.bottom; - rcTree.right=cx-rcTree.right; - if (m_bdData.bExtended) - rcTree.left+=rcShortcuts.Width(); - pWnd=GetDlgItem(IDC_FOLDER_TREE); - if (pWnd) - { - pWnd->MoveWindow(&rcTree); - pWnd->Invalidate(); - } - - // combo - CRect rcCombo(iMargin+(m_bdData.bExtended ? 5 : 0), iMargin+iLargeButtonHeight+5+iComboHeight, iMargin, iComboExpandedHeight/*iMargin+iLargeButtonHeight+5*/); - MapDialogRect(&rcCombo); - if (m_bdData.bExtended) - rcCombo.left+=rcShortcuts.Width(); - rcCombo.top=cy-rcCombo.top; - rcCombo.right=cx-rcCombo.right; - rcCombo.bottom+=rcCombo.top; - pWnd=GetDlgItem(IDC_PATH_COMBOBOXEX); - if (pWnd) - { - pWnd->MoveWindow(&rcCombo); - pWnd->Invalidate(); - } - - // button - add shortcut/remove shortcut - rcButton=CRect(0, iMargin+iLargeButtonHeight+5+iComboHeight, 0, 0); - MapDialogRect(&rcButton); - rcButton.top=cy-rcButton.top; - rcButton.left=rcShortcuts.right-iButtonWidth; - rcButton.right=rcButton.left+iButtonWidth; - rcButton.bottom=rcButton.top+iButtonHeight; - pWnd=GetDlgItem(IDC_ADDSHORTCUT_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - rcButton.left-=iButtonWidth; - rcButton.right-=iButtonWidth; - pWnd=GetDlgItem(IDC_REMOVESHORTCUT_BUTTON); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - // buttony - ok & cancel - rcButton=CRect(iMargin+2*iLargeButtonWidth+3, iMargin+iLargeButtonHeight, iMargin+iLargeButtonWidth+3, iMargin); - MapDialogRect(&rcButton); - rcButton.left=cx-rcButton.left; - rcButton.top=cy-rcButton.top; - rcButton.right=cx-rcButton.right; - rcButton.bottom=cy-rcButton.bottom; - pWnd=GetDlgItem(IDOK); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } - - rcButton=CRect(iMargin+iLargeButtonWidth, iMargin+iLargeButtonHeight, iMargin, iMargin); - MapDialogRect(&rcButton); - rcButton.left=cx-rcButton.left; - rcButton.top=cy-rcButton.top; - rcButton.right=cx-rcButton.right; - rcButton.bottom=cy-rcButton.bottom; - pWnd=GetDlgItem(IDCANCEL); - if (pWnd) - { - pWnd->MoveWindow(&rcButton); - pWnd->Invalidate(); - } -} - -/////////////////////////////////////////////////////////////////////////// -// minimum size of a window -void CFolderDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) -{ - CRect rcMin(0, 0, 200, 160); - MapDialogRect(&rcMin); - lpMMI->ptMinTrackSize=rcMin.BottomRight(); -} - -///////////////////////////////////////////////////////////////////////////// -// paints a gripper -void CFolderDialog::OnPaint() -{ - if (!IsZoomed()) - { - CPaintDC dc(this); // device context for painting - - CRect rc; - GetClientRect(rc); - - rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); - rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); - m_rcGripper=rc; - dc.DrawFrameControl(rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); - } - else - { - CPaintDC dc(this); - DefWindowProc(WM_PAINT, (WPARAM)dc.GetSafeHdc(), 0); - } -} - -//////////////////////////////////////////////////////////////////////////// -// hit testing in a gripper cause -UINT CFolderDialog::OnNcHitTest(CPoint point) -{ - UINT uiRes=CHLanguageDialog::OnNcHitTest(point); - if (uiRes == HTCLIENT) - { - CRect rc; - GetWindowRect(&rc); - rc.left = rc.right-GetSystemMetrics(SM_CXHSCROLL); - rc.top = rc.bottom-GetSystemMetrics(SM_CYVSCROLL); - if (rc.PtInRect(point)) - uiRes = HTBOTTOMRIGHT; - } - - return uiRes; -} - -//////////////////////////////////////////////////////////////////////////// -// returns combo's path after dialog finishes -void CFolderDialog::GetPath(LPTSTR pszPath) -{ - _tcscpy(pszPath, m_strPath); -} - -//////////////////////////////////////////////////////////////////////////// -// returns combo's path after dialog finishes -void CFolderDialog::GetPath(CString &rstrPath) -{ - rstrPath=m_strPath; -} - -//////////////////////////////////////////////////////////////////////////// -// opens choose folder dialog -int BrowseForFolder(CFolderDialog::BROWSEDATA* pData, LPTSTR pszPath) -{ - ASSERT(pData); - ASSERT(pszPath); - CFolderDialog dlg; - dlg.m_bdData=*pData; - - int iResult=dlg.DoModal(); - if (iResult == IDOK) - { - dlg.GetPath(pszPath); // returned path - *pData=dlg.m_bdData; // future - } - else - _tcscpy(pszPath, _T("")); - - return iResult; -} Index: src/ch/FolderDialog.h =================================================================== diff -u -N --- src/ch/FolderDialog.h (revision 0) +++ src/ch/FolderDialog.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,167 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + CFolderDialog dialog control + + Files: FolderDialog.h, FolderDialog.cpp + Author: Ixen Gerthannes + Usage: + 1. Construct variable of type CFolderDialog + 2. Fill m_bdData member with appropriate information + 3. Call DoModal() + Functions: + void GetPath(CString& rstrPath); - returns chosen path + void GetPath(LPTSTR pszPath); - returns chosen path +*************************************************************************/ +#ifndef __FOLDERDIALOG_H__ +#define __FOLDERDIALOG_H__ + +#include "afxtempl.h" +#include "DirTreeCtrl.h" +#include "ThemedButton.h" +#include "shortcuts.h" +#include "charvect.h" +#include "LanguageDialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CFolderDialog dialog + +class CFolderDialog : public CHLanguageDialog +{ +// Construction +public: + CFolderDialog(CWnd* pParent = NULL); // standard constructor + virtual ~CFolderDialog(); + +// Dialog Data + //{{AFX_DATA(CFolderDialog) + //}}AFX_DATA + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFolderDialog) + public: + virtual int DoModal(); + protected: + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +public: + virtual BOOL OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip); + + // structure used for passing parameters + struct BROWSEDATA + { + BROWSEDATA() { cx=0; cy=0; iView=2; bExtended=false; }; +// BROWSEDATA& operator=(const BROWSEDATA& data) { strCaption=data.strCaption; strText=data.strText; strInitialDir=data.strInitialDir; astrRecent.Copy(data.astrRecent); +// ascShortcuts.Copy(data.ascShortcuts); cx=data.cx; cy=data.cy; iView=data.iView; bExtended=data.bExtended; return *this;}; + + CString strCaption; + CString strText; + CString strInitialDir; + char_vector cvRecent; + char_vector cvShortcuts; + + int cx, cy; // pixels + int iView; // type of view (large icons, small icons, ...) + bool bExtended; // with the shortcuts or not + bool bIgnoreDialogs; // if tree ctrl should show shell dialogs in style 'insert floppy' + } m_bdData; + + // getting path - after dialog exits + void GetPath(CString& rstrPath); + void GetPath(LPTSTR pszPath); + + // function displays dialog with some parameters + friend int BrowseForFolder(BROWSEDATA* pData, LPTSTR pszPath); + +// Implementation +protected: + void InitImageList(); + void ApplyExpandState(bool bExpand); + int CreateControls(); + void SetView(int iView); + void UpdateComboIcon(); + void SetComboPath(LPCTSTR lpszPath); + void ResizeControls(int cx, int cy); + + CString m_strTip; // for tooltip storage + TCHAR m_szBuffer[2048]; // shell functions buffer + CString m_strPath; // for path after dialog exits + + bool m_bIgnoreUpdate; // ignores nearest edit update (with path) + bool m_bIgnoreTreeRefresh; // ignores nearest refreshing of tree ctrl + HIMAGELIST m_hImages, m_hLargeImages; // two system image lists - large and small icons + + // button bitmaps + CImageList m_ilList; // image list with buttons' images + + // last position in which gripper has been drawn + CRect m_rcGripper; + + // controls that'll be diaplyed in a dialog + CStatic m_ctlTitle; + CDirTreeCtrl m_ctlTree; + CComboBoxEx m_ctlPath; + CListCtrl m_ctlShortcuts; + CThemedButton m_ctlLargeIcons; + CThemedButton m_ctlSmallIcons; + CThemedButton m_ctlList; + CThemedButton m_ctlReport; + CThemedButton m_ctlNewFolder; + CButton m_ctlOk; + CButton m_ctlCancel; + CThemedButton m_ctlToggle; + CThemedButton m_ctlAddShortcut; + CThemedButton m_ctlRemoveShortcut; + + + // Generated message map functions + //{{AFX_MSG(CFolderDialog) + afx_msg void OnEndLabelEditShortcutList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnAddShortcut(); + afx_msg void OnRemoveShortcut(); + afx_msg void OnToggleButton(); + afx_msg void OnSelchangedFolderTree(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnGetInfoTipFolderTree(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnShortcutKeyDown(NMHDR* pNMHDR, LRESULT* pResult); + virtual BOOL OnInitDialog(); + afx_msg void OnNewfolderButton(); + virtual void OnCancel(); + virtual void OnOK(); + afx_msg void OnPathChanging(); + afx_msg void OnIconsRadio(); + afx_msg void OnSmalliconsRadio(); + afx_msg void OnListRadio(); + afx_msg void OnReportRadio(); + afx_msg void OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnGetShortcutInfoTip(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnPaint(); + afx_msg UINT OnNcHitTest(CPoint point); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/FolderDialog.h =================================================================== diff -u -N --- ch/FolderDialog.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/FolderDialog.h (revision 0) @@ -1,167 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - CFolderDialog dialog control - - Files: FolderDialog.h, FolderDialog.cpp - Author: Ixen Gerthannes - Usage: - 1. Construct variable of type CFolderDialog - 2. Fill m_bdData member with appropriate information - 3. Call DoModal() - Functions: - void GetPath(CString& rstrPath); - returns chosen path - void GetPath(LPTSTR pszPath); - returns chosen path -*************************************************************************/ -#ifndef __FOLDERDIALOG_H__ -#define __FOLDERDIALOG_H__ - -#include "afxtempl.h" -#include "DirTreeCtrl.h" -#include "ThemedButton.h" -#include "shortcuts.h" -#include "charvect.h" -#include "LanguageDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CFolderDialog dialog - -class CFolderDialog : public CHLanguageDialog -{ -// Construction -public: - CFolderDialog(CWnd* pParent = NULL); // standard constructor - virtual ~CFolderDialog(); - -// Dialog Data - //{{AFX_DATA(CFolderDialog) - //}}AFX_DATA - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFolderDialog) - public: - virtual int DoModal(); - protected: - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -public: - virtual BOOL OnTooltipText(UINT uiID, TOOLTIPTEXT* pTip); - - // structure used for passing parameters - struct BROWSEDATA - { - BROWSEDATA() { cx=0; cy=0; iView=2; bExtended=false; }; -// BROWSEDATA& operator=(const BROWSEDATA& data) { strCaption=data.strCaption; strText=data.strText; strInitialDir=data.strInitialDir; astrRecent.Copy(data.astrRecent); -// ascShortcuts.Copy(data.ascShortcuts); cx=data.cx; cy=data.cy; iView=data.iView; bExtended=data.bExtended; return *this;}; - - CString strCaption; - CString strText; - CString strInitialDir; - char_vector cvRecent; - char_vector cvShortcuts; - - int cx, cy; // pixels - int iView; // type of view (large icons, small icons, ...) - bool bExtended; // with the shortcuts or not - bool bIgnoreDialogs; // if tree ctrl should show shell dialogs in style 'insert floppy' - } m_bdData; - - // getting path - after dialog exits - void GetPath(CString& rstrPath); - void GetPath(LPTSTR pszPath); - - // function displays dialog with some parameters - friend int BrowseForFolder(BROWSEDATA* pData, LPTSTR pszPath); - -// Implementation -protected: - void InitImageList(); - void ApplyExpandState(bool bExpand); - int CreateControls(); - void SetView(int iView); - void UpdateComboIcon(); - void SetComboPath(LPCTSTR lpszPath); - void ResizeControls(int cx, int cy); - - CString m_strTip; // for tooltip storage - TCHAR m_szBuffer[2048]; // shell functions buffer - CString m_strPath; // for path after dialog exits - - bool m_bIgnoreUpdate; // ignores nearest edit update (with path) - bool m_bIgnoreTreeRefresh; // ignores nearest refreshing of tree ctrl - HIMAGELIST m_hImages, m_hLargeImages; // two system image lists - large and small icons - - // button bitmaps - CImageList m_ilList; // image list with buttons' images - - // last position in which gripper has been drawn - CRect m_rcGripper; - - // controls that'll be diaplyed in a dialog - CStatic m_ctlTitle; - CDirTreeCtrl m_ctlTree; - CComboBoxEx m_ctlPath; - CListCtrl m_ctlShortcuts; - CThemedButton m_ctlLargeIcons; - CThemedButton m_ctlSmallIcons; - CThemedButton m_ctlList; - CThemedButton m_ctlReport; - CThemedButton m_ctlNewFolder; - CButton m_ctlOk; - CButton m_ctlCancel; - CThemedButton m_ctlToggle; - CThemedButton m_ctlAddShortcut; - CThemedButton m_ctlRemoveShortcut; - - - // Generated message map functions - //{{AFX_MSG(CFolderDialog) - afx_msg void OnEndLabelEditShortcutList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnAddShortcut(); - afx_msg void OnRemoveShortcut(); - afx_msg void OnToggleButton(); - afx_msg void OnSelchangedFolderTree(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnGetInfoTipFolderTree(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnShortcutKeyDown(NMHDR* pNMHDR, LRESULT* pResult); - virtual BOOL OnInitDialog(); - afx_msg void OnNewfolderButton(); - virtual void OnCancel(); - virtual void OnOK(); - afx_msg void OnPathChanging(); - afx_msg void OnIconsRadio(); - afx_msg void OnSmalliconsRadio(); - afx_msg void OnListRadio(); - afx_msg void OnReportRadio(); - afx_msg void OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnGetShortcutInfoTip(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnPaint(); - afx_msg UINT OnNcHitTest(CPoint point); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/HelpLngDialog.cpp =================================================================== diff -u -N --- src/ch/HelpLngDialog.cpp (revision 0) +++ src/ch/HelpLngDialog.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,65 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "HelpLngDialog.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CHLanguageDialog dialog + +BEGIN_MESSAGE_MAP(CHLanguageDialog, CLanguageDialog) + ON_WM_HELPINFO() + ON_WM_CONTEXTMENU() + ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton) +END_MESSAGE_MAP() + +BOOL CHLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo) +{ + if (pHelpInfo->iContextType == HELPINFO_WINDOW) + { + pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId; + return GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)pHelpInfo); + } + else + return false; +} + +void CHLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point) +{ + HELPINFO hi; + hi.cbSize=sizeof(HELPINFO); + hi.iCtrlId=pWnd->GetDlgCtrlID(); + hi.dwContextId=(m_uiResID << 16) | hi.iCtrlId; + hi.hItemHandle=pWnd->m_hWnd; + hi.iContextType=HELPINFO_WINDOW; + hi.MousePos=point; + + GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)&hi); +} + +void CHLanguageDialog::OnHelpButton() +{ + GetApp()->HtmlHelp(HH_HELP_CONTEXT, m_uiResID+0x20000); +} Index: ch/HelpLngDialog.cpp =================================================================== diff -u -N --- ch/HelpLngDialog.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/HelpLngDialog.cpp (revision 0) @@ -1,65 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "HelpLngDialog.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CHLanguageDialog dialog - -BEGIN_MESSAGE_MAP(CHLanguageDialog, CLanguageDialog) - ON_WM_HELPINFO() - ON_WM_CONTEXTMENU() - ON_BN_CLICKED(IDC_HELP_BUTTON, OnHelpButton) -END_MESSAGE_MAP() - -BOOL CHLanguageDialog::OnHelpInfo(HELPINFO* pHelpInfo) -{ - if (pHelpInfo->iContextType == HELPINFO_WINDOW) - { - pHelpInfo->dwContextId=(m_uiResID << 16) | pHelpInfo->iCtrlId; - return GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)pHelpInfo); - } - else - return false; -} - -void CHLanguageDialog::OnContextMenu(CWnd* pWnd, CPoint point) -{ - HELPINFO hi; - hi.cbSize=sizeof(HELPINFO); - hi.iCtrlId=pWnd->GetDlgCtrlID(); - hi.dwContextId=(m_uiResID << 16) | hi.iCtrlId; - hi.hItemHandle=pWnd->m_hWnd; - hi.iContextType=HELPINFO_WINDOW; - hi.MousePos=point; - - GetApp()->HtmlHelp(HH_DISPLAY_TEXT_POPUP, (LPARAM)&hi); -} - -void CHLanguageDialog::OnHelpButton() -{ - GetApp()->HtmlHelp(HH_HELP_CONTEXT, m_uiResID+0x20000); -} Index: src/ch/HelpLngDialog.h =================================================================== diff -u -N --- src/ch/HelpLngDialog.h (revision 0) +++ src/ch/HelpLngDialog.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,40 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#pragma once + +#include "LanguageDialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CHLanguageDialog dialog + +class CHLanguageDialog : public CLanguageDialog +{ +// Construction +public: + CHLanguageDialog(bool* pLock=NULL) : CLanguageDialog(pLock) { }; + CHLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(lpszTemplateName, pParent, pLock) { }; // standard constructor + CHLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(uiIDTemplate, pParent, pLock) { }; // standard constructor + + BOOL OnHelpInfo(HELPINFO* pHelpInfo); + void OnContextMenu(CWnd* pWnd, CPoint point); + void OnHelpButton(); + + DECLARE_MESSAGE_MAP() +}; \ No newline at end of file Index: ch/HelpLngDialog.h =================================================================== diff -u -N --- ch/HelpLngDialog.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/HelpLngDialog.h (revision 0) @@ -1,40 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#pragma once - -#include "LanguageDialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CHLanguageDialog dialog - -class CHLanguageDialog : public CLanguageDialog -{ -// Construction -public: - CHLanguageDialog(bool* pLock=NULL) : CLanguageDialog(pLock) { }; - CHLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(lpszTemplateName, pParent, pLock) { }; // standard constructor - CHLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL) : CLanguageDialog(uiIDTemplate, pParent, pLock) { }; // standard constructor - - BOOL OnHelpInfo(HELPINFO* pHelpInfo); - void OnContextMenu(CWnd* pWnd, CPoint point); - void OnHelpButton(); - - DECLARE_MESSAGE_MAP() -}; \ No newline at end of file Index: src/ch/IniFile.cpp =================================================================== diff -u -N --- src/ch/IniFile.cpp (revision 0) +++ src/ch/IniFile.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,817 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "IniFile.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define MAX_LINE 8192 + +/////////////////////////////////////////////////////////////// +// Opens .ini file, reads all lines from it and keep in memory +// pszFilename [in] - path to .ini file +// pszOneSection [in] - ptr to a string with section's name +// which we want to read +/////////////////////////////////////////////////////////////// +void CIniFile::Open(LPCTSTR pszFilename, PCTSTR pszOneSection, bool bEscapeConversion) +{ + // remember file name + m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; + _tcscpy(m_pszFilename, pszFilename); + + // count the length of a section member + size_t tSectionLen=(size_t)-1; + if (pszOneSection) + tSectionLen=_tcslen(pszOneSection); + + // open file + CFileEx file; + file.Open(pszFilename, FA_READ | FA_BUFFERED); // may throw an exception + + // read all lines from file and process it + TCHAR szLine[MAX_LINE]; + size_t ulLen; + + // config object - zero members + _PROFILE* pcfg=NULL; // current config object + _SECTION* psect=NULL; // current section + _ENTRY* pentry=NULL; // current entry + TCHAR* pszSeparator; // used for separating keys from values + + while(file.ReadLine(szLine, MAX_LINE)) + { + // process + ulLen=_tcslen(szLine); // length of read string + + if (ulLen == 0 || szLine[0] == '#') + continue; + + // if it's config-selector <...> + if (ulLen > 1 && szLine[0] == _T('<') && szLine[ulLen-1] == _T('>')) + { + // config-selector + // create new profile + pcfg=new _PROFILE; + pcfg->pszProfileName=new TCHAR[ulLen-1]; + _tcsncpy(pcfg->pszProfileName, szLine+1, ulLen-2); + pcfg->pszProfileName[ulLen-2]=_T('\0'); + m_vConfigProfiles.push_back(pcfg); + } + else if (ulLen > 1 && szLine[0] == _T('[') && szLine[ulLen-1] == _T(']')) + { + if (pszOneSection && psect != NULL) // break if the needed section has been read already + break; + + if (!pszOneSection || (ulLen-2 == tSectionLen && _tcsncmp(pszOneSection, szLine+1, ulLen-2) == 0)) + { + // section-selector + if (pcfg == NULL) + { + // encountered section without config-selector - create default one + pcfg=new _PROFILE; + pcfg->pszProfileName=new TCHAR[4]; + _tcscpy(pcfg->pszProfileName, _T("000")); + m_vConfigProfiles.push_back(pcfg); + } + + // new section + psect=new _SECTION; + psect->pszSectionName=new TCHAR[ulLen-1]; + _tcsncpy(psect->pszSectionName, szLine+1, ulLen-2); + psect->pszSectionName[ulLen-2]=_T('\0'); + pcfg->vSections.push_back(psect); + } + } + else + { + if (!pszOneSection || psect != NULL) + { + // normal line (not empty) + if (pcfg == NULL) + { + // config-selector doesn't exist - create default + pcfg=new _PROFILE; + pcfg->pszProfileName=new TCHAR[4]; + _tcscpy(pcfg->pszProfileName, _T("000")); + m_vConfigProfiles.push_back(pcfg); + } + + if (psect == NULL) + { + // section doesn't exist -create default + psect=new _SECTION; + psect->pszSectionName=new TCHAR[4]; + _tcscpy(psect->pszSectionName, _T("000")); + pcfg->vSections.push_back(psect); + } + + // analyze string and copy data + pentry=new _ENTRY; + pszSeparator=_tcschr(szLine, _T('=')); + if (pszSeparator != NULL) + { + pszSeparator[0]=_T('\0'); + pszSeparator++; + + pentry->pszKey=new TCHAR[_tcslen(szLine)+1]; + _tcscpy(pentry->pszKey, szLine); + + // now the value - correct the ansi escape sequences if needed + if (bEscapeConversion) + { +// int iLen=_tcslen(pszSeparator); + UnescapeString(pszSeparator); + } + pentry->pszValue=new TCHAR[_tcslen(pszSeparator)+1]; + _tcscpy(pentry->pszValue, pszSeparator); + } + else + { + // no '=' sign in the line + pentry->pszKey=NULL; + if (bEscapeConversion) + UnescapeString(szLine); + pentry->pszValue=new TCHAR[_tcslen(szLine)+1]; + _tcscpy(pentry->pszValue, szLine); + } + + psect->vEntries.push_back(pentry); + } + } + } + + file.Close(); +} + +void CIniFile::UnescapeString(PTSTR pszData) +{ + PTSTR pszOut=pszData; + while (*pszData != 0) + { + if (*pszData == _T('\\')) + { + pszData++; + switch(*pszData++) + { + case _T('t'): + *pszOut++=_T('\t'); + break; + case _T('r'): + *pszOut++=_T('\r'); + break; + case _T('n'): + *pszOut++=_T('\n'); + break; + default: + *pszOut++=_T('\\'); + } + } + else + *pszOut++=*pszData++; + } + *pszOut=_T('\0'); +} + +/////////////////////////////////////////////////////////////// +// Saves data from memory to an .ini file +/////////////////////////////////////////////////////////////// +void CIniFile::Save() +{ + // if saving data is needed + if (!m_bModified) + return; + + _ASSERT(m_pszFilename); // is there a filename + + // open file for writing + CFileEx file; + file.Open(m_pszFilename, FA_WRITE | FA_BUFFERED); // may throw an exception + + // enumerate through all data and store it to the file + TCHAR szLine[MAX_LINE]; + int iLen; + vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); + vector<_SECTION*>::const_iterator sit; + vector<_ENTRY*>::const_iterator eit; + while (cit != m_vConfigProfiles.end()) + { + // store profile name + iLen=_stprintf(szLine, _T("<%s>"), (*cit)->pszProfileName); + file.WriteLine(szLine); + + // enumerate through sections + sit=(*cit)->vSections.begin(); + while (sit != (*cit)->vSections.end()) + { + // write section name + iLen=_stprintf(szLine, _T("[%s]"), (*sit)->pszSectionName); + file.WriteLine(szLine); + + // enumerate through attributes + eit=(*sit)->vEntries.begin(); + while(eit != (*sit)->vEntries.end()) + { + // store data + iLen=_stprintf(szLine, _T("%s=%s"), (*eit)->pszKey, (*eit)->pszValue); + file.WriteLine(szLine); + + // analyze next element + eit++; + } + + // cosmetics + file.WriteLine(_T("")); + + // analyze next section + sit++; + } + + // analyze next profile + cit++; + } + + // close file + file.Close(); + + m_bModified=false; +} + +/////////////////////////////////////////////////////////////// +// Closes the .ini file. Causes data from memory to be saved, +// and frees all the memory. +/////////////////////////////////////////////////////////////// +void CIniFile::Close() +{ + // save file and free all data (doesn't matter if save succeeded) + try + { + Save(); + } + catch(...) + { + FreeData(); + throw; + } + FreeData(); +} + +/////////////////////////////////////////////////////////////// +// Gets a string from .ini file (more precisely from the data +// from memory). +// pszConfig [in] - profile name +// pszSection [in] - section name +// pszKey [in] - key name +// pszValue [out] - value name (read from file or default) +// pszDefault [in/out] - default value if there wasn't pszKey +// in .ini file. +// Ret Value [out] - if the pszValue was read from file (=true) +// or is the default one (=false) +/////////////////////////////////////////////////////////////// +bool CIniFile::GetStr(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault) +{ + // localize config + vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); + while (cit != m_vConfigProfiles.end()) + { + // if this is not a config name - enumerate next + if (_tcsicmp((*cit)->pszProfileName, pszConfig) != 0) + { + cit++; + continue; + } + + // config found - check for section + vector<_SECTION*>::const_iterator sit=(*cit)->vSections.begin(); + while (sit != (*cit)->vSections.end()) + { + // continue if this is not the needed section + if (_tcsicmp((*sit)->pszSectionName, pszSection) != 0) + { + sit++; + continue; + } + + // now - localize key in section + vector<_ENTRY*>::const_iterator eit=(*sit)->vEntries.begin(); + while (eit != (*sit)->vEntries.end()) + { + // continue if needed + if (_tcsicmp((*eit)->pszKey, pszKey) != 0) + { + eit++; + continue; + } + + // read associated value - from file + _tcscpy(pszValue, (*eit)->pszValue); + m_bDefault=false; + return true; + } + + // section was found, but key in it wasn't + _tcscpy(pszValue, pszDefault); + m_bDefault=true; + return false; + } + + // section not found + _tcscpy(pszValue, pszDefault); + m_bDefault=true; + return false; + } + + // nothing + _tcscpy(pszValue, pszDefault); + m_bDefault=true; + return false; +} + +/////////////////////////////////////////////////////////////// +// Reads string from .ini file +// Look @ CIniFile::GetStr for param desc +// Ret Value [out] - string that was read (or the default one) +/////////////////////////////////////////////////////////////// +LPTSTR CIniFile::GetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault) +{ + GetStr(pszConfig, pszSection, pszKey, pszValue, pszDefault); + return pszValue; +} + +/////////////////////////////////////////////////////////////// +// Writes string to .ini file (to memory) +// For param desc's look @GetStr +// pszValue [in] - string to store under pszKey +/////////////////////////////////////////////////////////////// +void CIniFile::SetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue) +{ + // localize config + vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); + _PROFILE* pcfg=NULL; + while (cit != m_vConfigProfiles.end()) + { + // if this is not a config name - enumerate next + if (_tcsicmp((*cit)->pszProfileName, pszConfig) != 0) + { + cit++; + continue; + } + + // found + pcfg=*cit; + break; + } + + // if section doesn't exist - create it + if (pcfg == NULL) + { + pcfg=new _PROFILE; + pcfg->pszProfileName=new TCHAR[_tcslen(pszConfig)+1]; + _tcscpy(pcfg->pszProfileName, pszConfig); + m_vConfigProfiles.push_back(pcfg); + } + + // config is ready - now search for section + vector<_SECTION*>::const_iterator sit=pcfg->vSections.begin(); + _SECTION* psect=NULL; + while (sit != pcfg->vSections.end()) + { + // continue if this is not the needed section + if (_tcsicmp((*sit)->pszSectionName, pszSection) != 0) + { + sit++; + continue; + } + + // found + psect=*sit; + break; + } + + // create section if doesn't exist + if (psect == NULL) + { + psect=new _SECTION; + psect->pszSectionName=new TCHAR[_tcslen(pszSection)+1]; + _tcscpy(psect->pszSectionName, pszSection); + pcfg->vSections.push_back(psect); + } + + // now entry... + vector<_ENTRY*>::const_iterator eit=psect->vEntries.begin(); + _ENTRY* pentry=NULL; + while (eit != psect->vEntries.end()) + { + // continue if needed + if (_tcsicmp((*eit)->pszKey, pszKey) != 0) + { + eit++; + continue; + } + + // found + pentry=*eit; + break; + } + + // create entry if needed + if (pentry == NULL) + { + pentry=new _ENTRY; + pentry->pszKey=new TCHAR[_tcslen(pszKey)+1]; + _tcscpy(pentry->pszKey, pszKey); + pentry->pszValue=NULL; + psect->vEntries.push_back(pentry); + } + + // copy value to entry->pszValue + if (pentry->pszValue != NULL) + delete [] pentry->pszValue; + + pentry->pszValue=new TCHAR[_tcslen(pszValue)+1]; + _tcscpy(pentry->pszValue, pszValue); + + m_bModified=true; +} + +/////////////////////////////////////////////////////////////// +// Sets the int value in the .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// iValue [in] - value to set +/////////////////////////////////////////////////////////////// +void CIniFile::SetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iValue) +{ + TCHAR szBuffer[11]; + SetString(pszConfig, pszSection, pszKey, _itot(iValue, szBuffer, 10)); +} + +/////////////////////////////////////////////////////////////// +// Gets the int value from .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// iDefault [in] - default value - used if the file doesn't +// contain neede value +// pszBuffer [in] - buffer for internal processing (must +// contain at last 5 TCHARs). +// Ret Value [out] - value associated with the given position +/////////////////////////////////////////////////////////////// +int CIniFile::GetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, LPTSTR pszBuffer) +{ + // get string and process it + if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) + return _ttoi(pszBuffer); + else + return iDefault; +} + +/////////////////////////////////////////////////////////////// +// Sets the bool value in the .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// bValue [in] - value to set +/////////////////////////////////////////////////////////////// +void CIniFile::SetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bValue) +{ + TCHAR szBuffer[2]={ (TCHAR)(48+(bValue ? 1 : 0)), 0 }; + SetString(pszConfig, pszSection, pszKey, szBuffer); +} + +/////////////////////////////////////////////////////////////// +// Gets the bool value from .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// bDefault [in] - default value - used if the file doesn't +// contain needed value +// pszBuffer [in] - buffer for internal processing (must +// contain at last 2 TCHARs-better/safer is 1024). +// Ret Value [out] - value associated with the given position +/////////////////////////////////////////////////////////////// +bool CIniFile::GetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, LPTSTR pszBuffer) +{ + // get string and process it + if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) + return pszBuffer[0] != _T('0'); + else + return bDefault; +} + +/////////////////////////////////////////////////////////////// +// Sets the int64 value in the .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// llValue [in] - value to set +/////////////////////////////////////////////////////////////// +void CIniFile::SetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llValue) +{ + TCHAR szBuffer[21]; + SetString(pszConfig, pszSection, pszKey, _i64tot(llValue, szBuffer, 10)); +} + +/////////////////////////////////////////////////////////////// +// Gets the int64 value from .ini file (memory) +// pszConfig, pszSection, pszKey [in] - position in .ini file +// llDefault [in] - default value - used if the file doesn't +// contain needed value +// pszBuffer [in] - buffer for internal processing (must +// contain at last 9 TCHARs-better/safer is 1024). +// Ret Value [out] - value associated with the given position +/////////////////////////////////////////////////////////////// +__int64 CIniFile::GetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, LPTSTR pszBuffer) +{ + // get string and process it + if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) + return _ttoi64(pszBuffer); + else + return llDefault; +} + +/////////////////////////////////////////////////////////////// +// Gets the profile name at a given index in a file +// uiIndex [in] - index of profile to retrieve +// pszName [out] - name of the profile +/////////////////////////////////////////////////////////////// +void CIniFile::GetProfileName(UINT uiIndex, LPTSTR pszName) +{ + _tcscpy(pszName, m_vConfigProfiles.at(uiIndex)->pszProfileName); +} + +/////////////////////////////////////////////////////////////// +// Sets profile name at a given index +// uiIndex [in] - profile index +// pszName [in] - new profile name +/////////////////////////////////////////////////////////////// +void CIniFile::SetProfileName(UINT uiIndex, LPCTSTR pszName) +{ + delete [] m_vConfigProfiles.at(uiIndex)->pszProfileName; + m_vConfigProfiles.at(uiIndex)->pszProfileName=new TCHAR[_tcslen(pszName)+1]; + _tcscpy(m_vConfigProfiles.at(uiIndex)->pszProfileName, pszName); +} + +/////////////////////////////////////////////////////////////// +// Deletes one of the configurations (completely) +// uiIndex [in] - profile index to delete +/////////////////////////////////////////////////////////////// +void CIniFile::DeleteProfile(UINT uiIndex) +{ + m_vConfigProfiles.erase(m_vConfigProfiles.begin()+uiIndex); +} + +/////////////////////////////////////////////////////////////// +// Creates new profile in .ini file +// pszName [in] - new profile's name +/////////////////////////////////////////////////////////////// +void CIniFile::CreateProfile(LPCTSTR pszName) +{ + _PROFILE* pcfg=new _PROFILE; + pcfg->pszProfileName=new _TCHAR[_tcslen(pszName)+1]; + _tcscpy(pcfg->pszProfileName, pszName); +} + +/////////////////////////////////////////////////////////////// +// (Internal) Frees all data associated with this class +/////////////////////////////////////////////////////////////// +void CIniFile::FreeData() +{ + // free name string + delete [] m_pszFilename; + m_pszFilename=NULL; + + // other data + _PROFILE* pcfg=NULL; // current config object + _SECTION* psect=NULL; // current section + _ENTRY* pentry=NULL; // current entry + size_t uiIndex1=m_vConfigProfiles.size(), uiIndex2, uiIndex3; + while (uiIndex1--) + { + // delete profile name + pcfg=m_vConfigProfiles.at(uiIndex1); + delete [] pcfg->pszProfileName; + + // delete all sections + uiIndex2=pcfg->vSections.size(); + while (uiIndex2--) + { + // delete section name + psect=pcfg->vSections.at(uiIndex2); + delete [] psect->pszSectionName; + + // free all key=value strings + uiIndex3=psect->vEntries.size(); + while (uiIndex3--) + { + pentry=psect->vEntries.at(uiIndex3); + + // delete all values and this entry + delete [] pentry->pszKey; + delete [] pentry->pszValue; + delete pentry; + } + + // free this section + delete psect; + } + + // delete this profile + delete pcfg; + } + + m_vConfigProfiles.clear(); + m_bModified=false; + m_bDefault=false; +} + +void CIniFile::RemoveSection(LPCTSTR pszConfig, LPCTSTR pszSection) +{ + // localize section + _PROFILE *pcfg=NULL; + _SECTION *psect=NULL; + + vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); + while (it != m_vConfigProfiles.end()) + { + pcfg=(*it); + if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) + break; + pcfg=NULL; + it++; + } + + if (pcfg == NULL) + return; + + // find the section + vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); + while(sit != pcfg->vSections.end()) + { + psect=(*sit); + if (_tcscmp(psect->pszSectionName, pszSection) == 0) + break; + psect=NULL; + sit++; + } + + if (psect == NULL) + return; + + // delete + delete [] psect->pszSectionName; + + // free all key=value strings + size_t tIndex=psect->vEntries.size(); + _ENTRY* pentry; + while (tIndex--) + { + pentry=psect->vEntries.at(tIndex); + + // delete all values and this entry + delete [] pentry->pszKey; + delete [] pentry->pszValue; + delete pentry; + } + + // free this section + delete psect; + pcfg->vSections.erase(sit); +} + +void CIniFile::RemoveKey(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bAllAfter) +{ + // localize section + _PROFILE *pcfg=NULL; + _SECTION *psect=NULL; + + vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); + while (it != m_vConfigProfiles.end()) + { + pcfg=(*it); + if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) + break; + pcfg=NULL; + it++; + } + + if (pcfg == NULL) + return; + + // find the section + vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); + while(sit != pcfg->vSections.end()) + { + psect=(*sit); + if (_tcscmp(psect->pszSectionName, pszSection) == 0) + break; + psect=NULL; + sit++; + } + + if (psect == NULL) + return; + + // localize the key(s) + _ENTRY* pentry=NULL; + vector<_ENTRY*>::iterator eit=psect->vEntries.begin(); + while (eit != psect->vEntries.end()) + { + pentry=(*eit); + if (_tcscmp(pentry->pszKey, pszKey) == 0) + break; + pentry=NULL; + eit++; + } + + if (pentry == NULL) + return; + + vector<_ENTRY*>::iterator eit2=eit; + if (bAllAfter) + { + while(eit != psect->vEntries.end()) + { + pentry=(*eit); + delete [] pentry->pszKey; + delete [] pentry->pszValue; + delete pentry; + eit++; + } + + psect->vEntries.erase(eit2, psect->vEntries.end()); + } + else + { + delete [] pentry->pszKey; + delete [] pentry->pszValue; + delete pentry; + psect->vEntries.erase(eit); + } +} + +const _PROFILE* CIniFile::GetProfile(PCTSTR pszConfig) +{ + _PROFILE *pcfg=NULL; + + vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); + while (it != m_vConfigProfiles.end()) + { + pcfg=(*it); + if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) + break; + pcfg=NULL; + it++; + } + + if (pcfg == NULL) + return NULL; + else + return pcfg; +} + +const _SECTION* CIniFile::GetSection(PCTSTR pszConfig, PCTSTR pszSection) +{ + // localize section + _PROFILE *pcfg=NULL; + _SECTION *psect=NULL; + + vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); + while (it != m_vConfigProfiles.end()) + { + pcfg=(*it); + if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) + break; + pcfg=NULL; + it++; + } + + if (pcfg == NULL) + return NULL; + + // find the section + vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); + while(sit != pcfg->vSections.end()) + { + psect=(*sit); + if (_tcscmp(psect->pszSectionName, pszSection) == 0) + break; + psect=NULL; + sit++; + } + + if (psect == NULL) + return NULL; + else + return psect; +} Index: ch/IniFile.cpp =================================================================== diff -u -N --- ch/IniFile.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/IniFile.cpp (revision 0) @@ -1,817 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "IniFile.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#define MAX_LINE 8192 - -/////////////////////////////////////////////////////////////// -// Opens .ini file, reads all lines from it and keep in memory -// pszFilename [in] - path to .ini file -// pszOneSection [in] - ptr to a string with section's name -// which we want to read -/////////////////////////////////////////////////////////////// -void CIniFile::Open(LPCTSTR pszFilename, PCTSTR pszOneSection, bool bEscapeConversion) -{ - // remember file name - m_pszFilename=new TCHAR[_tcslen(pszFilename)+1]; - _tcscpy(m_pszFilename, pszFilename); - - // count the length of a section member - size_t tSectionLen=(size_t)-1; - if (pszOneSection) - tSectionLen=_tcslen(pszOneSection); - - // open file - CFileEx file; - file.Open(pszFilename, FA_READ | FA_BUFFERED); // may throw an exception - - // read all lines from file and process it - TCHAR szLine[MAX_LINE]; - size_t ulLen; - - // config object - zero members - _PROFILE* pcfg=NULL; // current config object - _SECTION* psect=NULL; // current section - _ENTRY* pentry=NULL; // current entry - TCHAR* pszSeparator; // used for separating keys from values - - while(file.ReadLine(szLine, MAX_LINE)) - { - // process - ulLen=_tcslen(szLine); // length of read string - - if (ulLen == 0 || szLine[0] == '#') - continue; - - // if it's config-selector <...> - if (ulLen > 1 && szLine[0] == _T('<') && szLine[ulLen-1] == _T('>')) - { - // config-selector - // create new profile - pcfg=new _PROFILE; - pcfg->pszProfileName=new TCHAR[ulLen-1]; - _tcsncpy(pcfg->pszProfileName, szLine+1, ulLen-2); - pcfg->pszProfileName[ulLen-2]=_T('\0'); - m_vConfigProfiles.push_back(pcfg); - } - else if (ulLen > 1 && szLine[0] == _T('[') && szLine[ulLen-1] == _T(']')) - { - if (pszOneSection && psect != NULL) // break if the needed section has been read already - break; - - if (!pszOneSection || (ulLen-2 == tSectionLen && _tcsncmp(pszOneSection, szLine+1, ulLen-2) == 0)) - { - // section-selector - if (pcfg == NULL) - { - // encountered section without config-selector - create default one - pcfg=new _PROFILE; - pcfg->pszProfileName=new TCHAR[4]; - _tcscpy(pcfg->pszProfileName, _T("000")); - m_vConfigProfiles.push_back(pcfg); - } - - // new section - psect=new _SECTION; - psect->pszSectionName=new TCHAR[ulLen-1]; - _tcsncpy(psect->pszSectionName, szLine+1, ulLen-2); - psect->pszSectionName[ulLen-2]=_T('\0'); - pcfg->vSections.push_back(psect); - } - } - else - { - if (!pszOneSection || psect != NULL) - { - // normal line (not empty) - if (pcfg == NULL) - { - // config-selector doesn't exist - create default - pcfg=new _PROFILE; - pcfg->pszProfileName=new TCHAR[4]; - _tcscpy(pcfg->pszProfileName, _T("000")); - m_vConfigProfiles.push_back(pcfg); - } - - if (psect == NULL) - { - // section doesn't exist -create default - psect=new _SECTION; - psect->pszSectionName=new TCHAR[4]; - _tcscpy(psect->pszSectionName, _T("000")); - pcfg->vSections.push_back(psect); - } - - // analyze string and copy data - pentry=new _ENTRY; - pszSeparator=_tcschr(szLine, _T('=')); - if (pszSeparator != NULL) - { - pszSeparator[0]=_T('\0'); - pszSeparator++; - - pentry->pszKey=new TCHAR[_tcslen(szLine)+1]; - _tcscpy(pentry->pszKey, szLine); - - // now the value - correct the ansi escape sequences if needed - if (bEscapeConversion) - { -// int iLen=_tcslen(pszSeparator); - UnescapeString(pszSeparator); - } - pentry->pszValue=new TCHAR[_tcslen(pszSeparator)+1]; - _tcscpy(pentry->pszValue, pszSeparator); - } - else - { - // no '=' sign in the line - pentry->pszKey=NULL; - if (bEscapeConversion) - UnescapeString(szLine); - pentry->pszValue=new TCHAR[_tcslen(szLine)+1]; - _tcscpy(pentry->pszValue, szLine); - } - - psect->vEntries.push_back(pentry); - } - } - } - - file.Close(); -} - -void CIniFile::UnescapeString(PTSTR pszData) -{ - PTSTR pszOut=pszData; - while (*pszData != 0) - { - if (*pszData == _T('\\')) - { - pszData++; - switch(*pszData++) - { - case _T('t'): - *pszOut++=_T('\t'); - break; - case _T('r'): - *pszOut++=_T('\r'); - break; - case _T('n'): - *pszOut++=_T('\n'); - break; - default: - *pszOut++=_T('\\'); - } - } - else - *pszOut++=*pszData++; - } - *pszOut=_T('\0'); -} - -/////////////////////////////////////////////////////////////// -// Saves data from memory to an .ini file -/////////////////////////////////////////////////////////////// -void CIniFile::Save() -{ - // if saving data is needed - if (!m_bModified) - return; - - _ASSERT(m_pszFilename); // is there a filename - - // open file for writing - CFileEx file; - file.Open(m_pszFilename, FA_WRITE | FA_BUFFERED); // may throw an exception - - // enumerate through all data and store it to the file - TCHAR szLine[MAX_LINE]; - int iLen; - vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); - vector<_SECTION*>::const_iterator sit; - vector<_ENTRY*>::const_iterator eit; - while (cit != m_vConfigProfiles.end()) - { - // store profile name - iLen=_stprintf(szLine, _T("<%s>"), (*cit)->pszProfileName); - file.WriteLine(szLine); - - // enumerate through sections - sit=(*cit)->vSections.begin(); - while (sit != (*cit)->vSections.end()) - { - // write section name - iLen=_stprintf(szLine, _T("[%s]"), (*sit)->pszSectionName); - file.WriteLine(szLine); - - // enumerate through attributes - eit=(*sit)->vEntries.begin(); - while(eit != (*sit)->vEntries.end()) - { - // store data - iLen=_stprintf(szLine, _T("%s=%s"), (*eit)->pszKey, (*eit)->pszValue); - file.WriteLine(szLine); - - // analyze next element - eit++; - } - - // cosmetics - file.WriteLine(_T("")); - - // analyze next section - sit++; - } - - // analyze next profile - cit++; - } - - // close file - file.Close(); - - m_bModified=false; -} - -/////////////////////////////////////////////////////////////// -// Closes the .ini file. Causes data from memory to be saved, -// and frees all the memory. -/////////////////////////////////////////////////////////////// -void CIniFile::Close() -{ - // save file and free all data (doesn't matter if save succeeded) - try - { - Save(); - } - catch(...) - { - FreeData(); - throw; - } - FreeData(); -} - -/////////////////////////////////////////////////////////////// -// Gets a string from .ini file (more precisely from the data -// from memory). -// pszConfig [in] - profile name -// pszSection [in] - section name -// pszKey [in] - key name -// pszValue [out] - value name (read from file or default) -// pszDefault [in/out] - default value if there wasn't pszKey -// in .ini file. -// Ret Value [out] - if the pszValue was read from file (=true) -// or is the default one (=false) -/////////////////////////////////////////////////////////////// -bool CIniFile::GetStr(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault) -{ - // localize config - vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); - while (cit != m_vConfigProfiles.end()) - { - // if this is not a config name - enumerate next - if (_tcsicmp((*cit)->pszProfileName, pszConfig) != 0) - { - cit++; - continue; - } - - // config found - check for section - vector<_SECTION*>::const_iterator sit=(*cit)->vSections.begin(); - while (sit != (*cit)->vSections.end()) - { - // continue if this is not the needed section - if (_tcsicmp((*sit)->pszSectionName, pszSection) != 0) - { - sit++; - continue; - } - - // now - localize key in section - vector<_ENTRY*>::const_iterator eit=(*sit)->vEntries.begin(); - while (eit != (*sit)->vEntries.end()) - { - // continue if needed - if (_tcsicmp((*eit)->pszKey, pszKey) != 0) - { - eit++; - continue; - } - - // read associated value - from file - _tcscpy(pszValue, (*eit)->pszValue); - m_bDefault=false; - return true; - } - - // section was found, but key in it wasn't - _tcscpy(pszValue, pszDefault); - m_bDefault=true; - return false; - } - - // section not found - _tcscpy(pszValue, pszDefault); - m_bDefault=true; - return false; - } - - // nothing - _tcscpy(pszValue, pszDefault); - m_bDefault=true; - return false; -} - -/////////////////////////////////////////////////////////////// -// Reads string from .ini file -// Look @ CIniFile::GetStr for param desc -// Ret Value [out] - string that was read (or the default one) -/////////////////////////////////////////////////////////////// -LPTSTR CIniFile::GetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault) -{ - GetStr(pszConfig, pszSection, pszKey, pszValue, pszDefault); - return pszValue; -} - -/////////////////////////////////////////////////////////////// -// Writes string to .ini file (to memory) -// For param desc's look @GetStr -// pszValue [in] - string to store under pszKey -/////////////////////////////////////////////////////////////// -void CIniFile::SetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue) -{ - // localize config - vector<_PROFILE*>::const_iterator cit=m_vConfigProfiles.begin(); - _PROFILE* pcfg=NULL; - while (cit != m_vConfigProfiles.end()) - { - // if this is not a config name - enumerate next - if (_tcsicmp((*cit)->pszProfileName, pszConfig) != 0) - { - cit++; - continue; - } - - // found - pcfg=*cit; - break; - } - - // if section doesn't exist - create it - if (pcfg == NULL) - { - pcfg=new _PROFILE; - pcfg->pszProfileName=new TCHAR[_tcslen(pszConfig)+1]; - _tcscpy(pcfg->pszProfileName, pszConfig); - m_vConfigProfiles.push_back(pcfg); - } - - // config is ready - now search for section - vector<_SECTION*>::const_iterator sit=pcfg->vSections.begin(); - _SECTION* psect=NULL; - while (sit != pcfg->vSections.end()) - { - // continue if this is not the needed section - if (_tcsicmp((*sit)->pszSectionName, pszSection) != 0) - { - sit++; - continue; - } - - // found - psect=*sit; - break; - } - - // create section if doesn't exist - if (psect == NULL) - { - psect=new _SECTION; - psect->pszSectionName=new TCHAR[_tcslen(pszSection)+1]; - _tcscpy(psect->pszSectionName, pszSection); - pcfg->vSections.push_back(psect); - } - - // now entry... - vector<_ENTRY*>::const_iterator eit=psect->vEntries.begin(); - _ENTRY* pentry=NULL; - while (eit != psect->vEntries.end()) - { - // continue if needed - if (_tcsicmp((*eit)->pszKey, pszKey) != 0) - { - eit++; - continue; - } - - // found - pentry=*eit; - break; - } - - // create entry if needed - if (pentry == NULL) - { - pentry=new _ENTRY; - pentry->pszKey=new TCHAR[_tcslen(pszKey)+1]; - _tcscpy(pentry->pszKey, pszKey); - pentry->pszValue=NULL; - psect->vEntries.push_back(pentry); - } - - // copy value to entry->pszValue - if (pentry->pszValue != NULL) - delete [] pentry->pszValue; - - pentry->pszValue=new TCHAR[_tcslen(pszValue)+1]; - _tcscpy(pentry->pszValue, pszValue); - - m_bModified=true; -} - -/////////////////////////////////////////////////////////////// -// Sets the int value in the .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// iValue [in] - value to set -/////////////////////////////////////////////////////////////// -void CIniFile::SetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iValue) -{ - TCHAR szBuffer[11]; - SetString(pszConfig, pszSection, pszKey, _itot(iValue, szBuffer, 10)); -} - -/////////////////////////////////////////////////////////////// -// Gets the int value from .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// iDefault [in] - default value - used if the file doesn't -// contain neede value -// pszBuffer [in] - buffer for internal processing (must -// contain at last 5 TCHARs). -// Ret Value [out] - value associated with the given position -/////////////////////////////////////////////////////////////// -int CIniFile::GetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, LPTSTR pszBuffer) -{ - // get string and process it - if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) - return _ttoi(pszBuffer); - else - return iDefault; -} - -/////////////////////////////////////////////////////////////// -// Sets the bool value in the .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// bValue [in] - value to set -/////////////////////////////////////////////////////////////// -void CIniFile::SetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bValue) -{ - TCHAR szBuffer[2]={ (TCHAR)(48+(bValue ? 1 : 0)), 0 }; - SetString(pszConfig, pszSection, pszKey, szBuffer); -} - -/////////////////////////////////////////////////////////////// -// Gets the bool value from .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// bDefault [in] - default value - used if the file doesn't -// contain needed value -// pszBuffer [in] - buffer for internal processing (must -// contain at last 2 TCHARs-better/safer is 1024). -// Ret Value [out] - value associated with the given position -/////////////////////////////////////////////////////////////// -bool CIniFile::GetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, LPTSTR pszBuffer) -{ - // get string and process it - if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) - return pszBuffer[0] != _T('0'); - else - return bDefault; -} - -/////////////////////////////////////////////////////////////// -// Sets the int64 value in the .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// llValue [in] - value to set -/////////////////////////////////////////////////////////////// -void CIniFile::SetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llValue) -{ - TCHAR szBuffer[21]; - SetString(pszConfig, pszSection, pszKey, _i64tot(llValue, szBuffer, 10)); -} - -/////////////////////////////////////////////////////////////// -// Gets the int64 value from .ini file (memory) -// pszConfig, pszSection, pszKey [in] - position in .ini file -// llDefault [in] - default value - used if the file doesn't -// contain needed value -// pszBuffer [in] - buffer for internal processing (must -// contain at last 9 TCHARs-better/safer is 1024). -// Ret Value [out] - value associated with the given position -/////////////////////////////////////////////////////////////// -__int64 CIniFile::GetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, LPTSTR pszBuffer) -{ - // get string and process it - if (GetStr(pszConfig, pszSection, pszKey, pszBuffer, _T(""))) - return _ttoi64(pszBuffer); - else - return llDefault; -} - -/////////////////////////////////////////////////////////////// -// Gets the profile name at a given index in a file -// uiIndex [in] - index of profile to retrieve -// pszName [out] - name of the profile -/////////////////////////////////////////////////////////////// -void CIniFile::GetProfileName(UINT uiIndex, LPTSTR pszName) -{ - _tcscpy(pszName, m_vConfigProfiles.at(uiIndex)->pszProfileName); -} - -/////////////////////////////////////////////////////////////// -// Sets profile name at a given index -// uiIndex [in] - profile index -// pszName [in] - new profile name -/////////////////////////////////////////////////////////////// -void CIniFile::SetProfileName(UINT uiIndex, LPCTSTR pszName) -{ - delete [] m_vConfigProfiles.at(uiIndex)->pszProfileName; - m_vConfigProfiles.at(uiIndex)->pszProfileName=new TCHAR[_tcslen(pszName)+1]; - _tcscpy(m_vConfigProfiles.at(uiIndex)->pszProfileName, pszName); -} - -/////////////////////////////////////////////////////////////// -// Deletes one of the configurations (completely) -// uiIndex [in] - profile index to delete -/////////////////////////////////////////////////////////////// -void CIniFile::DeleteProfile(UINT uiIndex) -{ - m_vConfigProfiles.erase(m_vConfigProfiles.begin()+uiIndex); -} - -/////////////////////////////////////////////////////////////// -// Creates new profile in .ini file -// pszName [in] - new profile's name -/////////////////////////////////////////////////////////////// -void CIniFile::CreateProfile(LPCTSTR pszName) -{ - _PROFILE* pcfg=new _PROFILE; - pcfg->pszProfileName=new _TCHAR[_tcslen(pszName)+1]; - _tcscpy(pcfg->pszProfileName, pszName); -} - -/////////////////////////////////////////////////////////////// -// (Internal) Frees all data associated with this class -/////////////////////////////////////////////////////////////// -void CIniFile::FreeData() -{ - // free name string - delete [] m_pszFilename; - m_pszFilename=NULL; - - // other data - _PROFILE* pcfg=NULL; // current config object - _SECTION* psect=NULL; // current section - _ENTRY* pentry=NULL; // current entry - size_t uiIndex1=m_vConfigProfiles.size(), uiIndex2, uiIndex3; - while (uiIndex1--) - { - // delete profile name - pcfg=m_vConfigProfiles.at(uiIndex1); - delete [] pcfg->pszProfileName; - - // delete all sections - uiIndex2=pcfg->vSections.size(); - while (uiIndex2--) - { - // delete section name - psect=pcfg->vSections.at(uiIndex2); - delete [] psect->pszSectionName; - - // free all key=value strings - uiIndex3=psect->vEntries.size(); - while (uiIndex3--) - { - pentry=psect->vEntries.at(uiIndex3); - - // delete all values and this entry - delete [] pentry->pszKey; - delete [] pentry->pszValue; - delete pentry; - } - - // free this section - delete psect; - } - - // delete this profile - delete pcfg; - } - - m_vConfigProfiles.clear(); - m_bModified=false; - m_bDefault=false; -} - -void CIniFile::RemoveSection(LPCTSTR pszConfig, LPCTSTR pszSection) -{ - // localize section - _PROFILE *pcfg=NULL; - _SECTION *psect=NULL; - - vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); - while (it != m_vConfigProfiles.end()) - { - pcfg=(*it); - if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) - break; - pcfg=NULL; - it++; - } - - if (pcfg == NULL) - return; - - // find the section - vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); - while(sit != pcfg->vSections.end()) - { - psect=(*sit); - if (_tcscmp(psect->pszSectionName, pszSection) == 0) - break; - psect=NULL; - sit++; - } - - if (psect == NULL) - return; - - // delete - delete [] psect->pszSectionName; - - // free all key=value strings - size_t tIndex=psect->vEntries.size(); - _ENTRY* pentry; - while (tIndex--) - { - pentry=psect->vEntries.at(tIndex); - - // delete all values and this entry - delete [] pentry->pszKey; - delete [] pentry->pszValue; - delete pentry; - } - - // free this section - delete psect; - pcfg->vSections.erase(sit); -} - -void CIniFile::RemoveKey(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bAllAfter) -{ - // localize section - _PROFILE *pcfg=NULL; - _SECTION *psect=NULL; - - vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); - while (it != m_vConfigProfiles.end()) - { - pcfg=(*it); - if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) - break; - pcfg=NULL; - it++; - } - - if (pcfg == NULL) - return; - - // find the section - vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); - while(sit != pcfg->vSections.end()) - { - psect=(*sit); - if (_tcscmp(psect->pszSectionName, pszSection) == 0) - break; - psect=NULL; - sit++; - } - - if (psect == NULL) - return; - - // localize the key(s) - _ENTRY* pentry=NULL; - vector<_ENTRY*>::iterator eit=psect->vEntries.begin(); - while (eit != psect->vEntries.end()) - { - pentry=(*eit); - if (_tcscmp(pentry->pszKey, pszKey) == 0) - break; - pentry=NULL; - eit++; - } - - if (pentry == NULL) - return; - - vector<_ENTRY*>::iterator eit2=eit; - if (bAllAfter) - { - while(eit != psect->vEntries.end()) - { - pentry=(*eit); - delete [] pentry->pszKey; - delete [] pentry->pszValue; - delete pentry; - eit++; - } - - psect->vEntries.erase(eit2, psect->vEntries.end()); - } - else - { - delete [] pentry->pszKey; - delete [] pentry->pszValue; - delete pentry; - psect->vEntries.erase(eit); - } -} - -const _PROFILE* CIniFile::GetProfile(PCTSTR pszConfig) -{ - _PROFILE *pcfg=NULL; - - vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); - while (it != m_vConfigProfiles.end()) - { - pcfg=(*it); - if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) - break; - pcfg=NULL; - it++; - } - - if (pcfg == NULL) - return NULL; - else - return pcfg; -} - -const _SECTION* CIniFile::GetSection(PCTSTR pszConfig, PCTSTR pszSection) -{ - // localize section - _PROFILE *pcfg=NULL; - _SECTION *psect=NULL; - - vector<_PROFILE*>::iterator it=m_vConfigProfiles.begin(); - while (it != m_vConfigProfiles.end()) - { - pcfg=(*it); - if (_tcscmp(pcfg->pszProfileName, pszConfig) == 0) - break; - pcfg=NULL; - it++; - } - - if (pcfg == NULL) - return NULL; - - // find the section - vector<_SECTION*>::iterator sit=pcfg->vSections.begin(); - while(sit != pcfg->vSections.end()) - { - psect=(*sit); - if (_tcscmp(psect->pszSectionName, pszSection) == 0) - break; - psect=NULL; - sit++; - } - - if (psect == NULL) - return NULL; - else - return psect; -} Index: src/ch/IniFile.h =================================================================== diff -u -N --- src/ch/IniFile.h (revision 0) +++ src/ch/IniFile.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,130 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + File: IniFile.h + Version: 1.0 + Author: Ixen Gerthannes (ixen@interia.pl) + File description: + Contains classes/structures providing functionality of ini + file. Ini file in this case is a bit modified, because it + provides something called profile. It could be used to + maintain more than one set of options in an ini file. + Classes: + CIniFile + - handles ini files in format: + - + - [section name] + - key=value + - work with/without mfc. + - NOT thread-safe + Structures: + _PROFILE - contains profile name and array of sections + _SECTION - contains section name and array of entries + _ENTRY - contains key name, value in string format +*************************************************************************/ + +#ifndef __INIFILE_H__ +#define __INIFILE_H__ + +#include "FileEx.h" +#include + +using namespace std; + +// internal structures used in managing profiles, keys, ... +struct _ENTRY +{ + TCHAR* pszKey; // key name - common for all config profiles + TCHAR* pszValue; // set of values bound to above key - differs between config-profiles +}; + +struct _SECTION +{ + TCHAR* pszSectionName; + vector<_ENTRY*> vEntries; +}; + +struct _PROFILE +{ + TCHAR* pszProfileName; + vector<_SECTION*> vSections; +}; + +// class +class CIniFile +{ +public: + // construction/destruction + CIniFile() { m_pszFilename=NULL; m_bModified=false; m_bDefault=false; }; + ~CIniFile() { Close(); }; + + // opening/closing + void Open(LPCTSTR pszFilename, PCTSTR pszOneSection=NULL, bool bEscapeConversion=false); // loads data from file and interpretes it + void Save(); // saves data to file (without closing it) + void Close(); // saves file and closes it + + // reading/writing some data from/to .ini file + bool GetStr(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault); // gets string from .ini file + LPTSTR GetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault); // gets string from .ini file + void SetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue); // sets string in .ini file + + void SetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iValue); + int GetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, LPTSTR pszBuffer); + + void SetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bValue); + bool GetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, LPTSTR pszBuffer); + + void SetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llValue); + __int64 GetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, LPTSTR pszBuffer); + + // remove functions + void RemoveSection(LPCTSTR pszConfig, LPCTSTR pszSection); + void RemoveKey(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bAllAfter); + + // Get functions + const _PROFILE* GetProfile(PCTSTR pszConfig); + const _SECTION* GetSection(PCTSTR pszConfig, PCTSTR pszSection); + + // config-selection funcs + UINT GetProfilesCount() { return (UINT)m_vConfigProfiles.size(); }; // returns count of profiles + void GetProfileName(UINT uiIndex, LPTSTR pszName); // return profile name + void SetProfileName(UINT uiIndex, LPCTSTR pszName); // sets the profile name + void DeleteProfile(UINT uiIndex); // deletes whole profile + void CreateProfile(LPCTSTR pszName); // creates new profile + + // def + bool IsDefault() const { return m_bDefault; }; + +protected: + // helpers + void FreeData(); // frees data from m_vConfigProfiles + void UnescapeString(PTSTR pszData); + +protected: + TCHAR* m_pszFilename; // this configuration's file filename + bool m_bModified; // global modification flag + bool m_bDefault; // every GetXXX refreshed member - if returned value was the default one or + // read from file + + vector<_PROFILE*> m_vConfigProfiles; // contains configuration profiles's names (user names) + // each config profile contains the same set of sections and keys +}; + +#endif \ No newline at end of file Index: ch/IniFile.h =================================================================== diff -u -N --- ch/IniFile.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/IniFile.h (revision 0) @@ -1,130 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - File: IniFile.h - Version: 1.0 - Author: Ixen Gerthannes (ixen@interia.pl) - File description: - Contains classes/structures providing functionality of ini - file. Ini file in this case is a bit modified, because it - provides something called profile. It could be used to - maintain more than one set of options in an ini file. - Classes: - CIniFile - - handles ini files in format: - - - - [section name] - - key=value - - work with/without mfc. - - NOT thread-safe - Structures: - _PROFILE - contains profile name and array of sections - _SECTION - contains section name and array of entries - _ENTRY - contains key name, value in string format -*************************************************************************/ - -#ifndef __INIFILE_H__ -#define __INIFILE_H__ - -#include "FileEx.h" -#include - -using namespace std; - -// internal structures used in managing profiles, keys, ... -struct _ENTRY -{ - TCHAR* pszKey; // key name - common for all config profiles - TCHAR* pszValue; // set of values bound to above key - differs between config-profiles -}; - -struct _SECTION -{ - TCHAR* pszSectionName; - vector<_ENTRY*> vEntries; -}; - -struct _PROFILE -{ - TCHAR* pszProfileName; - vector<_SECTION*> vSections; -}; - -// class -class CIniFile -{ -public: - // construction/destruction - CIniFile() { m_pszFilename=NULL; m_bModified=false; m_bDefault=false; }; - ~CIniFile() { Close(); }; - - // opening/closing - void Open(LPCTSTR pszFilename, PCTSTR pszOneSection=NULL, bool bEscapeConversion=false); // loads data from file and interpretes it - void Save(); // saves data to file (without closing it) - void Close(); // saves file and closes it - - // reading/writing some data from/to .ini file - bool GetStr(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault); // gets string from .ini file - LPTSTR GetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPTSTR pszValue, LPCTSTR pszDefault); // gets string from .ini file - void SetString(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, LPCTSTR pszValue); // sets string in .ini file - - void SetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iValue); - int GetInt(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, int iDefault, LPTSTR pszBuffer); - - void SetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bValue); - bool GetBool(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bDefault, LPTSTR pszBuffer); - - void SetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llValue); - __int64 GetInt64(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, __int64 llDefault, LPTSTR pszBuffer); - - // remove functions - void RemoveSection(LPCTSTR pszConfig, LPCTSTR pszSection); - void RemoveKey(LPCTSTR pszConfig, LPCTSTR pszSection, LPCTSTR pszKey, bool bAllAfter); - - // Get functions - const _PROFILE* GetProfile(PCTSTR pszConfig); - const _SECTION* GetSection(PCTSTR pszConfig, PCTSTR pszSection); - - // config-selection funcs - UINT GetProfilesCount() { return (UINT)m_vConfigProfiles.size(); }; // returns count of profiles - void GetProfileName(UINT uiIndex, LPTSTR pszName); // return profile name - void SetProfileName(UINT uiIndex, LPCTSTR pszName); // sets the profile name - void DeleteProfile(UINT uiIndex); // deletes whole profile - void CreateProfile(LPCTSTR pszName); // creates new profile - - // def - bool IsDefault() const { return m_bDefault; }; - -protected: - // helpers - void FreeData(); // frees data from m_vConfigProfiles - void UnescapeString(PTSTR pszData); - -protected: - TCHAR* m_pszFilename; // this configuration's file filename - bool m_bModified; // global modification flag - bool m_bDefault; // every GetXXX refreshed member - if returned value was the default one or - // read from file - - vector<_PROFILE*> m_vConfigProfiles; // contains configuration profiles's names (user names) - // each config profile contains the same set of sections and keys -}; - -#endif \ No newline at end of file Index: src/ch/LanguageDialog.cpp =================================================================== diff -u -N --- src/ch/LanguageDialog.cpp (revision 0) +++ src/ch/LanguageDialog.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,675 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "LanguageDialog.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CDlgTemplate +CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate) +{ + Open(pDlgTemplate); +} + +CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate) +{ + Open((DLGTEMPLATE*)pDlgTemplate); +} + +CDlgTemplate::~CDlgTemplate() +{ + delete [] m_pszMenu; + delete [] m_pszClass; + delete [] m_pszTitle; + delete [] m_pszFace; + + // items + vector<_ITEM>::iterator it; + for (it=m_vItems.begin();it != m_vItems.end();it++) + { + delete [] (*it).m_pbyCreationData; + delete [] (*it).m_pszClass; + delete [] (*it).m_pszTitle; + } +} + +bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate) +{ + if (pDlgTemplate == NULL) + return false; + bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff; + const BYTE* pData=((BYTE*)pDlgTemplate); + if (bExt) + { + m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate); + pData+=sizeof(DLGTEMPLATEEX); + } + else + { + ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate); + pData+=sizeof(DLGTEMPLATE); + } + + // here is the menu, class and title + pData=ReadCompoundData(pData, &m_wMenu, &m_pszMenu); + pData=ReadCompoundData(pData, &m_wClass, &m_pszClass); + pData=ReadCompoundData(pData, &m_wTitle, &m_pszTitle); + + // font + if (m_dlgTemplate.style & DS_SETFONT || m_dlgTemplate.style & DS_SHELLFONT) + { + m_wFontSize=*((WORD*)pData); + pData+=sizeof(WORD); + if (bExt) + { + m_wWeight=*((WORD*)pData); + pData+=sizeof(WORD); + m_byItalic=*((BYTE*)pData); + pData+=sizeof(BYTE); + m_byCharset=*((BYTE*)pData); + pData+=sizeof(BYTE); + } + else + { + m_wWeight=FW_NORMAL; + m_byItalic=FALSE; + m_byCharset=DEFAULT_CHARSET; + } + DWORD dwLen=(DWORD)wcslen((wchar_t*)pData); + m_pszFace=new TCHAR[dwLen+1]; +#ifdef _UNICODE + _tcscpy(m_pszFace, (wchar_t*)pData); +#else + WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pData, dwLen+1, m_pszFace, dwLen+1, NULL, NULL); +#endif + pData+=(dwLen+1)*sizeof(wchar_t); + } + else + { + m_wFontSize=0xffff; + m_pszFace=NULL; + } + + // items + _ITEM item; + for (int i=0;i 0) + { + item.m_wCreationDataSize-=sizeof(WORD); + item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize]; + memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize); + } + else + item.m_pbyCreationData=NULL; + + m_vItems.push_back(item); + } + + return true; +} + +void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst) +{ + pDst->helpID=0; + pDst->exStyle=pSrc->dwExtendedStyle; + pDst->style=pSrc->style; + pDst->x=pSrc->x; + pDst->y=pSrc->y; + pDst->cx=pSrc->cx; + pDst->cy=pSrc->cy; + pDst->id=pSrc->id; +} + +void CDlgTemplate::ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst) +{ + pDst->dlgVer=1; + pDst->signature=0x0000; + pDst->helpID=(ULONG)0; + pDst->exStyle=pSrc->dwExtendedStyle; + pDst->style=pSrc->style; + pDst->cDlgItems=pSrc->cdit; + pDst->x=pSrc->x; + pDst->y=pSrc->y; + pDst->cx=pSrc->cx; + pDst->cy=pSrc->cy; +} + +const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr) +{ + if (*((WORD*)pBuffer) == 0xffff) + { + *pwData=*((WORD*)(pBuffer+2)); + *ppszStr=NULL; + + return pBuffer+4; + } + else + { + *pwData=0xffff; + DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer); + *ppszStr=new TCHAR[dwLen+1]; +#ifdef _UNICODE + _tcscpy(*ppszStr, (wchar_t*)pBuffer); +#else + WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, NULL, NULL); +#endif + return pBuffer+(dwLen+1)*sizeof(wchar_t); + } + +} + +///////////////////////////////////////////////////////////////////////////// +// CLanguageDialog dialog + +CResourceManager *CLanguageDialog::m_prm=NULL; + +/////////////////////////////////////////////////////////////// +// Standard constructor +// pLock [in] - specifies address of a bool value that'll be +// used to check if another instance of this window has +// already been shown. Should be declared in derived class +// as 'static bool m_xxx;' and initialized to 0. +/////////////////////////////////////////////////////////////// +CLanguageDialog::CLanguageDialog(bool* pLock) : CDialog() +{ + m_pszResName=NULL; + m_uiResID=0; + m_pParent=NULL; + m_cType=-1; + m_bAutoDelete=false; + m_pFont=NULL; + m_pbLock=pLock; + m_bLockChanged=false; + m_bLockInstance=false; + m_iBaseX=m_iBaseY=0; + _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready + m_prm->m_lhDialogs.push_back(this); +} + +/////////////////////////////////////////////////////////////// +// Constructor that takes string based template name +// lpszTemplateName [in] - specifies the template name to load +// and show as this dialog. +// pParent [in] - logical (everyone knows) +// pLock [in] - address of a bool for dialog instance checks +/////////////////////////////////////////////////////////////// +CLanguageDialog::CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent, bool* pLock) : CDialog() +{ + m_pszResName=lpszTemplateName; + if (IS_INTRESOURCE(lpszTemplateName)) + m_uiResID=(WORD)lpszTemplateName; + else + m_uiResID=0; + m_pParent=pParent; + m_cType=-1; + m_bAutoDelete=false; + m_pFont=NULL; + m_pbLock=pLock; + m_bLockChanged=false; + m_bLockInstance=false; + m_iBaseX=m_iBaseY=0; + _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready + m_prm->m_lhDialogs.push_back(this); +} + +/////////////////////////////////////////////////////////////// +// Constructor that takes UINT based template name +// uiIDTemplate [in] - specifies the template ID to load +// and show as this dialog. +// pParent [in] - logical (everyone knows) +// pLock [in] - address of a bool for dialog instance checks +/////////////////////////////////////////////////////////////// +CLanguageDialog::CLanguageDialog(UINT uiIDTemplate, CWnd* pParent, bool* pLock) : CDialog() +{ + m_pszResName=MAKEINTRESOURCE(uiIDTemplate); + m_uiResID=uiIDTemplate; + m_pParent=pParent; + m_cType=-1; + m_bAutoDelete=false; + m_pFont=NULL; + m_pbLock=pLock; + m_bLockChanged=false; + m_bLockInstance=false; + m_iBaseX=m_iBaseY=0; + _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready + m_prm->m_lhDialogs.push_back(this); +} + +/////////////////////////////////////////////////////////////// +// Standard destructor +// Removes itself from a list in CWinApp (not to get any window +// messages anymore). +/////////////////////////////////////////////////////////////// +CLanguageDialog::~CLanguageDialog() +{ + list::iterator it=m_prm->m_lhDialogs.begin(); + while (it != m_prm->m_lhDialogs.end()) + { + if (*it == this) + { + m_prm->m_lhDialogs.erase(it); + break; + } + + it++; + } +} + +///////////////////////////////////////////////////////////////////////////// +// CLanguageDialog message handlers + +/////////////////////////////////////////////////////////////// +// Makes properly constructed dialog modal. +// RetVal [out] - value returned by dialog proc +/////////////////////////////////////////////////////////////// +INT_PTR CLanguageDialog::DoModal() +{ + if (m_pszResName) + { + HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); + if (!InitModalIndirect(hDialog)) + return -1; + } + m_cType=0; + return CDialog::DoModal(); +} + +/////////////////////////////////////////////////////////////// +// Creates (and shows probably) this constructed dialog. +// RetVal [out] - if creation succeeded +/////////////////////////////////////////////////////////////// +BOOL CLanguageDialog::Create() +{ + _ASSERT(m_pszResName); // nothing was set as a dialog template + + if (!m_bLockInstance || m_pbLock == NULL || !(*m_pbLock)) + { + HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); + + // modeless dialog + if (!CreateIndirect(hDialog, m_pParent)) + return FALSE; + + m_cType=1; + if (m_pbLock) + { + *m_pbLock=true; + m_bLockChanged=true; + } + + return TRUE; + } + else + { + m_bLockChanged=false; + Cleanup(); + return FALSE; + } +} + +/////////////////////////////////////////////////////////////// +// Changes values based on dialog units into the values in +// pixels. Change is based on std MapDialogRect if the language +// hasn't been changed otf or takes current font into +// consideration. +// pRect [in/out] - on [in] - dialog units, on [out] - pixels +/////////////////////////////////////////////////////////////// +void CLanguageDialog::MapRect(RECT* pRect) +{ + if (m_pFont) + { + pRect->left=MulDiv(pRect->left, m_iBaseX, 4); + pRect->right=MulDiv(pRect->right, m_iBaseX, 4); + pRect->top=MulDiv(pRect->top, m_iBaseY, 8); + pRect->bottom=MulDiv(pRect->bottom, m_iBaseY, 8); + } + else + MapDialogRect(pRect); +} + +/////////////////////////////////////////////////////////////// +// Helper function - called when this dialog receives message +// WM_RMNOTIFY (with WPARAM == RMNT_LANGCHANGE). Updates the +// dialog with data from a new template. Passes params to +// virtual function OnLanguageChanged. +// wOldLang [in] - specifies the old language code +// wNewLang [in] - specifies the new language code. +/////////////////////////////////////////////////////////////// +void CLanguageDialog::UpdateLanguage(WORD /*wOldLang*/, WORD /*wNewLang*/) +{ + // cannot update for string based template + if (m_uiResID == 0) + return; + + // set the title + SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0)); + + // load the dialog template + CDlgTemplate dt; + if (!dt.Open(m_prm->LoadDialog(MAKEINTRESOURCE(m_uiResID)))) + { + TRACE("Cannot open dialog template in UpdateLanguage\n"); + return; + } + + // update the menu + if (GetMenu()) + m_prm->UpdateMenu(GetMenu()->m_hMenu, dt.m_wMenu); + + // font + if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) + { + // dialog font + LOGFONT lf; + memset(&lf, 0, sizeof(LOGFONT)); + HDC hdc=::GetDC(NULL); + lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); + ::ReleaseDC(NULL, hdc); + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = m_prm->m_ld.GetCharset(); + _tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace()); + + delete m_pFont; + m_pFont=new CFont(); + m_pFont->CreateFontIndirect(&lf); + + // change base dlg units + CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize); + } + + if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE)) + { + // dialog size + CRect rcWin; + GetWindowRect(&rcWin); + + CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy); + MapRect(&rcDialog); + rcDialog.bottom+=2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION); + + // correct the height by a menu height + if ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != NULL) && _tcslen(dt.m_pszMenu) != 0)) + rcDialog.bottom+=GetSystemMetrics(SM_CYMENU); + + rcDialog.right+=2*GetSystemMetrics(SM_CXDLGFRAME); + rcDialog.OffsetRect(rcWin.CenterPoint().x-rcDialog.Width()/2, rcWin.CenterPoint().y-rcDialog.Height()/2); + + //TEMP + TRACE("Old dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu; \n\tNew dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu\n", rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height()); + SetWindowPos(NULL, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + } + + // the controls + CWnd* pWnd; + vector::iterator it; + for (it=dt.m_vItems.begin();it != dt.m_vItems.end();it++) + { + // skip controls that cannot be modified + if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == NULL) + continue; + + // the font + if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) + pWnd->SetFont(m_pFont, FALSE); + + // style&ex style + // modify only the rtl/ltr reading order + LONG lStyleEx=::GetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE); + if (lStyleEx & WS_EX_RTLREADING) + { + if (!m_prm->m_ld.GetDirection()) + lStyleEx &= ~WS_EX_RTLREADING; + } + else + { + if (m_prm->m_ld.GetDirection()) + lStyleEx |= WS_EX_RTLREADING; + } + + ::SetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE, lStyleEx); + + // size + CRect rc((*it).m_itemTemplate.x, (*it).m_itemTemplate.y, (*it).m_itemTemplate.x+(*it).m_itemTemplate.cx, (*it).m_itemTemplate.y+(*it).m_itemTemplate.cy); + MapRect(&rc); + pWnd->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + + // text/caption + if ( (*it).m_wClass == 0x0080 || (*it).m_wClass == 0x0082 || (*it).m_wClass == 0x0086 || ((*it).m_pszClass != NULL && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) ) + pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id)); + } +} + +/////////////////////////////////////////////////////////////// +// Helper function - does the cleanup after destroying the +// dialog (that means releasing the instance lock, deleting +// unused fonts and in some cases deleting itself). +/////////////////////////////////////////////////////////////// +void CLanguageDialog::Cleanup() +{ + TRACE("CLanguageDialog::Cleanup()\n"); + + if (m_bLockChanged && m_pbLock) + *m_pbLock=false; + + delete m_pFont; + + if (m_bAutoDelete) + delete this; +} + +/////////////////////////////////////////////////////////////// +// Standard msg - initializes tool tip handling +/////////////////////////////////////////////////////////////// +BOOL CLanguageDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + UpdateLanguage(0,0); // because initially all the texts are empty + + EnableToolTips(TRUE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +/////////////////////////////////////////////////////////////// +// Standard handler for pressing cancel button in a dialog. +// For modeless dialog causes dialog to be destroyed. +/////////////////////////////////////////////////////////////// +void CLanguageDialog::OnCancel() +{ + switch (m_cType) + { + case 0: + CDialog::OnCancel(); + break; + case 1: + DestroyWindow(); + break; + } +} + +/////////////////////////////////////////////////////////////// +// Standard handler for pressing OK button in a dialog. +// For modeless dialog causes destruction of a dialog. +/////////////////////////////////////////////////////////////// +void CLanguageDialog::OnOK() +{ + switch(m_cType) + { + case 0: + CDialog::OnOK(); + break; + case 1: + DestroyWindow(); + break; + } +} + +/////////////////////////////////////////////////////////////// +// Standard override - calls cleanup. +/////////////////////////////////////////////////////////////// +void CLanguageDialog::PostNcDestroy() +{ + CDialog::PostNcDestroy(); + Cleanup(); +} + +/////////////////////////////////////////////////////////////// +// This dialog's window procedure handler - look at ms docs. +/////////////////////////////////////////////////////////////// +LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_RMNOTIFY: + if ((UINT)wParam == RMNT_LANGCHANGE) + { + UpdateLanguage(HIWORD(lParam), LOWORD(lParam)); + + // now update user controls (everybody has to do it him(her)self) + OnLanguageChanged(HIWORD(lParam), LOWORD(lParam)); + break; + } + case WM_NOTIFY: + { + NMHDR* pnmh=(NMHDR*)lParam; + if (pnmh->code == TTN_NEEDTEXT) + { + // establish the ID of a control + TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh; + UINT nID; + if (ppt->uFlags & TTF_IDISHWND) + nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom); + else + nID=(UINT)pnmh->idFrom; + + return OnTooltipText(nID, ppt); + } + break; + } + } + + return CDialog::WindowProc(message, wParam, lParam); +} + +/////////////////////////////////////////////////////////////// +// Helper function. Recalculates current sizes of a dialog base +// units (font dependent) and stores in the internal members. +// pszFacename [in] - font's face name. +// wPointSize [in] - size of the font in points. +/////////////////////////////////////////////////////////////// +void CLanguageDialog::CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize) +{ + LOGFONT lf; + HDC hDC = ::GetDC(NULL); + memset(&lf, 0, sizeof(LOGFONT)); + lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); + lf.lfWeight = FW_NORMAL; + lf.lfCharSet = DEFAULT_CHARSET; + lstrcpy(lf.lfFaceName, pszFacename); + + HFONT hNewFont = CreateFontIndirect(&lf); + if (hNewFont != NULL) + { + HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont); + TEXTMETRIC tm; + GetTextMetrics(hDC, &tm); + m_iBaseY = tm.tmHeight + tm.tmExternalLeading; + SIZE size; + ::GetTextExtentPoint32(hDC, _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &size); + m_iBaseX = (size.cx + 26) / 52; + SelectObject(hDC, hFontOld); + DeleteObject(hNewFont); + } + else + { + // Could not create the font so just use the system's values + m_iBaseX = LOWORD(GetDialogBaseUnits()); + m_iBaseY = HIWORD(GetDialogBaseUnits()); + } + ::ReleaseDC(NULL, hDC); +} \ No newline at end of file Index: ch/LanguageDialog.cpp =================================================================== diff -u -N --- ch/LanguageDialog.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/LanguageDialog.cpp (revision 0) @@ -1,675 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "LanguageDialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CDlgTemplate -CDlgTemplate::CDlgTemplate(const DLGTEMPLATE* pDlgTemplate) -{ - Open(pDlgTemplate); -} - -CDlgTemplate::CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate) -{ - Open((DLGTEMPLATE*)pDlgTemplate); -} - -CDlgTemplate::~CDlgTemplate() -{ - delete [] m_pszMenu; - delete [] m_pszClass; - delete [] m_pszTitle; - delete [] m_pszFace; - - // items - vector<_ITEM>::iterator it; - for (it=m_vItems.begin();it != m_vItems.end();it++) - { - delete [] (*it).m_pbyCreationData; - delete [] (*it).m_pszClass; - delete [] (*it).m_pszTitle; - } -} - -bool CDlgTemplate::Open(const DLGTEMPLATE* pDlgTemplate) -{ - if (pDlgTemplate == NULL) - return false; - bool bExt=((DLGTEMPLATEEX*)pDlgTemplate)->signature == 0xffff; - const BYTE* pData=((BYTE*)pDlgTemplate); - if (bExt) - { - m_dlgTemplate=*((DLGTEMPLATEEX*)pDlgTemplate); - pData+=sizeof(DLGTEMPLATEEX); - } - else - { - ConvertDlgToEx(pDlgTemplate, &m_dlgTemplate); - pData+=sizeof(DLGTEMPLATE); - } - - // here is the menu, class and title - pData=ReadCompoundData(pData, &m_wMenu, &m_pszMenu); - pData=ReadCompoundData(pData, &m_wClass, &m_pszClass); - pData=ReadCompoundData(pData, &m_wTitle, &m_pszTitle); - - // font - if (m_dlgTemplate.style & DS_SETFONT || m_dlgTemplate.style & DS_SHELLFONT) - { - m_wFontSize=*((WORD*)pData); - pData+=sizeof(WORD); - if (bExt) - { - m_wWeight=*((WORD*)pData); - pData+=sizeof(WORD); - m_byItalic=*((BYTE*)pData); - pData+=sizeof(BYTE); - m_byCharset=*((BYTE*)pData); - pData+=sizeof(BYTE); - } - else - { - m_wWeight=FW_NORMAL; - m_byItalic=FALSE; - m_byCharset=DEFAULT_CHARSET; - } - DWORD dwLen=(DWORD)wcslen((wchar_t*)pData); - m_pszFace=new TCHAR[dwLen+1]; -#ifdef _UNICODE - _tcscpy(m_pszFace, (wchar_t*)pData); -#else - WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pData, dwLen+1, m_pszFace, dwLen+1, NULL, NULL); -#endif - pData+=(dwLen+1)*sizeof(wchar_t); - } - else - { - m_wFontSize=0xffff; - m_pszFace=NULL; - } - - // items - _ITEM item; - for (int i=0;i 0) - { - item.m_wCreationDataSize-=sizeof(WORD); - item.m_pbyCreationData=new BYTE[item.m_wCreationDataSize]; - memcpy(item.m_pbyCreationData, pData, item.m_wCreationDataSize); - } - else - item.m_pbyCreationData=NULL; - - m_vItems.push_back(item); - } - - return true; -} - -void CDlgTemplate::ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst) -{ - pDst->helpID=0; - pDst->exStyle=pSrc->dwExtendedStyle; - pDst->style=pSrc->style; - pDst->x=pSrc->x; - pDst->y=pSrc->y; - pDst->cx=pSrc->cx; - pDst->cy=pSrc->cy; - pDst->id=pSrc->id; -} - -void CDlgTemplate::ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst) -{ - pDst->dlgVer=1; - pDst->signature=0x0000; - pDst->helpID=(ULONG)0; - pDst->exStyle=pSrc->dwExtendedStyle; - pDst->style=pSrc->style; - pDst->cDlgItems=pSrc->cdit; - pDst->x=pSrc->x; - pDst->y=pSrc->y; - pDst->cx=pSrc->cx; - pDst->cy=pSrc->cy; -} - -const BYTE* CDlgTemplate::ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr) -{ - if (*((WORD*)pBuffer) == 0xffff) - { - *pwData=*((WORD*)(pBuffer+2)); - *ppszStr=NULL; - - return pBuffer+4; - } - else - { - *pwData=0xffff; - DWORD dwLen=(DWORD)wcslen((wchar_t*)pBuffer); - *ppszStr=new TCHAR[dwLen+1]; -#ifdef _UNICODE - _tcscpy(*ppszStr, (wchar_t*)pBuffer); -#else - WideCharToMultiByte(CP_ACP, 0, (wchar_t*)pBuffer, dwLen+1, *ppszStr, dwLen+1, NULL, NULL); -#endif - return pBuffer+(dwLen+1)*sizeof(wchar_t); - } - -} - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog - -CResourceManager *CLanguageDialog::m_prm=NULL; - -/////////////////////////////////////////////////////////////// -// Standard constructor -// pLock [in] - specifies address of a bool value that'll be -// used to check if another instance of this window has -// already been shown. Should be declared in derived class -// as 'static bool m_xxx;' and initialized to 0. -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(bool* pLock) : CDialog() -{ - m_pszResName=NULL; - m_uiResID=0; - m_pParent=NULL; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Constructor that takes string based template name -// lpszTemplateName [in] - specifies the template name to load -// and show as this dialog. -// pParent [in] - logical (everyone knows) -// pLock [in] - address of a bool for dialog instance checks -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent, bool* pLock) : CDialog() -{ - m_pszResName=lpszTemplateName; - if (IS_INTRESOURCE(lpszTemplateName)) - m_uiResID=(WORD)lpszTemplateName; - else - m_uiResID=0; - m_pParent=pParent; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Constructor that takes UINT based template name -// uiIDTemplate [in] - specifies the template ID to load -// and show as this dialog. -// pParent [in] - logical (everyone knows) -// pLock [in] - address of a bool for dialog instance checks -/////////////////////////////////////////////////////////////// -CLanguageDialog::CLanguageDialog(UINT uiIDTemplate, CWnd* pParent, bool* pLock) : CDialog() -{ - m_pszResName=MAKEINTRESOURCE(uiIDTemplate); - m_uiResID=uiIDTemplate; - m_pParent=pParent; - m_cType=-1; - m_bAutoDelete=false; - m_pFont=NULL; - m_pbLock=pLock; - m_bLockChanged=false; - m_bLockInstance=false; - m_iBaseX=m_iBaseY=0; - _ASSERT(m_prm); // make sure the CLanguageDialog::SetResManager() has been called aready - m_prm->m_lhDialogs.push_back(this); -} - -/////////////////////////////////////////////////////////////// -// Standard destructor -// Removes itself from a list in CWinApp (not to get any window -// messages anymore). -/////////////////////////////////////////////////////////////// -CLanguageDialog::~CLanguageDialog() -{ - list::iterator it=m_prm->m_lhDialogs.begin(); - while (it != m_prm->m_lhDialogs.end()) - { - if (*it == this) - { - m_prm->m_lhDialogs.erase(it); - break; - } - - it++; - } -} - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog message handlers - -/////////////////////////////////////////////////////////////// -// Makes properly constructed dialog modal. -// RetVal [out] - value returned by dialog proc -/////////////////////////////////////////////////////////////// -INT_PTR CLanguageDialog::DoModal() -{ - if (m_pszResName) - { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); - if (!InitModalIndirect(hDialog)) - return -1; - } - m_cType=0; - return CDialog::DoModal(); -} - -/////////////////////////////////////////////////////////////// -// Creates (and shows probably) this constructed dialog. -// RetVal [out] - if creation succeeded -/////////////////////////////////////////////////////////////// -BOOL CLanguageDialog::Create() -{ - _ASSERT(m_pszResName); // nothing was set as a dialog template - - if (!m_bLockInstance || m_pbLock == NULL || !(*m_pbLock)) - { - HGLOBAL hDialog=m_prm->LoadResource(RT_DIALOG, m_pszResName); - - // modeless dialog - if (!CreateIndirect(hDialog, m_pParent)) - return FALSE; - - m_cType=1; - if (m_pbLock) - { - *m_pbLock=true; - m_bLockChanged=true; - } - - return TRUE; - } - else - { - m_bLockChanged=false; - Cleanup(); - return FALSE; - } -} - -/////////////////////////////////////////////////////////////// -// Changes values based on dialog units into the values in -// pixels. Change is based on std MapDialogRect if the language -// hasn't been changed otf or takes current font into -// consideration. -// pRect [in/out] - on [in] - dialog units, on [out] - pixels -/////////////////////////////////////////////////////////////// -void CLanguageDialog::MapRect(RECT* pRect) -{ - if (m_pFont) - { - pRect->left=MulDiv(pRect->left, m_iBaseX, 4); - pRect->right=MulDiv(pRect->right, m_iBaseX, 4); - pRect->top=MulDiv(pRect->top, m_iBaseY, 8); - pRect->bottom=MulDiv(pRect->bottom, m_iBaseY, 8); - } - else - MapDialogRect(pRect); -} - -/////////////////////////////////////////////////////////////// -// Helper function - called when this dialog receives message -// WM_RMNOTIFY (with WPARAM == RMNT_LANGCHANGE). Updates the -// dialog with data from a new template. Passes params to -// virtual function OnLanguageChanged. -// wOldLang [in] - specifies the old language code -// wNewLang [in] - specifies the new language code. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::UpdateLanguage(WORD /*wOldLang*/, WORD /*wNewLang*/) -{ - // cannot update for string based template - if (m_uiResID == 0) - return; - - // set the title - SetWindowText(m_prm->LoadString((WORD)m_uiResID, 0)); - - // load the dialog template - CDlgTemplate dt; - if (!dt.Open(m_prm->LoadDialog(MAKEINTRESOURCE(m_uiResID)))) - { - TRACE("Cannot open dialog template in UpdateLanguage\n"); - return; - } - - // update the menu - if (GetMenu()) - m_prm->UpdateMenu(GetMenu()->m_hMenu, dt.m_wMenu); - - // font - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) - { - // dialog font - LOGFONT lf; - memset(&lf, 0, sizeof(LOGFONT)); - HDC hdc=::GetDC(NULL); - lf.lfHeight = -MulDiv(m_prm->m_ld.GetPointSize(), GetDeviceCaps(hdc, LOGPIXELSY), 72); - ::ReleaseDC(NULL, hdc); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = m_prm->m_ld.GetCharset(); - _tcscpy(lf.lfFaceName, m_prm->m_ld.GetFontFace()); - - delete m_pFont; - m_pFont=new CFont(); - m_pFont->CreateFontIndirect(&lf); - - // change base dlg units - CalcBaseUnits(dt.m_pszFace, dt.m_wFontSize); - } - - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGSIZE)) - { - // dialog size - CRect rcWin; - GetWindowRect(&rcWin); - - CRect rcDialog(0, 0, dt.m_dlgTemplate.cx, dt.m_dlgTemplate.cy); - MapRect(&rcDialog); - rcDialog.bottom+=2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYCAPTION); - - // correct the height by a menu height - if ((dt.m_wMenu != 0xffff) || ((dt.m_pszMenu != NULL) && _tcslen(dt.m_pszMenu) != 0)) - rcDialog.bottom+=GetSystemMetrics(SM_CYMENU); - - rcDialog.right+=2*GetSystemMetrics(SM_CXDLGFRAME); - rcDialog.OffsetRect(rcWin.CenterPoint().x-rcDialog.Width()/2, rcWin.CenterPoint().y-rcDialog.Height()/2); - - //TEMP - TRACE("Old dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu; \n\tNew dlg pos/size: x=%lu, y=%lu, cx=%lu, cy=%lu\n", rcWin.left, rcWin.top, rcWin.Width(), rcWin.Height(), rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height()); - SetWindowPos(NULL, rcDialog.left, rcDialog.top, rcDialog.Width(), rcDialog.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - } - - // the controls - CWnd* pWnd; - vector::iterator it; - for (it=dt.m_vItems.begin();it != dt.m_vItems.end();it++) - { - // skip controls that cannot be modified - if ( (*it).m_itemTemplate.id == 0xffff || (pWnd=GetDlgItem((*it).m_itemTemplate.id)) == NULL) - continue; - - // the font - if (!(GetLanguageUpdateOptions() & LDF_NODIALOGFONT)) - pWnd->SetFont(m_pFont, FALSE); - - // style&ex style - // modify only the rtl/ltr reading order - LONG lStyleEx=::GetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE); - if (lStyleEx & WS_EX_RTLREADING) - { - if (!m_prm->m_ld.GetDirection()) - lStyleEx &= ~WS_EX_RTLREADING; - } - else - { - if (m_prm->m_ld.GetDirection()) - lStyleEx |= WS_EX_RTLREADING; - } - - ::SetWindowLong(pWnd->m_hWnd, GWL_EXSTYLE, lStyleEx); - - // size - CRect rc((*it).m_itemTemplate.x, (*it).m_itemTemplate.y, (*it).m_itemTemplate.x+(*it).m_itemTemplate.cx, (*it).m_itemTemplate.y+(*it).m_itemTemplate.cy); - MapRect(&rc); - pWnd->SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); - - // text/caption - if ( (*it).m_wClass == 0x0080 || (*it).m_wClass == 0x0082 || (*it).m_wClass == 0x0086 || ((*it).m_pszClass != NULL && _tcscmp((*it).m_pszClass, _T("STATICEX")) == 0) ) - pWnd->SetWindowText(m_prm->LoadString((WORD)m_uiResID, (*it).m_itemTemplate.id)); - } -} - -/////////////////////////////////////////////////////////////// -// Helper function - does the cleanup after destroying the -// dialog (that means releasing the instance lock, deleting -// unused fonts and in some cases deleting itself). -/////////////////////////////////////////////////////////////// -void CLanguageDialog::Cleanup() -{ - TRACE("CLanguageDialog::Cleanup()\n"); - - if (m_bLockChanged && m_pbLock) - *m_pbLock=false; - - delete m_pFont; - - if (m_bAutoDelete) - delete this; -} - -/////////////////////////////////////////////////////////////// -// Standard msg - initializes tool tip handling -/////////////////////////////////////////////////////////////// -BOOL CLanguageDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - UpdateLanguage(0,0); // because initially all the texts are empty - - EnableToolTips(TRUE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/////////////////////////////////////////////////////////////// -// Standard handler for pressing cancel button in a dialog. -// For modeless dialog causes dialog to be destroyed. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::OnCancel() -{ - switch (m_cType) - { - case 0: - CDialog::OnCancel(); - break; - case 1: - DestroyWindow(); - break; - } -} - -/////////////////////////////////////////////////////////////// -// Standard handler for pressing OK button in a dialog. -// For modeless dialog causes destruction of a dialog. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::OnOK() -{ - switch(m_cType) - { - case 0: - CDialog::OnOK(); - break; - case 1: - DestroyWindow(); - break; - } -} - -/////////////////////////////////////////////////////////////// -// Standard override - calls cleanup. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::PostNcDestroy() -{ - CDialog::PostNcDestroy(); - Cleanup(); -} - -/////////////////////////////////////////////////////////////// -// This dialog's window procedure handler - look at ms docs. -/////////////////////////////////////////////////////////////// -LRESULT CLanguageDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_RMNOTIFY: - if ((UINT)wParam == RMNT_LANGCHANGE) - { - UpdateLanguage(HIWORD(lParam), LOWORD(lParam)); - - // now update user controls (everybody has to do it him(her)self) - OnLanguageChanged(HIWORD(lParam), LOWORD(lParam)); - break; - } - case WM_NOTIFY: - { - NMHDR* pnmh=(NMHDR*)lParam; - if (pnmh->code == TTN_NEEDTEXT) - { - // establish the ID of a control - TOOLTIPTEXT *ppt=(TOOLTIPTEXT*)pnmh; - UINT nID; - if (ppt->uFlags & TTF_IDISHWND) - nID=(UINT)::GetDlgCtrlID((HWND)pnmh->idFrom); - else - nID=(UINT)pnmh->idFrom; - - return OnTooltipText(nID, ppt); - } - break; - } - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -/////////////////////////////////////////////////////////////// -// Helper function. Recalculates current sizes of a dialog base -// units (font dependent) and stores in the internal members. -// pszFacename [in] - font's face name. -// wPointSize [in] - size of the font in points. -/////////////////////////////////////////////////////////////// -void CLanguageDialog::CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize) -{ - LOGFONT lf; - HDC hDC = ::GetDC(NULL); - memset(&lf, 0, sizeof(LOGFONT)); - lf.lfHeight = -MulDiv(wPointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72); - lf.lfWeight = FW_NORMAL; - lf.lfCharSet = DEFAULT_CHARSET; - lstrcpy(lf.lfFaceName, pszFacename); - - HFONT hNewFont = CreateFontIndirect(&lf); - if (hNewFont != NULL) - { - HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont); - TEXTMETRIC tm; - GetTextMetrics(hDC, &tm); - m_iBaseY = tm.tmHeight + tm.tmExternalLeading; - SIZE size; - ::GetTextExtentPoint32(hDC, _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52, &size); - m_iBaseX = (size.cx + 26) / 52; - SelectObject(hDC, hFontOld); - DeleteObject(hNewFont); - } - else - { - // Could not create the font so just use the system's values - m_iBaseX = LOWORD(GetDialogBaseUnits()); - m_iBaseY = HIWORD(GetDialogBaseUnits()); - } - ::ReleaseDC(NULL, hDC); -} \ No newline at end of file Index: src/ch/LanguageDialog.h =================================================================== diff -u -N --- src/ch/LanguageDialog.h (revision 0) +++ src/ch/LanguageDialog.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,202 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/************************************************************************* + CLanguageDialog template + + Files: LanguageDialog.h, LanguageDialog.cpp + Author: Ixen Gerthannes + Usage: + Derive your class from CLanguageDialog instead of CDialog, change all + calls from CDialog to CLanguageDialog, change call to base constructor + so it can take language as parameter. + Creating dialog class: + - derive class from CLanguageDialog + - change all occurences of CDialog to CLanguageDialog + - change parameters list of your default constructor so it can take + language as parameter (WORD wLang) + - modify call to base class constructor by putting into it declared + wLang from your constructor + Displaying dialog box: + - declare object as your dialog class + - eventually set public member m_bAutoDelete to true if you're + creating dialog with operator new, and it should be + automatically deleted when closed + - call DoModal/Create/CreateModeless member function for + modal/modeless/mixed mode dialog + Members: + Constructors - as described in CDialog constructors - language + specifies resource language to load + CLanguageDialog(); + CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL); + CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL); + Functions: + int DoModal(); - like in CDialog + BOOL Create(); - creates modeless dialog box; this class + automatically handles DestroyWindow, and like + void Cleanup(); - function cleans unused data - use only when + window object wasn't created yet (in Create() and earlier) + WORD GetCurrentLanguage() const; - retrieves current language + setting for this dialog + Attributes: + bool m_bAutoDelete; - specifies whether this dialog should be + deleted (by 'delete this') when closed. +*************************************************************************/ +#pragma once + +#include "ResourceManager.h" + +#pragma pack(push, 1) +struct DLGTEMPLATEEX +{ + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; +}; + +struct DLGITEMTEMPLATEEX +{ + DWORD helpID; + DWORD exStyle; + DWORD style; + short x; + short y; + short cx; + short cy; + WORD id; + WORD __DUMMY__; +}; +#pragma pack(pop) + +class CDlgTemplate +{ +public: + CDlgTemplate() { m_wMenu=(WORD)-1; m_pszMenu=NULL; m_wClass=(WORD)-1; m_pszClass=NULL, m_wTitle=(WORD)-1; m_pszTitle=NULL; m_wFontSize=0; m_wWeight=0; m_byItalic=0; m_byCharset=0; m_pszFace=NULL; }; + CDlgTemplate(const DLGTEMPLATE* pDlgTemplate); + CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate); + ~CDlgTemplate(); + + bool Open(const DLGTEMPLATE* pDlgTemplate); + +protected: + void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst); // converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX + void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst); + + const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr); + +public: + struct _ITEM + { + DLGITEMTEMPLATEEX m_itemTemplate; + + WORD m_wClass; + TCHAR *m_pszClass; + + WORD m_wTitle; + TCHAR *m_pszTitle; + + WORD m_wCreationDataSize; + BYTE *m_pbyCreationData; + }; + vector<_ITEM> m_vItems; + + DLGTEMPLATEEX m_dlgTemplate; + + WORD m_wMenu; + TCHAR *m_pszMenu; + + WORD m_wClass; + TCHAR *m_pszClass; + + WORD m_wTitle; // always -1 + TCHAR *m_pszTitle; + + // font + WORD m_wFontSize; + WORD m_wWeight; + BYTE m_byItalic; + BYTE m_byCharset; + TCHAR *m_pszFace; +}; + +///////////////////////////////////////////////////////////////////////////// +// CLanguageDialog dialog +#define LDF_NODIALOGSIZE 0x01 +#define LDF_NODIALOGFONT 0x02 + +class CLanguageDialog : public CDialog +{ +public: +// Construction/destruction + CLanguageDialog(bool* pLock=NULL); + CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor + CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor + + ~CLanguageDialog(); + + // static members - initialize global pointer to a resource manager + static void SetResManager(CResourceManager* prm) { m_prm=prm; }; + + // creation + virtual INT_PTR DoModal(); + virtual BOOL Create(); + + void MapRect(RECT* pRect); + CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); }; + +protected: + void UpdateLanguage(WORD wOldLang, WORD wNewLang); + virtual UINT GetLanguageUpdateOptions() { return 0; }; + virtual void OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) { }; + void Cleanup(); + + virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; }; + virtual BOOL OnInitDialog(); + virtual void OnCancel(); + virtual void OnOK(); + virtual void PostNcDestroy(); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + +private: + void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize); + +// Attributes +public: + bool m_bAutoDelete; // deletes this dialog when exiting + bool m_bLockInstance; // allows only one instance of this dialog if set + +protected: + static CResourceManager* m_prm; // points to the resource manager instance + + bool *m_pbLock; // dialog box instance lock system + bool m_bLockChanged; // if this dialog changed the lock + PCTSTR m_pszResName; // resource (string) name of the dialog template + UINT m_uiResID; // resource ID if any of the dialog template + CWnd* m_pParent; // parent window ptr + char m_cType; // type of this dialog box + CFont* m_pFont; // currently used font + int m_iBaseX, m_iBaseY; +}; \ No newline at end of file Index: ch/LanguageDialog.h =================================================================== diff -u -N --- ch/LanguageDialog.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/LanguageDialog.h (revision 0) @@ -1,202 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/************************************************************************* - CLanguageDialog template - - Files: LanguageDialog.h, LanguageDialog.cpp - Author: Ixen Gerthannes - Usage: - Derive your class from CLanguageDialog instead of CDialog, change all - calls from CDialog to CLanguageDialog, change call to base constructor - so it can take language as parameter. - Creating dialog class: - - derive class from CLanguageDialog - - change all occurences of CDialog to CLanguageDialog - - change parameters list of your default constructor so it can take - language as parameter (WORD wLang) - - modify call to base class constructor by putting into it declared - wLang from your constructor - Displaying dialog box: - - declare object as your dialog class - - eventually set public member m_bAutoDelete to true if you're - creating dialog with operator new, and it should be - automatically deleted when closed - - call DoModal/Create/CreateModeless member function for - modal/modeless/mixed mode dialog - Members: - Constructors - as described in CDialog constructors - language - specifies resource language to load - CLanguageDialog(); - CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL); - CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL); - Functions: - int DoModal(); - like in CDialog - BOOL Create(); - creates modeless dialog box; this class - automatically handles DestroyWindow, and like - void Cleanup(); - function cleans unused data - use only when - window object wasn't created yet (in Create() and earlier) - WORD GetCurrentLanguage() const; - retrieves current language - setting for this dialog - Attributes: - bool m_bAutoDelete; - specifies whether this dialog should be - deleted (by 'delete this') when closed. -*************************************************************************/ -#pragma once - -#include "ResourceManager.h" - -#pragma pack(push, 1) -struct DLGTEMPLATEEX -{ - WORD dlgVer; - WORD signature; - DWORD helpID; - DWORD exStyle; - DWORD style; - WORD cDlgItems; - short x; - short y; - short cx; - short cy; -}; - -struct DLGITEMTEMPLATEEX -{ - DWORD helpID; - DWORD exStyle; - DWORD style; - short x; - short y; - short cx; - short cy; - WORD id; - WORD __DUMMY__; -}; -#pragma pack(pop) - -class CDlgTemplate -{ -public: - CDlgTemplate() { m_wMenu=(WORD)-1; m_pszMenu=NULL; m_wClass=(WORD)-1; m_pszClass=NULL, m_wTitle=(WORD)-1; m_pszTitle=NULL; m_wFontSize=0; m_wWeight=0; m_byItalic=0; m_byCharset=0; m_pszFace=NULL; }; - CDlgTemplate(const DLGTEMPLATE* pDlgTemplate); - CDlgTemplate(const DLGTEMPLATEEX* pDlgTemplate); - ~CDlgTemplate(); - - bool Open(const DLGTEMPLATE* pDlgTemplate); - -protected: - void ConvertItemToEx(const DLGITEMTEMPLATE* pSrc, DLGITEMTEMPLATEEX* pDst); // converts DLGITEMTEMPLATE to DLGITEMTEMPLATEEX - void ConvertDlgToEx(const DLGTEMPLATE* pSrc, DLGTEMPLATEEX* pDst); - - const BYTE* ReadCompoundData(const BYTE* pBuffer, WORD* pwData, PTSTR* ppszStr); - -public: - struct _ITEM - { - DLGITEMTEMPLATEEX m_itemTemplate; - - WORD m_wClass; - TCHAR *m_pszClass; - - WORD m_wTitle; - TCHAR *m_pszTitle; - - WORD m_wCreationDataSize; - BYTE *m_pbyCreationData; - }; - vector<_ITEM> m_vItems; - - DLGTEMPLATEEX m_dlgTemplate; - - WORD m_wMenu; - TCHAR *m_pszMenu; - - WORD m_wClass; - TCHAR *m_pszClass; - - WORD m_wTitle; // always -1 - TCHAR *m_pszTitle; - - // font - WORD m_wFontSize; - WORD m_wWeight; - BYTE m_byItalic; - BYTE m_byCharset; - TCHAR *m_pszFace; -}; - -///////////////////////////////////////////////////////////////////////////// -// CLanguageDialog dialog -#define LDF_NODIALOGSIZE 0x01 -#define LDF_NODIALOGFONT 0x02 - -class CLanguageDialog : public CDialog -{ -public: -// Construction/destruction - CLanguageDialog(bool* pLock=NULL); - CLanguageDialog(PCTSTR lpszTemplateName, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor - CLanguageDialog(UINT uiIDTemplate, CWnd* pParent = NULL, bool* pLock=NULL); // standard constructor - - ~CLanguageDialog(); - - // static members - initialize global pointer to a resource manager - static void SetResManager(CResourceManager* prm) { m_prm=prm; }; - - // creation - virtual INT_PTR DoModal(); - virtual BOOL Create(); - - void MapRect(RECT* pRect); - CFont* GetFont() { return m_pFont ? m_pFont : ((CDialog*)this)->GetFont(); }; - -protected: - void UpdateLanguage(WORD wOldLang, WORD wNewLang); - virtual UINT GetLanguageUpdateOptions() { return 0; }; - virtual void OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) { }; - void Cleanup(); - - virtual BOOL OnTooltipText(UINT /*uiID*/, TOOLTIPTEXT* /*pTip*/) { return FALSE; }; - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - virtual void OnOK(); - virtual void PostNcDestroy(); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - -private: - void CalcBaseUnits(PCTSTR pszFacename, WORD wPointSize); - -// Attributes -public: - bool m_bAutoDelete; // deletes this dialog when exiting - bool m_bLockInstance; // allows only one instance of this dialog if set - -protected: - static CResourceManager* m_prm; // points to the resource manager instance - - bool *m_pbLock; // dialog box instance lock system - bool m_bLockChanged; // if this dialog changed the lock - PCTSTR m_pszResName; // resource (string) name of the dialog template - UINT m_uiResID; // resource ID if any of the dialog template - CWnd* m_pParent; // parent window ptr - char m_cType; // type of this dialog box - CFont* m_pFont; // currently used font - int m_iBaseX, m_iBaseY; -}; \ No newline at end of file Index: src/ch/MainWnd.cpp =================================================================== diff -u -N --- src/ch/MainWnd.cpp (revision 0) +++ src/ch/MainWnd.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,2088 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" + +#include "MainWnd.h" +#include "OptionsDlg.h" + +#include "shlobj.h" +#include "tchar.h" +#include "structs.h" +#include "dialogs.h" + +#pragma warning (disable : 4201) +#include "mmsystem.h" +#pragma warning (default : 4201) + +#include "FolderDialog.h" + +#include "CustomCopyDlg.h" +#include "ReplaceFilesDlg.h" +#include "btnIDs.h" +#include "SmallReplaceFilesDlg.h" +#include "ReplaceOnlyDlg.h" +#include "DstFileErrorDlg.h" +#include "..\Common\FileSupport.h" +#include "AboutDlg.h" +#include "NotEnoughRoomDlg.h" +#include "register.h" +#include "ShutdownDlg.h" +#include "StringHelpers.h" +#include "..\common\ipcstructs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define WM_ICON_NOTIFY WM_USER+4 +#define WM_SHOWMINIVIEW WM_USER+3 +#define WM_IDENTIFY WM_USER+11 + +#define TM_AUTOREMOVE 1000 +#define TM_AUTORESUME 1000 +#define TM_ACCEPTING 100 + +// assume max sectors of 4kB (for rounding) +#define MAXSECTORSIZE 4096 + +extern CSharedConfigStruct* g_pscsShared; + +extern int iCount; +extern unsigned short msg[]; + +extern int iOffCount; +extern unsigned char off[]; +extern unsigned short _hash[]; + + +///////////////////////////////////////////////////////////////////////////// +// CMainWnd +// registers main window class +ATOM CMainWnd::RegisterClass() +{ + WNDCLASS wc; + + wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = (WNDPROC)::DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = AfxGetInstanceHandle(); + wc.hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(AFX_IDI_STD_FRAME)); + wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wc.lpszMenuName = NULL; + wc.lpszClassName = _T("Copy Handler Wnd Class"); + + return ::RegisterClass(&wc); +} + +// creates this window +BOOL CMainWnd::Create() +{ + ATOM at=RegisterClass(); + + return CreateEx(WS_EX_TOOLWINDOW, (LPCTSTR)at, _T("Copy Handler"), WS_OVERLAPPED, 10, 10, 10, 10, NULL, (HMENU)NULL, NULL); +} + +int CMainWnd::ShowTrayIcon() +{ + // create system tray icon + HICON hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_VGACOLOR); + bool bRes=m_ctlTray.CreateIcon(m_hWnd, WM_TRAYNOTIFY, GetApp()->GetAppNameVer(), hIcon, 0); + if (!bRes) + { +// GetLog()->Log(_T("[CMainWnd] ... creating tray icon failed.")); + return -1; + } + +/* if (!m_ctlTray.ShowIcon()) + GetLog()->Log(_T("[CMainWnd] ... showing tray icon failed.")); + else + GetLog()->Log(_T("[CMainWnd] ... showing tray icon succeeded.")); +*/ + return 0; +} + +IMPLEMENT_DYNCREATE(CMainWnd, CWnd) + +BEGIN_MESSAGE_MAP(CMainWnd, CWnd) + //{{AFX_MSG_MAP(CMainWnd) + ON_COMMAND(ID_POPUP_SHOW_STATUS, OnPopupShowStatus) + ON_COMMAND(ID_POPUP_OPTIONS, OnPopupShowOptions) + ON_WM_CLOSE() + ON_WM_TIMER() + ON_WM_COPYDATA() + ON_WM_CREATE() + ON_COMMAND(ID_SHOW_MINI_VIEW, OnShowMiniView) + ON_COMMAND(ID_POPUP_CUSTOM_COPY, OnPopupCustomCopy) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + ON_COMMAND(ID_POPUP_MONITORING, OnPopupMonitoring) + ON_COMMAND(ID_POPUP_SHUTAFTERFINISHED, OnPopupShutafterfinished) + ON_COMMAND(ID_POPUP_REGISTERDLL, OnPopupRegisterdll) + ON_COMMAND(ID_POPUP_UNREGISTERDLL, OnPopupUnregisterdll) + ON_COMMAND(ID_APP_EXIT, OnAppExit) + ON_COMMAND(ID_POPUP_HELP, OnPopupHelp) + //}}AFX_MSG_MAP + ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CMainWnd construction/destruction + +CMainWnd::CMainWnd() +{ + m_pdlgStatus=NULL; + m_pdlgMiniView=NULL; + m_dwLastTime=0; +} + +CMainWnd::~CMainWnd() +{ +} + +// case insensitive replacement +inline void ReplaceNoCase(CString& rString, CString strOld, CString strNew) +{ + if (rString.Left(strOld.GetLength()).CompareNoCase(strOld) == 0) + rString=strNew+rString.Right(rString.GetLength()-strOld.GetLength()); +} + +bool TimeToFileTime(const COleDateTime& time, LPFILETIME pFileTime) +{ + SYSTEMTIME sysTime; + sysTime.wYear = (WORD)time.GetYear(); + sysTime.wMonth = (WORD)time.GetMonth(); + sysTime.wDay = (WORD)time.GetDay(); + sysTime.wHour = (WORD)time.GetHour(); + sysTime.wMinute = (WORD)time.GetMinute(); + sysTime.wSecond = (WORD)time.GetSecond(); + sysTime.wMilliseconds = 0; + + // convert system time to local file time + FILETIME localTime; + if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, &localTime)) + return false; + + // convert local file time to UTC file time + if (!LocalFileTimeToFileTime(&localTime, pFileTime)) + return false; + + return true; +} + +bool SetFileDirectoryTime(LPCTSTR lpszName, CFileInfo* pSrcInfo) +{ + FILETIME creation, lastAccess, lastWrite; + + if (!TimeToFileTime(pSrcInfo->GetCreationTime(), &creation) + || !TimeToFileTime(pSrcInfo->GetLastAccessTime(), &lastAccess) + || !TimeToFileTime(pSrcInfo->GetLastWriteTime(), &lastWrite) ) + return false; + + HANDLE handle=CreateFile(lpszName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (handle == INVALID_HANDLE_VALUE) + return false; + + if (!SetFileTime(handle, &creation, &lastAccess, &lastWrite)) + { + CloseHandle(handle); + return false; + } + + if (!CloseHandle(handle)) + return false; + + return true; +} + +// searching for files +inline void RecurseDirectories(CTask* pTask) +{ + TRACE("Searching for files...\n"); + + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFSEARCHINGFORFILES_STRING)); + + // update status + pTask->SetStatus(ST_SEARCHING, ST_STEP_MASK); + + // delete the content of m_files + pTask->FilesRemoveAll(); + + // enter some data to m_files + int nSize=pTask->GetClipboardDataSize(); // size of m_clipboard + const CFiltersArray* pFilters=pTask->GetFilters(); + int iDestDrvNumber=pTask->GetDestDriveNumber(); + bool bIgnoreDirs=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; + bool bForceDirectories=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; + bool bMove=pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE; + CFileInfo fi; + fi.SetClipboard(pTask->GetClipboard()); + + // add everything + for (int i=0;iGetClipboardData(i)->GetPath(), i)) + { + // log + pTask->m_log.logw(GetResManager()->LoadString(IDS_OTFMISSINGCLIPBOARDINPUT_STRING), (PCTSTR)pTask->GetClipboardData(i)->GetPath()); + continue; + } + else + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDINGCLIPBOARDFILE_STRING), (PCTSTR)pTask->GetClipboardData(i)->GetPath()); + } + + // found file/folder - check if the dest name has been generated + if (pTask->GetClipboardData(i)->m_astrDstPaths.GetSize() == 0) + { + // generate something - if dest folder == src folder - search for copy + if (pTask->GetDestPath().GetPath() == fi.GetFileRoot()) + { + CString strSubst; + FindFreeSubstituteName(fi.GetFullFilePath(), pTask->GetDestPath().GetPath(), &strSubst); + pTask->GetClipboardData(i)->m_astrDstPaths.Add(strSubst); + } + else + pTask->GetClipboardData(i)->m_astrDstPaths.Add(fi.GetFileName()); + } + + // add if needed + if (fi.IsDirectory()) + { + // add if folder's aren't ignored + if (!bIgnoreDirs && !bForceDirectories) + { + pTask->FilesAdd(fi); + + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDEDFOLDER_STRING), (PCTSTR)fi.GetFullFilePath()); + } + + // don't add folder contents when moving inside one disk boundary + if (bIgnoreDirs || !bMove || pTask->GetCopies() > 1 || iDestDrvNumber == -1 + || iDestDrvNumber != fi.GetDriveNumber() || CFileInfo::Exist(fi.GetDestinationPath(pTask->GetDestPath().GetPath(), 0, ((int)bForceDirectories) << 1)) ) + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFRECURSINGFOLDER_STRING), (PCTSTR)fi.GetFullFilePath()); + + // no movefile possibility - use CustomCopyFile + pTask->GetClipboardData(i)->SetMove(false); + + pTask->FilesAddDir(fi.GetFullFilePath(), pFilters, i, true, !bIgnoreDirs || bForceDirectories); + } + + // check for kill need + if (pTask->GetKillFlag()) + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDINGKILLREQEST_STRING)); + throw new CProcessingException(E_KILL_REQUEST, pTask); + } + } + else + { + if (bMove && pTask->GetCopies() == 1 && iDestDrvNumber != -1 && iDestDrvNumber == fi.GetDriveNumber() && + !CFileInfo::Exist(fi.GetDestinationPath(pTask->GetDestPath().GetPath(), 0, ((int)bForceDirectories) << 1)) ) + { + // if moving within one partition boundary set the file size to 0 so the overall size will + // be ok + fi.SetLength64(0); + } + else + pTask->GetClipboardData(i)->SetMove(false); // no MoveFile + + pTask->FilesAdd(fi); // file - add + + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDEDFILE_STRING), (PCTSTR)fi.GetFullFilePath()); + } + } + + // calc size of all files + pTask->CalcAllSize(); + + // update *m_pnTasksAll; + pTask->IncreaseAllTasksSize(pTask->GetAllSize()); + + // change state to ST_COPYING - finished searching for files + pTask->SetStatus(ST_COPYING, ST_STEP_MASK); + + // save task status + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + pTask->Store(szPath, true); + pTask->Store(szPath, false); + + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFSEARCHINGFINISHED_STRING)); +} + +// delete files - after copying +void DeleteFiles(CTask* pTask) +{ + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGFILES_STRING)); + + // current processed path + BOOL bSuccess; + CFileInfo fi; + + // index points to 0 or next item to process + for (int i=pTask->GetCurrentIndex();iFilesGetSize();i++) + { + // set index in pTask to currently deleted element + pTask->SetCurrentIndex(i); + + // check for kill flag + if (pTask->GetKillFlag()) + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGKILLREQUEST_STRING)); + throw new CProcessingException(E_KILL_REQUEST, pTask); + } + + // current processed element + fi=pTask->FilesGetAt(pTask->FilesGetSize()-i-1); + + // delete data + if (fi.IsDirectory()) + { + if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); + bSuccess=RemoveDirectory(fi.GetFullFilePath()); + } + else + { + // set files attributes to normal - it'd slow processing a bit, but it's better. + if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); + bSuccess=DeleteFile(fi.GetFullFilePath()); + } + + // operation failed + DWORD dwLastError=GetLastError(); + if (!bSuccess && dwLastError != ERROR_PATH_NOT_FOUND && dwLastError != ERROR_FILE_NOT_FOUND) + { + // log + pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDELETINGERROR_STRING), dwLastError, (PCTSTR)fi.GetFullFilePath()); + throw new CProcessingException(E_ERROR, pTask, IDS_CPEDELETINGERROR_STRING, dwLastError, fi.GetFullFilePath()); + } + }//for + + // change status to finished + pTask->SetStatus(ST_FINISHED, ST_STEP_MASK); + + // add 1 to current index - looks better + pTask->IncreaseCurrentIndex(); + + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGFINISHED_STRING)); +} + +void CustomCopyFile(PCUSTOM_COPY_PARAMS pData) +{ + HANDLE hSrc=INVALID_HANDLE_VALUE, hDst=INVALID_HANDLE_VALUE; + try + { + // do we copy rest or recopy ? + bool bCopyRest=GetConfig()->GetBoolValue(PP_CMUSEAUTOCOMPLETEFILES); + UINT uiNotificationType=GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK); + + // Data regarding dest file + CFileInfo fiDest; + bool bExist=fiDest.Create(pData->strDstFile, -1); + + int iDlgCode=-1; + int *piLastDlgDesc=NULL; // ptr to int describing last used dialog + + // don't ask for copy rest + bool bDontAsk=(pData->pTask->GetCurrentIndex() == pData->pTask->GetLastProcessedIndex()); + pData->pTask->SetLastProcessedIndex(-1); + + // if dest file size >0 - we can do somethng more than usual + if ( bExist ) + { + // src and dst files are the same + if (fiDest == *pData->pfiSrcFile) + { + // copy automatically or ask + if (uiNotificationType > 1 && !bDontAsk) + { + if (pData->pTask->m_iIdentical == -1) + { + // show feedback + CSmallReplaceFilesDlg dlg; + dlg.m_pfiSource=pData->pfiSrcFile; + dlg.m_pfiDest=&fiDest; + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + dlg.m_iDefaultOption=ID_IGNORE; + iDlgCode=dlg.DoModal(); + + piLastDlgDesc=&pData->pTask->m_iIdentical; + } + else + iDlgCode=pData->pTask->m_iIdentical; + } + else + { + // increase progress + pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); + pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); + + return; // don't continue if NC==0 or 1 + } + } + else // iDst != *pData->pfiSrcFile + { + // src and dst are different - check sizes + if (fiDest.GetLength64() < pData->pfiSrcFile->GetLength64()) + { + // we can copy rest + if (uiNotificationType > 0 && !bDontAsk) + { + if (pData->pTask->m_iDestinationLess == -1) + { + // show dialog + CReplaceFilesDlg dlg; + dlg.m_pfiSource=pData->pfiSrcFile; + dlg.m_pfiDest=&fiDest; + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + dlg.m_iDefaultOption=ID_COPYREST; + + iDlgCode=dlg.DoModal(); + + piLastDlgDesc=&pData->pTask->m_iDestinationLess; + } + else + iDlgCode=pData->pTask->m_iDestinationLess; + } + // else do nothing - bCopyRest has been initialized + } + else + { + // dst >= src size + if (uiNotificationType > 1 && !bDontAsk) + { + if (pData->pTask->m_iDestinationGreater == -1) + { + CSmallReplaceFilesDlg dlg; + dlg.m_pfiSource=pData->pfiSrcFile; + dlg.m_pfiDest=&fiDest; + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + dlg.m_iDefaultOption=ID_RECOPY; + iDlgCode=dlg.DoModal(); // wy�wietl + + piLastDlgDesc=&pData->pTask->m_iDestinationGreater; + } + else + iDlgCode=pData->pTask->m_iDestinationGreater; + } + else + bCopyRest=false; // this case - recopy + } + } // iDst == *pData->pfiSrcFile + } // bExist + + // check for dialog result + switch (iDlgCode) + { + case -1: + break; + case ID_IGNOREALL: + if (piLastDlgDesc != NULL) + *piLastDlgDesc=ID_IGNOREALL; + case ID_IGNORE: + pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); + pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); + return; + break; + case ID_COPYRESTALL: + if (piLastDlgDesc != NULL) + *piLastDlgDesc=ID_COPYRESTALL; + case ID_COPYREST: + bCopyRest=true; + break; + case IDCANCEL: + // log + if (GetConfig()->GetBoolValue(PP_CMCREATELOG)) + pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPRECHECKCANCELREQUEST_STRING), (PCTSTR)pData->pfiSrcFile->GetFullFilePath()); + throw new CProcessingException(E_CANCEL, pData->pTask); + break; + case ID_RECOPYALL: + if (piLastDlgDesc != NULL) + *piLastDlgDesc=ID_RECOPYALL; + case ID_RECOPY: + bCopyRest=false; + break; + } + + // change attributes of a dest file + if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + SetFileAttributes(pData->strDstFile, FILE_ATTRIBUTE_NORMAL); + + // first or second pass ? only for FFNB + bool bFirstPass=true; + + // check size of src file to know whether use flag FILE_FLAG_NOBUFFERING +l_start: + bool bNoBuffer=(bFirstPass && GetConfig()->GetBoolValue(PP_BFUSENOBUFFERING) && pData->pfiSrcFile->GetLength64() >= GetConfig()->GetIntValue(PP_BFBOUNDARYLIMIT)); + + // refresh data about file + if (!bFirstPass) + bExist=fiDest.Create(pData->strDstFile, -1); + + // open src +l_openingsrc: + hSrc=CreateFile(pData->pfiSrcFile->GetFullFilePath(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffer ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); + if (hSrc == INVALID_HANDLE_VALUE) + { + DWORD dwLastError=GetLastError(); + if (uiNotificationType < 1) + { + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGERROR_STRING), dwLastError, (PCTSTR)pData->pfiSrcFile->GetFullFilePath()); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEOPENINGERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath()); + } + else + { + if (pData->pTask->m_iMissingInput == -1) + { + // no source file - feedback + CFileInfo fiRealSrc; + fiRealSrc.Create(pData->pfiSrcFile->GetFullFilePath(), -1); + + CReplaceOnlyDlg dlg; + dlg.m_pfiSource=pData->pfiSrcFile; + dlg.m_pfiDest=&fiRealSrc; + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + dlg.m_iDefaultOption=ID_WAIT; + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, dlg.m_strMessage.GetBuffer(_MAX_PATH), _MAX_PATH, NULL); + dlg.m_strMessage.ReleaseBuffer(); + + iDlgCode=dlg.DoModal(); + } + else + iDlgCode=pData->pTask->m_iMissingInput; + + switch (iDlgCode) + { + case ID_IGNOREALL: + pData->pTask->m_iMissingInput=ID_IGNOREALL; + case ID_IGNORE: + pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); + pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); + return; + break; + case IDCANCEL: + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGCANCELREQUEST_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); + throw new CProcessingException(E_CANCEL, pData->pTask); + break; + case ID_WAIT: + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGWAITREQUEST_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEOPENINGERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath()); + break; + case ID_RETRY: + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGRETRY_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); + goto l_openingsrc; + break; + } + } + } + + // open dest +l_openingdst: + hDst=CreateFile(pData->strDstFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffer ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); + if (hDst == INVALID_HANDLE_VALUE) + { + DWORD dwLastError=GetLastError(); + if (uiNotificationType < 1) + { + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGERROR_STRING), dwLastError, pData->strDstFile); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEDESTOPENINGERROR_STRING, dwLastError, pData->strDstFile); + } + else + { + if (pData->pTask->m_iOutputError == -1) + { + CDstFileErrorDlg dlg; + dlg.m_strFilename=pData->strDstFile; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, dlg.m_strMessage.GetBuffer(_MAX_PATH), _MAX_PATH, NULL); + dlg.m_strMessage.ReleaseBuffer(); + + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + dlg.m_iDefaultOption=ID_WAIT; + iDlgCode=dlg.DoModal(); + } + else + iDlgCode=pData->pTask->m_iOutputError; + + switch (iDlgCode) + { + case ID_RETRY: + // change attributes + if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + SetFileAttributes(pData->strDstFile, FILE_ATTRIBUTE_NORMAL); + + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGRETRY_STRING), dwLastError, pData->strDstFile); + goto l_openingdst; + break; + case IDCANCEL: + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGCANCELREQUEST_STRING), dwLastError, pData->strDstFile); + throw new CProcessingException(E_CANCEL, pData->pTask); + break; + case ID_IGNOREALL: + pData->pTask->m_iOutputError=ID_IGNOREALL; + case ID_IGNORE: + pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); + pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); + return; + break; + case ID_WAIT: + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGWAITREQUEST_STRING), dwLastError, pData->strDstFile); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEDESTOPENINGERROR_STRING, dwLastError, pData->strDstFile); + break; + } + } + } + + // seeking + DWORD dwLastError=0; + if (!pData->bOnlyCreate) + { + if ( bCopyRest ) // if copy rest + { + if (!bFirstPass || (bExist && fiDest.GetLength64() > 0)) + { + // try to move file pointers to the end + ULONGLONG ullMove=(bNoBuffer ? ROUNDDOWN(fiDest.GetLength64(), MAXSECTORSIZE) : fiDest.GetLength64()); + if (SetFilePointer64(hSrc, ullMove, FILE_BEGIN) == -1 || SetFilePointer64(hDst, ullMove, FILE_BEGIN) == -1) + { + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFMOVINGPOINTERSERROR_STRING), GetLastError(), pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile, ullMove); + + // seek failed - seek to begin + if (SetFilePointer64(hSrc, 0, FILE_BEGIN) == -1 || SetFilePointer64(hDst, 0, FILE_BEGIN) == -1) + { + // log + dwLastError=GetLastError(); + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFRESTORINGPOINTERSERROR_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPERESTORINGPOINTERSERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); + } + else + { + // file pointers restored - if second pass subtract what's needed + if (!bFirstPass) + { + pData->pTask->IncreaseProcessedSize(-static_cast<__int64>(ullMove)); + pData->pTask->IncreaseProcessedTasksSize(-static_cast<__int64>(ullMove)); + } + } + } + else + { + // file pointers moved - so we have skipped some work - update positions + if (bFirstPass) // przy drugim obiegu jest ju� uwzgl�dnione + { + pData->pTask->IncreaseProcessedSize(ullMove); + pData->pTask->IncreaseProcessedTasksSize(ullMove); + } + } + } + } + else + if (!SetEndOfFile(hDst)) // if recopying - reset the dest file + { + // log + dwLastError=GetLastError(); + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFSETTINGZEROSIZEERROR_STRING), dwLastError, pData->strDstFile); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPESETTINGZEROSIZEERROR_STRING, dwLastError, pData->strDstFile); + } + + // copying + unsigned long tord, rd, wr; + int iBufferIndex; + do + { + // kill flag checks + if (pData->pTask->GetKillFlag()) + { + // log + pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCOPYINGKILLREQUEST_STRING), pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); + throw new CProcessingException(E_KILL_REQUEST, pData->pTask); + } + + // recreate buffer if needed + if (!(*pData->dbBuffer.GetSizes() == *pData->pTask->GetBufferSizes())) + { + // log + const BUFFERSIZES *pbs1=pData->dbBuffer.GetSizes(), *pbs2=pData->pTask->GetBufferSizes(); + + pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCHANGINGBUFFERSIZE_STRING), + pbs1->m_uiDefaultSize, pbs1->m_uiOneDiskSize, pbs1->m_uiTwoDisksSize, pbs1->m_uiCDSize, pbs1->m_uiLANSize, + pbs2->m_uiDefaultSize, pbs2->m_uiOneDiskSize, pbs2->m_uiTwoDisksSize, pbs2->m_uiCDSize, pbs2->m_uiLANSize, + pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); + pData->pTask->SetBufferSizes(pData->dbBuffer.Create(pData->pTask->GetBufferSizes())); + } + + // establish count of data to read + iBufferIndex=pData->pTask->GetBufferSizes()->m_bOnlyDefault ? 0 : pData->pfiSrcFile->GetBufferIndex(); + tord=bNoBuffer ? ROUNDUP(pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex], MAXSECTORSIZE) : pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex]; + + // read + if (!ReadFile(hSrc, pData->dbBuffer, tord, &rd, NULL)) + { + // log + dwLastError=GetLastError(); + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFREADINGERROR_STRING), dwLastError, tord, pData->pfiSrcFile->GetFullFilePath()); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEREADINGERROR_STRING, dwLastError, tord, pData->pfiSrcFile->GetFullFilePath()); + } + + // change count of stored data + if (bNoBuffer && (ROUNDUP(rd, MAXSECTORSIZE)) != rd) + { + // we need to copy rest so do the second pass + // close files + CloseHandle(hSrc); + CloseHandle(hDst); + + // second pass + bFirstPass=false; + bCopyRest=true; // nedd to copy rest + + goto l_start; + } + + // zapisz + if (!WriteFile(hDst, pData->dbBuffer, rd, &wr, NULL) || wr != rd) + { + // log + dwLastError=GetLastError(); + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFWRITINGERROR_STRING), dwLastError, rd, pData->strDstFile); + throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEWRITINGERROR_STRING, dwLastError, rd, pData->strDstFile); + } + + // increase count of processed data + pData->pTask->IncreaseProcessedSize(rd); + pData->pTask->IncreaseProcessedTasksSize(rd); +// TRACE("Read: %d, Written: %d\n", rd, wr); + } + while ( rd != 0 ); + } + else + { + // we don't copy contents, but need to increase processed size + pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); + pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); + } + + // close files + CloseHandle(hSrc); + CloseHandle(hDst); + } + catch(...) + { + // log + pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCAUGHTEXCEPTIONCCF_STRING), GetLastError()); + + // close handles + if (hSrc != INVALID_HANDLE_VALUE) + CloseHandle(hSrc); + if (hDst != INVALID_HANDLE_VALUE) + CloseHandle(hDst); + + throw; + } +} + +// function processes files/folders +void ProcessFiles(CTask* pTask) +{ + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFILES_STRING)); + + // count how much has been done (updates also a member in CTaskArray) + pTask->CalcProcessedSize(); + + // create a buffer of size pTask->m_nBufferSize + CUSTOM_COPY_PARAMS ccp; + ccp.pTask=pTask; + ccp.bOnlyCreate=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_CONTENT) != 0; + ccp.dbBuffer.Create(pTask->GetBufferSizes()); + + // helpers + CFileInfo fi; // for currently processed element + DWORD dwLastError; + + // begin at index which wasn't processed previously + int nSize=pTask->FilesGetSize(); // wielko�� tablicy + int iCopiesCount=pTask->GetCopies(); // ilo�� kopii + bool bIgnoreFolders=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; + bool bForceDirectories=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; + const CDestPath& dpDestPath=pTask->GetDestPath(); + + // log + const BUFFERSIZES* pbs=ccp.dbBuffer.GetSizes(); + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFILESDATA_STRING), ccp.bOnlyCreate, + pbs->m_uiDefaultSize, pbs->m_uiOneDiskSize, pbs->m_uiTwoDisksSize, pbs->m_uiCDSize, pbs->m_uiLANSize, + nSize, iCopiesCount, bIgnoreFolders, dpDestPath.GetPath(), pTask->GetCurrentCopy(), pTask->GetCurrentIndex()); + + for (unsigned char j=pTask->GetCurrentCopy();jSetCurrentCopy(j); + for (int i=pTask->GetCurrentIndex();iSetCurrentIndex(i); + fi=pTask->FilesGetAtCurrentIndex(); + + // should we kill ? + if (pTask->GetKillFlag()) + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGKILLREQUEST_STRING)); + throw new CProcessingException(E_KILL_REQUEST, pTask); + } + + // set dest path with filename + ccp.strDstFile=fi.GetDestinationPath(dpDestPath.GetPath(), j, ((int)bForceDirectories) << 1 | (int)bIgnoreFolders); + + // are the files/folders lie on the same partition ? + bool bMove=pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE; + if (bMove && dpDestPath.GetDriveNumber() != -1 && dpDestPath.GetDriveNumber() == fi.GetDriveNumber() && iCopiesCount == 1 && fi.GetMove()) + { + if (!MoveFile(fi.GetFullFilePath(), ccp.strDstFile)) + { + dwLastError=GetLastError(); + //log + pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFMOVEFILEERROR_STRING), dwLastError, fi.GetFullFilePath(), ccp.strDstFile); + throw new CProcessingException(E_ERROR, pTask, IDS_CPEMOVEFILEERROR_STRING, dwLastError, fi.GetFullFilePath(), ccp.strDstFile); + } + } + else + { + // if folder - create it + if ( fi.IsDirectory() ) + { + if (!CreateDirectory(ccp.strDstFile, NULL) && (dwLastError=GetLastError()) != ERROR_ALREADY_EXISTS ) + { + // log + pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCREATEDIRECTORYERROR_STRING), dwLastError, ccp.strDstFile); + throw new CProcessingException(E_ERROR, pTask, IDS_CPECREATEDIRECTORYERROR_STRING, dwLastError, ccp.strDstFile); + } + + pTask->IncreaseProcessedSize(fi.GetLength64()); + pTask->IncreaseProcessedTasksSize(fi.GetLength64()); + } + else + { + // start copying/moving file + ccp.pfiSrcFile=&fi; + + // kopiuj dane + CustomCopyFile(&ccp); + + // if moving - delete file (only if config flag is set) + if (bMove && !GetConfig()->GetBoolValue(PP_CMDELETEAFTERFINISHED) && j == iCopiesCount-1) + { + if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); + DeleteFile(fi.GetFullFilePath()); // there will be another try later, so I don't check + // if succeeded + } + } + + // set a time + if (GetConfig()->GetBoolValue(PP_CMSETDESTDATE)) + SetFileDirectoryTime(ccp.strDstFile, &fi); // no error check - ma�o istotne + + // attributes + if (GetConfig()->GetBoolValue(PP_CMSETDESTATTRIBUTES)) + SetFileAttributes(ccp.strDstFile, fi.GetAttributes()); // j.w. + } + } + + // current copy finished - change what's needed + pTask->SetCurrentIndex(0); + } + + // delete buffer - it's not needed + ccp.dbBuffer.Delete(); + + // change status + if (pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE) + { + pTask->SetStatus(ST_DELETING, ST_STEP_MASK); + // set the index to 0 before deleting + pTask->SetCurrentIndex(0); + } + else + { + pTask->SetStatus(ST_FINISHED, ST_STEP_MASK); + + // to look better - increase current index by 1 + pTask->SetCurrentIndex(nSize); + } + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFINISHED_STRING)); +} + +void CheckForWaitState(CTask* pTask) +{ + // limiting operation count + pTask->SetStatus(ST_WAITING, ST_WAITING_MASK); + bool bContinue=false; + while (!bContinue) + { + if (pTask->CanBegin()) + { + TRACE("CAN BEGIN ALLOWED TO CONTINUE...\n"); + pTask->SetStatus(0, ST_WAITING); + bContinue=true; + + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFWAITINGFINISHED_STRING)); + +// return; // skips sleep and kill flag checking + } + + Sleep(50); // not to make it too hard for processor + + if (pTask->GetKillFlag()) + { + // log + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFWAITINGKILLREQUEST_STRING)); + throw new CProcessingException(E_KILL_REQUEST, pTask); + } + } +} + +UINT ThrdProc(LPVOID pParam) +{ + TRACE("\n\nENTERING ThrdProc (new task started)...\n"); + CTask* pTask=static_cast(pParam); + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + _tcscat(szPath, pTask->GetUniqueName()+_T(".log")); + pTask->m_log.init(szPath, 262144, LT_DEBUG, false, false); + + // set thread boost + HANDLE hThread=GetCurrentThread(); + ::SetThreadPriorityBoost(hThread, GetConfig()->GetBoolValue(PP_CMDISABLEPRIORITYBOOST)); + + CTime tm=CTime::GetCurrentTime(); + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFTHREADSTART_STRING), tm.GetDay(), tm.GetMonth(), tm.GetYear(), tm.GetHour(), tm.GetMinute(), tm.GetSecond()); + + try + { + // to make the value stable + bool bReadTasksSize=GetConfig()->GetBoolValue(PP_CMREADSIZEBEFOREBLOCKING); + + if (!bReadTasksSize) + CheckForWaitState(pTask); // operation limiting + + // set what's needed + pTask->m_lLastTime=time(NULL); // last time (start counting) + + // search for files if needed + if ((pTask->GetStatus(ST_STEP_MASK) == ST_NULL_STATUS + || pTask->GetStatus(ST_STEP_MASK) == ST_SEARCHING)) + { + // get rid of info about processed sizes + pTask->DecreaseProcessedTasksSize(pTask->GetProcessedSize()); + pTask->SetProcessedSize(0); + pTask->DecreaseAllTasksSize(pTask->GetAllSize()); + pTask->SetAllSize(0); + + // start searching + RecurseDirectories(pTask); + } + + // check for free space + __int64 i64Needed, i64Available; +l_showfeedback: + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCHECKINGSPACE_STRING)); + + if (!pTask->GetRequiredFreeSpace(&i64Needed, &i64Available)) + { + pTask->m_log.logw(GetResManager()->LoadString(IDS_OTFNOTENOUGHFREESPACE_STRING), i64Needed, i64Available); + + // default + int iResult=ID_IGNORE; + + if (GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK) > 0) + { + // make user know that some place is missing + CNotEnoughRoomDlg dlg; + dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); + dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); + + dlg.m_llRequired=i64Needed; + + for (int i=0;iGetClipboardDataSize();i++) + dlg.m_strFiles.Add(pTask->GetClipboardData(i)->GetPath()); + + dlg.m_strDisk=pTask->GetDestPath().GetPath(); + + // show + iResult=dlg.DoModal(); + } + + switch (iResult) + { + case IDCANCEL: + { + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACECANCELREQUEST_STRING)); + throw new CProcessingException(E_CANCEL, pTask); + break; + } + case ID_RETRY: + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACERETRYING_STRING)); + goto l_showfeedback; + break; + case ID_IGNORE: + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACEIGNORE_STRING)); + break; + } + } + + if (bReadTasksSize) + { + pTask->UpdateTime(); + pTask->m_lLastTime=-1; + + CheckForWaitState(pTask); + + pTask->m_lLastTime=time(NULL); + } + + // Phase II - copying/moving + if (pTask->GetStatus(ST_STEP_MASK) == ST_COPYING) + { + // decrease processed in ctaskarray - the rest will be done in ProcessFiles + pTask->DecreaseProcessedTasksSize(pTask->GetProcessedSize()); + ProcessFiles(pTask); + } + + // deleting data - III phase + if (pTask->GetStatus(ST_STEP_MASK) == ST_DELETING) + DeleteFiles(pTask); + + // refresh time + pTask->UpdateTime(); + + // save progress before killed + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + pTask->Store(szPath, false); + + // we are ending + pTask->DecreaseOperationsPending(); + + // play sound + if (GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) + { + GetConfig()->GetStringValue(PP_SNDFINISHEDSOUNDPATH, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + PlaySound(szPath, NULL, SND_FILENAME | SND_ASYNC); + } + + CTime tm=CTime::GetCurrentTime(); + pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFTHREADFINISHED_STRING), tm.GetDay(), tm.GetMonth(), tm.GetYear(), tm.GetHour(), tm.GetMinute(), tm.GetSecond()); + + // we have been killed - the last operation + InterlockedIncrement(pTask->m_plFinished); + pTask->CleanupAfterKill(); + pTask->SetKilledFlag(); + } + catch(CProcessingException* e) + { + // increment count of beginnings + InterlockedIncrement(pTask->m_plFinished); + + // refresh time + pTask->UpdateTime(); + + // log + pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCAUGHTEXCEPTIONMAIN_STRING), e->m_dwError, e->m_iType); + + if (e->m_iType == E_ERROR && GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) + { + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_SNDERRORSOUNDPATH, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + PlaySound(szPath, NULL, SND_FILENAME | SND_ASYNC); + } + + // cleanup changes flags and calls cleanup for a task + e->Cleanup(); + delete e; + + if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) + pTask->SetStatus(0, ST_WAITING); + + pTask->DecreaseOperationsPending(); + pTask->SetContinueFlag(false); + pTask->SetForceFlag(false); + + return 0xffffffff; // almost like -1 + } + + TRACE("TASK FINISHED - exiting ThrdProc.\n"); + return 0; +} + +UINT ClipboardMonitorProc(LPVOID pParam) +{ + volatile CLIPBOARDMONITORDATA* pData=static_cast(pParam); + ASSERT(pData->m_hwnd); + + // bufor + TCHAR path[_MAX_PATH]; + UINT i; // counter + CTask *pTask; // ptr to a task + CClipboardEntry* pEntry=NULL; + + // register clipboard format + UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); + UINT uiCounter=0, uiShutCounter=0;; + LONG lFinished=0; + bool bEnd=false; + + while (!pData->bKill) + { + if (uiCounter == 0 && GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING) && IsClipboardFormatAvailable(CF_HDROP)) + { + // get data from clipboard + OpenClipboard(pData->m_hwnd); + HANDLE handle=GetClipboardData(CF_HDROP); + + UINT nCount=DragQueryFile(static_cast(handle), 0xffffffff, NULL, 0); + + pTask=new CTask(&pData->m_pTasks->m_tcd); + + for (i=0;i(handle), i, path, _MAX_PATH); + pEntry=new CClipboardEntry; + pEntry->SetPath(path); + pTask->AddClipboardData(pEntry); + } + + if (IsClipboardFormatAvailable(nFormat)) + { + HANDLE handle=GetClipboardData(nFormat); + LPVOID addr=GlobalLock(handle); + + DWORD dwData=((DWORD*)addr)[0]; + if (dwData & DROPEFFECT_COPY) + pTask->SetStatus(ST_COPY, ST_OPERATION_MASK); // copy + else if (dwData & DROPEFFECT_MOVE) + pTask->SetStatus(ST_MOVE, ST_OPERATION_MASK); // move + + GlobalUnlock(handle); + } + else + pTask->SetStatus(ST_COPY, ST_OPERATION_MASK); // default - copy + + EmptyClipboard(); + CloseClipboard(); + + BUFFERSIZES bs; + bs.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); + bs.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); + bs.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); + bs.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); + bs.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); + bs.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); + + pTask->SetBufferSizes(&bs); + pTask->SetPriority(GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY)); + + // get dest folder + CFolderDialog dlg; + GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &dlg.m_bdData.cvShortcuts); + GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_bdData.cvRecent); + dlg.m_bdData.bExtended=GetConfig()->GetBoolValue(PP_FDEXTENDEDVIEW); + dlg.m_bdData.cx=GetConfig()->GetIntValue(PP_FDWIDTH); + dlg.m_bdData.cy=GetConfig()->GetIntValue(PP_FDHEIGHT); + dlg.m_bdData.iView=GetConfig()->GetIntValue(PP_FDSHORTCUTLISTSTYLE); + dlg.m_bdData.bIgnoreDialogs=GetConfig()->GetBoolValue(PP_FDIGNORESHELLDIALOGS); + + dlg.m_bdData.strInitialDir=(dlg.m_bdData.cvRecent.size() > 0) ? dlg.m_bdData.cvRecent.at(0) : _T(""); + + int iStatus=pTask->GetStatus(ST_OPERATION_MASK); + if (iStatus == ST_COPY) + dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLECOPY_STRING); + else if (iStatus == ST_MOVE) + dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLEMOVE_STRING); + else + dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLEUNKNOWNOPERATION_STRING); + dlg.m_bdData.strText=GetResManager()->LoadString(IDS_MAINBROWSETEXT_STRING); + + // set count of data to display + int iClipboardSize=pTask->GetClipboardDataSize(); + int iEntries=(iClipboardSize > 3) ? 2 : iClipboardSize; + for (int i=0;iGetClipboardData(i)->GetPath()+_T("\n"); + + // add ... + if (iEntries < iClipboardSize) + dlg.m_bdData.strText+=_T("..."); + + // show window + int iResult=dlg.DoModal(); + + // set data to config + GetConfig()->SetStringArrayValue(PP_SHORTCUTS, &dlg.m_bdData.cvShortcuts); + GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_bdData.cvRecent); + GetConfig()->SetBoolValue(PP_FDEXTENDEDVIEW, dlg.m_bdData.bExtended); + GetConfig()->SetIntValue(PP_FDWIDTH, dlg.m_bdData.cx); + GetConfig()->SetIntValue(PP_FDHEIGHT, dlg.m_bdData.cy); + GetConfig()->SetIntValue(PP_FDSHORTCUTLISTSTYLE, dlg.m_bdData.iView); + GetConfig()->SetBoolValue(PP_FDIGNORESHELLDIALOGS, dlg.m_bdData.bIgnoreDialogs); + GetConfig()->Save(); + + if ( iResult != IDOK ) + delete pTask; + else + { + // get dest path + CString strData; + dlg.GetPath(strData); + pTask->SetDestPath(strData); + + // get the relationship between src and dst paths + for (int i=0;iGetClipboard()->GetSize();i++) + pTask->GetClipboard()->GetAt(i)->CalcBufferIndex(pTask->GetDestPath()); + + // write pTask to a file + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + pTask->Store(szPath, true); + pTask->Store(szPath, false); + + // add task to a list of tasks and start + pData->m_pTasks->Add(pTask); + + // start processing + pTask->BeginProcessing(); + } + } + + // do we need to check for turning computer off + if (GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)) + { + if (uiShutCounter == 0) + { + if (lFinished != pData->m_pTasks->m_lFinished) + { + bEnd=true; + lFinished=pData->m_pTasks->m_lFinished; + } + + if (bEnd && pData->m_pTasks->IsFinished()) + { + TRACE("Shut down windows\n"); + bool bShutdown=true; + if (GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN) != 0) + { + CShutdownDlg dlg; + dlg.m_iOverallTime=GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN); + if (dlg.m_iOverallTime < 0) + dlg.m_iOverallTime=-dlg.m_iOverallTime; + bShutdown=(dlg.DoModal() != IDCANCEL); + } + + GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, false); + GetConfig()->Save(); + if (bShutdown) + { + // we're killed + pData->bKilled=true; + + // adjust token privileges for NT + HANDLE hToken=NULL; + TOKEN_PRIVILEGES tp; + if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken) + && LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tp.Privileges[0].Luid)) + { + tp.PrivilegeCount=1; + tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; + + AdjustTokenPrivileges(hToken, FALSE, &tp, NULL, NULL, NULL); + } + + BOOL bExit=ExitWindowsEx(EWX_POWEROFF | EWX_SHUTDOWN | (GetConfig()->GetBoolValue(PP_PFORCESHUTDOWN) ? EWX_FORCE : 0), 0); + if (bExit) + return 1; + else + { + pData->bKilled=false; + + // some kind of error + CString strErr; + strErr.Format(GetResManager()->LoadString(IDS_SHUTDOWNERROR_STRING), GetLastError()); + AfxMessageBox(strErr, MB_ICONERROR | MB_OK | MB_SYSTEMMODAL); + } + } + } + } + } + else + { + bEnd=false; + lFinished=pData->m_pTasks->m_lFinished; + } + + // sleep for some time + const int iSleepCount=200; + Sleep(iSleepCount); + uiCounter+=iSleepCount; + uiShutCounter+=iSleepCount; + if (uiCounter >= (UINT)GetConfig()->GetIntValue(PP_PMONITORSCANINTERVAL)) + uiCounter=0; + if (uiShutCounter >= 800) + uiShutCounter=0; + } + + pData->bKilled=true; + TRACE("Monitoring clipboard proc aborted...\n"); + + return 0; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainWnd message handlers + +int CMainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + lpCreateStruct->dwExStyle |= WS_EX_TOPMOST; + if (CWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + // get msg id of taskbar created message + m_uiTaskbarRestart=RegisterWindowMessage(_T("TaskbarCreated")); + + // Create the tray icon + ShowTrayIcon(); + + // initialize CTaskArray + m_tasks.Create(&ThrdProc); + + // load last state + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + m_tasks.LoadDataProgress(szPath); + m_tasks.TasksRetryProcessing(); + + // start clipboard monitoring + cmd.bKill=false; + cmd.bKilled=false; + cmd.m_hwnd=this->m_hWnd; + cmd.m_pTasks=&m_tasks; + + AfxBeginThread(&ClipboardMonitorProc, static_cast(&cmd), THREAD_PRIORITY_IDLE); + + // start saving timer + SetTimer(1023, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL), NULL); + + SetTimer(7834, TM_AUTORESUME/*GetConfig()->GetAutoRetryInterval()*/, NULL); + SetTimer(3245, TM_AUTOREMOVE, NULL); + SetTimer(8743, TM_ACCEPTING, NULL); // ends wait state in tasks + + if (GetConfig()->GetBoolValue(PP_MVAUTOSHOWWHENRUN)) + PostMessage(WM_SHOWMINIVIEW); + + return 0; +} + +LRESULT CMainWnd::OnTrayNotification(WPARAM wParam, LPARAM lParam) +{ + if (wParam != m_ctlTray.m_tnd.uID) + return (LRESULT)FALSE; + + TCHAR text[_MAX_PATH]; + switch(LOWORD(lParam)) + { + case WM_LBUTTONDOWN: + { + ::SetForegroundWindow(this->m_hWnd); + break; + } + case WM_LBUTTONDBLCLK: + { + CMenu mMenu, *pSubMenu; + HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_POPUP_MENU)); + if (!mMenu.Attach(hMenu)) + return (LRESULT)FALSE; + + if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) + return (LRESULT)FALSE; + + // double click received, the default action is to execute first menu item + ::SetForegroundWindow(this->m_hWnd); + ::SendMessage(this->m_hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0); + + pSubMenu->DestroyMenu(); + mMenu.DestroyMenu(); + break; + } + case WM_RBUTTONUP: + { + // load main menu + HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_POPUP_MENU)); + CMenu mMenu, *pSubMenu; + if (!mMenu.Attach(hMenu)) + return (LRESULT)FALSE; + + if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) + return (LRESULT)FALSE; + + // set menu default item + pSubMenu->SetDefaultItem(0, TRUE); + + // make window foreground + SetForegroundWindow(); + + // get current cursor pos + POINT pt; + GetCursorPos(&pt); + + pSubMenu->CheckMenuItem(ID_POPUP_MONITORING, MF_BYCOMMAND | (GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING) ? MF_CHECKED : MF_UNCHECKED)); + pSubMenu->CheckMenuItem(ID_POPUP_SHUTAFTERFINISHED, MF_BYCOMMAND | (GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED) ? MF_CHECKED : MF_UNCHECKED)); + + // track the menu + pSubMenu->TrackPopupMenu(TPM_LEFTBUTTON, pt.x, pt.y, this); + + // destroy + pSubMenu->DestroyMenu(); + mMenu.DestroyMenu(); + + break; + } + case WM_MOUSEMOVE: + { + if (m_tasks.GetSize() != 0) + { + _stprintf(text, _T("%s - %d %%"), GetApp()->GetAppName(), m_tasks.GetPercent()); + m_ctlTray.SetTooltipText(text); + } + else + m_ctlTray.SetTooltipText(GetApp()->GetAppNameVer()); + break; + } + } + + return (LRESULT)TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainWnd/CTrayIcon menu message handlers + +void CMainWnd::ShowStatusWindow(const CTask *pSelect) +{ + m_pdlgStatus=new CStatusDlg(&m_tasks, this); // self deleting + m_pdlgStatus->m_pInitialSelection=pSelect; + m_pdlgStatus->m_bLockInstance=true; + m_pdlgStatus->m_bAutoDelete=true; + m_pdlgStatus->Create(); + + // hide miniview if showing status + if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock) + { + if (::IsWindow(m_pdlgMiniView->m_hWnd)) + m_pdlgMiniView->HideWindow(); + } +} + +void CMainWnd::OnPopupShowStatus() +{ + ShowStatusWindow(); +} + +void CMainWnd::OnClose() +{ + PrepareToExit(); + CWnd::OnClose(); +} + +void CMainWnd::OnTimer(UINT nIDEvent) +{ + switch (nIDEvent) + { + case 1023: + // autosave timer + KillTimer(1023); + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + m_tasks.SaveProgress(szPath); + SetTimer(1023, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL), NULL); + break; + case 7834: + { + // auto-resume timer + KillTimer(7834); + DWORD dwTime=GetTickCount(); + DWORD dwInterval=(m_dwLastTime == 0) ? TM_AUTORESUME : dwTime-m_dwLastTime; + m_dwLastTime=dwTime; + + if (GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR)) + { + if (m_tasks.TasksRetryProcessing(true, dwInterval) && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) + m_pdlgStatus->SendMessage(WM_UPDATESTATUS); + } + SetTimer(7834, TM_AUTORESUME/*GetConfig()->GetAutoRetryInterval()*/, NULL); + } + break; + case 3245: + // auto-delete finished tasks timer + KillTimer(3245); + if (GetConfig()->GetBoolValue(PP_STATUSAUTOREMOVEFINISHED)) + { + int iSize=m_tasks.GetSize(); + m_tasks.RemoveAllFinished(); + if (m_tasks.GetSize() != iSize && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) + m_pdlgStatus->SendMessage(WM_UPDATESTATUS); + } + + SetTimer(3245, TM_AUTOREMOVE, NULL); + break; + case 8743: + { + // wait state handling section + CTask* pTask; + if (GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS) == 0 || m_tasks.GetOperationsPending() < (UINT)GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS)) + { + for (int i=0;iGetStatus(ST_WAITING_MASK) & ST_WAITING && (GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS) == 0 || m_tasks.GetOperationsPending() < (UINT)GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS))) + { + TRACE("Enabling task %ld\n", i); + pTask->SetContinueFlag(true); + pTask->IncreaseOperationsPending(); + pTask->SetStatus(0, ST_WAITING); // turn off wait state + } + } + } + break; + } + } + + CWnd::OnTimer(nIDEvent); +} + +void CMainWnd::OnPopupShowOptions() +{ + COptionsDlg *pDlg=new COptionsDlg(this); + pDlg->m_bAutoDelete=true; + pDlg->m_bLockInstance=true; + pDlg->Create(); +} + +BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) +{ + // copying or moving ? + bool bMove=false; + switch(pCopyDataStruct->dwData & OPERATION_MASK) + { + case DD_MOVE_FLAG: + case EC_MOVETO_FLAG: + bMove=true; + break; + case EC_PASTE_FLAG: + case EC_PASTESPECIAL_FLAG: + bMove=(pCopyDataStruct->dwData & ~OPERATION_MASK) != 0; + break; + } + + // buffer with: dst path and src paths separated by single '\0' + TCHAR *pBuffer=static_cast(pCopyDataStruct->lpData); + unsigned long ulLen=pCopyDataStruct->cbData; + + CString str, strDstPath; + CStringArray astrFiles; + UINT iOffset=0; + + do + { + str=pBuffer+iOffset; + if (iOffset == 0) + strDstPath=str; + else + astrFiles.Add(str); + + iOffset+=str.GetLength()+1; + } + while (iOffset < ulLen); + + // special operation - modify stuff + CFiltersArray ffFilters; + int iPriority=GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY); + BUFFERSIZES bsSizes; + bsSizes.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); + bsSizes.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); + bsSizes.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); + bsSizes.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); + bsSizes.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); + bsSizes.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); + + BOOL bOnlyCreate=FALSE; + BOOL bIgnoreDirs=FALSE; + BOOL bForceDirectories=FALSE; + unsigned char ucCopies=1; + switch(pCopyDataStruct->dwData & OPERATION_MASK) + { + case DD_COPYMOVESPECIAL_FLAG: + case EC_PASTESPECIAL_FLAG: + case EC_COPYMOVETOSPECIAL_FLAG: + CCustomCopyDlg dlg; + dlg.m_ccData.m_astrPaths.Copy(astrFiles); + dlg.m_ccData.m_iOperation=bMove ? 1 : 0; + dlg.m_ccData.m_iPriority=iPriority; + dlg.m_ccData.m_strDestPath=strDstPath; + dlg.m_ccData.m_bsSizes=bsSizes; + dlg.m_ccData.m_bIgnoreFolders=(bIgnoreDirs != 0); + dlg.m_ccData.m_bForceDirectories=(bForceDirectories != 0); + dlg.m_ccData.m_bCreateStructure=(bOnlyCreate != 0); + dlg.m_ccData.m_ucCount=ucCopies; + GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); // recent paths + + int iModalResult; + if ( (iModalResult=dlg.DoModal()) == IDCANCEL) + return CWnd::OnCopyData(pWnd, pCopyDataStruct); + else if (iModalResult == -1) // windows has been closed by a parent + return TRUE; + + astrFiles.Copy(dlg.m_ccData.m_astrPaths); + bMove=(dlg.m_ccData.m_iOperation != 0); + iPriority=dlg.m_ccData.m_iPriority; + strDstPath=dlg.m_ccData.m_strDestPath; + bsSizes=dlg.m_ccData.m_bsSizes; + ffFilters.Copy(dlg.m_ccData.m_afFilters); + bIgnoreDirs=dlg.m_ccData.m_bIgnoreFolders; + bForceDirectories=dlg.m_ccData.m_bForceDirectories; + bOnlyCreate=dlg.m_ccData.m_bCreateStructure; + ucCopies=dlg.m_ccData.m_ucCount; + dlg.m_ccData.m_vRecent.insert(dlg.m_ccData.m_vRecent.begin(), (const PTSTR)(LPCTSTR)strDstPath, true); + + GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); + } + + // create new task + CTask *pTask=new CTask(&m_tasks.m_tcd); + pTask->SetDestPath(strDstPath); + CClipboardEntry* pEntry; + + // files + for (int i=0;iSetPath(astrFiles.GetAt(i)); + pEntry->CalcBufferIndex(pTask->GetDestPath()); + pTask->AddClipboardData(pEntry); + } + + pTask->SetStatus(bMove ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); + + // special status + pTask->SetStatus((bOnlyCreate ? ST_IGNORE_CONTENT : 0) | (bIgnoreDirs ? ST_IGNORE_DIRS : 0) | (bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); + + // set some stuff related with task + pTask->SetBufferSizes(&bsSizes); + pTask->SetPriority(iPriority); + pTask->SetFilters(&ffFilters); + pTask->SetCopies(ucCopies); + + // save state of a task + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + pTask->Store(szPath, true); + pTask->Store(szPath, false); + + // add to task list and start processing + m_tasks.Add(pTask); + pTask->BeginProcessing(); + + return CWnd::OnCopyData(pWnd, pCopyDataStruct); +} + +void CMainWnd::OnShowMiniView() +{ + m_pdlgMiniView=new CMiniViewDlg(&m_tasks, &CStatusDlg::m_bLock, this); // self-deleting + m_pdlgMiniView->m_bAutoDelete=true; + m_pdlgMiniView->m_bLockInstance=true; + m_pdlgMiniView->Create(); +} + +void CMainWnd::OnPopupCustomCopy() +{ + CCustomCopyDlg dlg; + dlg.m_ccData.m_iOperation=0; + dlg.m_ccData.m_iPriority=GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY); + dlg.m_ccData.m_bsSizes.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); + dlg.m_ccData.m_bsSizes.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); + dlg.m_ccData.m_bsSizes.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); + dlg.m_ccData.m_bsSizes.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); + dlg.m_ccData.m_bsSizes.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); + dlg.m_ccData.m_bsSizes.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); + + dlg.m_ccData.m_bCreateStructure=false; + dlg.m_ccData.m_bForceDirectories=false; + dlg.m_ccData.m_bIgnoreFolders=false; + dlg.m_ccData.m_ucCount=1; + GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); + + if (dlg.DoModal() == IDOK) + { + // save recent paths + dlg.m_ccData.m_vRecent.push_back((const PTSTR)(LPCTSTR)dlg.m_ccData.m_strDestPath, true); + GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); + + // new task + CTask *pTask=new CTask(&m_tasks.m_tcd); + pTask->SetDestPath(dlg.m_ccData.m_strDestPath); + CClipboardEntry *pEntry; + for (int i=0;iSetPath(dlg.m_ccData.m_astrPaths.GetAt(i)); + pEntry->CalcBufferIndex(pTask->GetDestPath()); + pTask->AddClipboardData(pEntry); + } + + pTask->SetStatus((dlg.m_ccData.m_iOperation == 1) ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); + + // special status + pTask->SetStatus((dlg.m_ccData.m_bCreateStructure ? ST_IGNORE_CONTENT : 0) | (dlg.m_ccData.m_bIgnoreFolders ? ST_IGNORE_DIRS : 0) + | (dlg.m_ccData.m_bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); + + pTask->SetBufferSizes(&dlg.m_ccData.m_bsSizes); + pTask->SetPriority(dlg.m_ccData.m_iPriority); + pTask->SetFilters(&dlg.m_ccData.m_afFilters); + + // save + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + pTask->Store(szPath, true); + pTask->Store(szPath, false); + + // store and start + m_tasks.Add(pTask); + pTask->BeginProcessing(); + } +} + +LRESULT CMainWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_MINIVIEWDBLCLK: + { + ShowStatusWindow((CTask*)lParam); + break; + } + case WM_SHOWMINIVIEW: + { + OnShowMiniView(); + return static_cast(0); + break; + } + + case WM_CONFIGNOTIFY: + { + GetApp()->SetAutorun(GetConfig()->GetBoolValue(PP_PRELOADAFTERRESTART)); + + // set this process class + HANDLE hProcess=GetCurrentProcess(); + ::SetPriorityClass(hProcess, GetConfig()->GetIntValue(PP_PPROCESSPRIORITYCLASS)); + + break; + } + + case WM_GETCONFIG: + { + // std config values + g_pscsShared->bShowFreeSpace=GetConfig()->GetBoolValue(PP_SHSHOWFREESPACE); + + // experimental - doesn't work on all systems + g_pscsShared->bShowShortcutIcons=GetConfig()->GetBoolValue(PP_SHSHOWSHELLICONS); + g_pscsShared->bOverrideDefault=GetConfig()->GetBoolValue(PP_SHUSEDRAGDROP); // only for d&d + g_pscsShared->uiDefaultAction=GetConfig()->GetIntValue(PP_SHDEFAULTACTION); + + // sizes + for (int i=0;i<6;i++) + _tcscpy(g_pscsShared->szSizes[i], GetResManager()->LoadString(IDS_BYTE_STRING+i)); + + // convert to list of _COMMAND's + _COMMAND *pCommand=(_COMMAND*)g_pscsShared->szData; + + // what kind of menu ? + switch (wParam) + { + case GC_DRAGDROP: + { + g_pscsShared->iCommandCount=3; + g_pscsShared->iShortcutsCount=0; + g_pscsShared->uiFlags=(GetConfig()->GetBoolValue(PP_SHSHOWCOPY) ? DD_COPY_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWMOVE) ? DD_MOVE_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVE) ? DD_COPYMOVESPECIAL_FLAG : 0); + + pCommand[0].uiCommandID=DD_COPY_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUCOPY_STRING, pCommand[0].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPCOPY_STRING, pCommand[0].szDesc, 128); + + pCommand[1].uiCommandID=DD_MOVE_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUMOVE_STRING, pCommand[1].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPMOVE_STRING, pCommand[1].szDesc, 128); + + pCommand[2].uiCommandID=DD_COPYMOVESPECIAL_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUCOPYMOVESPECIAL_STRING, pCommand[2].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYMOVESPECIAL_STRING, pCommand[2].szDesc, 128); + } + break; + case GC_EXPLORER: + { + g_pscsShared->iCommandCount=5; + g_pscsShared->uiFlags=(GetConfig()->GetBoolValue(PP_SHSHOWPASTE) ? EC_PASTE_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWPASTESPECIAL) ? EC_PASTESPECIAL_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYTO) ? EC_COPYTO_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWMOVETO) ? EC_MOVETO_FLAG : 0) + | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVETO) ? EC_COPYMOVETOSPECIAL_FLAG : 0); + + pCommand[0].uiCommandID=EC_PASTE_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUPASTE_STRING, pCommand[0].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPPASTE_STRING, pCommand[0].szDesc, 128); + pCommand[1].uiCommandID=EC_PASTESPECIAL_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUPASTESPECIAL_STRING, pCommand[1].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPPASTESPECIAL_STRING, pCommand[1].szDesc, 128); + pCommand[2].uiCommandID=EC_COPYTO_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUCOPYTO_STRING, pCommand[2].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYTO_STRING, pCommand[2].szDesc, 128); + pCommand[3].uiCommandID=EC_MOVETO_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUMOVETO_STRING, pCommand[3].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPMOVETO_STRING, pCommand[3].szDesc, 128); + pCommand[4].uiCommandID=EC_COPYMOVETOSPECIAL_FLAG; + GetResManager()->LoadStringCopy(IDS_MENUCOPYMOVETOSPECIAL_STRING, pCommand[4].szCommand, 128); + GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING, pCommand[4].szDesc, 128); + + // prepare shortcuts + char_vector cvShortcuts; + GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &cvShortcuts); + + // count of shortcuts to store + g_pscsShared->iShortcutsCount=__min(cvShortcuts.size(), SHARED_BUFFERSIZE-5*sizeof(_COMMAND)); + _SHORTCUT* pShortcut=(_SHORTCUT*)(g_pscsShared->szData+5*sizeof(_COMMAND)); + CShortcut sc; + for (int i=0;iiShortcutsCount;i++) + { + sc=CString(cvShortcuts.at(i)); + _tcsncpy(pShortcut[i].szName, sc.m_strName, 128); + _tcsncpy(pShortcut[i].szPath, sc.m_strPath, _MAX_PATH); + } + } + break; + default: + ASSERT(false); // what's happening ? + } + } + break; + + case WM_IDENTIFY: + { + //decode + unsigned char *dec=new unsigned char[iCount+1]; + dec[iCount]=0; + + unsigned short sData; + for (int i=0, j=0;i(msg[i] - _hash[j]); + + sData >>= off[j]; + dec[i]=static_cast(sData); + + if (++j >= iOffCount) + j=0; + } + + AfxMessageBox(reinterpret_cast(dec)); + delete [] dec; + + break; + } + case WM_STATUSCLOSING: + { + if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock && ::IsWindow(m_pdlgMiniView->m_hWnd)) + m_pdlgMiniView->RefreshStatus(); + + break; + } + case WM_ENDSESSION: + { + PrepareToExit(); + break; + } + case WM_TRAYNOTIFY: + { + return OnTrayNotification(wParam, lParam); + break; + } + } + + // if this is a notification of new tray - recreate the icon + if (message == m_uiTaskbarRestart) + { + ShowTrayIcon(); + return (LRESULT)TRUE; + } + + return CWnd::WindowProc(message, wParam, lParam); +} + +void CMainWnd::OnAppAbout() +{ + CAboutDlg *pdlg=new CAboutDlg; + pdlg->m_bAutoDelete=true; + pdlg->m_bLockInstance=true; + pdlg->Create(); +} + +void CMainWnd::OnPopupMonitoring() +{ + // change flag in config + GetConfig()->SetBoolValue(PP_PCLIPBOARDMONITORING, !GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING)); + GetConfig()->Save(); +} + +void CMainWnd::OnPopupShutafterfinished() +{ + GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, !GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)); + GetConfig()->Save(); +} + +void CMainWnd::OnPopupRegisterdll() +{ + DWORD dwErr; + if ((dwErr=RegisterShellExtDll(_T("chext.dll"), true)) == 0) + MsgBox(IDS_REGISTEROK_STRING, MB_ICONINFORMATION | MB_OK); + else + { + TCHAR szStr[256], szText[768]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, 0, szStr, 256, NULL); + while (szStr[_tcslen(szStr)-1] == _T('\n') || szStr[_tcslen(szStr)-1] == _T('\r') || szStr[_tcslen(szStr)-1] == _T('.')) + szStr[_tcslen(szStr)-1]=_T('\0'); + _stprintf(szText, GetResManager()->LoadString(IDS_REGISTERERR_STRING), dwErr, szStr); + AfxMessageBox(szText, MB_ICONERROR | MB_OK); + } +} + +void CMainWnd::OnPopupUnregisterdll() +{ + DWORD dwErr; + if ((dwErr=RegisterShellExtDll(_T("chext.dll"), false)) == 0) + MsgBox(IDS_UNREGISTEROK_STRING, MB_ICONINFORMATION | MB_OK); + else + { + TCHAR szStr[256], szText[768]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, 0, szStr, 256, NULL); + while (szStr[_tcslen(szStr)-1] == _T('\n') || szStr[_tcslen(szStr)-1] == _T('\r') || szStr[_tcslen(szStr)-1] == _T('.')) + szStr[_tcslen(szStr)-1]=_T('\0'); + _stprintf(szText, GetResManager()->LoadString(IDS_UNREGISTERERR_STRING), dwErr, szStr); + AfxMessageBox(szText, MB_ICONERROR | MB_OK); + } +} + +void CMainWnd::PrepareToExit() +{ + // kill thread that monitors clipboard + cmd.bKill=true; + while (!cmd.bKilled) + Sleep(10); + + // kill all unfinished tasks - send kill request + for (int i=0;iSetKillFlag(); + + // wait for finishing + for (i=0;iGetKilledFlag()) + Sleep(10); + m_tasks.GetAt(i)->CleanupAfterKill(); + } + + // save + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + m_tasks.SaveProgress(szPath); + + // delete all tasks + int iSize=m_tasks.GetSize(); + for (i=0;i* >(&m_tasks))->RemoveAll(); +} + +void CMainWnd::OnAppExit() +{ + PostMessage(WM_CLOSE); +} + +void CMainWnd::OnPopupHelp() +{ + if (!GetApp()->HtmlHelp(HH_DISPLAY_TOPIC, NULL)) + { + TCHAR szStr[512+2*_MAX_PATH]; + _stprintf(szStr, GetResManager()->LoadString(IDS_HELPERR_STRING), GetApp()->GetHelpPath()); + + AfxMessageBox(szStr, MB_OK | MB_ICONERROR); + } +} \ No newline at end of file Index: ch/MainWnd.cpp =================================================================== diff -u -N --- ch/MainWnd.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/MainWnd.cpp (revision 0) @@ -1,2088 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" - -#include "MainWnd.h" -#include "OptionsDlg.h" - -#include "shlobj.h" -#include "tchar.h" -#include "structs.h" -#include "dialogs.h" - -#pragma warning (disable : 4201) -#include "mmsystem.h" -#pragma warning (default : 4201) - -#include "FolderDialog.h" - -#include "CustomCopyDlg.h" -#include "ReplaceFilesDlg.h" -#include "btnIDs.h" -#include "SmallReplaceFilesDlg.h" -#include "ReplaceOnlyDlg.h" -#include "DstFileErrorDlg.h" -#include "..\Common\FileSupport.h" -#include "AboutDlg.h" -#include "NotEnoughRoomDlg.h" -#include "register.h" -#include "ShutdownDlg.h" -#include "StringHelpers.h" -#include "..\common\ipcstructs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define WM_ICON_NOTIFY WM_USER+4 -#define WM_SHOWMINIVIEW WM_USER+3 -#define WM_IDENTIFY WM_USER+11 - -#define TM_AUTOREMOVE 1000 -#define TM_AUTORESUME 1000 -#define TM_ACCEPTING 100 - -// assume max sectors of 4kB (for rounding) -#define MAXSECTORSIZE 4096 - -extern CSharedConfigStruct* g_pscsShared; - -extern int iCount; -extern unsigned short msg[]; - -extern int iOffCount; -extern unsigned char off[]; -extern unsigned short _hash[]; - - -///////////////////////////////////////////////////////////////////////////// -// CMainWnd -// registers main window class -ATOM CMainWnd::RegisterClass() -{ - WNDCLASS wc; - - wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = (WNDPROC)::DefWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = AfxGetInstanceHandle(); - wc.hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(AFX_IDI_STD_FRAME)); - wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wc.lpszMenuName = NULL; - wc.lpszClassName = _T("Copy Handler Wnd Class"); - - return ::RegisterClass(&wc); -} - -// creates this window -BOOL CMainWnd::Create() -{ - ATOM at=RegisterClass(); - - return CreateEx(WS_EX_TOOLWINDOW, (LPCTSTR)at, _T("Copy Handler"), WS_OVERLAPPED, 10, 10, 10, 10, NULL, (HMENU)NULL, NULL); -} - -int CMainWnd::ShowTrayIcon() -{ - // create system tray icon - HICON hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_VGACOLOR); - bool bRes=m_ctlTray.CreateIcon(m_hWnd, WM_TRAYNOTIFY, GetApp()->GetAppNameVer(), hIcon, 0); - if (!bRes) - { -// GetLog()->Log(_T("[CMainWnd] ... creating tray icon failed.")); - return -1; - } - -/* if (!m_ctlTray.ShowIcon()) - GetLog()->Log(_T("[CMainWnd] ... showing tray icon failed.")); - else - GetLog()->Log(_T("[CMainWnd] ... showing tray icon succeeded.")); -*/ - return 0; -} - -IMPLEMENT_DYNCREATE(CMainWnd, CWnd) - -BEGIN_MESSAGE_MAP(CMainWnd, CWnd) - //{{AFX_MSG_MAP(CMainWnd) - ON_COMMAND(ID_POPUP_SHOW_STATUS, OnPopupShowStatus) - ON_COMMAND(ID_POPUP_OPTIONS, OnPopupShowOptions) - ON_WM_CLOSE() - ON_WM_TIMER() - ON_WM_COPYDATA() - ON_WM_CREATE() - ON_COMMAND(ID_SHOW_MINI_VIEW, OnShowMiniView) - ON_COMMAND(ID_POPUP_CUSTOM_COPY, OnPopupCustomCopy) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_POPUP_MONITORING, OnPopupMonitoring) - ON_COMMAND(ID_POPUP_SHUTAFTERFINISHED, OnPopupShutafterfinished) - ON_COMMAND(ID_POPUP_REGISTERDLL, OnPopupRegisterdll) - ON_COMMAND(ID_POPUP_UNREGISTERDLL, OnPopupUnregisterdll) - ON_COMMAND(ID_APP_EXIT, OnAppExit) - ON_COMMAND(ID_POPUP_HELP, OnPopupHelp) - //}}AFX_MSG_MAP - ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMainWnd construction/destruction - -CMainWnd::CMainWnd() -{ - m_pdlgStatus=NULL; - m_pdlgMiniView=NULL; - m_dwLastTime=0; -} - -CMainWnd::~CMainWnd() -{ -} - -// case insensitive replacement -inline void ReplaceNoCase(CString& rString, CString strOld, CString strNew) -{ - if (rString.Left(strOld.GetLength()).CompareNoCase(strOld) == 0) - rString=strNew+rString.Right(rString.GetLength()-strOld.GetLength()); -} - -bool TimeToFileTime(const COleDateTime& time, LPFILETIME pFileTime) -{ - SYSTEMTIME sysTime; - sysTime.wYear = (WORD)time.GetYear(); - sysTime.wMonth = (WORD)time.GetMonth(); - sysTime.wDay = (WORD)time.GetDay(); - sysTime.wHour = (WORD)time.GetHour(); - sysTime.wMinute = (WORD)time.GetMinute(); - sysTime.wSecond = (WORD)time.GetSecond(); - sysTime.wMilliseconds = 0; - - // convert system time to local file time - FILETIME localTime; - if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, &localTime)) - return false; - - // convert local file time to UTC file time - if (!LocalFileTimeToFileTime(&localTime, pFileTime)) - return false; - - return true; -} - -bool SetFileDirectoryTime(LPCTSTR lpszName, CFileInfo* pSrcInfo) -{ - FILETIME creation, lastAccess, lastWrite; - - if (!TimeToFileTime(pSrcInfo->GetCreationTime(), &creation) - || !TimeToFileTime(pSrcInfo->GetLastAccessTime(), &lastAccess) - || !TimeToFileTime(pSrcInfo->GetLastWriteTime(), &lastWrite) ) - return false; - - HANDLE handle=CreateFile(lpszName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - return false; - - if (!SetFileTime(handle, &creation, &lastAccess, &lastWrite)) - { - CloseHandle(handle); - return false; - } - - if (!CloseHandle(handle)) - return false; - - return true; -} - -// searching for files -inline void RecurseDirectories(CTask* pTask) -{ - TRACE("Searching for files...\n"); - - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFSEARCHINGFORFILES_STRING)); - - // update status - pTask->SetStatus(ST_SEARCHING, ST_STEP_MASK); - - // delete the content of m_files - pTask->FilesRemoveAll(); - - // enter some data to m_files - int nSize=pTask->GetClipboardDataSize(); // size of m_clipboard - const CFiltersArray* pFilters=pTask->GetFilters(); - int iDestDrvNumber=pTask->GetDestDriveNumber(); - bool bIgnoreDirs=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; - bool bForceDirectories=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; - bool bMove=pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE; - CFileInfo fi; - fi.SetClipboard(pTask->GetClipboard()); - - // add everything - for (int i=0;iGetClipboardData(i)->GetPath(), i)) - { - // log - pTask->m_log.logw(GetResManager()->LoadString(IDS_OTFMISSINGCLIPBOARDINPUT_STRING), (PCTSTR)pTask->GetClipboardData(i)->GetPath()); - continue; - } - else - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDINGCLIPBOARDFILE_STRING), (PCTSTR)pTask->GetClipboardData(i)->GetPath()); - } - - // found file/folder - check if the dest name has been generated - if (pTask->GetClipboardData(i)->m_astrDstPaths.GetSize() == 0) - { - // generate something - if dest folder == src folder - search for copy - if (pTask->GetDestPath().GetPath() == fi.GetFileRoot()) - { - CString strSubst; - FindFreeSubstituteName(fi.GetFullFilePath(), pTask->GetDestPath().GetPath(), &strSubst); - pTask->GetClipboardData(i)->m_astrDstPaths.Add(strSubst); - } - else - pTask->GetClipboardData(i)->m_astrDstPaths.Add(fi.GetFileName()); - } - - // add if needed - if (fi.IsDirectory()) - { - // add if folder's aren't ignored - if (!bIgnoreDirs && !bForceDirectories) - { - pTask->FilesAdd(fi); - - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDEDFOLDER_STRING), (PCTSTR)fi.GetFullFilePath()); - } - - // don't add folder contents when moving inside one disk boundary - if (bIgnoreDirs || !bMove || pTask->GetCopies() > 1 || iDestDrvNumber == -1 - || iDestDrvNumber != fi.GetDriveNumber() || CFileInfo::Exist(fi.GetDestinationPath(pTask->GetDestPath().GetPath(), 0, ((int)bForceDirectories) << 1)) ) - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFRECURSINGFOLDER_STRING), (PCTSTR)fi.GetFullFilePath()); - - // no movefile possibility - use CustomCopyFile - pTask->GetClipboardData(i)->SetMove(false); - - pTask->FilesAddDir(fi.GetFullFilePath(), pFilters, i, true, !bIgnoreDirs || bForceDirectories); - } - - // check for kill need - if (pTask->GetKillFlag()) - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDINGKILLREQEST_STRING)); - throw new CProcessingException(E_KILL_REQUEST, pTask); - } - } - else - { - if (bMove && pTask->GetCopies() == 1 && iDestDrvNumber != -1 && iDestDrvNumber == fi.GetDriveNumber() && - !CFileInfo::Exist(fi.GetDestinationPath(pTask->GetDestPath().GetPath(), 0, ((int)bForceDirectories) << 1)) ) - { - // if moving within one partition boundary set the file size to 0 so the overall size will - // be ok - fi.SetLength64(0); - } - else - pTask->GetClipboardData(i)->SetMove(false); // no MoveFile - - pTask->FilesAdd(fi); // file - add - - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFADDEDFILE_STRING), (PCTSTR)fi.GetFullFilePath()); - } - } - - // calc size of all files - pTask->CalcAllSize(); - - // update *m_pnTasksAll; - pTask->IncreaseAllTasksSize(pTask->GetAllSize()); - - // change state to ST_COPYING - finished searching for files - pTask->SetStatus(ST_COPYING, ST_STEP_MASK); - - // save task status - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); - - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFSEARCHINGFINISHED_STRING)); -} - -// delete files - after copying -void DeleteFiles(CTask* pTask) -{ - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGFILES_STRING)); - - // current processed path - BOOL bSuccess; - CFileInfo fi; - - // index points to 0 or next item to process - for (int i=pTask->GetCurrentIndex();iFilesGetSize();i++) - { - // set index in pTask to currently deleted element - pTask->SetCurrentIndex(i); - - // check for kill flag - if (pTask->GetKillFlag()) - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGKILLREQUEST_STRING)); - throw new CProcessingException(E_KILL_REQUEST, pTask); - } - - // current processed element - fi=pTask->FilesGetAt(pTask->FilesGetSize()-i-1); - - // delete data - if (fi.IsDirectory()) - { - if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); - bSuccess=RemoveDirectory(fi.GetFullFilePath()); - } - else - { - // set files attributes to normal - it'd slow processing a bit, but it's better. - if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); - bSuccess=DeleteFile(fi.GetFullFilePath()); - } - - // operation failed - DWORD dwLastError=GetLastError(); - if (!bSuccess && dwLastError != ERROR_PATH_NOT_FOUND && dwLastError != ERROR_FILE_NOT_FOUND) - { - // log - pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDELETINGERROR_STRING), dwLastError, (PCTSTR)fi.GetFullFilePath()); - throw new CProcessingException(E_ERROR, pTask, IDS_CPEDELETINGERROR_STRING, dwLastError, fi.GetFullFilePath()); - } - }//for - - // change status to finished - pTask->SetStatus(ST_FINISHED, ST_STEP_MASK); - - // add 1 to current index - looks better - pTask->IncreaseCurrentIndex(); - - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFDELETINGFINISHED_STRING)); -} - -void CustomCopyFile(PCUSTOM_COPY_PARAMS pData) -{ - HANDLE hSrc=INVALID_HANDLE_VALUE, hDst=INVALID_HANDLE_VALUE; - try - { - // do we copy rest or recopy ? - bool bCopyRest=GetConfig()->GetBoolValue(PP_CMUSEAUTOCOMPLETEFILES); - UINT uiNotificationType=GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK); - - // Data regarding dest file - CFileInfo fiDest; - bool bExist=fiDest.Create(pData->strDstFile, -1); - - int iDlgCode=-1; - int *piLastDlgDesc=NULL; // ptr to int describing last used dialog - - // don't ask for copy rest - bool bDontAsk=(pData->pTask->GetCurrentIndex() == pData->pTask->GetLastProcessedIndex()); - pData->pTask->SetLastProcessedIndex(-1); - - // if dest file size >0 - we can do somethng more than usual - if ( bExist ) - { - // src and dst files are the same - if (fiDest == *pData->pfiSrcFile) - { - // copy automatically or ask - if (uiNotificationType > 1 && !bDontAsk) - { - if (pData->pTask->m_iIdentical == -1) - { - // show feedback - CSmallReplaceFilesDlg dlg; - dlg.m_pfiSource=pData->pfiSrcFile; - dlg.m_pfiDest=&fiDest; - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - dlg.m_iDefaultOption=ID_IGNORE; - iDlgCode=dlg.DoModal(); - - piLastDlgDesc=&pData->pTask->m_iIdentical; - } - else - iDlgCode=pData->pTask->m_iIdentical; - } - else - { - // increase progress - pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); - pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); - - return; // don't continue if NC==0 or 1 - } - } - else // iDst != *pData->pfiSrcFile - { - // src and dst are different - check sizes - if (fiDest.GetLength64() < pData->pfiSrcFile->GetLength64()) - { - // we can copy rest - if (uiNotificationType > 0 && !bDontAsk) - { - if (pData->pTask->m_iDestinationLess == -1) - { - // show dialog - CReplaceFilesDlg dlg; - dlg.m_pfiSource=pData->pfiSrcFile; - dlg.m_pfiDest=&fiDest; - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - dlg.m_iDefaultOption=ID_COPYREST; - - iDlgCode=dlg.DoModal(); - - piLastDlgDesc=&pData->pTask->m_iDestinationLess; - } - else - iDlgCode=pData->pTask->m_iDestinationLess; - } - // else do nothing - bCopyRest has been initialized - } - else - { - // dst >= src size - if (uiNotificationType > 1 && !bDontAsk) - { - if (pData->pTask->m_iDestinationGreater == -1) - { - CSmallReplaceFilesDlg dlg; - dlg.m_pfiSource=pData->pfiSrcFile; - dlg.m_pfiDest=&fiDest; - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - dlg.m_iDefaultOption=ID_RECOPY; - iDlgCode=dlg.DoModal(); // wy�wietl - - piLastDlgDesc=&pData->pTask->m_iDestinationGreater; - } - else - iDlgCode=pData->pTask->m_iDestinationGreater; - } - else - bCopyRest=false; // this case - recopy - } - } // iDst == *pData->pfiSrcFile - } // bExist - - // check for dialog result - switch (iDlgCode) - { - case -1: - break; - case ID_IGNOREALL: - if (piLastDlgDesc != NULL) - *piLastDlgDesc=ID_IGNOREALL; - case ID_IGNORE: - pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); - pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); - return; - break; - case ID_COPYRESTALL: - if (piLastDlgDesc != NULL) - *piLastDlgDesc=ID_COPYRESTALL; - case ID_COPYREST: - bCopyRest=true; - break; - case IDCANCEL: - // log - if (GetConfig()->GetBoolValue(PP_CMCREATELOG)) - pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPRECHECKCANCELREQUEST_STRING), (PCTSTR)pData->pfiSrcFile->GetFullFilePath()); - throw new CProcessingException(E_CANCEL, pData->pTask); - break; - case ID_RECOPYALL: - if (piLastDlgDesc != NULL) - *piLastDlgDesc=ID_RECOPYALL; - case ID_RECOPY: - bCopyRest=false; - break; - } - - // change attributes of a dest file - if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - SetFileAttributes(pData->strDstFile, FILE_ATTRIBUTE_NORMAL); - - // first or second pass ? only for FFNB - bool bFirstPass=true; - - // check size of src file to know whether use flag FILE_FLAG_NOBUFFERING -l_start: - bool bNoBuffer=(bFirstPass && GetConfig()->GetBoolValue(PP_BFUSENOBUFFERING) && pData->pfiSrcFile->GetLength64() >= GetConfig()->GetIntValue(PP_BFBOUNDARYLIMIT)); - - // refresh data about file - if (!bFirstPass) - bExist=fiDest.Create(pData->strDstFile, -1); - - // open src -l_openingsrc: - hSrc=CreateFile(pData->pfiSrcFile->GetFullFilePath(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffer ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); - if (hSrc == INVALID_HANDLE_VALUE) - { - DWORD dwLastError=GetLastError(); - if (uiNotificationType < 1) - { - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGERROR_STRING), dwLastError, (PCTSTR)pData->pfiSrcFile->GetFullFilePath()); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEOPENINGERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath()); - } - else - { - if (pData->pTask->m_iMissingInput == -1) - { - // no source file - feedback - CFileInfo fiRealSrc; - fiRealSrc.Create(pData->pfiSrcFile->GetFullFilePath(), -1); - - CReplaceOnlyDlg dlg; - dlg.m_pfiSource=pData->pfiSrcFile; - dlg.m_pfiDest=&fiRealSrc; - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - dlg.m_iDefaultOption=ID_WAIT; - - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, dlg.m_strMessage.GetBuffer(_MAX_PATH), _MAX_PATH, NULL); - dlg.m_strMessage.ReleaseBuffer(); - - iDlgCode=dlg.DoModal(); - } - else - iDlgCode=pData->pTask->m_iMissingInput; - - switch (iDlgCode) - { - case ID_IGNOREALL: - pData->pTask->m_iMissingInput=ID_IGNOREALL; - case ID_IGNORE: - pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); - pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); - return; - break; - case IDCANCEL: - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGCANCELREQUEST_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); - throw new CProcessingException(E_CANCEL, pData->pTask); - break; - case ID_WAIT: - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGWAITREQUEST_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEOPENINGERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath()); - break; - case ID_RETRY: - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFOPENINGRETRY_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath()); - goto l_openingsrc; - break; - } - } - } - - // open dest -l_openingdst: - hDst=CreateFile(pData->strDstFile, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffer ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); - if (hDst == INVALID_HANDLE_VALUE) - { - DWORD dwLastError=GetLastError(); - if (uiNotificationType < 1) - { - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGERROR_STRING), dwLastError, pData->strDstFile); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEDESTOPENINGERROR_STRING, dwLastError, pData->strDstFile); - } - else - { - if (pData->pTask->m_iOutputError == -1) - { - CDstFileErrorDlg dlg; - dlg.m_strFilename=pData->strDstFile; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwLastError, 0, dlg.m_strMessage.GetBuffer(_MAX_PATH), _MAX_PATH, NULL); - dlg.m_strMessage.ReleaseBuffer(); - - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - dlg.m_iDefaultOption=ID_WAIT; - iDlgCode=dlg.DoModal(); - } - else - iDlgCode=pData->pTask->m_iOutputError; - - switch (iDlgCode) - { - case ID_RETRY: - // change attributes - if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - SetFileAttributes(pData->strDstFile, FILE_ATTRIBUTE_NORMAL); - - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGRETRY_STRING), dwLastError, pData->strDstFile); - goto l_openingdst; - break; - case IDCANCEL: - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGCANCELREQUEST_STRING), dwLastError, pData->strDstFile); - throw new CProcessingException(E_CANCEL, pData->pTask); - break; - case ID_IGNOREALL: - pData->pTask->m_iOutputError=ID_IGNOREALL; - case ID_IGNORE: - pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); - pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); - return; - break; - case ID_WAIT: - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFDESTOPENINGWAITREQUEST_STRING), dwLastError, pData->strDstFile); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEDESTOPENINGERROR_STRING, dwLastError, pData->strDstFile); - break; - } - } - } - - // seeking - DWORD dwLastError=0; - if (!pData->bOnlyCreate) - { - if ( bCopyRest ) // if copy rest - { - if (!bFirstPass || (bExist && fiDest.GetLength64() > 0)) - { - // try to move file pointers to the end - ULONGLONG ullMove=(bNoBuffer ? ROUNDDOWN(fiDest.GetLength64(), MAXSECTORSIZE) : fiDest.GetLength64()); - if (SetFilePointer64(hSrc, ullMove, FILE_BEGIN) == -1 || SetFilePointer64(hDst, ullMove, FILE_BEGIN) == -1) - { - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFMOVINGPOINTERSERROR_STRING), GetLastError(), pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile, ullMove); - - // seek failed - seek to begin - if (SetFilePointer64(hSrc, 0, FILE_BEGIN) == -1 || SetFilePointer64(hDst, 0, FILE_BEGIN) == -1) - { - // log - dwLastError=GetLastError(); - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFRESTORINGPOINTERSERROR_STRING), dwLastError, pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPERESTORINGPOINTERSERROR_STRING, dwLastError, pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); - } - else - { - // file pointers restored - if second pass subtract what's needed - if (!bFirstPass) - { - pData->pTask->IncreaseProcessedSize(-static_cast<__int64>(ullMove)); - pData->pTask->IncreaseProcessedTasksSize(-static_cast<__int64>(ullMove)); - } - } - } - else - { - // file pointers moved - so we have skipped some work - update positions - if (bFirstPass) // przy drugim obiegu jest ju� uwzgl�dnione - { - pData->pTask->IncreaseProcessedSize(ullMove); - pData->pTask->IncreaseProcessedTasksSize(ullMove); - } - } - } - } - else - if (!SetEndOfFile(hDst)) // if recopying - reset the dest file - { - // log - dwLastError=GetLastError(); - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFSETTINGZEROSIZEERROR_STRING), dwLastError, pData->strDstFile); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPESETTINGZEROSIZEERROR_STRING, dwLastError, pData->strDstFile); - } - - // copying - unsigned long tord, rd, wr; - int iBufferIndex; - do - { - // kill flag checks - if (pData->pTask->GetKillFlag()) - { - // log - pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCOPYINGKILLREQUEST_STRING), pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); - throw new CProcessingException(E_KILL_REQUEST, pData->pTask); - } - - // recreate buffer if needed - if (!(*pData->dbBuffer.GetSizes() == *pData->pTask->GetBufferSizes())) - { - // log - const BUFFERSIZES *pbs1=pData->dbBuffer.GetSizes(), *pbs2=pData->pTask->GetBufferSizes(); - - pData->pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCHANGINGBUFFERSIZE_STRING), - pbs1->m_uiDefaultSize, pbs1->m_uiOneDiskSize, pbs1->m_uiTwoDisksSize, pbs1->m_uiCDSize, pbs1->m_uiLANSize, - pbs2->m_uiDefaultSize, pbs2->m_uiOneDiskSize, pbs2->m_uiTwoDisksSize, pbs2->m_uiCDSize, pbs2->m_uiLANSize, - pData->pfiSrcFile->GetFullFilePath(), pData->strDstFile); - pData->pTask->SetBufferSizes(pData->dbBuffer.Create(pData->pTask->GetBufferSizes())); - } - - // establish count of data to read - iBufferIndex=pData->pTask->GetBufferSizes()->m_bOnlyDefault ? 0 : pData->pfiSrcFile->GetBufferIndex(); - tord=bNoBuffer ? ROUNDUP(pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex], MAXSECTORSIZE) : pData->dbBuffer.GetSizes()->m_auiSizes[iBufferIndex]; - - // read - if (!ReadFile(hSrc, pData->dbBuffer, tord, &rd, NULL)) - { - // log - dwLastError=GetLastError(); - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFREADINGERROR_STRING), dwLastError, tord, pData->pfiSrcFile->GetFullFilePath()); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEREADINGERROR_STRING, dwLastError, tord, pData->pfiSrcFile->GetFullFilePath()); - } - - // change count of stored data - if (bNoBuffer && (ROUNDUP(rd, MAXSECTORSIZE)) != rd) - { - // we need to copy rest so do the second pass - // close files - CloseHandle(hSrc); - CloseHandle(hDst); - - // second pass - bFirstPass=false; - bCopyRest=true; // nedd to copy rest - - goto l_start; - } - - // zapisz - if (!WriteFile(hDst, pData->dbBuffer, rd, &wr, NULL) || wr != rd) - { - // log - dwLastError=GetLastError(); - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFWRITINGERROR_STRING), dwLastError, rd, pData->strDstFile); - throw new CProcessingException(E_ERROR, pData->pTask, IDS_CPEWRITINGERROR_STRING, dwLastError, rd, pData->strDstFile); - } - - // increase count of processed data - pData->pTask->IncreaseProcessedSize(rd); - pData->pTask->IncreaseProcessedTasksSize(rd); -// TRACE("Read: %d, Written: %d\n", rd, wr); - } - while ( rd != 0 ); - } - else - { - // we don't copy contents, but need to increase processed size - pData->pTask->IncreaseProcessedSize(pData->pfiSrcFile->GetLength64()); - pData->pTask->IncreaseProcessedTasksSize(pData->pfiSrcFile->GetLength64()); - } - - // close files - CloseHandle(hSrc); - CloseHandle(hDst); - } - catch(...) - { - // log - pData->pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCAUGHTEXCEPTIONCCF_STRING), GetLastError()); - - // close handles - if (hSrc != INVALID_HANDLE_VALUE) - CloseHandle(hSrc); - if (hDst != INVALID_HANDLE_VALUE) - CloseHandle(hDst); - - throw; - } -} - -// function processes files/folders -void ProcessFiles(CTask* pTask) -{ - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFILES_STRING)); - - // count how much has been done (updates also a member in CTaskArray) - pTask->CalcProcessedSize(); - - // create a buffer of size pTask->m_nBufferSize - CUSTOM_COPY_PARAMS ccp; - ccp.pTask=pTask; - ccp.bOnlyCreate=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_CONTENT) != 0; - ccp.dbBuffer.Create(pTask->GetBufferSizes()); - - // helpers - CFileInfo fi; // for currently processed element - DWORD dwLastError; - - // begin at index which wasn't processed previously - int nSize=pTask->FilesGetSize(); // wielko�� tablicy - int iCopiesCount=pTask->GetCopies(); // ilo�� kopii - bool bIgnoreFolders=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; - bool bForceDirectories=(pTask->GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; - const CDestPath& dpDestPath=pTask->GetDestPath(); - - // log - const BUFFERSIZES* pbs=ccp.dbBuffer.GetSizes(); - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFILESDATA_STRING), ccp.bOnlyCreate, - pbs->m_uiDefaultSize, pbs->m_uiOneDiskSize, pbs->m_uiTwoDisksSize, pbs->m_uiCDSize, pbs->m_uiLANSize, - nSize, iCopiesCount, bIgnoreFolders, dpDestPath.GetPath(), pTask->GetCurrentCopy(), pTask->GetCurrentIndex()); - - for (unsigned char j=pTask->GetCurrentCopy();jSetCurrentCopy(j); - for (int i=pTask->GetCurrentIndex();iSetCurrentIndex(i); - fi=pTask->FilesGetAtCurrentIndex(); - - // should we kill ? - if (pTask->GetKillFlag()) - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGKILLREQUEST_STRING)); - throw new CProcessingException(E_KILL_REQUEST, pTask); - } - - // set dest path with filename - ccp.strDstFile=fi.GetDestinationPath(dpDestPath.GetPath(), j, ((int)bForceDirectories) << 1 | (int)bIgnoreFolders); - - // are the files/folders lie on the same partition ? - bool bMove=pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE; - if (bMove && dpDestPath.GetDriveNumber() != -1 && dpDestPath.GetDriveNumber() == fi.GetDriveNumber() && iCopiesCount == 1 && fi.GetMove()) - { - if (!MoveFile(fi.GetFullFilePath(), ccp.strDstFile)) - { - dwLastError=GetLastError(); - //log - pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFMOVEFILEERROR_STRING), dwLastError, fi.GetFullFilePath(), ccp.strDstFile); - throw new CProcessingException(E_ERROR, pTask, IDS_CPEMOVEFILEERROR_STRING, dwLastError, fi.GetFullFilePath(), ccp.strDstFile); - } - } - else - { - // if folder - create it - if ( fi.IsDirectory() ) - { - if (!CreateDirectory(ccp.strDstFile, NULL) && (dwLastError=GetLastError()) != ERROR_ALREADY_EXISTS ) - { - // log - pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCREATEDIRECTORYERROR_STRING), dwLastError, ccp.strDstFile); - throw new CProcessingException(E_ERROR, pTask, IDS_CPECREATEDIRECTORYERROR_STRING, dwLastError, ccp.strDstFile); - } - - pTask->IncreaseProcessedSize(fi.GetLength64()); - pTask->IncreaseProcessedTasksSize(fi.GetLength64()); - } - else - { - // start copying/moving file - ccp.pfiSrcFile=&fi; - - // kopiuj dane - CustomCopyFile(&ccp); - - // if moving - delete file (only if config flag is set) - if (bMove && !GetConfig()->GetBoolValue(PP_CMDELETEAFTERFINISHED) && j == iCopiesCount-1) - { - if (!GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - SetFileAttributes(fi.GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); - DeleteFile(fi.GetFullFilePath()); // there will be another try later, so I don't check - // if succeeded - } - } - - // set a time - if (GetConfig()->GetBoolValue(PP_CMSETDESTDATE)) - SetFileDirectoryTime(ccp.strDstFile, &fi); // no error check - ma�o istotne - - // attributes - if (GetConfig()->GetBoolValue(PP_CMSETDESTATTRIBUTES)) - SetFileAttributes(ccp.strDstFile, fi.GetAttributes()); // j.w. - } - } - - // current copy finished - change what's needed - pTask->SetCurrentIndex(0); - } - - // delete buffer - it's not needed - ccp.dbBuffer.Delete(); - - // change status - if (pTask->GetStatus(ST_OPERATION_MASK) == ST_MOVE) - { - pTask->SetStatus(ST_DELETING, ST_STEP_MASK); - // set the index to 0 before deleting - pTask->SetCurrentIndex(0); - } - else - { - pTask->SetStatus(ST_FINISHED, ST_STEP_MASK); - - // to look better - increase current index by 1 - pTask->SetCurrentIndex(nSize); - } - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFPROCESSINGFINISHED_STRING)); -} - -void CheckForWaitState(CTask* pTask) -{ - // limiting operation count - pTask->SetStatus(ST_WAITING, ST_WAITING_MASK); - bool bContinue=false; - while (!bContinue) - { - if (pTask->CanBegin()) - { - TRACE("CAN BEGIN ALLOWED TO CONTINUE...\n"); - pTask->SetStatus(0, ST_WAITING); - bContinue=true; - - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFWAITINGFINISHED_STRING)); - -// return; // skips sleep and kill flag checking - } - - Sleep(50); // not to make it too hard for processor - - if (pTask->GetKillFlag()) - { - // log - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFWAITINGKILLREQUEST_STRING)); - throw new CProcessingException(E_KILL_REQUEST, pTask); - } - } -} - -UINT ThrdProc(LPVOID pParam) -{ - TRACE("\n\nENTERING ThrdProc (new task started)...\n"); - CTask* pTask=static_cast(pParam); - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - _tcscat(szPath, pTask->GetUniqueName()+_T(".log")); - pTask->m_log.init(szPath, 262144, LT_DEBUG, false, false); - - // set thread boost - HANDLE hThread=GetCurrentThread(); - ::SetThreadPriorityBoost(hThread, GetConfig()->GetBoolValue(PP_CMDISABLEPRIORITYBOOST)); - - CTime tm=CTime::GetCurrentTime(); - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFTHREADSTART_STRING), tm.GetDay(), tm.GetMonth(), tm.GetYear(), tm.GetHour(), tm.GetMinute(), tm.GetSecond()); - - try - { - // to make the value stable - bool bReadTasksSize=GetConfig()->GetBoolValue(PP_CMREADSIZEBEFOREBLOCKING); - - if (!bReadTasksSize) - CheckForWaitState(pTask); // operation limiting - - // set what's needed - pTask->m_lLastTime=time(NULL); // last time (start counting) - - // search for files if needed - if ((pTask->GetStatus(ST_STEP_MASK) == ST_NULL_STATUS - || pTask->GetStatus(ST_STEP_MASK) == ST_SEARCHING)) - { - // get rid of info about processed sizes - pTask->DecreaseProcessedTasksSize(pTask->GetProcessedSize()); - pTask->SetProcessedSize(0); - pTask->DecreaseAllTasksSize(pTask->GetAllSize()); - pTask->SetAllSize(0); - - // start searching - RecurseDirectories(pTask); - } - - // check for free space - __int64 i64Needed, i64Available; -l_showfeedback: - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFCHECKINGSPACE_STRING)); - - if (!pTask->GetRequiredFreeSpace(&i64Needed, &i64Available)) - { - pTask->m_log.logw(GetResManager()->LoadString(IDS_OTFNOTENOUGHFREESPACE_STRING), i64Needed, i64Available); - - // default - int iResult=ID_IGNORE; - - if (GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK) > 0) - { - // make user know that some place is missing - CNotEnoughRoomDlg dlg; - dlg.m_bEnableTimer=GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK); - dlg.m_iTime=GetConfig()->GetIntValue(PP_CMFEEDBACKTIME); - - dlg.m_llRequired=i64Needed; - - for (int i=0;iGetClipboardDataSize();i++) - dlg.m_strFiles.Add(pTask->GetClipboardData(i)->GetPath()); - - dlg.m_strDisk=pTask->GetDestPath().GetPath(); - - // show - iResult=dlg.DoModal(); - } - - switch (iResult) - { - case IDCANCEL: - { - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACECANCELREQUEST_STRING)); - throw new CProcessingException(E_CANCEL, pTask); - break; - } - case ID_RETRY: - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACERETRYING_STRING)); - goto l_showfeedback; - break; - case ID_IGNORE: - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFFREESPACEIGNORE_STRING)); - break; - } - } - - if (bReadTasksSize) - { - pTask->UpdateTime(); - pTask->m_lLastTime=-1; - - CheckForWaitState(pTask); - - pTask->m_lLastTime=time(NULL); - } - - // Phase II - copying/moving - if (pTask->GetStatus(ST_STEP_MASK) == ST_COPYING) - { - // decrease processed in ctaskarray - the rest will be done in ProcessFiles - pTask->DecreaseProcessedTasksSize(pTask->GetProcessedSize()); - ProcessFiles(pTask); - } - - // deleting data - III phase - if (pTask->GetStatus(ST_STEP_MASK) == ST_DELETING) - DeleteFiles(pTask); - - // refresh time - pTask->UpdateTime(); - - // save progress before killed - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, false); - - // we are ending - pTask->DecreaseOperationsPending(); - - // play sound - if (GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) - { - GetConfig()->GetStringValue(PP_SNDFINISHEDSOUNDPATH, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - PlaySound(szPath, NULL, SND_FILENAME | SND_ASYNC); - } - - CTime tm=CTime::GetCurrentTime(); - pTask->m_log.logi(GetResManager()->LoadString(IDS_OTFTHREADFINISHED_STRING), tm.GetDay(), tm.GetMonth(), tm.GetYear(), tm.GetHour(), tm.GetMinute(), tm.GetSecond()); - - // we have been killed - the last operation - InterlockedIncrement(pTask->m_plFinished); - pTask->CleanupAfterKill(); - pTask->SetKilledFlag(); - } - catch(CProcessingException* e) - { - // increment count of beginnings - InterlockedIncrement(pTask->m_plFinished); - - // refresh time - pTask->UpdateTime(); - - // log - pTask->m_log.logerr(GetResManager()->LoadString(IDS_OTFCAUGHTEXCEPTIONMAIN_STRING), e->m_dwError, e->m_iType); - - if (e->m_iType == E_ERROR && GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) - { - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_SNDERRORSOUNDPATH, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - PlaySound(szPath, NULL, SND_FILENAME | SND_ASYNC); - } - - // cleanup changes flags and calls cleanup for a task - e->Cleanup(); - delete e; - - if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) - pTask->SetStatus(0, ST_WAITING); - - pTask->DecreaseOperationsPending(); - pTask->SetContinueFlag(false); - pTask->SetForceFlag(false); - - return 0xffffffff; // almost like -1 - } - - TRACE("TASK FINISHED - exiting ThrdProc.\n"); - return 0; -} - -UINT ClipboardMonitorProc(LPVOID pParam) -{ - volatile CLIPBOARDMONITORDATA* pData=static_cast(pParam); - ASSERT(pData->m_hwnd); - - // bufor - TCHAR path[_MAX_PATH]; - UINT i; // counter - CTask *pTask; // ptr to a task - CClipboardEntry* pEntry=NULL; - - // register clipboard format - UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); - UINT uiCounter=0, uiShutCounter=0;; - LONG lFinished=0; - bool bEnd=false; - - while (!pData->bKill) - { - if (uiCounter == 0 && GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING) && IsClipboardFormatAvailable(CF_HDROP)) - { - // get data from clipboard - OpenClipboard(pData->m_hwnd); - HANDLE handle=GetClipboardData(CF_HDROP); - - UINT nCount=DragQueryFile(static_cast(handle), 0xffffffff, NULL, 0); - - pTask=new CTask(&pData->m_pTasks->m_tcd); - - for (i=0;i(handle), i, path, _MAX_PATH); - pEntry=new CClipboardEntry; - pEntry->SetPath(path); - pTask->AddClipboardData(pEntry); - } - - if (IsClipboardFormatAvailable(nFormat)) - { - HANDLE handle=GetClipboardData(nFormat); - LPVOID addr=GlobalLock(handle); - - DWORD dwData=((DWORD*)addr)[0]; - if (dwData & DROPEFFECT_COPY) - pTask->SetStatus(ST_COPY, ST_OPERATION_MASK); // copy - else if (dwData & DROPEFFECT_MOVE) - pTask->SetStatus(ST_MOVE, ST_OPERATION_MASK); // move - - GlobalUnlock(handle); - } - else - pTask->SetStatus(ST_COPY, ST_OPERATION_MASK); // default - copy - - EmptyClipboard(); - CloseClipboard(); - - BUFFERSIZES bs; - bs.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); - bs.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); - bs.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); - bs.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); - bs.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); - bs.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); - - pTask->SetBufferSizes(&bs); - pTask->SetPriority(GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY)); - - // get dest folder - CFolderDialog dlg; - GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &dlg.m_bdData.cvShortcuts); - GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_bdData.cvRecent); - dlg.m_bdData.bExtended=GetConfig()->GetBoolValue(PP_FDEXTENDEDVIEW); - dlg.m_bdData.cx=GetConfig()->GetIntValue(PP_FDWIDTH); - dlg.m_bdData.cy=GetConfig()->GetIntValue(PP_FDHEIGHT); - dlg.m_bdData.iView=GetConfig()->GetIntValue(PP_FDSHORTCUTLISTSTYLE); - dlg.m_bdData.bIgnoreDialogs=GetConfig()->GetBoolValue(PP_FDIGNORESHELLDIALOGS); - - dlg.m_bdData.strInitialDir=(dlg.m_bdData.cvRecent.size() > 0) ? dlg.m_bdData.cvRecent.at(0) : _T(""); - - int iStatus=pTask->GetStatus(ST_OPERATION_MASK); - if (iStatus == ST_COPY) - dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLECOPY_STRING); - else if (iStatus == ST_MOVE) - dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLEMOVE_STRING); - else - dlg.m_bdData.strCaption=GetResManager()->LoadString(IDS_TITLEUNKNOWNOPERATION_STRING); - dlg.m_bdData.strText=GetResManager()->LoadString(IDS_MAINBROWSETEXT_STRING); - - // set count of data to display - int iClipboardSize=pTask->GetClipboardDataSize(); - int iEntries=(iClipboardSize > 3) ? 2 : iClipboardSize; - for (int i=0;iGetClipboardData(i)->GetPath()+_T("\n"); - - // add ... - if (iEntries < iClipboardSize) - dlg.m_bdData.strText+=_T("..."); - - // show window - int iResult=dlg.DoModal(); - - // set data to config - GetConfig()->SetStringArrayValue(PP_SHORTCUTS, &dlg.m_bdData.cvShortcuts); - GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_bdData.cvRecent); - GetConfig()->SetBoolValue(PP_FDEXTENDEDVIEW, dlg.m_bdData.bExtended); - GetConfig()->SetIntValue(PP_FDWIDTH, dlg.m_bdData.cx); - GetConfig()->SetIntValue(PP_FDHEIGHT, dlg.m_bdData.cy); - GetConfig()->SetIntValue(PP_FDSHORTCUTLISTSTYLE, dlg.m_bdData.iView); - GetConfig()->SetBoolValue(PP_FDIGNORESHELLDIALOGS, dlg.m_bdData.bIgnoreDialogs); - GetConfig()->Save(); - - if ( iResult != IDOK ) - delete pTask; - else - { - // get dest path - CString strData; - dlg.GetPath(strData); - pTask->SetDestPath(strData); - - // get the relationship between src and dst paths - for (int i=0;iGetClipboard()->GetSize();i++) - pTask->GetClipboard()->GetAt(i)->CalcBufferIndex(pTask->GetDestPath()); - - // write pTask to a file - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); - - // add task to a list of tasks and start - pData->m_pTasks->Add(pTask); - - // start processing - pTask->BeginProcessing(); - } - } - - // do we need to check for turning computer off - if (GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)) - { - if (uiShutCounter == 0) - { - if (lFinished != pData->m_pTasks->m_lFinished) - { - bEnd=true; - lFinished=pData->m_pTasks->m_lFinished; - } - - if (bEnd && pData->m_pTasks->IsFinished()) - { - TRACE("Shut down windows\n"); - bool bShutdown=true; - if (GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN) != 0) - { - CShutdownDlg dlg; - dlg.m_iOverallTime=GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN); - if (dlg.m_iOverallTime < 0) - dlg.m_iOverallTime=-dlg.m_iOverallTime; - bShutdown=(dlg.DoModal() != IDCANCEL); - } - - GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, false); - GetConfig()->Save(); - if (bShutdown) - { - // we're killed - pData->bKilled=true; - - // adjust token privileges for NT - HANDLE hToken=NULL; - TOKEN_PRIVILEGES tp; - if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken) - && LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tp.Privileges[0].Luid)) - { - tp.PrivilegeCount=1; - tp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED; - - AdjustTokenPrivileges(hToken, FALSE, &tp, NULL, NULL, NULL); - } - - BOOL bExit=ExitWindowsEx(EWX_POWEROFF | EWX_SHUTDOWN | (GetConfig()->GetBoolValue(PP_PFORCESHUTDOWN) ? EWX_FORCE : 0), 0); - if (bExit) - return 1; - else - { - pData->bKilled=false; - - // some kind of error - CString strErr; - strErr.Format(GetResManager()->LoadString(IDS_SHUTDOWNERROR_STRING), GetLastError()); - AfxMessageBox(strErr, MB_ICONERROR | MB_OK | MB_SYSTEMMODAL); - } - } - } - } - } - else - { - bEnd=false; - lFinished=pData->m_pTasks->m_lFinished; - } - - // sleep for some time - const int iSleepCount=200; - Sleep(iSleepCount); - uiCounter+=iSleepCount; - uiShutCounter+=iSleepCount; - if (uiCounter >= (UINT)GetConfig()->GetIntValue(PP_PMONITORSCANINTERVAL)) - uiCounter=0; - if (uiShutCounter >= 800) - uiShutCounter=0; - } - - pData->bKilled=true; - TRACE("Monitoring clipboard proc aborted...\n"); - - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainWnd message handlers - -int CMainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - lpCreateStruct->dwExStyle |= WS_EX_TOPMOST; - if (CWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - // get msg id of taskbar created message - m_uiTaskbarRestart=RegisterWindowMessage(_T("TaskbarCreated")); - - // Create the tray icon - ShowTrayIcon(); - - // initialize CTaskArray - m_tasks.Create(&ThrdProc); - - // load last state - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.LoadDataProgress(szPath); - m_tasks.TasksRetryProcessing(); - - // start clipboard monitoring - cmd.bKill=false; - cmd.bKilled=false; - cmd.m_hwnd=this->m_hWnd; - cmd.m_pTasks=&m_tasks; - - AfxBeginThread(&ClipboardMonitorProc, static_cast(&cmd), THREAD_PRIORITY_IDLE); - - // start saving timer - SetTimer(1023, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL), NULL); - - SetTimer(7834, TM_AUTORESUME/*GetConfig()->GetAutoRetryInterval()*/, NULL); - SetTimer(3245, TM_AUTOREMOVE, NULL); - SetTimer(8743, TM_ACCEPTING, NULL); // ends wait state in tasks - - if (GetConfig()->GetBoolValue(PP_MVAUTOSHOWWHENRUN)) - PostMessage(WM_SHOWMINIVIEW); - - return 0; -} - -LRESULT CMainWnd::OnTrayNotification(WPARAM wParam, LPARAM lParam) -{ - if (wParam != m_ctlTray.m_tnd.uID) - return (LRESULT)FALSE; - - TCHAR text[_MAX_PATH]; - switch(LOWORD(lParam)) - { - case WM_LBUTTONDOWN: - { - ::SetForegroundWindow(this->m_hWnd); - break; - } - case WM_LBUTTONDBLCLK: - { - CMenu mMenu, *pSubMenu; - HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_POPUP_MENU)); - if (!mMenu.Attach(hMenu)) - return (LRESULT)FALSE; - - if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) - return (LRESULT)FALSE; - - // double click received, the default action is to execute first menu item - ::SetForegroundWindow(this->m_hWnd); - ::SendMessage(this->m_hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0); - - pSubMenu->DestroyMenu(); - mMenu.DestroyMenu(); - break; - } - case WM_RBUTTONUP: - { - // load main menu - HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_POPUP_MENU)); - CMenu mMenu, *pSubMenu; - if (!mMenu.Attach(hMenu)) - return (LRESULT)FALSE; - - if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) - return (LRESULT)FALSE; - - // set menu default item - pSubMenu->SetDefaultItem(0, TRUE); - - // make window foreground - SetForegroundWindow(); - - // get current cursor pos - POINT pt; - GetCursorPos(&pt); - - pSubMenu->CheckMenuItem(ID_POPUP_MONITORING, MF_BYCOMMAND | (GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING) ? MF_CHECKED : MF_UNCHECKED)); - pSubMenu->CheckMenuItem(ID_POPUP_SHUTAFTERFINISHED, MF_BYCOMMAND | (GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED) ? MF_CHECKED : MF_UNCHECKED)); - - // track the menu - pSubMenu->TrackPopupMenu(TPM_LEFTBUTTON, pt.x, pt.y, this); - - // destroy - pSubMenu->DestroyMenu(); - mMenu.DestroyMenu(); - - break; - } - case WM_MOUSEMOVE: - { - if (m_tasks.GetSize() != 0) - { - _stprintf(text, _T("%s - %d %%"), GetApp()->GetAppName(), m_tasks.GetPercent()); - m_ctlTray.SetTooltipText(text); - } - else - m_ctlTray.SetTooltipText(GetApp()->GetAppNameVer()); - break; - } - } - - return (LRESULT)TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainWnd/CTrayIcon menu message handlers - -void CMainWnd::ShowStatusWindow(const CTask *pSelect) -{ - m_pdlgStatus=new CStatusDlg(&m_tasks, this); // self deleting - m_pdlgStatus->m_pInitialSelection=pSelect; - m_pdlgStatus->m_bLockInstance=true; - m_pdlgStatus->m_bAutoDelete=true; - m_pdlgStatus->Create(); - - // hide miniview if showing status - if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock) - { - if (::IsWindow(m_pdlgMiniView->m_hWnd)) - m_pdlgMiniView->HideWindow(); - } -} - -void CMainWnd::OnPopupShowStatus() -{ - ShowStatusWindow(); -} - -void CMainWnd::OnClose() -{ - PrepareToExit(); - CWnd::OnClose(); -} - -void CMainWnd::OnTimer(UINT nIDEvent) -{ - switch (nIDEvent) - { - case 1023: - // autosave timer - KillTimer(1023); - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.SaveProgress(szPath); - SetTimer(1023, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL), NULL); - break; - case 7834: - { - // auto-resume timer - KillTimer(7834); - DWORD dwTime=GetTickCount(); - DWORD dwInterval=(m_dwLastTime == 0) ? TM_AUTORESUME : dwTime-m_dwLastTime; - m_dwLastTime=dwTime; - - if (GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR)) - { - if (m_tasks.TasksRetryProcessing(true, dwInterval) && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) - m_pdlgStatus->SendMessage(WM_UPDATESTATUS); - } - SetTimer(7834, TM_AUTORESUME/*GetConfig()->GetAutoRetryInterval()*/, NULL); - } - break; - case 3245: - // auto-delete finished tasks timer - KillTimer(3245); - if (GetConfig()->GetBoolValue(PP_STATUSAUTOREMOVEFINISHED)) - { - int iSize=m_tasks.GetSize(); - m_tasks.RemoveAllFinished(); - if (m_tasks.GetSize() != iSize && m_pdlgStatus && m_pdlgStatus->m_bLock && IsWindow(m_pdlgStatus->m_hWnd)) - m_pdlgStatus->SendMessage(WM_UPDATESTATUS); - } - - SetTimer(3245, TM_AUTOREMOVE, NULL); - break; - case 8743: - { - // wait state handling section - CTask* pTask; - if (GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS) == 0 || m_tasks.GetOperationsPending() < (UINT)GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS)) - { - for (int i=0;iGetStatus(ST_WAITING_MASK) & ST_WAITING && (GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS) == 0 || m_tasks.GetOperationsPending() < (UINT)GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS))) - { - TRACE("Enabling task %ld\n", i); - pTask->SetContinueFlag(true); - pTask->IncreaseOperationsPending(); - pTask->SetStatus(0, ST_WAITING); // turn off wait state - } - } - } - break; - } - } - - CWnd::OnTimer(nIDEvent); -} - -void CMainWnd::OnPopupShowOptions() -{ - COptionsDlg *pDlg=new COptionsDlg(this); - pDlg->m_bAutoDelete=true; - pDlg->m_bLockInstance=true; - pDlg->Create(); -} - -BOOL CMainWnd::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) -{ - // copying or moving ? - bool bMove=false; - switch(pCopyDataStruct->dwData & OPERATION_MASK) - { - case DD_MOVE_FLAG: - case EC_MOVETO_FLAG: - bMove=true; - break; - case EC_PASTE_FLAG: - case EC_PASTESPECIAL_FLAG: - bMove=(pCopyDataStruct->dwData & ~OPERATION_MASK) != 0; - break; - } - - // buffer with: dst path and src paths separated by single '\0' - TCHAR *pBuffer=static_cast(pCopyDataStruct->lpData); - unsigned long ulLen=pCopyDataStruct->cbData; - - CString str, strDstPath; - CStringArray astrFiles; - UINT iOffset=0; - - do - { - str=pBuffer+iOffset; - if (iOffset == 0) - strDstPath=str; - else - astrFiles.Add(str); - - iOffset+=str.GetLength()+1; - } - while (iOffset < ulLen); - - // special operation - modify stuff - CFiltersArray ffFilters; - int iPriority=GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY); - BUFFERSIZES bsSizes; - bsSizes.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); - bsSizes.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); - bsSizes.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); - bsSizes.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); - bsSizes.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); - bsSizes.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); - - BOOL bOnlyCreate=FALSE; - BOOL bIgnoreDirs=FALSE; - BOOL bForceDirectories=FALSE; - unsigned char ucCopies=1; - switch(pCopyDataStruct->dwData & OPERATION_MASK) - { - case DD_COPYMOVESPECIAL_FLAG: - case EC_PASTESPECIAL_FLAG: - case EC_COPYMOVETOSPECIAL_FLAG: - CCustomCopyDlg dlg; - dlg.m_ccData.m_astrPaths.Copy(astrFiles); - dlg.m_ccData.m_iOperation=bMove ? 1 : 0; - dlg.m_ccData.m_iPriority=iPriority; - dlg.m_ccData.m_strDestPath=strDstPath; - dlg.m_ccData.m_bsSizes=bsSizes; - dlg.m_ccData.m_bIgnoreFolders=(bIgnoreDirs != 0); - dlg.m_ccData.m_bForceDirectories=(bForceDirectories != 0); - dlg.m_ccData.m_bCreateStructure=(bOnlyCreate != 0); - dlg.m_ccData.m_ucCount=ucCopies; - GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); // recent paths - - int iModalResult; - if ( (iModalResult=dlg.DoModal()) == IDCANCEL) - return CWnd::OnCopyData(pWnd, pCopyDataStruct); - else if (iModalResult == -1) // windows has been closed by a parent - return TRUE; - - astrFiles.Copy(dlg.m_ccData.m_astrPaths); - bMove=(dlg.m_ccData.m_iOperation != 0); - iPriority=dlg.m_ccData.m_iPriority; - strDstPath=dlg.m_ccData.m_strDestPath; - bsSizes=dlg.m_ccData.m_bsSizes; - ffFilters.Copy(dlg.m_ccData.m_afFilters); - bIgnoreDirs=dlg.m_ccData.m_bIgnoreFolders; - bForceDirectories=dlg.m_ccData.m_bForceDirectories; - bOnlyCreate=dlg.m_ccData.m_bCreateStructure; - ucCopies=dlg.m_ccData.m_ucCount; - dlg.m_ccData.m_vRecent.insert(dlg.m_ccData.m_vRecent.begin(), (const PTSTR)(LPCTSTR)strDstPath, true); - - GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); - } - - // create new task - CTask *pTask=new CTask(&m_tasks.m_tcd); - pTask->SetDestPath(strDstPath); - CClipboardEntry* pEntry; - - // files - for (int i=0;iSetPath(astrFiles.GetAt(i)); - pEntry->CalcBufferIndex(pTask->GetDestPath()); - pTask->AddClipboardData(pEntry); - } - - pTask->SetStatus(bMove ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); - - // special status - pTask->SetStatus((bOnlyCreate ? ST_IGNORE_CONTENT : 0) | (bIgnoreDirs ? ST_IGNORE_DIRS : 0) | (bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); - - // set some stuff related with task - pTask->SetBufferSizes(&bsSizes); - pTask->SetPriority(iPriority); - pTask->SetFilters(&ffFilters); - pTask->SetCopies(ucCopies); - - // save state of a task - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); - - // add to task list and start processing - m_tasks.Add(pTask); - pTask->BeginProcessing(); - - return CWnd::OnCopyData(pWnd, pCopyDataStruct); -} - -void CMainWnd::OnShowMiniView() -{ - m_pdlgMiniView=new CMiniViewDlg(&m_tasks, &CStatusDlg::m_bLock, this); // self-deleting - m_pdlgMiniView->m_bAutoDelete=true; - m_pdlgMiniView->m_bLockInstance=true; - m_pdlgMiniView->Create(); -} - -void CMainWnd::OnPopupCustomCopy() -{ - CCustomCopyDlg dlg; - dlg.m_ccData.m_iOperation=0; - dlg.m_ccData.m_iPriority=GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY); - dlg.m_ccData.m_bsSizes.m_bOnlyDefault=GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT); - dlg.m_ccData.m_bsSizes.m_uiDefaultSize=GetConfig()->GetIntValue(PP_BFDEFAULT); - dlg.m_ccData.m_bsSizes.m_uiOneDiskSize=GetConfig()->GetIntValue(PP_BFONEDISK); - dlg.m_ccData.m_bsSizes.m_uiTwoDisksSize=GetConfig()->GetIntValue(PP_BFTWODISKS); - dlg.m_ccData.m_bsSizes.m_uiCDSize=GetConfig()->GetIntValue(PP_BFCD); - dlg.m_ccData.m_bsSizes.m_uiLANSize=GetConfig()->GetIntValue(PP_BFLAN); - - dlg.m_ccData.m_bCreateStructure=false; - dlg.m_ccData.m_bForceDirectories=false; - dlg.m_ccData.m_bIgnoreFolders=false; - dlg.m_ccData.m_ucCount=1; - GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); - - if (dlg.DoModal() == IDOK) - { - // save recent paths - dlg.m_ccData.m_vRecent.push_back((const PTSTR)(LPCTSTR)dlg.m_ccData.m_strDestPath, true); - GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &dlg.m_ccData.m_vRecent); - - // new task - CTask *pTask=new CTask(&m_tasks.m_tcd); - pTask->SetDestPath(dlg.m_ccData.m_strDestPath); - CClipboardEntry *pEntry; - for (int i=0;iSetPath(dlg.m_ccData.m_astrPaths.GetAt(i)); - pEntry->CalcBufferIndex(pTask->GetDestPath()); - pTask->AddClipboardData(pEntry); - } - - pTask->SetStatus((dlg.m_ccData.m_iOperation == 1) ? ST_MOVE : ST_COPY, ST_OPERATION_MASK); - - // special status - pTask->SetStatus((dlg.m_ccData.m_bCreateStructure ? ST_IGNORE_CONTENT : 0) | (dlg.m_ccData.m_bIgnoreFolders ? ST_IGNORE_DIRS : 0) - | (dlg.m_ccData.m_bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); - - pTask->SetBufferSizes(&dlg.m_ccData.m_bsSizes); - pTask->SetPriority(dlg.m_ccData.m_iPriority); - pTask->SetFilters(&dlg.m_ccData.m_afFilters); - - // save - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - pTask->Store(szPath, true); - pTask->Store(szPath, false); - - // store and start - m_tasks.Add(pTask); - pTask->BeginProcessing(); - } -} - -LRESULT CMainWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_MINIVIEWDBLCLK: - { - ShowStatusWindow((CTask*)lParam); - break; - } - case WM_SHOWMINIVIEW: - { - OnShowMiniView(); - return static_cast(0); - break; - } - - case WM_CONFIGNOTIFY: - { - GetApp()->SetAutorun(GetConfig()->GetBoolValue(PP_PRELOADAFTERRESTART)); - - // set this process class - HANDLE hProcess=GetCurrentProcess(); - ::SetPriorityClass(hProcess, GetConfig()->GetIntValue(PP_PPROCESSPRIORITYCLASS)); - - break; - } - - case WM_GETCONFIG: - { - // std config values - g_pscsShared->bShowFreeSpace=GetConfig()->GetBoolValue(PP_SHSHOWFREESPACE); - - // experimental - doesn't work on all systems - g_pscsShared->bShowShortcutIcons=GetConfig()->GetBoolValue(PP_SHSHOWSHELLICONS); - g_pscsShared->bOverrideDefault=GetConfig()->GetBoolValue(PP_SHUSEDRAGDROP); // only for d&d - g_pscsShared->uiDefaultAction=GetConfig()->GetIntValue(PP_SHDEFAULTACTION); - - // sizes - for (int i=0;i<6;i++) - _tcscpy(g_pscsShared->szSizes[i], GetResManager()->LoadString(IDS_BYTE_STRING+i)); - - // convert to list of _COMMAND's - _COMMAND *pCommand=(_COMMAND*)g_pscsShared->szData; - - // what kind of menu ? - switch (wParam) - { - case GC_DRAGDROP: - { - g_pscsShared->iCommandCount=3; - g_pscsShared->iShortcutsCount=0; - g_pscsShared->uiFlags=(GetConfig()->GetBoolValue(PP_SHSHOWCOPY) ? DD_COPY_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWMOVE) ? DD_MOVE_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVE) ? DD_COPYMOVESPECIAL_FLAG : 0); - - pCommand[0].uiCommandID=DD_COPY_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUCOPY_STRING, pCommand[0].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPCOPY_STRING, pCommand[0].szDesc, 128); - - pCommand[1].uiCommandID=DD_MOVE_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUMOVE_STRING, pCommand[1].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPMOVE_STRING, pCommand[1].szDesc, 128); - - pCommand[2].uiCommandID=DD_COPYMOVESPECIAL_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUCOPYMOVESPECIAL_STRING, pCommand[2].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYMOVESPECIAL_STRING, pCommand[2].szDesc, 128); - } - break; - case GC_EXPLORER: - { - g_pscsShared->iCommandCount=5; - g_pscsShared->uiFlags=(GetConfig()->GetBoolValue(PP_SHSHOWPASTE) ? EC_PASTE_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWPASTESPECIAL) ? EC_PASTESPECIAL_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYTO) ? EC_COPYTO_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWMOVETO) ? EC_MOVETO_FLAG : 0) - | (GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVETO) ? EC_COPYMOVETOSPECIAL_FLAG : 0); - - pCommand[0].uiCommandID=EC_PASTE_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUPASTE_STRING, pCommand[0].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPPASTE_STRING, pCommand[0].szDesc, 128); - pCommand[1].uiCommandID=EC_PASTESPECIAL_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUPASTESPECIAL_STRING, pCommand[1].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPPASTESPECIAL_STRING, pCommand[1].szDesc, 128); - pCommand[2].uiCommandID=EC_COPYTO_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUCOPYTO_STRING, pCommand[2].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYTO_STRING, pCommand[2].szDesc, 128); - pCommand[3].uiCommandID=EC_MOVETO_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUMOVETO_STRING, pCommand[3].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPMOVETO_STRING, pCommand[3].szDesc, 128); - pCommand[4].uiCommandID=EC_COPYMOVETOSPECIAL_FLAG; - GetResManager()->LoadStringCopy(IDS_MENUCOPYMOVETOSPECIAL_STRING, pCommand[4].szCommand, 128); - GetResManager()->LoadStringCopy(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING, pCommand[4].szDesc, 128); - - // prepare shortcuts - char_vector cvShortcuts; - GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &cvShortcuts); - - // count of shortcuts to store - g_pscsShared->iShortcutsCount=__min(cvShortcuts.size(), SHARED_BUFFERSIZE-5*sizeof(_COMMAND)); - _SHORTCUT* pShortcut=(_SHORTCUT*)(g_pscsShared->szData+5*sizeof(_COMMAND)); - CShortcut sc; - for (int i=0;iiShortcutsCount;i++) - { - sc=CString(cvShortcuts.at(i)); - _tcsncpy(pShortcut[i].szName, sc.m_strName, 128); - _tcsncpy(pShortcut[i].szPath, sc.m_strPath, _MAX_PATH); - } - } - break; - default: - ASSERT(false); // what's happening ? - } - } - break; - - case WM_IDENTIFY: - { - //decode - unsigned char *dec=new unsigned char[iCount+1]; - dec[iCount]=0; - - unsigned short sData; - for (int i=0, j=0;i(msg[i] - _hash[j]); - - sData >>= off[j]; - dec[i]=static_cast(sData); - - if (++j >= iOffCount) - j=0; - } - - AfxMessageBox(reinterpret_cast(dec)); - delete [] dec; - - break; - } - case WM_STATUSCLOSING: - { - if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock && ::IsWindow(m_pdlgMiniView->m_hWnd)) - m_pdlgMiniView->RefreshStatus(); - - break; - } - case WM_ENDSESSION: - { - PrepareToExit(); - break; - } - case WM_TRAYNOTIFY: - { - return OnTrayNotification(wParam, lParam); - break; - } - } - - // if this is a notification of new tray - recreate the icon - if (message == m_uiTaskbarRestart) - { - ShowTrayIcon(); - return (LRESULT)TRUE; - } - - return CWnd::WindowProc(message, wParam, lParam); -} - -void CMainWnd::OnAppAbout() -{ - CAboutDlg *pdlg=new CAboutDlg; - pdlg->m_bAutoDelete=true; - pdlg->m_bLockInstance=true; - pdlg->Create(); -} - -void CMainWnd::OnPopupMonitoring() -{ - // change flag in config - GetConfig()->SetBoolValue(PP_PCLIPBOARDMONITORING, !GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING)); - GetConfig()->Save(); -} - -void CMainWnd::OnPopupShutafterfinished() -{ - GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, !GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)); - GetConfig()->Save(); -} - -void CMainWnd::OnPopupRegisterdll() -{ - DWORD dwErr; - if ((dwErr=RegisterShellExtDll(_T("chext.dll"), true)) == 0) - MsgBox(IDS_REGISTEROK_STRING, MB_ICONINFORMATION | MB_OK); - else - { - TCHAR szStr[256], szText[768]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, 0, szStr, 256, NULL); - while (szStr[_tcslen(szStr)-1] == _T('\n') || szStr[_tcslen(szStr)-1] == _T('\r') || szStr[_tcslen(szStr)-1] == _T('.')) - szStr[_tcslen(szStr)-1]=_T('\0'); - _stprintf(szText, GetResManager()->LoadString(IDS_REGISTERERR_STRING), dwErr, szStr); - AfxMessageBox(szText, MB_ICONERROR | MB_OK); - } -} - -void CMainWnd::OnPopupUnregisterdll() -{ - DWORD dwErr; - if ((dwErr=RegisterShellExtDll(_T("chext.dll"), false)) == 0) - MsgBox(IDS_UNREGISTEROK_STRING, MB_ICONINFORMATION | MB_OK); - else - { - TCHAR szStr[256], szText[768]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, 0, szStr, 256, NULL); - while (szStr[_tcslen(szStr)-1] == _T('\n') || szStr[_tcslen(szStr)-1] == _T('\r') || szStr[_tcslen(szStr)-1] == _T('.')) - szStr[_tcslen(szStr)-1]=_T('\0'); - _stprintf(szText, GetResManager()->LoadString(IDS_UNREGISTERERR_STRING), dwErr, szStr); - AfxMessageBox(szText, MB_ICONERROR | MB_OK); - } -} - -void CMainWnd::PrepareToExit() -{ - // kill thread that monitors clipboard - cmd.bKill=true; - while (!cmd.bKilled) - Sleep(10); - - // kill all unfinished tasks - send kill request - for (int i=0;iSetKillFlag(); - - // wait for finishing - for (i=0;iGetKilledFlag()) - Sleep(10); - m_tasks.GetAt(i)->CleanupAfterKill(); - } - - // save - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_tasks.SaveProgress(szPath); - - // delete all tasks - int iSize=m_tasks.GetSize(); - for (i=0;i* >(&m_tasks))->RemoveAll(); -} - -void CMainWnd::OnAppExit() -{ - PostMessage(WM_CLOSE); -} - -void CMainWnd::OnPopupHelp() -{ - if (!GetApp()->HtmlHelp(HH_DISPLAY_TOPIC, NULL)) - { - TCHAR szStr[512+2*_MAX_PATH]; - _stprintf(szStr, GetResManager()->LoadString(IDS_HELPERR_STRING), GetApp()->GetHelpPath()); - - AfxMessageBox(szStr, MB_OK | MB_ICONERROR); - } -} \ No newline at end of file Index: src/ch/MainWnd.h =================================================================== diff -u -N --- src/ch/MainWnd.h (revision 0) +++ src/ch/MainWnd.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,108 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __MAINFRM_H__ +#define __MAINFRM_H__ + +#include "TrayIcon.h" +#include "structs.h" +#include "MiniviewDlg.h" +#include "DataBuffer.h" +#include "StatusDlg.h" + +typedef struct _CUSTOM_COPY_PARAMS +{ + CTask* pTask; // ptr to CTask object on which we do the operation + + CFileInfo* pfiSrcFile; // CFileInfo - src file + CString strDstFile; // dest path with filename + + CDataBuffer dbBuffer; // buffer handling + bool bOnlyCreate; // flag from configuration - skips real copying - only create +} CUSTOM_COPY_PARAMS, *PCUSTOM_COPY_PARAMS; + +class CMainWnd : public CWnd +{ +public: + CMainWnd(); + DECLARE_DYNCREATE(CMainWnd) + + BOOL Create(); + +// Attributes +public: + CTrayIcon m_ctlTray; + CLIPBOARDMONITORDATA cmd; + + CTaskArray m_tasks; + + CMiniViewDlg* m_pdlgMiniView; + CStatusDlg* m_pdlgStatus; + + DWORD m_dwLastTime; + UINT m_uiTaskbarRestart; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + protected: + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMainWnd(); + +// Generated message map functions +protected: + ATOM RegisterClass(); + int ShowTrayIcon(); + void ShowStatusWindow(const CTask* pSelect=NULL); + void PrepareToExit(); + //{{AFX_MSG(CMainWnd) + afx_msg void OnPopupShowStatus(); + afx_msg void OnPopupShowOptions(); + afx_msg void OnClose(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnShowMiniView(); + afx_msg void OnPopupCustomCopy(); + afx_msg void OnAppAbout(); + afx_msg void OnPopupMonitoring(); + afx_msg void OnPopupShutafterfinished(); + afx_msg void OnPopupRegisterdll(); + afx_msg void OnPopupUnregisterdll(); + afx_msg void OnAppExit(); + afx_msg void OnPopupHelp(); + //}}AFX_MSG + afx_msg LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam); + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif Index: ch/MainWnd.h =================================================================== diff -u -N --- ch/MainWnd.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/MainWnd.h (revision 0) @@ -1,108 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __MAINFRM_H__ -#define __MAINFRM_H__ - -#include "TrayIcon.h" -#include "structs.h" -#include "MiniviewDlg.h" -#include "DataBuffer.h" -#include "StatusDlg.h" - -typedef struct _CUSTOM_COPY_PARAMS -{ - CTask* pTask; // ptr to CTask object on which we do the operation - - CFileInfo* pfiSrcFile; // CFileInfo - src file - CString strDstFile; // dest path with filename - - CDataBuffer dbBuffer; // buffer handling - bool bOnlyCreate; // flag from configuration - skips real copying - only create -} CUSTOM_COPY_PARAMS, *PCUSTOM_COPY_PARAMS; - -class CMainWnd : public CWnd -{ -public: - CMainWnd(); - DECLARE_DYNCREATE(CMainWnd) - - BOOL Create(); - -// Attributes -public: - CTrayIcon m_ctlTray; - CLIPBOARDMONITORDATA cmd; - - CTaskArray m_tasks; - - CMiniViewDlg* m_pdlgMiniView; - CStatusDlg* m_pdlgStatus; - - DWORD m_dwLastTime; - UINT m_uiTaskbarRestart; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - protected: - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMainWnd(); - -// Generated message map functions -protected: - ATOM RegisterClass(); - int ShowTrayIcon(); - void ShowStatusWindow(const CTask* pSelect=NULL); - void PrepareToExit(); - //{{AFX_MSG(CMainWnd) - afx_msg void OnPopupShowStatus(); - afx_msg void OnPopupShowOptions(); - afx_msg void OnClose(); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg BOOL OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct); - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnShowMiniView(); - afx_msg void OnPopupCustomCopy(); - afx_msg void OnAppAbout(); - afx_msg void OnPopupMonitoring(); - afx_msg void OnPopupShutafterfinished(); - afx_msg void OnPopupRegisterdll(); - afx_msg void OnPopupUnregisterdll(); - afx_msg void OnAppExit(); - afx_msg void OnPopupHelp(); - //}}AFX_MSG - afx_msg LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam); - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/MemDC.h =================================================================== diff -u -N --- src/ch/MemDC.h (revision 0) +++ src/ch/MemDC.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,106 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/////////////////////////////////////////////////////////////// +// CMemDC - memory DC +// +// Author: Keith Rule +// Email: keithr@europa.com +// Copyright 1996-1997, Keith Rule +// +// You may freely use or modify this code provided this +// Copyright is included in all derived versions. +// +/////////////////////////////////////////////////////////////// +#ifndef _MEMDC_H_ +#define _MEMDC_H_ + +/////////////////////////////////////////////////////////////// +// BCMenuMemDC - memory DC +// +// Author: Keith Rule +// Email: keithr@europa.com +// Copyright 1996-1997, Keith Rule +// +// You may freely use or modify this code provided this +// Copyright is included in all derived versions. +// +// History - 10/3/97 Fixed scrolling bug. +// Added print support. +// 25 feb 98 - fixed minor assertion bug +// +// This class implements a memory Device Context +/////////////////////////////////////////////////////////////// +class CMemDC : public CDC +{ +public: + + // constructor sets up the memory DC + CMemDC(CDC* pDC, LPCRECT lpSrcRect) : CDC() + { + ASSERT(pDC != NULL); + + m_rect.CopyRect(lpSrcRect); + m_pDC = pDC; + m_pOldBitmap = NULL; + m_bMemDC = !pDC->IsPrinting(); + + if (m_bMemDC) // Create a Memory DC + { + CreateCompatibleDC(pDC); + m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); + m_pOldBitmap = SelectObject(&m_bitmap); + SetWindowOrg(m_rect.left, m_rect.top); + } + else // Make a copy of the relevent parts of the current DC for printing + { + m_bPrinting = pDC->m_bPrinting; + m_hDC = pDC->m_hDC; + m_hAttribDC = pDC->m_hAttribDC; + } + } + + // Destructor copies the contents of the mem DC to the original DC + ~CMemDC() + { + if (m_bMemDC) + { + // Copy the offscreen bitmap onto the screen. + m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), + this, m_rect.left, m_rect.top, SRCCOPY); + + //Swap back the original bitmap. + SelectObject(m_pOldBitmap); + } else { + // All we need to do is replace the DC with an illegal value, + // this keeps us from accidently deleting the handles associated with + // the CDC that was passed to the constructor. + m_hDC = m_hAttribDC = NULL; + } + } + +private: + CBitmap m_bitmap; // Offscreen bitmap + CBitmap* m_pOldBitmap; // bitmap originally found in BCMenuMemDC + CDC* m_pDC; // Saves CDC passed in constructor + CRect m_rect; // Rectangle of drawing area. + BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. +}; + +#endif \ No newline at end of file Index: ch/MemDC.h =================================================================== diff -u -N --- ch/MemDC.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/MemDC.h (revision 0) @@ -1,106 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/////////////////////////////////////////////////////////////// -// CMemDC - memory DC -// -// Author: Keith Rule -// Email: keithr@europa.com -// Copyright 1996-1997, Keith Rule -// -// You may freely use or modify this code provided this -// Copyright is included in all derived versions. -// -/////////////////////////////////////////////////////////////// -#ifndef _MEMDC_H_ -#define _MEMDC_H_ - -/////////////////////////////////////////////////////////////// -// BCMenuMemDC - memory DC -// -// Author: Keith Rule -// Email: keithr@europa.com -// Copyright 1996-1997, Keith Rule -// -// You may freely use or modify this code provided this -// Copyright is included in all derived versions. -// -// History - 10/3/97 Fixed scrolling bug. -// Added print support. -// 25 feb 98 - fixed minor assertion bug -// -// This class implements a memory Device Context -/////////////////////////////////////////////////////////////// -class CMemDC : public CDC -{ -public: - - // constructor sets up the memory DC - CMemDC(CDC* pDC, LPCRECT lpSrcRect) : CDC() - { - ASSERT(pDC != NULL); - - m_rect.CopyRect(lpSrcRect); - m_pDC = pDC; - m_pOldBitmap = NULL; - m_bMemDC = !pDC->IsPrinting(); - - if (m_bMemDC) // Create a Memory DC - { - CreateCompatibleDC(pDC); - m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); - m_pOldBitmap = SelectObject(&m_bitmap); - SetWindowOrg(m_rect.left, m_rect.top); - } - else // Make a copy of the relevent parts of the current DC for printing - { - m_bPrinting = pDC->m_bPrinting; - m_hDC = pDC->m_hDC; - m_hAttribDC = pDC->m_hAttribDC; - } - } - - // Destructor copies the contents of the mem DC to the original DC - ~CMemDC() - { - if (m_bMemDC) - { - // Copy the offscreen bitmap onto the screen. - m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), - this, m_rect.left, m_rect.top, SRCCOPY); - - //Swap back the original bitmap. - SelectObject(m_pOldBitmap); - } else { - // All we need to do is replace the DC with an illegal value, - // this keeps us from accidently deleting the handles associated with - // the CDC that was passed to the constructor. - m_hDC = m_hAttribDC = NULL; - } - } - -private: - CBitmap m_bitmap; // Offscreen bitmap - CBitmap* m_pOldBitmap; // bitmap originally found in BCMenuMemDC - CDC* m_pDC; // Saves CDC passed in constructor - CRect m_rect; // Rectangle of drawing area. - BOOL m_bMemDC; // TRUE if CDC really is a Memory DC. -}; - -#endif \ No newline at end of file Index: src/ch/MiniViewDlg.cpp =================================================================== diff -u -N --- src/ch/MiniViewDlg.cpp (revision 0) +++ src/ch/MiniViewDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,800 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "MiniViewDlg.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#define WM_INITDATA WM_USER+5 + +static const int sg_iMargin=7; + +#define ROUND(val) ( ( (val)-static_cast(val) > 0.5 ) ? static_cast(val)+1 : static_cast(val) ) +#undef ROUNDUP // from other module +#define ROUNDUP(val, to) ( (static_cast((val)/(to))+1 )*(to) ) + +bool CMiniViewDlg::m_bLock=false; + +///////////////////////////////////////////////////////////////////////////// +// CMiniViewDlg dialog + +CMiniViewDlg::CMiniViewDlg(CTaskArray* pArray, bool *pbHide, CWnd* pParent /*=NULL*/) + : CHLanguageDialog(CMiniViewDlg::IDD, pParent, &m_bLock) +{ + //{{AFX_DATA_INIT(CMiniViewDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + + m_brBackground.CreateSolidBrush(GetSysColor(COLOR_3DFACE)); + m_iLastHeight=0; + m_bShown=false; + m_pTasks=pArray; + m_bActive=false; + m_iIndex=-1; + m_pbHide=pbHide; +} + + +void CMiniViewDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CMiniViewDlg) + DDX_Control(pDX, IDC_PROGRESS_LIST, m_ctlStatus); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CMiniViewDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CMiniViewDlg) + ON_WM_CTLCOLOR() + ON_WM_TIMER() + ON_LBN_SELCHANGE(IDC_PROGRESS_LIST, OnSelchangeProgressList) + ON_WM_NCLBUTTONDOWN() + ON_WM_LBUTTONUP() + ON_WM_NCPAINT() + ON_WM_NCACTIVATE() + ON_LBN_SETFOCUS(IDC_PROGRESS_LIST, OnSetfocusProgressList) + ON_LBN_SELCANCEL(IDC_PROGRESS_LIST, OnSelcancelProgressList) + ON_WM_MOUSEMOVE() + ON_WM_SETTINGCHANGE() + ON_LBN_DBLCLK(IDC_PROGRESS_LIST, OnDblclkProgressList) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CMiniViewDlg message handlers + +HBRUSH CMiniViewDlg::OnCtlColor(CDC*, CWnd*, UINT) +{ + return m_brBackground; +} + +BOOL CMiniViewDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // fill the buttons' structure + m_bdButtons[0].pfnCallbackFunc=&OnPause; + m_bdButtons[0].iPosition=4; + m_bdButtons[0].bPressed=false; + m_bdButtons[0].bEnabled=false; + m_bdButtons[1].pfnCallbackFunc=&OnResume; + m_bdButtons[1].iPosition=3; + m_bdButtons[1].bPressed=false; + m_bdButtons[1].bEnabled=false; + m_bdButtons[2].pfnCallbackFunc=&OnCancelBtn; + m_bdButtons[2].iPosition=2; + m_bdButtons[2].bPressed=false; + m_bdButtons[2].bEnabled=false; + m_bdButtons[3].pfnCallbackFunc=&OnRestartBtn; + m_bdButtons[3].iPosition=1; + m_bdButtons[3].bPressed=false; + m_bdButtons[3].bEnabled=false; + m_bdButtons[4].pfnCallbackFunc=&OnCloseBtn; + m_bdButtons[4].iPosition=0; + m_bdButtons[4].bPressed=false; + m_bdButtons[4].bEnabled=true; + + ResizeDialog(); + PostMessage(WM_INITDATA); + + return TRUE; +} + +void CMiniViewDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 9843) + { + KillTimer(9843); + + RefreshStatus(); + + SetTimer(9843, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL), NULL); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} + +void CMiniViewDlg::RecalcSize(int nHeight, bool bInitial) +{ + // set listbox size + CRect rcList; + m_ctlStatus.GetClientRect(&rcList); + + if (nHeight == 0) + nHeight=rcList.Height(); + + // don't do anything if height doesn't changed + if (nHeight == m_iLastHeight && !bInitial) + return; + + // remember height + m_iLastHeight = nHeight; + + // size of a dialog and screen + CRect rCLanguageDialog, rcScreen; + GetWindowRect(&rCLanguageDialog); + SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0); + + // place listbox in the best place + m_ctlStatus.SetWindowPos(NULL, sg_iMargin, 0/*sg_iMargin*/, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + + int iWidth=rcList.Width()+2*sg_iMargin+2*GetSystemMetrics(SM_CXDLGFRAME); + int iHeight=rcList.Height()+1*sg_iMargin+2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYSMCAPTION); + + if (bInitial || (rCLanguageDialog.left == rcScreen.right-rCLanguageDialog.Width() + && rCLanguageDialog.top == rcScreen.bottom-rCLanguageDialog.Height()) ) + { + SetWindowPos(&wndTopMost, rcScreen.right-iWidth, rcScreen.bottom-iHeight, iWidth, iHeight, + 0); + } + else + SetWindowPos(&wndTopMost, 0, 0, iWidth, iHeight, SWP_NOMOVE); +} + +void CMiniViewDlg::RefreshStatus() +{ + int index=0; + _PROGRESSITEM_* pItem=NULL; + + if (GetConfig()->GetBoolValue(PP_MVSHOWSINGLETASKS)) + { + for (int i=0;iGetSize();i++) + { + CTask* pTask=m_pTasks->GetAt(i); + pTask->GetMiniSnapshot(&dd); + + if ((dd.m_uiStatus & ST_STEP_MASK) != ST_FINISHED && (dd.m_uiStatus & ST_STEP_MASK) != ST_CANCELLED) + { + pItem=m_ctlStatus.GetItemAddress(index++); + + // load + if ((dd.m_uiStatus & ST_WORKING_MASK) == ST_ERROR) + pItem->m_crColor=RGB(255, 0, 0); + else if ((dd.m_uiStatus & ST_WORKING_MASK) == ST_PAUSED) + pItem->m_crColor=RGB(255, 255, 0); + else if ((dd.m_uiStatus & ST_WAITING_MASK) == ST_WAITING) + pItem->m_crColor=RGB(50, 50, 50); + else + pItem->m_crColor=RGB(0, 255, 0); + + pItem->m_strText=dd.m_fi.GetFileName(); + pItem->m_uiPos=dd.m_nPercent; + pItem->m_pTask=pTask; + } + } + } + + // should we show ? + bool bInitial=false; + if (index == 0) + { + if (m_bShown) + { + if (GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY) || *m_pbHide) + HideWindow(); + } + else if (!GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY) && !(*m_pbHide)) + { + // need to be visible + ShowWindow(); + bInitial=true; + } + } + else + { + if (!m_bShown) + { + if (!(*m_pbHide)) + { + ShowWindow(); + bInitial=true; + } + } + else + { + if (*m_pbHide) + HideWindow(); + } + } + + // add all state + pItem=m_ctlStatus.GetItemAddress(index++); + pItem->m_crColor=GetSysColor(COLOR_HIGHLIGHT); + pItem->m_strText=GetResManager()->LoadString(IDS_MINIVIEWALL_STRING); + pItem->m_uiPos=m_pTasks->GetPercent(); + pItem->m_pTask=NULL; + + // get rid of the rest + m_ctlStatus.SetSmoothProgress(GetConfig()->GetBoolValue(PP_MVUSESMOOTHPROGRESS)); + m_ctlStatus.UpdateItems(index, true); + + m_ctlStatus.SetShowCaptions(GetConfig()->GetBoolValue(PP_MVSHOWFILENAMES)); + + // calc size + RecalcSize(0, bInitial); +} + +LRESULT CMiniViewDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_INITDATA) + { + // listbox with progress pseudocontrols + m_ctlStatus.Init(); + + // refresh + RefreshStatus(); + + // set refresh timer + SetTimer(9843, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL), NULL); + + return static_cast(0); + } + + return CHLanguageDialog::WindowProc(message, wParam, lParam); +} + +void CMiniViewDlg::OnNcPaint() +{ + int iCXBorder=GetSystemMetrics(SM_CXBORDER); + int iCYBorder=GetSystemMetrics(SM_CYBORDER); + int iWidth=GetSystemMetrics(SM_CXSMSIZE); + int iHeight=GetSystemMetrics(SM_CYSMSIZE); + int iFrameHeight=GetSystemMetrics(SM_CYDLGFRAME); + int iFrameWidth=GetSystemMetrics(SM_CXDLGFRAME); + bool bEnabled=(m_ctlStatus.GetCurSel() != LB_ERR); + + // NC coordinates + CRect rcWindow; + GetWindowRect(&rcWindow); + rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); + + // device context + CWindowDC ncdc(this); + + // frame + ncdc.DrawEdge(&rcWindow, EDGE_RAISED, BF_RECT); + rcWindow.DeflateRect(iFrameWidth-iCXBorder, iFrameHeight-iCYBorder, iFrameWidth-iCXBorder, iFrameHeight-iCYBorder); + + CPen pen, pen2; + pen.CreatePen(PS_SOLID, iCXBorder, GetSysColor(COLOR_3DFACE)); + pen2.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE)); + + ncdc.SelectObject(&pen); + ncdc.SelectStockObject(NULL_BRUSH); + + ncdc.Rectangle(&rcWindow); + + // caption bar + rcWindow.DeflateRect(iCXBorder, iCXBorder, iCXBorder, 0); + rcWindow.bottom=rcWindow.top+iHeight; // caption pos + + // additional horz bar + ncdc.SelectObject(&pen2); + ncdc.MoveTo(rcWindow.left, rcWindow.bottom); + ncdc.LineTo(rcWindow.right, rcWindow.bottom); + + // memdc + CMemDC dc(&ncdc, &rcWindow); + + COLORREF crLeft=GetSysColor(m_bActive ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION); + dc.FillSolidRect(&rcWindow, crLeft); + + // caption text + CString strWindow; + GetWindowText(strWindow); +// TRACE("DRAWING TEXT: "+strWindow+"\n"); + + rcWindow.DeflateRect(5, 0, BTN_COUNT*iWidth+iFrameWidth+5, 0); + + // caption font + NONCLIENTMETRICS ncm; + ncm.cbSize=sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); + + CFont font; + font.CreateFontIndirect(&ncm.lfSmCaptionFont); + dc.SelectObject(&font); + + dc.SetTextColor(GetSysColor(COLOR_CAPTIONTEXT)); + dc.SetBkMode(TRANSPARENT); + dc.DrawText(strWindow, &rcWindow, DT_END_ELLIPSIS | DT_VCENTER | DT_LEFT | DT_NOCLIP | DT_SINGLELINE); + // button drawing + GetClientRect(&rcWindow); + + for (int i=0;ircButton; + rcCopy.DeflateRect(2,2,2,2); + + // frame drawing + if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + else + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + + // fill the background + rcCopy.DeflateRect(1, 1, 1, 1); + pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); + + // pause + CPen pen; + int iPenWidth=rcCopy.Width()/10+1; + pen.CreatePen(PS_SOLID, iPenWidth, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); + CPen* pOld=pDC->SelectObject(&pen); + + int iOffset=rcCopy.Width()/3; + pDC->MoveTo(rcCopy.left+iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.top+1*iPenWidth+pData->bPressed); + pDC->LineTo(rcCopy.left+iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.bottom-ROUND(1.5*iPenWidth)+pData->bPressed); + pDC->MoveTo(rcCopy.right-iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.top+1*iPenWidth+pData->bPressed); + pDC->LineTo(rcCopy.right-iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.bottom-ROUND(1.5*iPenWidth)+pData->bPressed); + + pDC->SelectObject(pOld); + break; + } + case MSG_ONCLICK: + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) + pTask->PauseProcessing(); + else + pDlg->m_pTasks->TasksPauseProcessing(); + + break; + } +} + +void OnCloseBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) +{ + switch (uiMsg) + { + case MSG_DRAWBUTTON: + { + CRect rcCopy=pData->rcButton; + rcCopy.DeflateRect(2,2,2,2); + + // frame + if (!pData->bPressed) + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + else + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + + // background + rcCopy.DeflateRect(1, 1, 1, 1); + pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); + + // close + CPen pen; + int iPenSize=rcCopy.Width()/10+1; + pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, iPenSize, GetSysColor(COLOR_BTNTEXT)); + CPen* pOld=pDC->SelectObject(&pen); + + switch (iPenSize) + { + case 1: + pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); + pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(1.6*iPenSize)); + pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.6*iPenSize)); + pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(0.4*iPenSize)); + break; + default: + pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); + pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(2.0*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.0*iPenSize)); + pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.0*iPenSize)); + pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(2.0*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); + break; + } + + pDC->SelectObject(pOld); + break; + } + case MSG_ONCLICK: + pDlg->SendMessage(WM_CLOSE, 0, 0); + break; + } +} + +void OnResume(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) +{ + switch (uiMsg) + { + case MSG_DRAWBUTTON: + { + CRect rcCopy=pData->rcButton; + rcCopy.DeflateRect(2,2,2,2); + + // frame + if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + else + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + + // bkgnd + rcCopy.DeflateRect(1, 1, 1, 1); + pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); + + // triangle + int iOffset=rcCopy.Width()/4; + int iHeight=rcCopy.Width()/10+1; + POINT pt[3]={ {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed}, {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.bottom-ROUND(1.625*iHeight)+pData->bPressed}, + {rcCopy.right-iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed+(rcCopy.Height()-3*iHeight+1)/2} }; + + CBrush brs; + brs.CreateSolidBrush(pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); + CBrush* pOld=pDC->SelectObject(&brs); + + CPen pen; + pen.CreatePen(PS_SOLID, 1, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); + CPen *pOldPen=pDC->SelectObject(&pen); + pDC->SetPolyFillMode(WINDING); + + pDC->Polygon(pt, 3); + + pDC->SelectObject(pOld); + pDC->SelectObject(pOldPen); + + break; + } + case MSG_ONCLICK: + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) + { + if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) + pTask->SetForceFlag(true); + else + pTask->ResumeProcessing(); + } + else + pDlg->m_pTasks->TasksResumeProcessing(); + break; + } +} + +void OnCancelBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) +{ + switch (uiMsg) + { + case MSG_DRAWBUTTON: + { + CRect rcCopy=pData->rcButton; + rcCopy.DeflateRect(2,2,2,2); + + // frame + if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + else + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + + // bkgnd + rcCopy.DeflateRect(1, 1, 1, 1); + pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); + + // square + int iWidth=rcCopy.Width()/10+1; + rcCopy.DeflateRect(1*iWidth+pData->bPressed, 1*iWidth+pData->bPressed, ROUND(1.6*iWidth)-pData->bPressed, 1*iWidth-pData->bPressed); + pDC->FillSolidRect(&rcCopy, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); + break; + } + case MSG_ONCLICK: + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) + pTask->CancelProcessing(); + else + pDlg->m_pTasks->TasksCancelProcessing(); + break; + } +} + +void OnRestartBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) +{ + switch (uiMsg) + { + case MSG_DRAWBUTTON: + { + CRect rcCopy=pData->rcButton; + rcCopy.DeflateRect(2,2,2,2); + + // frame + if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); + else + pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); + + // bkgnd + rcCopy.DeflateRect(1, 1, 1, 1); + pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); + + // triangle in a square + int iOffset=rcCopy.Width()/4; + int iHeight=rcCopy.Width()/10+1; + POINT pt[3]={ {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed}, {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.bottom-ROUND(1.625*iHeight)+pData->bPressed}, + {rcCopy.right-iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed+(rcCopy.Height()-3*iHeight+1)/2} }; + + CBrush brs; + brs.CreateSolidBrush(pData->bEnabled ? RGB(255, 0, 0) : GetSysColor(COLOR_BTNSHADOW)); + CBrush* pOld=pDC->SelectObject(&brs); + + CPen pen; + pen.CreatePen(PS_SOLID, 1, pData->bEnabled ? RGB(255, 0, 0) : GetSysColor(COLOR_BTNSHADOW)); + CPen *pOldPen=pDC->SelectObject(&pen); + + pDC->SetPolyFillMode(WINDING); + pDC->Polygon(pt, 3); + pDC->SelectObject(pOld); + pDC->SelectObject(pOldPen); + + break; + } + case MSG_ONCLICK: + int iSel=pDlg->m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR) + return; + CTask* pTask; + if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) + pTask->RestartProcessing(); + else + pDlg->m_pTasks->TasksRestartProcessing(); + break; + } +} + +void CMiniViewDlg::OnSelchangeProgressList() +{ + RefreshStatus(); + RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME); +// PostMessage(WM_NCPAINT); +} + +void CMiniViewDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + bool bEnabled=false; + CRect rcBtn; + int iNCHeight=GetSystemMetrics(SM_CYSMCAPTION)+GetSystemMetrics(SM_CYDLGFRAME); + + // has been button pressed ? + for (int i=0;i(static_cast(((9+2)-2*iEdgeWidth))*(2.0/3.0))+1; + int iWidth=BTN_COUNT*(GetSystemMetrics(SM_CYSMCAPTION))+sSize.cx+2*GetSystemMetrics(SM_CXDLGFRAME)+18; + + // change pos of listbox + m_ctlStatus.SetWindowPos(NULL, 0, 0, ROUNDUP(iWidth-2*sg_iMargin, iBoxWidth)+2*iEdgeWidth, rcList.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE); + + RecalcSize(0, true); +} + +void CMiniViewDlg::HideWindow() +{ + static_cast(this)->ShowWindow(SW_HIDE); + m_bShown=false; +} + +void CMiniViewDlg::ShowWindow() +{ + static_cast(this)->ShowWindow(SW_SHOW); + m_bShown=true; +} + +void CMiniViewDlg::OnDblclkProgressList() +{ + int iSel=m_ctlStatus.GetCurSel(); + if (iSel == LB_ERR) + return; + CTask* pTask; + pTask=m_ctlStatus.m_items.GetAt(iSel)->m_pTask; + + GetParent()->PostMessage(WM_MINIVIEWDBLCLK, 0, (LPARAM)pTask); +} + +void CMiniViewDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + ResizeDialog(); +} Index: ch/MiniViewDlg.cpp =================================================================== diff -u -N --- ch/MiniViewDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/MiniViewDlg.cpp (revision 0) @@ -1,800 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "MiniViewDlg.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#define WM_INITDATA WM_USER+5 - -static const int sg_iMargin=7; - -#define ROUND(val) ( ( (val)-static_cast(val) > 0.5 ) ? static_cast(val)+1 : static_cast(val) ) -#undef ROUNDUP // from other module -#define ROUNDUP(val, to) ( (static_cast((val)/(to))+1 )*(to) ) - -bool CMiniViewDlg::m_bLock=false; - -///////////////////////////////////////////////////////////////////////////// -// CMiniViewDlg dialog - -CMiniViewDlg::CMiniViewDlg(CTaskArray* pArray, bool *pbHide, CWnd* pParent /*=NULL*/) - : CHLanguageDialog(CMiniViewDlg::IDD, pParent, &m_bLock) -{ - //{{AFX_DATA_INIT(CMiniViewDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - m_brBackground.CreateSolidBrush(GetSysColor(COLOR_3DFACE)); - m_iLastHeight=0; - m_bShown=false; - m_pTasks=pArray; - m_bActive=false; - m_iIndex=-1; - m_pbHide=pbHide; -} - - -void CMiniViewDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CMiniViewDlg) - DDX_Control(pDX, IDC_PROGRESS_LIST, m_ctlStatus); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CMiniViewDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CMiniViewDlg) - ON_WM_CTLCOLOR() - ON_WM_TIMER() - ON_LBN_SELCHANGE(IDC_PROGRESS_LIST, OnSelchangeProgressList) - ON_WM_NCLBUTTONDOWN() - ON_WM_LBUTTONUP() - ON_WM_NCPAINT() - ON_WM_NCACTIVATE() - ON_LBN_SETFOCUS(IDC_PROGRESS_LIST, OnSetfocusProgressList) - ON_LBN_SELCANCEL(IDC_PROGRESS_LIST, OnSelcancelProgressList) - ON_WM_MOUSEMOVE() - ON_WM_SETTINGCHANGE() - ON_LBN_DBLCLK(IDC_PROGRESS_LIST, OnDblclkProgressList) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMiniViewDlg message handlers - -HBRUSH CMiniViewDlg::OnCtlColor(CDC*, CWnd*, UINT) -{ - return m_brBackground; -} - -BOOL CMiniViewDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // fill the buttons' structure - m_bdButtons[0].pfnCallbackFunc=&OnPause; - m_bdButtons[0].iPosition=4; - m_bdButtons[0].bPressed=false; - m_bdButtons[0].bEnabled=false; - m_bdButtons[1].pfnCallbackFunc=&OnResume; - m_bdButtons[1].iPosition=3; - m_bdButtons[1].bPressed=false; - m_bdButtons[1].bEnabled=false; - m_bdButtons[2].pfnCallbackFunc=&OnCancelBtn; - m_bdButtons[2].iPosition=2; - m_bdButtons[2].bPressed=false; - m_bdButtons[2].bEnabled=false; - m_bdButtons[3].pfnCallbackFunc=&OnRestartBtn; - m_bdButtons[3].iPosition=1; - m_bdButtons[3].bPressed=false; - m_bdButtons[3].bEnabled=false; - m_bdButtons[4].pfnCallbackFunc=&OnCloseBtn; - m_bdButtons[4].iPosition=0; - m_bdButtons[4].bPressed=false; - m_bdButtons[4].bEnabled=true; - - ResizeDialog(); - PostMessage(WM_INITDATA); - - return TRUE; -} - -void CMiniViewDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 9843) - { - KillTimer(9843); - - RefreshStatus(); - - SetTimer(9843, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL), NULL); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} - -void CMiniViewDlg::RecalcSize(int nHeight, bool bInitial) -{ - // set listbox size - CRect rcList; - m_ctlStatus.GetClientRect(&rcList); - - if (nHeight == 0) - nHeight=rcList.Height(); - - // don't do anything if height doesn't changed - if (nHeight == m_iLastHeight && !bInitial) - return; - - // remember height - m_iLastHeight = nHeight; - - // size of a dialog and screen - CRect rCLanguageDialog, rcScreen; - GetWindowRect(&rCLanguageDialog); - SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0); - - // place listbox in the best place - m_ctlStatus.SetWindowPos(NULL, sg_iMargin, 0/*sg_iMargin*/, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - - int iWidth=rcList.Width()+2*sg_iMargin+2*GetSystemMetrics(SM_CXDLGFRAME); - int iHeight=rcList.Height()+1*sg_iMargin+2*GetSystemMetrics(SM_CYDLGFRAME)+GetSystemMetrics(SM_CYSMCAPTION); - - if (bInitial || (rCLanguageDialog.left == rcScreen.right-rCLanguageDialog.Width() - && rCLanguageDialog.top == rcScreen.bottom-rCLanguageDialog.Height()) ) - { - SetWindowPos(&wndTopMost, rcScreen.right-iWidth, rcScreen.bottom-iHeight, iWidth, iHeight, - 0); - } - else - SetWindowPos(&wndTopMost, 0, 0, iWidth, iHeight, SWP_NOMOVE); -} - -void CMiniViewDlg::RefreshStatus() -{ - int index=0; - _PROGRESSITEM_* pItem=NULL; - - if (GetConfig()->GetBoolValue(PP_MVSHOWSINGLETASKS)) - { - for (int i=0;iGetSize();i++) - { - CTask* pTask=m_pTasks->GetAt(i); - pTask->GetMiniSnapshot(&dd); - - if ((dd.m_uiStatus & ST_STEP_MASK) != ST_FINISHED && (dd.m_uiStatus & ST_STEP_MASK) != ST_CANCELLED) - { - pItem=m_ctlStatus.GetItemAddress(index++); - - // load - if ((dd.m_uiStatus & ST_WORKING_MASK) == ST_ERROR) - pItem->m_crColor=RGB(255, 0, 0); - else if ((dd.m_uiStatus & ST_WORKING_MASK) == ST_PAUSED) - pItem->m_crColor=RGB(255, 255, 0); - else if ((dd.m_uiStatus & ST_WAITING_MASK) == ST_WAITING) - pItem->m_crColor=RGB(50, 50, 50); - else - pItem->m_crColor=RGB(0, 255, 0); - - pItem->m_strText=dd.m_fi.GetFileName(); - pItem->m_uiPos=dd.m_nPercent; - pItem->m_pTask=pTask; - } - } - } - - // should we show ? - bool bInitial=false; - if (index == 0) - { - if (m_bShown) - { - if (GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY) || *m_pbHide) - HideWindow(); - } - else if (!GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY) && !(*m_pbHide)) - { - // need to be visible - ShowWindow(); - bInitial=true; - } - } - else - { - if (!m_bShown) - { - if (!(*m_pbHide)) - { - ShowWindow(); - bInitial=true; - } - } - else - { - if (*m_pbHide) - HideWindow(); - } - } - - // add all state - pItem=m_ctlStatus.GetItemAddress(index++); - pItem->m_crColor=GetSysColor(COLOR_HIGHLIGHT); - pItem->m_strText=GetResManager()->LoadString(IDS_MINIVIEWALL_STRING); - pItem->m_uiPos=m_pTasks->GetPercent(); - pItem->m_pTask=NULL; - - // get rid of the rest - m_ctlStatus.SetSmoothProgress(GetConfig()->GetBoolValue(PP_MVUSESMOOTHPROGRESS)); - m_ctlStatus.UpdateItems(index, true); - - m_ctlStatus.SetShowCaptions(GetConfig()->GetBoolValue(PP_MVSHOWFILENAMES)); - - // calc size - RecalcSize(0, bInitial); -} - -LRESULT CMiniViewDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - if (message == WM_INITDATA) - { - // listbox with progress pseudocontrols - m_ctlStatus.Init(); - - // refresh - RefreshStatus(); - - // set refresh timer - SetTimer(9843, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL), NULL); - - return static_cast(0); - } - - return CHLanguageDialog::WindowProc(message, wParam, lParam); -} - -void CMiniViewDlg::OnNcPaint() -{ - int iCXBorder=GetSystemMetrics(SM_CXBORDER); - int iCYBorder=GetSystemMetrics(SM_CYBORDER); - int iWidth=GetSystemMetrics(SM_CXSMSIZE); - int iHeight=GetSystemMetrics(SM_CYSMSIZE); - int iFrameHeight=GetSystemMetrics(SM_CYDLGFRAME); - int iFrameWidth=GetSystemMetrics(SM_CXDLGFRAME); - bool bEnabled=(m_ctlStatus.GetCurSel() != LB_ERR); - - // NC coordinates - CRect rcWindow; - GetWindowRect(&rcWindow); - rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); - - // device context - CWindowDC ncdc(this); - - // frame - ncdc.DrawEdge(&rcWindow, EDGE_RAISED, BF_RECT); - rcWindow.DeflateRect(iFrameWidth-iCXBorder, iFrameHeight-iCYBorder, iFrameWidth-iCXBorder, iFrameHeight-iCYBorder); - - CPen pen, pen2; - pen.CreatePen(PS_SOLID, iCXBorder, GetSysColor(COLOR_3DFACE)); - pen2.CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DFACE)); - - ncdc.SelectObject(&pen); - ncdc.SelectStockObject(NULL_BRUSH); - - ncdc.Rectangle(&rcWindow); - - // caption bar - rcWindow.DeflateRect(iCXBorder, iCXBorder, iCXBorder, 0); - rcWindow.bottom=rcWindow.top+iHeight; // caption pos - - // additional horz bar - ncdc.SelectObject(&pen2); - ncdc.MoveTo(rcWindow.left, rcWindow.bottom); - ncdc.LineTo(rcWindow.right, rcWindow.bottom); - - // memdc - CMemDC dc(&ncdc, &rcWindow); - - COLORREF crLeft=GetSysColor(m_bActive ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION); - dc.FillSolidRect(&rcWindow, crLeft); - - // caption text - CString strWindow; - GetWindowText(strWindow); -// TRACE("DRAWING TEXT: "+strWindow+"\n"); - - rcWindow.DeflateRect(5, 0, BTN_COUNT*iWidth+iFrameWidth+5, 0); - - // caption font - NONCLIENTMETRICS ncm; - ncm.cbSize=sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); - - CFont font; - font.CreateFontIndirect(&ncm.lfSmCaptionFont); - dc.SelectObject(&font); - - dc.SetTextColor(GetSysColor(COLOR_CAPTIONTEXT)); - dc.SetBkMode(TRANSPARENT); - dc.DrawText(strWindow, &rcWindow, DT_END_ELLIPSIS | DT_VCENTER | DT_LEFT | DT_NOCLIP | DT_SINGLELINE); - // button drawing - GetClientRect(&rcWindow); - - for (int i=0;ircButton; - rcCopy.DeflateRect(2,2,2,2); - - // frame drawing - if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); - else - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); - - // fill the background - rcCopy.DeflateRect(1, 1, 1, 1); - pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); - - // pause - CPen pen; - int iPenWidth=rcCopy.Width()/10+1; - pen.CreatePen(PS_SOLID, iPenWidth, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); - CPen* pOld=pDC->SelectObject(&pen); - - int iOffset=rcCopy.Width()/3; - pDC->MoveTo(rcCopy.left+iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.top+1*iPenWidth+pData->bPressed); - pDC->LineTo(rcCopy.left+iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.bottom-ROUND(1.5*iPenWidth)+pData->bPressed); - pDC->MoveTo(rcCopy.right-iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.top+1*iPenWidth+pData->bPressed); - pDC->LineTo(rcCopy.right-iOffset-ROUND(0.66*iPenWidth)+pData->bPressed, rcCopy.bottom-ROUND(1.5*iPenWidth)+pData->bPressed); - - pDC->SelectObject(pOld); - break; - } - case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - pTask->PauseProcessing(); - else - pDlg->m_pTasks->TasksPauseProcessing(); - - break; - } -} - -void OnCloseBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) -{ - switch (uiMsg) - { - case MSG_DRAWBUTTON: - { - CRect rcCopy=pData->rcButton; - rcCopy.DeflateRect(2,2,2,2); - - // frame - if (!pData->bPressed) - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); - else - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); - - // background - rcCopy.DeflateRect(1, 1, 1, 1); - pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); - - // close - CPen pen; - int iPenSize=rcCopy.Width()/10+1; - pen.CreatePen(PS_SOLID | PS_INSIDEFRAME, iPenSize, GetSysColor(COLOR_BTNTEXT)); - CPen* pOld=pDC->SelectObject(&pen); - - switch (iPenSize) - { - case 1: - pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); - pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(1.6*iPenSize)); - pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.6*iPenSize)); - pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(0.4*iPenSize)); - break; - default: - pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); - pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(2.0*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.0*iPenSize)); - pDC->MoveTo(rcCopy.left+pData->bPressed+ROUND(1.4*iPenSize), rcCopy.bottom+pData->bPressed-ROUND(2.0*iPenSize)); - pDC->LineTo(rcCopy.right+pData->bPressed-ROUND(2.0*iPenSize), rcCopy.top+pData->bPressed+ROUND(1.4*iPenSize)); - break; - } - - pDC->SelectObject(pOld); - break; - } - case MSG_ONCLICK: - pDlg->SendMessage(WM_CLOSE, 0, 0); - break; - } -} - -void OnResume(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) -{ - switch (uiMsg) - { - case MSG_DRAWBUTTON: - { - CRect rcCopy=pData->rcButton; - rcCopy.DeflateRect(2,2,2,2); - - // frame - if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); - else - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); - - // bkgnd - rcCopy.DeflateRect(1, 1, 1, 1); - pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); - - // triangle - int iOffset=rcCopy.Width()/4; - int iHeight=rcCopy.Width()/10+1; - POINT pt[3]={ {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed}, {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.bottom-ROUND(1.625*iHeight)+pData->bPressed}, - {rcCopy.right-iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed+(rcCopy.Height()-3*iHeight+1)/2} }; - - CBrush brs; - brs.CreateSolidBrush(pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); - CBrush* pOld=pDC->SelectObject(&brs); - - CPen pen; - pen.CreatePen(PS_SOLID, 1, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); - CPen *pOldPen=pDC->SelectObject(&pen); - pDC->SetPolyFillMode(WINDING); - - pDC->Polygon(pt, 3); - - pDC->SelectObject(pOld); - pDC->SelectObject(pOldPen); - - break; - } - case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - { - if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) - pTask->SetForceFlag(true); - else - pTask->ResumeProcessing(); - } - else - pDlg->m_pTasks->TasksResumeProcessing(); - break; - } -} - -void OnCancelBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) -{ - switch (uiMsg) - { - case MSG_DRAWBUTTON: - { - CRect rcCopy=pData->rcButton; - rcCopy.DeflateRect(2,2,2,2); - - // frame - if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); - else - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); - - // bkgnd - rcCopy.DeflateRect(1, 1, 1, 1); - pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); - - // square - int iWidth=rcCopy.Width()/10+1; - rcCopy.DeflateRect(1*iWidth+pData->bPressed, 1*iWidth+pData->bPressed, ROUND(1.6*iWidth)-pData->bPressed, 1*iWidth-pData->bPressed); - pDC->FillSolidRect(&rcCopy, pData->bEnabled ? GetSysColor(COLOR_BTNTEXT) : GetSysColor(COLOR_BTNSHADOW)); - break; - } - case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - pTask->CancelProcessing(); - else - pDlg->m_pTasks->TasksCancelProcessing(); - break; - } -} - -void OnRestartBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC) -{ - switch (uiMsg) - { - case MSG_DRAWBUTTON: - { - CRect rcCopy=pData->rcButton; - rcCopy.DeflateRect(2,2,2,2); - - // frame - if (!pData->bPressed || pDlg->m_ctlStatus.GetCurSel() == LB_ERR) - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW)); - else - pDC->Draw3dRect(&rcCopy, GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHIGHLIGHT)); - - // bkgnd - rcCopy.DeflateRect(1, 1, 1, 1); - pDC->FillSolidRect(&rcCopy, GetSysColor(COLOR_3DFACE)); - - // triangle in a square - int iOffset=rcCopy.Width()/4; - int iHeight=rcCopy.Width()/10+1; - POINT pt[3]={ {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed}, {rcCopy.left+iOffset-1+pData->bPressed, rcCopy.bottom-ROUND(1.625*iHeight)+pData->bPressed}, - {rcCopy.right-iOffset-1+pData->bPressed, rcCopy.top+1*iHeight+pData->bPressed+(rcCopy.Height()-3*iHeight+1)/2} }; - - CBrush brs; - brs.CreateSolidBrush(pData->bEnabled ? RGB(255, 0, 0) : GetSysColor(COLOR_BTNSHADOW)); - CBrush* pOld=pDC->SelectObject(&brs); - - CPen pen; - pen.CreatePen(PS_SOLID, 1, pData->bEnabled ? RGB(255, 0, 0) : GetSysColor(COLOR_BTNSHADOW)); - CPen *pOldPen=pDC->SelectObject(&pen); - - pDC->SetPolyFillMode(WINDING); - pDC->Polygon(pt, 3); - pDC->SelectObject(pOld); - pDC->SelectObject(pOldPen); - - break; - } - case MSG_ONCLICK: - int iSel=pDlg->m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - if ( (pTask=pDlg->m_ctlStatus.m_items.GetAt(iSel)->m_pTask) != NULL) - pTask->RestartProcessing(); - else - pDlg->m_pTasks->TasksRestartProcessing(); - break; - } -} - -void CMiniViewDlg::OnSelchangeProgressList() -{ - RefreshStatus(); - RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_FRAME); -// PostMessage(WM_NCPAINT); -} - -void CMiniViewDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) -{ - bool bEnabled=false; - CRect rcBtn; - int iNCHeight=GetSystemMetrics(SM_CYSMCAPTION)+GetSystemMetrics(SM_CYDLGFRAME); - - // has been button pressed ? - for (int i=0;i(static_cast(((9+2)-2*iEdgeWidth))*(2.0/3.0))+1; - int iWidth=BTN_COUNT*(GetSystemMetrics(SM_CYSMCAPTION))+sSize.cx+2*GetSystemMetrics(SM_CXDLGFRAME)+18; - - // change pos of listbox - m_ctlStatus.SetWindowPos(NULL, 0, 0, ROUNDUP(iWidth-2*sg_iMargin, iBoxWidth)+2*iEdgeWidth, rcList.Height(), SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE); - - RecalcSize(0, true); -} - -void CMiniViewDlg::HideWindow() -{ - static_cast(this)->ShowWindow(SW_HIDE); - m_bShown=false; -} - -void CMiniViewDlg::ShowWindow() -{ - static_cast(this)->ShowWindow(SW_SHOW); - m_bShown=true; -} - -void CMiniViewDlg::OnDblclkProgressList() -{ - int iSel=m_ctlStatus.GetCurSel(); - if (iSel == LB_ERR) - return; - CTask* pTask; - pTask=m_ctlStatus.m_items.GetAt(iSel)->m_pTask; - - GetParent()->PostMessage(WM_MINIVIEWDBLCLK, 0, (LPARAM)pTask); -} - -void CMiniViewDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - ResizeDialog(); -} Index: src/ch/MiniViewDlg.h =================================================================== diff -u -N --- src/ch/MiniViewDlg.h (revision 0) +++ src/ch/MiniViewDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,128 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __MINIVIEWDLG_H__ +#define __MINIVIEWDLG_H__ + +///////////////////////////////////////////////////////////////////////////// +// CMiniViewDlg dialog +#include "structs.h" +#include "ProgressListBox.h" +#include "resource.h" + +#define BTN_COUNT 5 + +#define MSG_DRAWBUTTON 1 +#define MSG_ONCLICK 2 + +#define WM_MINIVIEWDBLCLK WM_USER+14 + +class CMiniViewDlg : public CHLanguageDialog +{ +// internal struct +public: + struct _BTNDATA_ + { + void (*pfnCallbackFunc)(CMiniViewDlg*, UINT, _BTNDATA_*, CDC*); // callback - click + int iPosition; // button pos counting from right + bool bPressed; // is it pressed ? + bool bEnabled; // is it enabled ? + + CRect rcButton; // filled in OnNCPaint + } m_bdButtons[BTN_COUNT]; + +// Construction +public: + CMiniViewDlg(CTaskArray* pArray, bool* pbHide, CWnd* pParent = NULL); // standard constructor + + void ShowWindow(); + void HideWindow(); + void ResizeDialog(); + friend void OnRestartBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); + friend void OnCancelBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); + friend void OnResume(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); + friend void OnPause(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); + friend void OnCloseBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC); + + void RefreshStatus(); + void RecalcSize(int nHeight, bool bInitial); + + virtual UINT GetLanguageUpdateOptions() { return LDF_NODIALOGSIZE; }; + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + + // from CMainWnd + CTaskArray *m_pTasks; + + CBrush m_brBackground; + int m_iLastHeight; + bool m_bShown; + _PROGRESSITEM_ item; + + // cache + TASK_MINI_DISPLAY_DATA dd; + bool m_bActive; + + // lock + static bool m_bLock; + bool *m_pbHide; // does the big status dialog visible ? + + // in onmousemove points to last pressed button + int m_iIndex; + +// Dialog Data + //{{AFX_DATA(CMiniViewDlg) + enum { IDD = IDD_MINIVIEW_DIALOG }; + CProgressListBox m_ctlStatus; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMiniViewDlg) + public: + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + // Generated message map functions + //{{AFX_MSG(CMiniViewDlg) + afx_msg HBRUSH OnCtlColor(CDC*, CWnd*, UINT); + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnSelchangeProgressList(); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnNcPaint(); + afx_msg BOOL OnNcActivate(BOOL bActive); + afx_msg void OnSetfocusProgressList(); + afx_msg void OnSelcancelProgressList(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); + afx_msg void OnDblclkProgressList(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/MiniViewDlg.h =================================================================== diff -u -N --- ch/MiniViewDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/MiniViewDlg.h (revision 0) @@ -1,128 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __MINIVIEWDLG_H__ -#define __MINIVIEWDLG_H__ - -///////////////////////////////////////////////////////////////////////////// -// CMiniViewDlg dialog -#include "structs.h" -#include "ProgressListBox.h" -#include "resource.h" - -#define BTN_COUNT 5 - -#define MSG_DRAWBUTTON 1 -#define MSG_ONCLICK 2 - -#define WM_MINIVIEWDBLCLK WM_USER+14 - -class CMiniViewDlg : public CHLanguageDialog -{ -// internal struct -public: - struct _BTNDATA_ - { - void (*pfnCallbackFunc)(CMiniViewDlg*, UINT, _BTNDATA_*, CDC*); // callback - click - int iPosition; // button pos counting from right - bool bPressed; // is it pressed ? - bool bEnabled; // is it enabled ? - - CRect rcButton; // filled in OnNCPaint - } m_bdButtons[BTN_COUNT]; - -// Construction -public: - CMiniViewDlg(CTaskArray* pArray, bool* pbHide, CWnd* pParent = NULL); // standard constructor - - void ShowWindow(); - void HideWindow(); - void ResizeDialog(); - friend void OnRestartBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); - friend void OnCancelBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); - friend void OnResume(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); - friend void OnPause(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC=NULL); - friend void OnCloseBtn(CMiniViewDlg* pDlg, UINT uiMsg, CMiniViewDlg::_BTNDATA_* pData, CDC* pDC); - - void RefreshStatus(); - void RecalcSize(int nHeight, bool bInitial); - - virtual UINT GetLanguageUpdateOptions() { return LDF_NODIALOGSIZE; }; - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - - // from CMainWnd - CTaskArray *m_pTasks; - - CBrush m_brBackground; - int m_iLastHeight; - bool m_bShown; - _PROGRESSITEM_ item; - - // cache - TASK_MINI_DISPLAY_DATA dd; - bool m_bActive; - - // lock - static bool m_bLock; - bool *m_pbHide; // does the big status dialog visible ? - - // in onmousemove points to last pressed button - int m_iIndex; - -// Dialog Data - //{{AFX_DATA(CMiniViewDlg) - enum { IDD = IDD_MINIVIEW_DIALOG }; - CProgressListBox m_ctlStatus; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMiniViewDlg) - public: - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - // Generated message map functions - //{{AFX_MSG(CMiniViewDlg) - afx_msg HBRUSH OnCtlColor(CDC*, CWnd*, UINT); - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg void OnSelchangeProgressList(); - afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnNcPaint(); - afx_msg BOOL OnNcActivate(BOOL bActive); - afx_msg void OnSetfocusProgressList(); - afx_msg void OnSelcancelProgressList(); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); - afx_msg void OnDblclkProgressList(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/NotEnoughRoomDlg.cpp =================================================================== diff -u -N --- src/ch/NotEnoughRoomDlg.cpp (revision 0) +++ src/ch/NotEnoughRoomDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,157 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "copy handler.h" +#include "NotEnoughRoomDlg.h" +#include "btnIDs.h" +#include "StringHelpers.h" +#include "..\Common\FileSupport.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CNotEnoughRoomDlg dialog + + +CNotEnoughRoomDlg::CNotEnoughRoomDlg() + : CHLanguageDialog(CNotEnoughRoomDlg::IDD) +{ + //{{AFX_DATA_INIT(CNotEnoughRoomDlg) + //}}AFX_DATA_INIT + m_bEnableTimer=false; + m_iTime=30000; + m_iDefaultOption=ID_IGNORE; +} + + +void CNotEnoughRoomDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CNotEnoughRoomDlg) + DDX_Control(pDX, IDC_FILES_LIST, m_ctlFiles); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CNotEnoughRoomDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CNotEnoughRoomDlg) + ON_WM_TIMER() + ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) + ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CNotEnoughRoomDlg message handlers +void CNotEnoughRoomDlg::UpdateDialog() +{ + // format needed text + TCHAR szText[2048]; + _stprintf(szText, GetResManager()->LoadString(IDS_NERPATH_STRING), m_strDisk); + CWnd* pWnd=GetDlgItem(IDC_HEADER_STATIC); + if (pWnd) + pWnd->SetWindowText(szText); + + // now the sizes + TCHAR szData[128]; + pWnd=GetDlgItem(IDC_REQUIRED_STATIC); + if (pWnd) + pWnd->SetWindowText(GetSizeString(m_llRequired, szData)); + __int64 llFree; + pWnd=GetDlgItem(IDC_AVAILABLE_STATIC); + if (pWnd && GetDynamicFreeSpace(m_strDisk, &llFree, NULL)) + pWnd->SetWindowText(GetSizeString(llFree, szData)); +} + +BOOL CNotEnoughRoomDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // set to top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + // needed data + for (int i=0;iSetWindowText(GetSizeString(llFree, szData)); + + // end dialog if this is enough + if (m_llRequired <= llFree) + { + CHLanguageDialog::OnTimer(nIDEvent); + EndDialog(ID_RETRY); + } + } + } + + CHLanguageDialog::OnTimer(nIDEvent); +} + +void CNotEnoughRoomDlg::OnRetryButton() +{ + EndDialog(ID_RETRY); +} + +void CNotEnoughRoomDlg::OnIgnoreButton() +{ + EndDialog(ID_IGNORE); +} + +void CNotEnoughRoomDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + UpdateDialog(); +} Index: ch/NotEnoughRoomDlg.cpp =================================================================== diff -u -N --- ch/NotEnoughRoomDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/NotEnoughRoomDlg.cpp (revision 0) @@ -1,157 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "copy handler.h" -#include "NotEnoughRoomDlg.h" -#include "btnIDs.h" -#include "StringHelpers.h" -#include "..\Common\FileSupport.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CNotEnoughRoomDlg dialog - - -CNotEnoughRoomDlg::CNotEnoughRoomDlg() - : CHLanguageDialog(CNotEnoughRoomDlg::IDD) -{ - //{{AFX_DATA_INIT(CNotEnoughRoomDlg) - //}}AFX_DATA_INIT - m_bEnableTimer=false; - m_iTime=30000; - m_iDefaultOption=ID_IGNORE; -} - - -void CNotEnoughRoomDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CNotEnoughRoomDlg) - DDX_Control(pDX, IDC_FILES_LIST, m_ctlFiles); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CNotEnoughRoomDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CNotEnoughRoomDlg) - ON_WM_TIMER() - ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) - ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CNotEnoughRoomDlg message handlers -void CNotEnoughRoomDlg::UpdateDialog() -{ - // format needed text - TCHAR szText[2048]; - _stprintf(szText, GetResManager()->LoadString(IDS_NERPATH_STRING), m_strDisk); - CWnd* pWnd=GetDlgItem(IDC_HEADER_STATIC); - if (pWnd) - pWnd->SetWindowText(szText); - - // now the sizes - TCHAR szData[128]; - pWnd=GetDlgItem(IDC_REQUIRED_STATIC); - if (pWnd) - pWnd->SetWindowText(GetSizeString(m_llRequired, szData)); - __int64 llFree; - pWnd=GetDlgItem(IDC_AVAILABLE_STATIC); - if (pWnd && GetDynamicFreeSpace(m_strDisk, &llFree, NULL)) - pWnd->SetWindowText(GetSizeString(llFree, szData)); -} - -BOOL CNotEnoughRoomDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // set to top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - // needed data - for (int i=0;iSetWindowText(GetSizeString(llFree, szData)); - - // end dialog if this is enough - if (m_llRequired <= llFree) - { - CHLanguageDialog::OnTimer(nIDEvent); - EndDialog(ID_RETRY); - } - } - } - - CHLanguageDialog::OnTimer(nIDEvent); -} - -void CNotEnoughRoomDlg::OnRetryButton() -{ - EndDialog(ID_RETRY); -} - -void CNotEnoughRoomDlg::OnIgnoreButton() -{ - EndDialog(ID_IGNORE); -} - -void CNotEnoughRoomDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - UpdateDialog(); -} Index: src/ch/NotEnoughRoomDlg.h =================================================================== diff -u -N --- src/ch/NotEnoughRoomDlg.h (revision 0) +++ src/ch/NotEnoughRoomDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,73 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __NOTENOUGHROOMDLG_H__ +#define __NOTENOUGHROOMDLG_H__ + +///////////////////////////////////////////////////////////////////////////// +// CNotEnoughRoomDlg dialog + +class CNotEnoughRoomDlg : public CHLanguageDialog +{ +// Construction +public: + CNotEnoughRoomDlg(); // standard constructor + +// Dialog Data + //{{AFX_DATA(CNotEnoughRoomDlg) + enum { IDD = IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG }; + CListBox m_ctlFiles; + //}}AFX_DATA + + CString m_strTitle; + CStringArray m_strFiles; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CNotEnoughRoomDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +public: + bool m_bEnableTimer; + int m_iTime; + int m_iDefaultOption; + CString m_strDisk; + __int64 m_llRequired; + +protected: + void UpdateDialog(); + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + + // Generated message map functions + //{{AFX_MSG(CNotEnoughRoomDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnRetryButton(); + afx_msg void OnIgnoreButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/NotEnoughRoomDlg.h =================================================================== diff -u -N --- ch/NotEnoughRoomDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/NotEnoughRoomDlg.h (revision 0) @@ -1,73 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __NOTENOUGHROOMDLG_H__ -#define __NOTENOUGHROOMDLG_H__ - -///////////////////////////////////////////////////////////////////////////// -// CNotEnoughRoomDlg dialog - -class CNotEnoughRoomDlg : public CHLanguageDialog -{ -// Construction -public: - CNotEnoughRoomDlg(); // standard constructor - -// Dialog Data - //{{AFX_DATA(CNotEnoughRoomDlg) - enum { IDD = IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG }; - CListBox m_ctlFiles; - //}}AFX_DATA - - CString m_strTitle; - CStringArray m_strFiles; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CNotEnoughRoomDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - bool m_bEnableTimer; - int m_iTime; - int m_iDefaultOption; - CString m_strDisk; - __int64 m_llRequired; - -protected: - void UpdateDialog(); - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - - // Generated message map functions - //{{AFX_MSG(CNotEnoughRoomDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg void OnRetryButton(); - afx_msg void OnIgnoreButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -N --- src/ch/OptionsDlg.cpp (revision 0) +++ src/ch/OptionsDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,523 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" +#include "resource.h" +#include "OptionsDlg.h" +#include "BufferSizeDlg.h" +#include "ShortcutsDlg.h" +#include "RecentDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool COptionsDlg::m_bLock=false; + +///////////////////////////////////////////////////////////////////////////// +// COptionsDlg dialog + +COptionsDlg::COptionsDlg(CWnd* pParent /*=NULL*/) + : CHLanguageDialog(COptionsDlg::IDD, pParent, &m_bLock) +{ + //{{AFX_DATA_INIT(COptionsDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + +void COptionsDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(COptionsDlg) + DDX_Control(pDX, IDC_PROPERTIES_LIST, m_ctlProperties); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(COptionsDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(COptionsDlg) + ON_BN_CLICKED(IDC_APPLY_BUTTON, OnApplyButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// COptionsDlg message handlers + +// properties handling macros +#define PROP_SEPARATOR(text)\ + m_ctlProperties.AddString(text); + +#define PROP_BOOL(text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, IDS_BOOLTEXT_STRING, (value)); + +#define PROP_UINT(text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_TEXT, _itot((value), m_szBuffer, 10), 0); + +#define PROP_COMBO(text, prop_text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, prop_text, (value)); + +#define PROP_DIR(text, prop_text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_DIR, (value)+CString(GetResManager()->LoadString(prop_text)), 0); + +#define PROP_PATH(text, prop_text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_PATH, (value)+CString(GetResManager()->LoadString(prop_text)), 0); + +#define PROP_CUSTOM_UINT(text, value, callback, param)\ + m_ctlProperties.AddString(text, ID_PROPERTY_CUSTOM, CString(_itot(value, m_szBuffer, 10)), callback, this, param, 0); + +#define SKIP_SEPARATOR(pos)\ + pos++; + +BOOL COptionsDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + m_ctlProperties.Init(); + + // copy shortcut and recent paths + GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &m_cvRecent); + GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &m_cvShortcuts); + + GetConfig()->GetStringValue(PP_PLANGDIR, m_szLangPath, _MAX_PATH); + GetApp()->ExpandPath(m_szLangPath); + + GetResManager()->Scan(m_szLangPath, &m_vld); + + // some attributes + m_ctlProperties.SetBkColor(RGB(255, 255, 255)); + m_ctlProperties.SetTextColor(RGB(80, 80, 80)); + m_ctlProperties.SetTextHighlightColor(RGB(80,80,80)); + m_ctlProperties.SetHighlightColor(RGB(200, 200, 200)); + m_ctlProperties.SetPropertyBkColor(RGB(255,255,255)); + m_ctlProperties.SetPropertyTextColor(RGB(0,0,0)); + m_ctlProperties.SetLineStyle(RGB(74,109,132), PS_SOLID); + + FillPropertyList(); + + return TRUE; +} + +void CustomPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex) +{ + COptionsDlg* pDlg=static_cast(lpParam); + CBufferSizeDlg dlg; + + dlg.m_bsSizes.m_bOnlyDefault=pDlg->GetBoolProp(iIndex-iParam-1); + dlg.m_bsSizes.m_uiDefaultSize=pDlg->GetUintProp(iIndex-iParam); + dlg.m_bsSizes.m_uiOneDiskSize=pDlg->GetUintProp(iIndex-iParam+1); + dlg.m_bsSizes.m_uiTwoDisksSize=pDlg->GetUintProp(iIndex-iParam+2); + dlg.m_bsSizes.m_uiCDSize=pDlg->GetUintProp(iIndex-iParam+3); + dlg.m_bsSizes.m_uiLANSize=pDlg->GetUintProp(iIndex-iParam+4); + dlg.m_iActiveIndex=iParam; // selected buffer for editing + + if (dlg.DoModal() == IDOK) + { + PROPERTYITEM* pItem; + TCHAR xx[32]; + + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam-1)); + pItem->nPropertySelected=(dlg.m_bsSizes.m_bOnlyDefault ? 1 : 0); + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiDefaultSize, xx, 10)); + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+1)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiOneDiskSize, xx, 10)); + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+2)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiTwoDisksSize, xx, 10)); + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+3)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiCDSize, xx, 10)); + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+4)); + pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiLANSize, xx, 10)); + } +} + +void ShortcutsPropertyCallbackProc(LPVOID lpParam, int /*iParam*/, CPtrList* pList, int iIndex) +{ + COptionsDlg* pDlg=static_cast(lpParam); + + CShortcutsDlg dlg; + dlg.m_cvShortcuts.assign(pDlg->m_cvShortcuts.begin(), pDlg->m_cvShortcuts.end(), true, true); + dlg.m_pcvRecent=&pDlg->m_cvRecent; + if (dlg.DoModal() == IDOK) + { + // restore shortcuts to pDlg->cvShortcuts + pDlg->m_cvShortcuts.assign(dlg.m_cvShortcuts.begin(), dlg.m_cvShortcuts.end(), true, false); + dlg.m_cvShortcuts.erase(dlg.m_cvShortcuts.begin(), dlg.m_cvShortcuts.end(), false); + + // property list + TCHAR szBuf[32]; + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); + pItem->csProperties.SetAt(0, _itot(pDlg->m_cvShortcuts.size(), szBuf, 10)); + } +} + +void RecentPropertyCallbackProc(LPVOID lpParam, int /*iParam*/, CPtrList* pList, int iIndex) +{ + COptionsDlg* pDlg=static_cast(lpParam); + + CRecentDlg dlg; + dlg.m_cvRecent.assign(pDlg->m_cvRecent.begin(), pDlg->m_cvRecent.end(), true, true); + if (dlg.DoModal() == IDOK) + { + // restore + pDlg->m_cvRecent.assign(dlg.m_cvRecent.begin(), dlg.m_cvRecent.end(), true, false); + dlg.m_cvRecent.erase(dlg.m_cvRecent.begin(), dlg.m_cvRecent.end(), false); + + // property list + TCHAR szBuf[32]; + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); + pItem->csProperties.SetAt(0, _itot(pDlg->m_cvRecent.size(), szBuf, 10)); + } +} + +void COptionsDlg::OnOK() +{ + // kill focuses + m_ctlProperties.HideControls(); + + ApplyProperties(); + + SendClosingNotify(); + CHLanguageDialog::OnOK(); +} + +void COptionsDlg::FillPropertyList() +{ + CString strPath; + + // load settings + PROP_SEPARATOR(IDS_PROGRAM_STRING) + PROP_BOOL(IDS_CLIPBOARDMONITORING_STRING, GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING)) + PROP_UINT(IDS_CLIPBOARDINTERVAL_STRING, GetConfig()->GetIntValue(PP_PMONITORSCANINTERVAL)) + PROP_BOOL(IDS_AUTORUNPROGRAM_STRING, GetConfig()->GetBoolValue(PP_PRELOADAFTERRESTART)) + PROP_BOOL(IDS_AUTOSHUTDOWN_STRING, GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)) + PROP_UINT(IDS_SHUTDOWNTIME_STRING, GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN)) + PROP_COMBO(IDS_FORCESHUTDOWN_STRING, IDS_FORCESHUTDOWNVALUES_STRING, GetConfig()->GetBoolValue(PP_PFORCESHUTDOWN)) + PROP_UINT(IDS_AUTOSAVEINTERVAL_STRING, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL)) + PROP_COMBO(IDS_CFGPRIORITYCLASS_STRING, IDS_CFGPRIORITYCLASSITEMS_STRING, PriorityClassToIndex(GetConfig()->GetIntValue(PP_PPROCESSPRIORITYCLASS))) + + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + TRACE("Autosavedir=%s\n", strPath); + PROP_DIR(IDS_TEMPFOLDER_STRING, IDS_TEMPFOLDERCHOOSE_STRING, strPath) + + GetConfig()->GetStringValue(PP_PPLUGINSDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + PROP_DIR(IDS_PLUGSFOLDER_STRING, IDS_PLUGSFOLDERCHOOSE_STRING, strPath) + + GetConfig()->GetStringValue(PP_PHELPDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + PROP_DIR(IDS_CFGHELPDIR_STRING, IDS_CFGHELPDIRCHOOSE_STRING, strPath) + + // lang + CString strLangs; + UINT uiIndex=0; + for (vector::iterator it=m_vld.begin();it != m_vld.end();it++) + { + strLangs+=(*it).pszLngName; + strLangs+=_T("!"); + if (_tcscmp((*it).GetFilename(true), GetResManager()->m_ld.GetFilename(true)) == 0) + uiIndex=it-m_vld.begin(); + } + strLangs.TrimRight(_T('!')); + + PROP_COMBO(IDS_LANGUAGE_STRING, strLangs, uiIndex) + + GetConfig()->GetStringValue(PP_PLANGDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + PROP_DIR(IDS_LANGUAGESFOLDER_STRING, IDS_LANGSFOLDERCHOOSE_STRING, strPath) + + ///////////////// + PROP_SEPARATOR(IDS_STATUSWINDOW_STRING); + PROP_UINT(IDS_REFRESHSTATUSINTERVAL_STRING, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL)) + PROP_BOOL(IDS_STATUSSHOWDETAILS_STRING, GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) + PROP_BOOL(IDS_STATUSAUTOREMOVE_STRING, GetConfig()->GetBoolValue(PP_STATUSAUTOREMOVEFINISHED)) + + PROP_SEPARATOR(IDS_MINIVIEW_STRING) + PROP_BOOL(IDS_SHOWFILENAMES_STRING, GetConfig()->GetBoolValue(PP_MVSHOWFILENAMES)) + PROP_BOOL(IDS_SHOWSINGLETASKS_STRING, GetConfig()->GetBoolValue(PP_MVSHOWSINGLETASKS)) + PROP_UINT(IDS_MINIVIEWREFRESHINTERVAL_STRING, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL)) + PROP_BOOL(IDS_MINIVIEWSHOWAFTERSTART_STRING, GetConfig()->GetBoolValue(PP_MVAUTOSHOWWHENRUN)) + PROP_BOOL(IDS_MINIVIEWAUTOHIDE_STRING, GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY)) + PROP_BOOL(IDS_MINIVIEWSMOOTHPROGRESS_STRING, GetConfig()->GetBoolValue(PP_MVUSESMOOTHPROGRESS)) + + PROP_SEPARATOR(IDS_CFGFOLDERDIALOG_STRING) + PROP_BOOL(IDS_CFGFDEXTVIEW_STRING, GetConfig()->GetBoolValue(PP_FDEXTENDEDVIEW)) + PROP_UINT(IDS_CFGFDWIDTH_STRING, GetConfig()->GetIntValue(PP_FDWIDTH)) + PROP_UINT(IDS_CFGFDHEIGHT_STRING, GetConfig()->GetIntValue(PP_FDHEIGHT)) + PROP_COMBO(IDS_CFGFDSHORTCUTS_STRING, IDS_CFGFDSHORTCUTSSTYLES_STRING, GetConfig()->GetIntValue(PP_FDSHORTCUTLISTSTYLE)) + PROP_BOOL(IDS_CFGFDIGNOREDIALOGS_STRING, GetConfig()->GetBoolValue(PP_FDIGNORESHELLDIALOGS)) + + PROP_SEPARATOR(IDS_CFGSHELL_STRING) + PROP_BOOL(IDS_CFGSHCOPY_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPY)) + PROP_BOOL(IDS_CFGSHMOVE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWMOVE)) + PROP_BOOL(IDS_CFGSHCMSPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVE)) + PROP_BOOL(IDS_CFGSHPASTE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWPASTE)) + PROP_BOOL(IDS_CFGSHPASTESPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWPASTESPECIAL)) + PROP_BOOL(IDS_CFGSHCOPYTO_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYTO)) + PROP_BOOL(IDS_CFGSHMOVETO_STRING, GetConfig()->GetBoolValue(PP_SHSHOWMOVETO)) + PROP_BOOL(IDS_CFGSHCMTOSPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVETO)) + PROP_BOOL(IDS_CFGSHSHOWFREESPACE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWFREESPACE)) + PROP_BOOL(IDS_CFGSHSHOWICONS_STRING, GetConfig()->GetBoolValue(PP_SHSHOWSHELLICONS)) + PROP_BOOL(IDS_CFGSHOVERRIDEDRAG_STRING, GetConfig()->GetBoolValue(PP_SHUSEDRAGDROP)) + PROP_COMBO(IDS_CFGOVERRIDEDEFACTION_STRING, IDS_CFGACTIONS_STRING, GetConfig()->GetIntValue(PP_SHDEFAULTACTION)); + + PROP_SEPARATOR(IDS_PROCESSINGTHREAD_STRING) + PROP_BOOL(IDS_AUTOCOPYREST_STRING, GetConfig()->GetBoolValue(PP_CMUSEAUTOCOMPLETEFILES)) + PROP_BOOL(IDS_SETDESTATTRIB_STRING, GetConfig()->GetBoolValue(PP_CMSETDESTATTRIBUTES)) + PROP_BOOL(IDS_SETDESTTIME_STRING, GetConfig()->GetBoolValue(PP_CMSETDESTDATE)) + PROP_BOOL(IDS_PROTECTROFILES_STRING, GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) + PROP_UINT(IDS_LIMITOPERATIONS_STRING, GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS)) + PROP_BOOL(IDS_READSIZEBEFOREBLOCK_STRING, GetConfig()->GetBoolValue(PP_CMREADSIZEBEFOREBLOCKING)) + PROP_COMBO(IDS_SHOWVISUALFEEDBACK_STRING, IDS_FEEDBACKTYPE_STRING, GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK)) + PROP_BOOL(IDS_USETIMEDDIALOGS_STRING, GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK)) + PROP_UINT(IDS_TIMEDDIALOGINTERVAL_STRING, GetConfig()->GetIntValue(PP_CMFEEDBACKTIME)) + PROP_BOOL(IDS_AUTORETRYONERROR_STRING, GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR)) + PROP_UINT(IDS_AUTORETRYINTERVAL_STRING, GetConfig()->GetIntValue(PP_CMAUTORETRYINTERVAL)) + PROP_COMBO(IDS_DEFAULTPRIORITY_STRING, MakeCompoundString(IDS_PRIORITY0_STRING, 7, _T("!")), PriorityToIndex(GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY))) + PROP_BOOL(IDS_CFGDISABLEPRIORITYBOOST_STRING, GetConfig()->GetBoolValue(PP_CMDISABLEPRIORITYBOOST)) + PROP_BOOL(IDS_DELETEAFTERFINISHED_STRING, GetConfig()->GetBoolValue(PP_CMDELETEAFTERFINISHED)) + PROP_BOOL(IDS_CREATELOGFILES_STRING, GetConfig()->GetBoolValue(PP_CMCREATELOG)) + + // Buffer + PROP_SEPARATOR(IDS_OPTIONSBUFFER_STRING) + PROP_BOOL(IDS_AUTODETECTBUFFERSIZE_STRING, GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT)) + PROP_CUSTOM_UINT(IDS_DEFAULTBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFDEFAULT), &CustomPropertyCallbackProc, 0) + PROP_CUSTOM_UINT(IDS_ONEDISKBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFONEDISK), &CustomPropertyCallbackProc, 1) + PROP_CUSTOM_UINT(IDS_TWODISKSBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFTWODISKS), &CustomPropertyCallbackProc, 2) + PROP_CUSTOM_UINT(IDS_CDBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFCD), &CustomPropertyCallbackProc, 3) + PROP_CUSTOM_UINT(IDS_LANBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFLAN), &CustomPropertyCallbackProc, 4) + PROP_BOOL(IDS_USENOBUFFERING_STRING, GetConfig()->GetBoolValue(PP_BFUSENOBUFFERING)) + PROP_UINT(IDS_LARGEFILESMINSIZE_STRING, GetConfig()->GetIntValue(PP_BFBOUNDARYLIMIT)) + + + // Sounds + PROP_SEPARATOR(IDS_SOUNDS_STRING) + PROP_BOOL(IDS_PLAYSOUNDS_STRING, GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) + GetConfig()->GetStringValue(PP_SNDERRORSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + PROP_PATH(IDS_SOUNDONERROR_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) + GetConfig()->GetStringValue(PP_SNDFINISHEDSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); + strPath.ReleaseBuffer(); + PROP_PATH(IDS_SOUNDONFINISH_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) + + PROP_SEPARATOR(IDS_CFGSHORTCUTS_STRING) + PROP_CUSTOM_UINT(IDS_CFGSCCOUNT_STRING, m_cvShortcuts.size(), &ShortcutsPropertyCallbackProc, 0) + + PROP_SEPARATOR(IDS_CFGRECENT_STRING) + PROP_CUSTOM_UINT(IDS_CFGRPCOUNT_STRING, m_cvRecent.size(), &RecentPropertyCallbackProc, 0) + + /* PROP_SEPARATOR(IDS_CFGLOGFILE_STRING) + PROP_BOOL(IDS_CFGENABLELOGGING_STRING, GetConfig()->GetBoolValue(PP_LOGENABLELOGGING)) + PROP_BOOL(IDS_CFGLIMITATION_STRING, GetConfig()->GetBoolValue(PP_LOGLIMITATION)) + PROP_UINT(IDS_CFGMAXLIMIT_STRING, GetConfig()->GetIntValue(PP_LOGMAXLIMIT)) + PROP_BOOL(IDS_CFGLOGPRECISELIMITING_STRING, GetConfig()->GetBoolValue(PP_LOGPRECISELIMITING)) + PROP_UINT(IDS_CFGTRUNCBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_LOGTRUNCBUFFERSIZE))*/ +} + +void COptionsDlg::ApplyProperties() +{ + // counter + int iPosition=0; + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_PCLIPBOARDMONITORING, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_PMONITORSCANINTERVAL, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_PRELOADAFTERRESTART, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_PTIMEBEFORESHUTDOWN, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_PFORCESHUTDOWN, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_PAUTOSAVEINTERVAL, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_PPROCESSPRIORITYCLASS, IndexToPriorityClass(GetIndexProp(iPosition++))); + GetConfig()->SetStringValue(PP_PAUTOSAVEDIRECTORY, GetStringProp(iPosition++)); + GetConfig()->SetStringValue(PP_PPLUGINSDIR, GetStringProp(iPosition++)); + GetConfig()->SetStringValue(PP_PHELPDIR, GetStringProp(iPosition++)); + // language + PCTSTR pszSrc=m_vld.at(GetIndexProp(iPosition++)).GetFilename(true); + if (_tcsnicmp(pszSrc, GetApp()->GetProgramPath(), _tcslen(GetApp()->GetProgramPath())) == 0) + { + // replace the first part of path with + TCHAR szData[_MAX_PATH]; + _stprintf(szData, _T("%s"), pszSrc+_tcslen(GetApp()->GetProgramPath())); + GetConfig()->SetStringValue(PP_PLANGUAGE, szData); + } + else + GetConfig()->SetStringValue(PP_PLANGUAGE, pszSrc); + GetConfig()->SetStringValue(PP_PLANGDIR, GetStringProp(iPosition++)); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetIntValue(PP_STATUSREFRESHINTERVAL, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_STATUSSHOWDETAILS, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_STATUSAUTOREMOVEFINISHED, GetBoolProp(iPosition++)); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_MVSHOWFILENAMES, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_MVSHOWSINGLETASKS, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_MVREFRESHINTERVAL, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_MVAUTOSHOWWHENRUN, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_MVAUTOHIDEWHENEMPTY, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_MVUSESMOOTHPROGRESS, GetBoolProp(iPosition++)); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_FDEXTENDEDVIEW, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_FDWIDTH, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_FDHEIGHT, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_FDSHORTCUTLISTSTYLE, GetIndexProp(iPosition++)); + GetConfig()->SetBoolValue(PP_FDIGNORESHELLDIALOGS, GetBoolProp(iPosition++)); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_SHSHOWCOPY, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWMOVE, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWCOPYMOVE, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWPASTE, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWPASTESPECIAL, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWCOPYTO, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWMOVETO, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWCOPYMOVETO, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWFREESPACE, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHSHOWSHELLICONS, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_SHUSEDRAGDROP, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_SHDEFAULTACTION, GetIndexProp(iPosition++)); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_CMUSEAUTOCOMPLETEFILES, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMSETDESTATTRIBUTES, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMSETDESTDATE, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMPROTECTROFILES, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_CMLIMITMAXOPERATIONS, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMREADSIZEBEFOREBLOCKING, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_CMSHOWVISUALFEEDBACK, GetIndexProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMUSETIMEDFEEDBACK, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_CMFEEDBACKTIME, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMAUTORETRYONERROR, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_CMAUTORETRYINTERVAL, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_CMDEFAULTPRIORITY, IndexToPriority(GetIndexProp(iPosition++))); + GetConfig()->SetBoolValue(PP_CMDISABLEPRIORITYBOOST, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMDELETEAFTERFINISHED, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_CMCREATELOG, GetBoolProp(iPosition++)); + + // Buffer + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_BFUSEONLYDEFAULT, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFDEFAULT, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFONEDISK, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFTWODISKS, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFCD, GetUintProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFLAN, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_BFUSENOBUFFERING, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_BFBOUNDARYLIMIT, GetUintProp(iPosition++)); + + // log file +/* SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_LOGENABLELOGGING, GetBoolProp(iPosition++)); + GetConfig()->SetBoolValue(PP_LOGLIMITATION, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_LOGMAXLIMIT, GetUintProp(iPosition++)); + GetConfig()->SetBoolValue(PP_LOGPRECISELIMITING, GetBoolProp(iPosition++)); + GetConfig()->SetIntValue(PP_LOGTRUNCBUFFERSIZE, GetUintProp(iPosition++));*/ + + // Sounds + SKIP_SEPARATOR(iPosition) + GetConfig()->SetBoolValue(PP_SNDPLAYSOUNDS, GetBoolProp(iPosition++)); + GetConfig()->SetStringValue(PP_SNDERRORSOUNDPATH, GetStringProp(iPosition++)); + GetConfig()->SetStringValue(PP_SNDFINISHEDSOUNDPATH, GetStringProp(iPosition++)); + + // shortcuts & recent paths + SKIP_SEPARATOR(iPosition) + GetConfig()->SetStringArrayValue(PP_SHORTCUTS, &m_cvShortcuts); + + SKIP_SEPARATOR(iPosition) + GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &m_cvRecent); + + GetConfig()->Save(); +} + +void COptionsDlg::OnCancel() +{ + SendClosingNotify(); + CHLanguageDialog::OnCancel(); +} + +void COptionsDlg::SendClosingNotify() +{ + GetParent()->PostMessage(WM_CONFIGNOTIFY); +} + +CString COptionsDlg::MakeCompoundString(UINT uiBase, int iCount, LPCTSTR lpszSeparator) +{ + _tcscpy(m_szBuffer, GetResManager()->LoadString(uiBase+0)); + for (int i=1;iLoadString(uiBase+i)); + } + + return CString((PCTSTR)m_szBuffer); +} + +bool COptionsDlg::GetBoolProp(int iPosition) +{ + m_ctlProperties.GetProperty(iPosition, &m_iSel); + return m_iSel != 0; +} + +UINT COptionsDlg::GetUintProp(int iPosition) +{ + m_ctlProperties.GetProperty(iPosition, &m_strTemp); + return _ttoi(m_strTemp); +} + +CString COptionsDlg::GetStringProp(int iPosition) +{ + m_ctlProperties.GetProperty(iPosition, &m_strTemp); + return m_strTemp; +} + +int COptionsDlg::GetIndexProp(int iPosition) +{ + m_ctlProperties.GetProperty(iPosition, &m_iSel); + return m_iSel; +} + +void COptionsDlg::OnApplyButton() +{ + // kill focuses + m_ctlProperties.HideControls(); + + ApplyProperties(); +} + +void COptionsDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + m_ctlProperties.Reinit(); + + // set attributes + m_ctlProperties.SetBkColor(RGB(255, 255, 255)); + m_ctlProperties.SetTextColor(RGB(80, 80, 80)); + m_ctlProperties.SetTextHighlightColor(RGB(80,80,80)); + m_ctlProperties.SetHighlightColor(RGB(200, 200, 200)); + m_ctlProperties.SetPropertyBkColor(RGB(255,255,255)); + m_ctlProperties.SetPropertyTextColor(RGB(0,0,0)); + m_ctlProperties.SetLineStyle(RGB(74,109,132), PS_SOLID); + + FillPropertyList(); +} Index: ch/OptionsDlg.cpp =================================================================== diff -u -N --- ch/OptionsDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/OptionsDlg.cpp (revision 0) @@ -1,523 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" -#include "resource.h" -#include "OptionsDlg.h" -#include "BufferSizeDlg.h" -#include "ShortcutsDlg.h" -#include "RecentDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -bool COptionsDlg::m_bLock=false; - -///////////////////////////////////////////////////////////////////////////// -// COptionsDlg dialog - -COptionsDlg::COptionsDlg(CWnd* pParent /*=NULL*/) - : CHLanguageDialog(COptionsDlg::IDD, pParent, &m_bLock) -{ - //{{AFX_DATA_INIT(COptionsDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void COptionsDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(COptionsDlg) - DDX_Control(pDX, IDC_PROPERTIES_LIST, m_ctlProperties); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(COptionsDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(COptionsDlg) - ON_BN_CLICKED(IDC_APPLY_BUTTON, OnApplyButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COptionsDlg message handlers - -// properties handling macros -#define PROP_SEPARATOR(text)\ - m_ctlProperties.AddString(text); - -#define PROP_BOOL(text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, IDS_BOOLTEXT_STRING, (value)); - -#define PROP_UINT(text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_TEXT, _itot((value), m_szBuffer, 10), 0); - -#define PROP_COMBO(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, prop_text, (value)); - -#define PROP_DIR(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_DIR, (value)+CString(GetResManager()->LoadString(prop_text)), 0); - -#define PROP_PATH(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_PATH, (value)+CString(GetResManager()->LoadString(prop_text)), 0); - -#define PROP_CUSTOM_UINT(text, value, callback, param)\ - m_ctlProperties.AddString(text, ID_PROPERTY_CUSTOM, CString(_itot(value, m_szBuffer, 10)), callback, this, param, 0); - -#define SKIP_SEPARATOR(pos)\ - pos++; - -BOOL COptionsDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - m_ctlProperties.Init(); - - // copy shortcut and recent paths - GetConfig()->GetStringArrayValue(PP_RECENTPATHS, &m_cvRecent); - GetConfig()->GetStringArrayValue(PP_SHORTCUTS, &m_cvShortcuts); - - GetConfig()->GetStringValue(PP_PLANGDIR, m_szLangPath, _MAX_PATH); - GetApp()->ExpandPath(m_szLangPath); - - GetResManager()->Scan(m_szLangPath, &m_vld); - - // some attributes - m_ctlProperties.SetBkColor(RGB(255, 255, 255)); - m_ctlProperties.SetTextColor(RGB(80, 80, 80)); - m_ctlProperties.SetTextHighlightColor(RGB(80,80,80)); - m_ctlProperties.SetHighlightColor(RGB(200, 200, 200)); - m_ctlProperties.SetPropertyBkColor(RGB(255,255,255)); - m_ctlProperties.SetPropertyTextColor(RGB(0,0,0)); - m_ctlProperties.SetLineStyle(RGB(74,109,132), PS_SOLID); - - FillPropertyList(); - - return TRUE; -} - -void CustomPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex) -{ - COptionsDlg* pDlg=static_cast(lpParam); - CBufferSizeDlg dlg; - - dlg.m_bsSizes.m_bOnlyDefault=pDlg->GetBoolProp(iIndex-iParam-1); - dlg.m_bsSizes.m_uiDefaultSize=pDlg->GetUintProp(iIndex-iParam); - dlg.m_bsSizes.m_uiOneDiskSize=pDlg->GetUintProp(iIndex-iParam+1); - dlg.m_bsSizes.m_uiTwoDisksSize=pDlg->GetUintProp(iIndex-iParam+2); - dlg.m_bsSizes.m_uiCDSize=pDlg->GetUintProp(iIndex-iParam+3); - dlg.m_bsSizes.m_uiLANSize=pDlg->GetUintProp(iIndex-iParam+4); - dlg.m_iActiveIndex=iParam; // selected buffer for editing - - if (dlg.DoModal() == IDOK) - { - PROPERTYITEM* pItem; - TCHAR xx[32]; - - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam-1)); - pItem->nPropertySelected=(dlg.m_bsSizes.m_bOnlyDefault ? 1 : 0); - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiDefaultSize, xx, 10)); - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+1)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiOneDiskSize, xx, 10)); - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+2)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiTwoDisksSize, xx, 10)); - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+3)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiCDSize, xx, 10)); - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex-iParam+4)); - pItem->csProperties.SetAt(0, _itot(dlg.m_bsSizes.m_uiLANSize, xx, 10)); - } -} - -void ShortcutsPropertyCallbackProc(LPVOID lpParam, int /*iParam*/, CPtrList* pList, int iIndex) -{ - COptionsDlg* pDlg=static_cast(lpParam); - - CShortcutsDlg dlg; - dlg.m_cvShortcuts.assign(pDlg->m_cvShortcuts.begin(), pDlg->m_cvShortcuts.end(), true, true); - dlg.m_pcvRecent=&pDlg->m_cvRecent; - if (dlg.DoModal() == IDOK) - { - // restore shortcuts to pDlg->cvShortcuts - pDlg->m_cvShortcuts.assign(dlg.m_cvShortcuts.begin(), dlg.m_cvShortcuts.end(), true, false); - dlg.m_cvShortcuts.erase(dlg.m_cvShortcuts.begin(), dlg.m_cvShortcuts.end(), false); - - // property list - TCHAR szBuf[32]; - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); - pItem->csProperties.SetAt(0, _itot(pDlg->m_cvShortcuts.size(), szBuf, 10)); - } -} - -void RecentPropertyCallbackProc(LPVOID lpParam, int /*iParam*/, CPtrList* pList, int iIndex) -{ - COptionsDlg* pDlg=static_cast(lpParam); - - CRecentDlg dlg; - dlg.m_cvRecent.assign(pDlg->m_cvRecent.begin(), pDlg->m_cvRecent.end(), true, true); - if (dlg.DoModal() == IDOK) - { - // restore - pDlg->m_cvRecent.assign(dlg.m_cvRecent.begin(), dlg.m_cvRecent.end(), true, false); - dlg.m_cvRecent.erase(dlg.m_cvRecent.begin(), dlg.m_cvRecent.end(), false); - - // property list - TCHAR szBuf[32]; - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); - pItem->csProperties.SetAt(0, _itot(pDlg->m_cvRecent.size(), szBuf, 10)); - } -} - -void COptionsDlg::OnOK() -{ - // kill focuses - m_ctlProperties.HideControls(); - - ApplyProperties(); - - SendClosingNotify(); - CHLanguageDialog::OnOK(); -} - -void COptionsDlg::FillPropertyList() -{ - CString strPath; - - // load settings - PROP_SEPARATOR(IDS_PROGRAM_STRING) - PROP_BOOL(IDS_CLIPBOARDMONITORING_STRING, GetConfig()->GetBoolValue(PP_PCLIPBOARDMONITORING)) - PROP_UINT(IDS_CLIPBOARDINTERVAL_STRING, GetConfig()->GetIntValue(PP_PMONITORSCANINTERVAL)) - PROP_BOOL(IDS_AUTORUNPROGRAM_STRING, GetConfig()->GetBoolValue(PP_PRELOADAFTERRESTART)) - PROP_BOOL(IDS_AUTOSHUTDOWN_STRING, GetConfig()->GetBoolValue(PP_PSHUTDOWNAFTREFINISHED)) - PROP_UINT(IDS_SHUTDOWNTIME_STRING, GetConfig()->GetIntValue(PP_PTIMEBEFORESHUTDOWN)) - PROP_COMBO(IDS_FORCESHUTDOWN_STRING, IDS_FORCESHUTDOWNVALUES_STRING, GetConfig()->GetBoolValue(PP_PFORCESHUTDOWN)) - PROP_UINT(IDS_AUTOSAVEINTERVAL_STRING, GetConfig()->GetIntValue(PP_PAUTOSAVEINTERVAL)) - PROP_COMBO(IDS_CFGPRIORITYCLASS_STRING, IDS_CFGPRIORITYCLASSITEMS_STRING, PriorityClassToIndex(GetConfig()->GetIntValue(PP_PPROCESSPRIORITYCLASS))) - - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - TRACE("Autosavedir=%s\n", strPath); - PROP_DIR(IDS_TEMPFOLDER_STRING, IDS_TEMPFOLDERCHOOSE_STRING, strPath) - - GetConfig()->GetStringValue(PP_PPLUGINSDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - PROP_DIR(IDS_PLUGSFOLDER_STRING, IDS_PLUGSFOLDERCHOOSE_STRING, strPath) - - GetConfig()->GetStringValue(PP_PHELPDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - PROP_DIR(IDS_CFGHELPDIR_STRING, IDS_CFGHELPDIRCHOOSE_STRING, strPath) - - // lang - CString strLangs; - UINT uiIndex=0; - for (vector::iterator it=m_vld.begin();it != m_vld.end();it++) - { - strLangs+=(*it).pszLngName; - strLangs+=_T("!"); - if (_tcscmp((*it).GetFilename(true), GetResManager()->m_ld.GetFilename(true)) == 0) - uiIndex=it-m_vld.begin(); - } - strLangs.TrimRight(_T('!')); - - PROP_COMBO(IDS_LANGUAGE_STRING, strLangs, uiIndex) - - GetConfig()->GetStringValue(PP_PLANGDIR, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - PROP_DIR(IDS_LANGUAGESFOLDER_STRING, IDS_LANGSFOLDERCHOOSE_STRING, strPath) - - ///////////////// - PROP_SEPARATOR(IDS_STATUSWINDOW_STRING); - PROP_UINT(IDS_REFRESHSTATUSINTERVAL_STRING, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL)) - PROP_BOOL(IDS_STATUSSHOWDETAILS_STRING, GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) - PROP_BOOL(IDS_STATUSAUTOREMOVE_STRING, GetConfig()->GetBoolValue(PP_STATUSAUTOREMOVEFINISHED)) - - PROP_SEPARATOR(IDS_MINIVIEW_STRING) - PROP_BOOL(IDS_SHOWFILENAMES_STRING, GetConfig()->GetBoolValue(PP_MVSHOWFILENAMES)) - PROP_BOOL(IDS_SHOWSINGLETASKS_STRING, GetConfig()->GetBoolValue(PP_MVSHOWSINGLETASKS)) - PROP_UINT(IDS_MINIVIEWREFRESHINTERVAL_STRING, GetConfig()->GetIntValue(PP_MVREFRESHINTERVAL)) - PROP_BOOL(IDS_MINIVIEWSHOWAFTERSTART_STRING, GetConfig()->GetBoolValue(PP_MVAUTOSHOWWHENRUN)) - PROP_BOOL(IDS_MINIVIEWAUTOHIDE_STRING, GetConfig()->GetBoolValue(PP_MVAUTOHIDEWHENEMPTY)) - PROP_BOOL(IDS_MINIVIEWSMOOTHPROGRESS_STRING, GetConfig()->GetBoolValue(PP_MVUSESMOOTHPROGRESS)) - - PROP_SEPARATOR(IDS_CFGFOLDERDIALOG_STRING) - PROP_BOOL(IDS_CFGFDEXTVIEW_STRING, GetConfig()->GetBoolValue(PP_FDEXTENDEDVIEW)) - PROP_UINT(IDS_CFGFDWIDTH_STRING, GetConfig()->GetIntValue(PP_FDWIDTH)) - PROP_UINT(IDS_CFGFDHEIGHT_STRING, GetConfig()->GetIntValue(PP_FDHEIGHT)) - PROP_COMBO(IDS_CFGFDSHORTCUTS_STRING, IDS_CFGFDSHORTCUTSSTYLES_STRING, GetConfig()->GetIntValue(PP_FDSHORTCUTLISTSTYLE)) - PROP_BOOL(IDS_CFGFDIGNOREDIALOGS_STRING, GetConfig()->GetBoolValue(PP_FDIGNORESHELLDIALOGS)) - - PROP_SEPARATOR(IDS_CFGSHELL_STRING) - PROP_BOOL(IDS_CFGSHCOPY_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPY)) - PROP_BOOL(IDS_CFGSHMOVE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWMOVE)) - PROP_BOOL(IDS_CFGSHCMSPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVE)) - PROP_BOOL(IDS_CFGSHPASTE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWPASTE)) - PROP_BOOL(IDS_CFGSHPASTESPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWPASTESPECIAL)) - PROP_BOOL(IDS_CFGSHCOPYTO_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYTO)) - PROP_BOOL(IDS_CFGSHMOVETO_STRING, GetConfig()->GetBoolValue(PP_SHSHOWMOVETO)) - PROP_BOOL(IDS_CFGSHCMTOSPECIAL_STRING, GetConfig()->GetBoolValue(PP_SHSHOWCOPYMOVETO)) - PROP_BOOL(IDS_CFGSHSHOWFREESPACE_STRING, GetConfig()->GetBoolValue(PP_SHSHOWFREESPACE)) - PROP_BOOL(IDS_CFGSHSHOWICONS_STRING, GetConfig()->GetBoolValue(PP_SHSHOWSHELLICONS)) - PROP_BOOL(IDS_CFGSHOVERRIDEDRAG_STRING, GetConfig()->GetBoolValue(PP_SHUSEDRAGDROP)) - PROP_COMBO(IDS_CFGOVERRIDEDEFACTION_STRING, IDS_CFGACTIONS_STRING, GetConfig()->GetIntValue(PP_SHDEFAULTACTION)); - - PROP_SEPARATOR(IDS_PROCESSINGTHREAD_STRING) - PROP_BOOL(IDS_AUTOCOPYREST_STRING, GetConfig()->GetBoolValue(PP_CMUSEAUTOCOMPLETEFILES)) - PROP_BOOL(IDS_SETDESTATTRIB_STRING, GetConfig()->GetBoolValue(PP_CMSETDESTATTRIBUTES)) - PROP_BOOL(IDS_SETDESTTIME_STRING, GetConfig()->GetBoolValue(PP_CMSETDESTDATE)) - PROP_BOOL(IDS_PROTECTROFILES_STRING, GetConfig()->GetBoolValue(PP_CMPROTECTROFILES)) - PROP_UINT(IDS_LIMITOPERATIONS_STRING, GetConfig()->GetIntValue(PP_CMLIMITMAXOPERATIONS)) - PROP_BOOL(IDS_READSIZEBEFOREBLOCK_STRING, GetConfig()->GetBoolValue(PP_CMREADSIZEBEFOREBLOCKING)) - PROP_COMBO(IDS_SHOWVISUALFEEDBACK_STRING, IDS_FEEDBACKTYPE_STRING, GetConfig()->GetIntValue(PP_CMSHOWVISUALFEEDBACK)) - PROP_BOOL(IDS_USETIMEDDIALOGS_STRING, GetConfig()->GetBoolValue(PP_CMUSETIMEDFEEDBACK)) - PROP_UINT(IDS_TIMEDDIALOGINTERVAL_STRING, GetConfig()->GetIntValue(PP_CMFEEDBACKTIME)) - PROP_BOOL(IDS_AUTORETRYONERROR_STRING, GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR)) - PROP_UINT(IDS_AUTORETRYINTERVAL_STRING, GetConfig()->GetIntValue(PP_CMAUTORETRYINTERVAL)) - PROP_COMBO(IDS_DEFAULTPRIORITY_STRING, MakeCompoundString(IDS_PRIORITY0_STRING, 7, _T("!")), PriorityToIndex(GetConfig()->GetIntValue(PP_CMDEFAULTPRIORITY))) - PROP_BOOL(IDS_CFGDISABLEPRIORITYBOOST_STRING, GetConfig()->GetBoolValue(PP_CMDISABLEPRIORITYBOOST)) - PROP_BOOL(IDS_DELETEAFTERFINISHED_STRING, GetConfig()->GetBoolValue(PP_CMDELETEAFTERFINISHED)) - PROP_BOOL(IDS_CREATELOGFILES_STRING, GetConfig()->GetBoolValue(PP_CMCREATELOG)) - - // Buffer - PROP_SEPARATOR(IDS_OPTIONSBUFFER_STRING) - PROP_BOOL(IDS_AUTODETECTBUFFERSIZE_STRING, GetConfig()->GetBoolValue(PP_BFUSEONLYDEFAULT)) - PROP_CUSTOM_UINT(IDS_DEFAULTBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFDEFAULT), &CustomPropertyCallbackProc, 0) - PROP_CUSTOM_UINT(IDS_ONEDISKBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFONEDISK), &CustomPropertyCallbackProc, 1) - PROP_CUSTOM_UINT(IDS_TWODISKSBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFTWODISKS), &CustomPropertyCallbackProc, 2) - PROP_CUSTOM_UINT(IDS_CDBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFCD), &CustomPropertyCallbackProc, 3) - PROP_CUSTOM_UINT(IDS_LANBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_BFLAN), &CustomPropertyCallbackProc, 4) - PROP_BOOL(IDS_USENOBUFFERING_STRING, GetConfig()->GetBoolValue(PP_BFUSENOBUFFERING)) - PROP_UINT(IDS_LARGEFILESMINSIZE_STRING, GetConfig()->GetIntValue(PP_BFBOUNDARYLIMIT)) - - - // Sounds - PROP_SEPARATOR(IDS_SOUNDS_STRING) - PROP_BOOL(IDS_PLAYSOUNDS_STRING, GetConfig()->GetBoolValue(PP_SNDPLAYSOUNDS)) - GetConfig()->GetStringValue(PP_SNDERRORSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - PROP_PATH(IDS_SOUNDONERROR_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) - GetConfig()->GetStringValue(PP_SNDFINISHEDSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); - strPath.ReleaseBuffer(); - PROP_PATH(IDS_SOUNDONFINISH_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) - - PROP_SEPARATOR(IDS_CFGSHORTCUTS_STRING) - PROP_CUSTOM_UINT(IDS_CFGSCCOUNT_STRING, m_cvShortcuts.size(), &ShortcutsPropertyCallbackProc, 0) - - PROP_SEPARATOR(IDS_CFGRECENT_STRING) - PROP_CUSTOM_UINT(IDS_CFGRPCOUNT_STRING, m_cvRecent.size(), &RecentPropertyCallbackProc, 0) - - /* PROP_SEPARATOR(IDS_CFGLOGFILE_STRING) - PROP_BOOL(IDS_CFGENABLELOGGING_STRING, GetConfig()->GetBoolValue(PP_LOGENABLELOGGING)) - PROP_BOOL(IDS_CFGLIMITATION_STRING, GetConfig()->GetBoolValue(PP_LOGLIMITATION)) - PROP_UINT(IDS_CFGMAXLIMIT_STRING, GetConfig()->GetIntValue(PP_LOGMAXLIMIT)) - PROP_BOOL(IDS_CFGLOGPRECISELIMITING_STRING, GetConfig()->GetBoolValue(PP_LOGPRECISELIMITING)) - PROP_UINT(IDS_CFGTRUNCBUFFERSIZE_STRING, GetConfig()->GetIntValue(PP_LOGTRUNCBUFFERSIZE))*/ -} - -void COptionsDlg::ApplyProperties() -{ - // counter - int iPosition=0; - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_PCLIPBOARDMONITORING, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_PMONITORSCANINTERVAL, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_PRELOADAFTERRESTART, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_PSHUTDOWNAFTREFINISHED, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_PTIMEBEFORESHUTDOWN, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_PFORCESHUTDOWN, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_PAUTOSAVEINTERVAL, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_PPROCESSPRIORITYCLASS, IndexToPriorityClass(GetIndexProp(iPosition++))); - GetConfig()->SetStringValue(PP_PAUTOSAVEDIRECTORY, GetStringProp(iPosition++)); - GetConfig()->SetStringValue(PP_PPLUGINSDIR, GetStringProp(iPosition++)); - GetConfig()->SetStringValue(PP_PHELPDIR, GetStringProp(iPosition++)); - // language - PCTSTR pszSrc=m_vld.at(GetIndexProp(iPosition++)).GetFilename(true); - if (_tcsnicmp(pszSrc, GetApp()->GetProgramPath(), _tcslen(GetApp()->GetProgramPath())) == 0) - { - // replace the first part of path with - TCHAR szData[_MAX_PATH]; - _stprintf(szData, _T("%s"), pszSrc+_tcslen(GetApp()->GetProgramPath())); - GetConfig()->SetStringValue(PP_PLANGUAGE, szData); - } - else - GetConfig()->SetStringValue(PP_PLANGUAGE, pszSrc); - GetConfig()->SetStringValue(PP_PLANGDIR, GetStringProp(iPosition++)); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetIntValue(PP_STATUSREFRESHINTERVAL, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_STATUSSHOWDETAILS, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_STATUSAUTOREMOVEFINISHED, GetBoolProp(iPosition++)); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_MVSHOWFILENAMES, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_MVSHOWSINGLETASKS, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_MVREFRESHINTERVAL, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_MVAUTOSHOWWHENRUN, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_MVAUTOHIDEWHENEMPTY, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_MVUSESMOOTHPROGRESS, GetBoolProp(iPosition++)); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_FDEXTENDEDVIEW, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_FDWIDTH, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_FDHEIGHT, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_FDSHORTCUTLISTSTYLE, GetIndexProp(iPosition++)); - GetConfig()->SetBoolValue(PP_FDIGNORESHELLDIALOGS, GetBoolProp(iPosition++)); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_SHSHOWCOPY, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWMOVE, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWCOPYMOVE, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWPASTE, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWPASTESPECIAL, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWCOPYTO, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWMOVETO, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWCOPYMOVETO, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWFREESPACE, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHSHOWSHELLICONS, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_SHUSEDRAGDROP, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_SHDEFAULTACTION, GetIndexProp(iPosition++)); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_CMUSEAUTOCOMPLETEFILES, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMSETDESTATTRIBUTES, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMSETDESTDATE, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMPROTECTROFILES, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_CMLIMITMAXOPERATIONS, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMREADSIZEBEFOREBLOCKING, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_CMSHOWVISUALFEEDBACK, GetIndexProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMUSETIMEDFEEDBACK, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_CMFEEDBACKTIME, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMAUTORETRYONERROR, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_CMAUTORETRYINTERVAL, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_CMDEFAULTPRIORITY, IndexToPriority(GetIndexProp(iPosition++))); - GetConfig()->SetBoolValue(PP_CMDISABLEPRIORITYBOOST, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMDELETEAFTERFINISHED, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_CMCREATELOG, GetBoolProp(iPosition++)); - - // Buffer - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_BFUSEONLYDEFAULT, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFDEFAULT, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFONEDISK, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFTWODISKS, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFCD, GetUintProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFLAN, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_BFUSENOBUFFERING, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_BFBOUNDARYLIMIT, GetUintProp(iPosition++)); - - // log file -/* SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_LOGENABLELOGGING, GetBoolProp(iPosition++)); - GetConfig()->SetBoolValue(PP_LOGLIMITATION, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_LOGMAXLIMIT, GetUintProp(iPosition++)); - GetConfig()->SetBoolValue(PP_LOGPRECISELIMITING, GetBoolProp(iPosition++)); - GetConfig()->SetIntValue(PP_LOGTRUNCBUFFERSIZE, GetUintProp(iPosition++));*/ - - // Sounds - SKIP_SEPARATOR(iPosition) - GetConfig()->SetBoolValue(PP_SNDPLAYSOUNDS, GetBoolProp(iPosition++)); - GetConfig()->SetStringValue(PP_SNDERRORSOUNDPATH, GetStringProp(iPosition++)); - GetConfig()->SetStringValue(PP_SNDFINISHEDSOUNDPATH, GetStringProp(iPosition++)); - - // shortcuts & recent paths - SKIP_SEPARATOR(iPosition) - GetConfig()->SetStringArrayValue(PP_SHORTCUTS, &m_cvShortcuts); - - SKIP_SEPARATOR(iPosition) - GetConfig()->SetStringArrayValue(PP_RECENTPATHS, &m_cvRecent); - - GetConfig()->Save(); -} - -void COptionsDlg::OnCancel() -{ - SendClosingNotify(); - CHLanguageDialog::OnCancel(); -} - -void COptionsDlg::SendClosingNotify() -{ - GetParent()->PostMessage(WM_CONFIGNOTIFY); -} - -CString COptionsDlg::MakeCompoundString(UINT uiBase, int iCount, LPCTSTR lpszSeparator) -{ - _tcscpy(m_szBuffer, GetResManager()->LoadString(uiBase+0)); - for (int i=1;iLoadString(uiBase+i)); - } - - return CString((PCTSTR)m_szBuffer); -} - -bool COptionsDlg::GetBoolProp(int iPosition) -{ - m_ctlProperties.GetProperty(iPosition, &m_iSel); - return m_iSel != 0; -} - -UINT COptionsDlg::GetUintProp(int iPosition) -{ - m_ctlProperties.GetProperty(iPosition, &m_strTemp); - return _ttoi(m_strTemp); -} - -CString COptionsDlg::GetStringProp(int iPosition) -{ - m_ctlProperties.GetProperty(iPosition, &m_strTemp); - return m_strTemp; -} - -int COptionsDlg::GetIndexProp(int iPosition) -{ - m_ctlProperties.GetProperty(iPosition, &m_iSel); - return m_iSel; -} - -void COptionsDlg::OnApplyButton() -{ - // kill focuses - m_ctlProperties.HideControls(); - - ApplyProperties(); -} - -void COptionsDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - m_ctlProperties.Reinit(); - - // set attributes - m_ctlProperties.SetBkColor(RGB(255, 255, 255)); - m_ctlProperties.SetTextColor(RGB(80, 80, 80)); - m_ctlProperties.SetTextHighlightColor(RGB(80,80,80)); - m_ctlProperties.SetHighlightColor(RGB(200, 200, 200)); - m_ctlProperties.SetPropertyBkColor(RGB(255,255,255)); - m_ctlProperties.SetPropertyTextColor(RGB(0,0,0)); - m_ctlProperties.SetLineStyle(RGB(74,109,132), PS_SOLID); - - FillPropertyList(); -} Index: src/ch/OptionsDlg.h =================================================================== diff -u -N --- src/ch/OptionsDlg.h (revision 0) +++ src/ch/OptionsDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,98 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __OPTIONSDLG_H__ +#define __OPTIONSDLG_H__ + +#include "PropertyListCtrl.h" +#include "structs.h" +#include "shortcuts.h" +#include "charvect.h" + +#define WM_CONFIGNOTIFY WM_USER+13 + +///////////////////////////////////////////////////////////////////////////// +// COptionsDlg dialog + +class COptionsDlg : public CHLanguageDialog +{ +// Construction +public: + void SendClosingNotify(); + COptionsDlg(CWnd* pParent = NULL); // standard constructor + + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + + static bool m_bLock; // locker + + char_vector m_cvRecent; + char_vector m_cvShortcuts; + + // for languages + vector m_vld; + TCHAR m_szLangPath[_MAX_PATH]; // the full path to a folder with langs (@read) + + friend void CustomPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); + friend void ShortcutsPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); + friend void RecentPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); + +// Dialog Data + //{{AFX_DATA(COptionsDlg) + enum { IDD = IDD_OPTIONS_DIALOG }; + CPropertyListCtrl m_ctlProperties; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(COptionsDlg) + public: + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + void FillPropertyList(); + void ApplyProperties(); + + int GetIndexProp(int iPosition); + CString GetStringProp(int iPosition); + UINT GetUintProp(int iPosition); + bool GetBoolProp(int iPosition); + CString MakeCompoundString(UINT uiBase, int iCount, LPCTSTR lpszSeparator); + + TCHAR m_szBuffer[_MAX_PATH]; // for macro use + CString m_strTemp; + int m_iSel; + + // Generated message map functions + //{{AFX_MSG(COptionsDlg) + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual void OnCancel(); + afx_msg void OnApplyButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/OptionsDlg.h =================================================================== diff -u -N --- ch/OptionsDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/OptionsDlg.h (revision 0) @@ -1,98 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __OPTIONSDLG_H__ -#define __OPTIONSDLG_H__ - -#include "PropertyListCtrl.h" -#include "structs.h" -#include "shortcuts.h" -#include "charvect.h" - -#define WM_CONFIGNOTIFY WM_USER+13 - -///////////////////////////////////////////////////////////////////////////// -// COptionsDlg dialog - -class COptionsDlg : public CHLanguageDialog -{ -// Construction -public: - void SendClosingNotify(); - COptionsDlg(CWnd* pParent = NULL); // standard constructor - - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - - static bool m_bLock; // locker - - char_vector m_cvRecent; - char_vector m_cvShortcuts; - - // for languages - vector m_vld; - TCHAR m_szLangPath[_MAX_PATH]; // the full path to a folder with langs (@read) - - friend void CustomPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); - friend void ShortcutsPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); - friend void RecentPropertyCallbackProc(LPVOID lpParam, int iParam, CPtrList* pList, int iIndex); - -// Dialog Data - //{{AFX_DATA(COptionsDlg) - enum { IDD = IDD_OPTIONS_DIALOG }; - CPropertyListCtrl m_ctlProperties; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(COptionsDlg) - public: - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void FillPropertyList(); - void ApplyProperties(); - - int GetIndexProp(int iPosition); - CString GetStringProp(int iPosition); - UINT GetUintProp(int iPosition); - bool GetBoolProp(int iPosition); - CString MakeCompoundString(UINT uiBase, int iCount, LPCTSTR lpszSeparator); - - TCHAR m_szBuffer[_MAX_PATH]; // for macro use - CString m_strTemp; - int m_iSel; - - // Generated message map functions - //{{AFX_MSG(COptionsDlg) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - virtual void OnCancel(); - afx_msg void OnApplyButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ProgressListBox.cpp =================================================================== diff -u -N --- src/ch/ProgressListBox.cpp (revision 0) +++ src/ch/ProgressListBox.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,246 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "ProgressListBox.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +//#define USE_SMOOTH_PROGRESS + +///////////////////////////////////////////////////////////////////////////// +// CProgressListBox + +CProgressListBox::CProgressListBox() +{ + m_bShowCaptions=true; + m_bSmoothProgress=false; +} + +CProgressListBox::~CProgressListBox() +{ + for (int i=0;iitemID == -1) + return; + _PROGRESSITEM_* pItem=m_items.GetAt(lpDrawItemStruct->itemID); + + // device context + CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); + pDC->SetBkMode(TRANSPARENT); + + if (lpDrawItemStruct->itemState & ODS_SELECTED) + { + // fill with color, because in other way the trash appears + pDC->FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_3DFACE)); + CPoint apt[3]={ CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4), + CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+3*((lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4)), + CPoint(lpDrawItemStruct->rcItem.left+7, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/2) }; + pDC->Polygon(apt, 3); + lpDrawItemStruct->rcItem.left+=10; + } + + // draw text + if (m_bShowCaptions) + { + CRect rcText(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+2, + lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom-(9+2)); + pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT)); + pDC->DrawText(pItem->m_strText, &rcText, + DT_PATH_ELLIPSIS | DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); + } + + // frame sizes + int iEdgeWidth=1/*GetSystemMetrics(SM_CXEDGE)*/; + int iEdgeHeight=1/*GetSystemMetrics(SM_CYEDGE)*/; + + // progress like drawing + int iBoxWidth=static_cast(static_cast(((9+2)-2*iEdgeWidth))*(2.0/3.0))+1; + CRect rcProgress(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom-(9+2), + lpDrawItemStruct->rcItem.left+2*iEdgeWidth+((lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left-2*iEdgeWidth)/iBoxWidth)*iBoxWidth, + lpDrawItemStruct->rcItem.bottom); + + // edge + pDC->Draw3dRect(&rcProgress, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHIGHLIGHT)); + + if (!m_bSmoothProgress) + { + // boxes within edge + double dCount=static_cast(static_cast(((rcProgress.Width()-2*iEdgeHeight)/iBoxWidth)) + *(static_cast(pItem->m_uiPos)/static_cast(pItem->m_uiRange))); + int iBoxCount=((dCount-static_cast(dCount)) > 0.2) ? static_cast(dCount)+1 : static_cast(dCount); + + for (int i=0;iFillSolidRect(lpDrawItemStruct->rcItem.left+i*iBoxWidth+iEdgeWidth+1, + lpDrawItemStruct->rcItem.bottom-(9+2)+iEdgeHeight+1, + iBoxWidth-2, rcProgress.Height()-2*iEdgeHeight-2, pItem->m_crColor); + } + else + { + pDC->FillSolidRect(lpDrawItemStruct->rcItem.left+iEdgeWidth+1, lpDrawItemStruct->rcItem.bottom-(9+2)+iEdgeHeight+1, + static_cast((rcProgress.Width()-2*iEdgeHeight-3)*(static_cast(pItem->m_uiPos)/static_cast(pItem->m_uiRange))), + rcProgress.Height()-2*iEdgeHeight-2, pItem->m_crColor); + } +} + +bool CProgressListBox::GetShowCaptions() +{ + return m_bShowCaptions; +} + +void CProgressListBox::SetShowCaptions(bool bShow) +{ + if (bShow != m_bShowCaptions) + { + m_bShowCaptions=bShow; + if (bShow) + { + CClientDC dc(this); + dc.SelectObject(GetFont()); + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); + int iHeight=MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY); + + SetItemHeight(0, 9+2+2+iHeight); + } + else + SetItemHeight(0, 9+2+2); + + RecalcHeight(); + } +} + +void CProgressListBox::RecalcHeight() +{ + // new height + int iCtlHeight=m_items.GetSize()*GetItemHeight(0); + + // change control size + CRect rcCtl; + GetClientRect(&rcCtl); + this->SetWindowPos(NULL, 0, 0, rcCtl.Width(), iCtlHeight, SWP_NOZORDER | SWP_NOMOVE); +} + +void CProgressListBox::Init() +{ + // set new height of an item + CClientDC dc(this); + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); + int iHeight=MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY); + SetItemHeight(0, m_bShowCaptions ? iHeight+2+9+2 : 2+9+2); +} + +_PROGRESSITEM_* CProgressListBox::GetItemAddress(int iIndex) +{ + if (m_items.GetSize() > iIndex) + return m_items.GetAt(iIndex); + else + { + _PROGRESSITEM_* pItem=new _PROGRESSITEM_; + pItem->m_uiRange=100; + m_items.Add(pItem); + return pItem; + } +} + +void CProgressListBox::UpdateItems(int nLimit, bool bUpdateSize) +{ + // delete items from array + while (m_items.GetSize() > nLimit) + { + delete m_items.GetAt(nLimit); + m_items.RemoveAt(nLimit); + } + + // change count of elements in a listbox + if (GetCount() != m_items.GetSize()) + { + while (GetCount() < m_items.GetSize()) + AddString(""); + + while (GetCount() > m_items.GetSize()) + DeleteString(m_items.GetSize()); + } + + if (bUpdateSize) + { + Invalidate(); + RecalcHeight(); + } +} + +void CProgressListBox::OnPaint() +{ + CPaintDC dc(this); // device context for painting + CRect rcClip; + dc.GetClipBox(&rcClip); + + CMemDC memDC(&dc, &rcClip); + memDC.FillSolidRect(&rcClip, GetSysColor(COLOR_3DFACE)); + + DefWindowProc(WM_PAINT, reinterpret_cast(memDC.m_hDC), 0); +} + +BOOL CProgressListBox::OnEraseBkgnd(CDC*) +{ + return FALSE/*CListBox::OnEraseBkgnd(pDC)*/; +} + +int CProgressListBox::SetCurSel(int nSelect) +{ + int nResult=static_cast(this)->SetCurSel(nSelect); + if (nSelect == -1) + GetParent()->SendMessage(WM_COMMAND, (LBN_SELCANCEL << 16) | GetDlgCtrlID(), reinterpret_cast(this->m_hWnd)); + + return nResult; +} + +void CProgressListBox::OnKillfocus() +{ + SetCurSel(-1); +} + +void CProgressListBox::SetSmoothProgress(bool bSmoothProgress) +{ + m_bSmoothProgress=bSmoothProgress; +} Index: ch/ProgressListBox.cpp =================================================================== diff -u -N --- ch/ProgressListBox.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ProgressListBox.cpp (revision 0) @@ -1,246 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "ProgressListBox.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -//#define USE_SMOOTH_PROGRESS - -///////////////////////////////////////////////////////////////////////////// -// CProgressListBox - -CProgressListBox::CProgressListBox() -{ - m_bShowCaptions=true; - m_bSmoothProgress=false; -} - -CProgressListBox::~CProgressListBox() -{ - for (int i=0;iitemID == -1) - return; - _PROGRESSITEM_* pItem=m_items.GetAt(lpDrawItemStruct->itemID); - - // device context - CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); - pDC->SetBkMode(TRANSPARENT); - - if (lpDrawItemStruct->itemState & ODS_SELECTED) - { - // fill with color, because in other way the trash appears - pDC->FillSolidRect(&lpDrawItemStruct->rcItem, GetSysColor(COLOR_3DFACE)); - CPoint apt[3]={ CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4), - CPoint(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+3*((lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/4)), - CPoint(lpDrawItemStruct->rcItem.left+7, lpDrawItemStruct->rcItem.top+(lpDrawItemStruct->rcItem.bottom-lpDrawItemStruct->rcItem.top)/2) }; - pDC->Polygon(apt, 3); - lpDrawItemStruct->rcItem.left+=10; - } - - // draw text - if (m_bShowCaptions) - { - CRect rcText(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top+2, - lpDrawItemStruct->rcItem.right, lpDrawItemStruct->rcItem.bottom-(9+2)); - pDC->SetTextColor(GetSysColor(COLOR_BTNTEXT)); - pDC->DrawText(pItem->m_strText, &rcText, - DT_PATH_ELLIPSIS | DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); - } - - // frame sizes - int iEdgeWidth=1/*GetSystemMetrics(SM_CXEDGE)*/; - int iEdgeHeight=1/*GetSystemMetrics(SM_CYEDGE)*/; - - // progress like drawing - int iBoxWidth=static_cast(static_cast(((9+2)-2*iEdgeWidth))*(2.0/3.0))+1; - CRect rcProgress(lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.bottom-(9+2), - lpDrawItemStruct->rcItem.left+2*iEdgeWidth+((lpDrawItemStruct->rcItem.right-lpDrawItemStruct->rcItem.left-2*iEdgeWidth)/iBoxWidth)*iBoxWidth, - lpDrawItemStruct->rcItem.bottom); - - // edge - pDC->Draw3dRect(&rcProgress, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHIGHLIGHT)); - - if (!m_bSmoothProgress) - { - // boxes within edge - double dCount=static_cast(static_cast(((rcProgress.Width()-2*iEdgeHeight)/iBoxWidth)) - *(static_cast(pItem->m_uiPos)/static_cast(pItem->m_uiRange))); - int iBoxCount=((dCount-static_cast(dCount)) > 0.2) ? static_cast(dCount)+1 : static_cast(dCount); - - for (int i=0;iFillSolidRect(lpDrawItemStruct->rcItem.left+i*iBoxWidth+iEdgeWidth+1, - lpDrawItemStruct->rcItem.bottom-(9+2)+iEdgeHeight+1, - iBoxWidth-2, rcProgress.Height()-2*iEdgeHeight-2, pItem->m_crColor); - } - else - { - pDC->FillSolidRect(lpDrawItemStruct->rcItem.left+iEdgeWidth+1, lpDrawItemStruct->rcItem.bottom-(9+2)+iEdgeHeight+1, - static_cast((rcProgress.Width()-2*iEdgeHeight-3)*(static_cast(pItem->m_uiPos)/static_cast(pItem->m_uiRange))), - rcProgress.Height()-2*iEdgeHeight-2, pItem->m_crColor); - } -} - -bool CProgressListBox::GetShowCaptions() -{ - return m_bShowCaptions; -} - -void CProgressListBox::SetShowCaptions(bool bShow) -{ - if (bShow != m_bShowCaptions) - { - m_bShowCaptions=bShow; - if (bShow) - { - CClientDC dc(this); - dc.SelectObject(GetFont()); - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); - int iHeight=MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY); - - SetItemHeight(0, 9+2+2+iHeight); - } - else - SetItemHeight(0, 9+2+2); - - RecalcHeight(); - } -} - -void CProgressListBox::RecalcHeight() -{ - // new height - int iCtlHeight=m_items.GetSize()*GetItemHeight(0); - - // change control size - CRect rcCtl; - GetClientRect(&rcCtl); - this->SetWindowPos(NULL, 0, 0, rcCtl.Width(), iCtlHeight, SWP_NOZORDER | SWP_NOMOVE); -} - -void CProgressListBox::Init() -{ - // set new height of an item - CClientDC dc(this); - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); - int iHeight=MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY); - SetItemHeight(0, m_bShowCaptions ? iHeight+2+9+2 : 2+9+2); -} - -_PROGRESSITEM_* CProgressListBox::GetItemAddress(int iIndex) -{ - if (m_items.GetSize() > iIndex) - return m_items.GetAt(iIndex); - else - { - _PROGRESSITEM_* pItem=new _PROGRESSITEM_; - pItem->m_uiRange=100; - m_items.Add(pItem); - return pItem; - } -} - -void CProgressListBox::UpdateItems(int nLimit, bool bUpdateSize) -{ - // delete items from array - while (m_items.GetSize() > nLimit) - { - delete m_items.GetAt(nLimit); - m_items.RemoveAt(nLimit); - } - - // change count of elements in a listbox - if (GetCount() != m_items.GetSize()) - { - while (GetCount() < m_items.GetSize()) - AddString(""); - - while (GetCount() > m_items.GetSize()) - DeleteString(m_items.GetSize()); - } - - if (bUpdateSize) - { - Invalidate(); - RecalcHeight(); - } -} - -void CProgressListBox::OnPaint() -{ - CPaintDC dc(this); // device context for painting - CRect rcClip; - dc.GetClipBox(&rcClip); - - CMemDC memDC(&dc, &rcClip); - memDC.FillSolidRect(&rcClip, GetSysColor(COLOR_3DFACE)); - - DefWindowProc(WM_PAINT, reinterpret_cast(memDC.m_hDC), 0); -} - -BOOL CProgressListBox::OnEraseBkgnd(CDC*) -{ - return FALSE/*CListBox::OnEraseBkgnd(pDC)*/; -} - -int CProgressListBox::SetCurSel(int nSelect) -{ - int nResult=static_cast(this)->SetCurSel(nSelect); - if (nSelect == -1) - GetParent()->SendMessage(WM_COMMAND, (LBN_SELCANCEL << 16) | GetDlgCtrlID(), reinterpret_cast(this->m_hWnd)); - - return nResult; -} - -void CProgressListBox::OnKillfocus() -{ - SetCurSel(-1); -} - -void CProgressListBox::SetSmoothProgress(bool bSmoothProgress) -{ - m_bSmoothProgress=bSmoothProgress; -} Index: src/ch/ProgressListBox.h =================================================================== diff -u -N --- src/ch/ProgressListBox.h (revision 0) +++ src/ch/ProgressListBox.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,97 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __PROGRESSLISTBOX_H__ +#define __PROGRESSLISTBOX_H__ + +#include "memdc.h" +#include "afxtempl.h" +#include "structs.h" + +///////////////////////////////////////////////////////////////////////////// +// CProgressListBox window +struct _PROGRESSITEM_ +{ + CString m_strText; + + UINT m_uiPos; + UINT m_uiRange; + + COLORREF m_crColor; + + CTask* m_pTask; +}; + +class CProgressListBox : public CListBox +{ +// Construction +public: + CProgressListBox(); + +// Attributes +public: + +// Operations +public: + CArray<_PROGRESSITEM_*, _PROGRESSITEM_*> m_items; + +protected: + bool m_bShowCaptions; + bool m_bSmoothProgress; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CProgressListBox) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + //}}AFX_VIRTUAL + +// Implementation +public: + void SetSmoothProgress(bool bSmoothProgress); + int SetCurSel( int nSelect ); + void Init(); + + void UpdateItems(int nLimit, bool bUpdateSize); // updates items in listbox + void RecalcHeight(); // sets size of a listbox by counting szie of the items + + _PROGRESSITEM_* GetItemAddress(int iIndex); + + void SetShowCaptions(bool bShow=true); + bool GetShowCaptions(); + + virtual ~CProgressListBox(); + + // Generated message map functions +protected: + //{{AFX_MSG(CProgressListBox) + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC*); + afx_msg void OnKillfocus(); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ProgressListBox.h =================================================================== diff -u -N --- ch/ProgressListBox.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ProgressListBox.h (revision 0) @@ -1,97 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PROGRESSLISTBOX_H__ -#define __PROGRESSLISTBOX_H__ - -#include "memdc.h" -#include "afxtempl.h" -#include "structs.h" - -///////////////////////////////////////////////////////////////////////////// -// CProgressListBox window -struct _PROGRESSITEM_ -{ - CString m_strText; - - UINT m_uiPos; - UINT m_uiRange; - - COLORREF m_crColor; - - CTask* m_pTask; -}; - -class CProgressListBox : public CListBox -{ -// Construction -public: - CProgressListBox(); - -// Attributes -public: - -// Operations -public: - CArray<_PROGRESSITEM_*, _PROGRESSITEM_*> m_items; - -protected: - bool m_bShowCaptions; - bool m_bSmoothProgress; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CProgressListBox) - public: - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - //}}AFX_VIRTUAL - -// Implementation -public: - void SetSmoothProgress(bool bSmoothProgress); - int SetCurSel( int nSelect ); - void Init(); - - void UpdateItems(int nLimit, bool bUpdateSize); // updates items in listbox - void RecalcHeight(); // sets size of a listbox by counting szie of the items - - _PROGRESSITEM_* GetItemAddress(int iIndex); - - void SetShowCaptions(bool bShow=true); - bool GetShowCaptions(); - - virtual ~CProgressListBox(); - - // Generated message map functions -protected: - //{{AFX_MSG(CProgressListBox) - afx_msg void OnPaint(); - afx_msg BOOL OnEraseBkgnd(CDC*); - afx_msg void OnKillfocus(); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/PropertyListCtrl.cpp =================================================================== diff -u -N --- src/ch/PropertyListCtrl.cpp (revision 0) +++ src/ch/PropertyListCtrl.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1265 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" +#include "PropertyListCtrl.h" +#include "dialogs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CComboButton +CComboButton::CComboButton() +{ +} + +CComboButton::~CComboButton() +{ + // Delete the objects created + delete m_pBkBrush; + delete m_pBlackBrush; +// delete m_pGrayPen; + delete m_pBkPen; +} + +BEGIN_MESSAGE_MAP(CComboButton, CButton) + //{{AFX_MSG_MAP(CComboButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CComboButton message handlers +BOOL CComboButton::Create( CRect Rect, CWnd* pParent, UINT uID) +{ + // Create the Brushes and Pens + m_pBkBrush = new CBrush( GetSysColor(COLOR_BTNFACE)); + m_pBkPen = new CPen( PS_SOLID, 1, GetSysColor(COLOR_BTNFACE)); +// m_pGrayPen = new CPen( PS_SOLID, 1, RGB(128,128,128)); + m_pBlackBrush = new CBrush(GetSysColor(COLOR_BTNTEXT)); + + // Create the CButton + if( !CButton::Create("", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, Rect, pParent, uID )) + return FALSE; + + return 0; +} + +///////////////////////////////////////////////////////////////////////////// +// Draw the Button +void CComboButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct ) +{ + CDC* prDC = CDC::FromHandle(lpDrawItemStruct->hDC); + CRect ButtonRect = lpDrawItemStruct->rcItem; + CMemDC dc(prDC, ButtonRect); + CMemDC *pDC=&dc; + + // Fill the Background + CBrush* pOldBrush = (CBrush*)pDC->SelectObject( m_pBkBrush ); + CPen* pOldPen = (CPen*)pDC->SelectObject(m_pBkPen); + pDC->Rectangle(ButtonRect); + + // Draw the Correct Border + if(lpDrawItemStruct->itemState & ODS_SELECTED) + { + pDC->DrawEdge(ButtonRect, EDGE_SUNKEN, BF_RECT); + ButtonRect.left++; + ButtonRect.right++; + ButtonRect.bottom++; + ButtonRect.top++; + } + else + pDC->DrawEdge(ButtonRect, EDGE_RAISED, BF_RECT); + + // Draw the Triangle + ButtonRect.left += 3; + ButtonRect.right -= 4; + ButtonRect.top += 5; + ButtonRect.bottom -= 5; + DrawTriangle(pDC, ButtonRect); + + // Return what was used + pDC->SelectObject( pOldPen ); + pDC->SelectObject( pOldBrush ); +} + +void CComboButton::DrawTriangle(CDC* pDC, CRect Rect) +{ + POINT ptArray[3]; + + // Figure out the Top left + ptArray[0].x = Rect.left; + ptArray[0].y = Rect.top; + ptArray[1].x = Rect.right; + ptArray[1].y = Rect.top; + ptArray[2].x = Rect.right - (Rect.Width() / 2); + ptArray[2].y = Rect.bottom; + + // Select the Brush and Draw the triangle + /*CBrush* pOldBrush = (CBrush*)*/pDC->SelectObject(m_pBlackBrush); + pDC->Polygon(ptArray, 3 ); +} +void CComboButton::MeasureItem(LPMEASUREITEMSTRUCT/* lpMeasureItemStruct*/) +{ +} + +///////////////////////////////////////////////////////////////////////////// +// CPropertyListCtrl +CPropertyListCtrl::CPropertyListCtrl() +{ + m_nWidestItem = 0; + m_bDeleteFont = TRUE; + m_bBoldSelection = TRUE; + + m_pBkBrush = NULL; + m_pBkPropertyBrush = NULL; + m_pEditWnd = NULL; + m_pFontButton = NULL; + m_pPathButton = NULL; + m_pDirButton=NULL; + m_pCustomButton=NULL; + m_pComboButton = NULL; + m_pListBox = NULL; + m_pBkHighlightBrush = NULL; + m_pSelectedFont = NULL; + m_pBorderPen = NULL; + m_pCurItem = NULL; + m_pCurFont = NULL; + m_pCurDrawItem = NULL; + m_pTextFont = NULL; + m_pSelectedFont = NULL; + m_pBorderPen = NULL; + + m_crBorderColor = RGB(192,192,192); + m_crBkColor = GetSysColor(COLOR_WINDOW); + m_crPropertyBkColor = m_crBkColor; + m_crTextColor = GetSysColor(COLOR_WINDOWTEXT); + m_crPropertyTextColor = m_crTextColor; + m_crHighlightColor = GetSysColor(COLOR_HIGHLIGHT); + m_crTextHighlightColor = GetSysColor(COLOR_HIGHLIGHTTEXT); +} + +CPropertyListCtrl::~CPropertyListCtrl() +{ + if(m_bDeleteFont) delete m_pTextFont; + + if(m_pEditWnd) delete m_pEditWnd; + if(m_pFontButton) delete m_pFontButton; + if(m_pPathButton) delete m_pPathButton; + if (m_pDirButton) delete m_pDirButton; + if (m_pCustomButton) + delete m_pCustomButton; + if(m_pListBox) delete m_pListBox; + if(m_pComboButton) delete m_pComboButton; + + if(m_pBkBrush) delete m_pBkBrush; + if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; + if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; + if(m_pSelectedFont) delete m_pSelectedFont; + if(m_pBorderPen) delete m_pBorderPen; + + // Clear items + Reset(); +} + +void CPropertyListCtrl::Reinit() +{ + ResetContent(); + + // Clean up + if(m_bDeleteFont) delete m_pTextFont; + + if(m_pEditWnd) delete m_pEditWnd; + if(m_pFontButton) delete m_pFontButton; + if(m_pPathButton) delete m_pPathButton; + if (m_pDirButton) delete m_pDirButton; + if (m_pCustomButton) + delete m_pCustomButton; + if(m_pListBox) delete m_pListBox; + if(m_pComboButton) delete m_pComboButton; + + if(m_pBkBrush) delete m_pBkBrush; + if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; + if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; + if(m_pSelectedFont) delete m_pSelectedFont; + if(m_pBorderPen) delete m_pBorderPen; + + // Clear items + Reset(); + + m_nWidestItem = 0; + m_bDeleteFont = TRUE; + m_bBoldSelection = TRUE; + + m_pBkBrush = NULL; + m_pBkPropertyBrush = NULL; + m_pEditWnd = NULL; + m_pFontButton = NULL; + m_pPathButton = NULL; + m_pDirButton=NULL; + m_pCustomButton=NULL; + m_pComboButton = NULL; + m_pListBox = NULL; + m_pBkHighlightBrush = NULL; + m_pSelectedFont = NULL; + m_pBorderPen = NULL; + m_pCurItem = NULL; + m_pCurFont = NULL; + m_pCurDrawItem = NULL; + m_pTextFont = NULL; + m_pSelectedFont = NULL; + m_pBorderPen = NULL; + + m_crBorderColor = RGB(192,192,192); + m_crBkColor = GetSysColor(COLOR_WINDOW); + m_crPropertyBkColor = m_crBkColor; + m_crTextColor = GetSysColor(COLOR_WINDOWTEXT); + m_crPropertyTextColor = m_crTextColor; + m_crHighlightColor = GetSysColor(COLOR_HIGHLIGHT); + m_crTextHighlightColor = GetSysColor(COLOR_HIGHLIGHTTEXT); + + Init(); +} + +void CPropertyListCtrl::Reset() +{ + // Clear the List + POSITION Pos = m_Items.GetHeadPosition(); + while(Pos) + { + m_pCurItem = (PROPERTYITEM*)m_Items.GetNext(Pos); + if(m_pCurItem->pBrush) + delete m_pCurItem->pBrush; + delete m_pCurItem; + } + m_Items.RemoveAll(); +} + +BEGIN_MESSAGE_MAP(CPropertyListCtrl, CListBox) + //{{AFX_MSG_MAP(CPropertyListCtrl) + ON_WM_CREATE() + ON_WM_CTLCOLOR_REFLECT() + ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange) + ON_WM_CTLCOLOR() + ON_CONTROL_REFLECT(LBN_DBLCLK, OnDblclk) + ON_EN_KILLFOCUS( ID_PROPERTY_TEXT, OnEditLostFocus ) + ON_EN_CHANGE( ID_PROPERTY_TEXT, OnEditChange ) + ON_BN_CLICKED( ID_PROPERTY_FONT, OnFontPropertyClick ) + ON_BN_CLICKED( ID_PROPERTY_PATH, OnPathPropertyClick ) + ON_BN_CLICKED( ID_PROPERTY_DIR, OnDirPropertyClick ) + ON_BN_CLICKED( ID_PROPERTY_CUSTOM, OnCustomPropertyClick ) + ON_BN_CLICKED( ID_PROPERTY_COMBO_BTN, OnComboBoxClick ) + ON_LBN_SELCHANGE(ID_PROPERTY_COMBO_LIST, OnSelChange) + ON_LBN_KILLFOCUS(ID_PROPERTY_COMBO_LIST, OnListboxLostFocus) + ON_WM_LBUTTONDOWN() + ON_WM_VSCROLL() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPropertyListCtrl message handlers + +HBRUSH CPropertyListCtrl::CtlColor(CDC* /*pDC*/, UINT/* nCtlColor*/) +{ + return (HBRUSH)m_pBkBrush->GetSafeHandle(); +} + +HBRUSH CPropertyListCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) +{ + HBRUSH hbr = CListBox::OnCtlColor(pDC, pWnd, nCtlColor); + +/* if( nCtlColor == CTLCOLOR_EDIT) + { + pDC->SetBkColor(m_crPropertyBkColor); + pDC->SetTextColor(m_crPropertyTextColor); + }*/ + pDC->SetBkColor(m_crPropertyBkColor); + pDC->SetTextColor(m_crPropertyTextColor); + + if(m_pBkPropertyBrush) + return (HBRUSH)(m_pBkPropertyBrush->GetSafeHandle() ); + else + return hbr; +} +void CPropertyListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + // Make sure its a valid item + if( lpDrawItemStruct->itemID == LB_ERR ) + return; + + // Obtain the text for this item + m_csText.Empty(); + GetText(lpDrawItemStruct->itemID, m_csText); + + // Get the drawing DC + CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); + + // Set the Current member we are drawing + m_pCurDrawItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(lpDrawItemStruct->itemID)); + + // Obtain the Item Rect + CRect ItemRect(lpDrawItemStruct->rcItem); + + // Draw This item + DrawItem( pDC, ItemRect, lpDrawItemStruct->itemState & ODS_SELECTED); +} +void CPropertyListCtrl::MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/) +{ +} +void CPropertyListCtrl::OnDblclk() +{ + // Get the Course Position + POINT pPoint; + GetCursorPos(&pPoint); + + // Convert this rect to coordinates of the desktop + CRect TempRect = m_CurRect; + MapWindowPoints(GetDesktopWindow(), TempRect); + + // Display the Correct Control + switch(m_pCurItem->nType) + { + case ID_PROPERTY_BOOL: + // Is the Mouse in this area + if(TempRect.PtInRect(pPoint)) + { + // Reverse the Selection + m_pCurItem->nPropertySelected = !m_pCurItem->nPropertySelected; + + // Redraw this item + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + } + break; + + case ID_PROPERTY_FONT: + m_pFontButton->SetFocus(); + OnFontPropertyClick(); + break; + + case ID_PROPERTY_PATH: + m_pPathButton->SetFocus(); + OnPathPropertyClick(); + break; + + case ID_PROPERTY_DIR: + m_pDirButton->SetFocus(); + OnDirPropertyClick(); + break; + + case ID_PROPERTY_CUSTOM: + m_pCustomButton->SetFocus(); + OnCustomPropertyClick(); + break; + + case ID_PROPERTY_COLOR: + LOGBRUSH lb; + m_pCurItem->pBrush->GetLogBrush(&lb); + CColorDialog ColorDialog(lb.lbColor, 0, GetParent()); + if(ColorDialog.DoModal() != IDOK) + return; + + // Destroy the Brush and create a new one + if(m_pCurItem->pBrush) delete m_pCurItem->pBrush; + m_pCurItem->pBrush = new CBrush(ColorDialog.GetColor()); + + // Redraw the Widow (Theres probably a better way) + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + break; + } + +} +void CPropertyListCtrl::OnSelchange() +{ + HideControls(); + + // Display the Correct Control + CRect TempRect = m_CurRect; + TempRect.InflateRect(-1,-1); + switch(m_pCurItem->nType) + { + case ID_PROPERTY_TEXT: + TempRect.left += 1; + m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(0)); + m_pEditWnd->MoveWindow(TempRect); + m_pEditWnd->ShowWindow(SW_SHOWNORMAL); +// m_pEditWnd->SetFocus(); +// m_pEditWnd->SetSel(0,-1); + break; + + case ID_PROPERTY_FONT: + TempRect.left = TempRect.right - 17; + m_pFontButton->MoveWindow(TempRect); + m_pFontButton->ShowWindow(SW_SHOWNORMAL); + break; + + case ID_PROPERTY_PATH: + TempRect.left = TempRect.right - 17; + m_pPathButton->MoveWindow(TempRect); + m_pPathButton->ShowWindow(SW_SHOWNORMAL); + break; + + case ID_PROPERTY_DIR: + TempRect.left = TempRect.right - 17; + m_pDirButton->MoveWindow(TempRect); + m_pDirButton->ShowWindow(SW_SHOWNORMAL); + break; + + case ID_PROPERTY_CUSTOM: + TempRect.left = TempRect.right - 17; + m_pCustomButton->MoveWindow(TempRect); + m_pCustomButton->ShowWindow(SW_SHOWNORMAL); + break; + + case ID_PROPERTY_COMBO_LIST: + TempRect.left = TempRect.right - 17; + m_pComboButton->MoveWindow(TempRect); + m_pComboButton->ShowWindow(SW_SHOWNORMAL); + + TempRect.left = m_CurRect.left + 2; + TempRect.right -= 17; + if(m_pCurItem->bComboEditable) + { + m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(m_pCurItem->nPropertySelected)); +// m_pEditWnd->SetFocus(); +// m_pEditWnd->SetSel(0,-1); + m_pEditWnd->MoveWindow(TempRect); + m_pEditWnd->ShowWindow(SW_SHOWNORMAL); + } + + // Move the Lsit box +// TempRect.left--; + TempRect.right += 18; + TempRect.top = TempRect.bottom; + + // Set the Bottom Height + if(m_pCurItem->csProperties.GetSize() > 5) + TempRect.bottom += GetItemHeight(0) * 5; + else + TempRect.bottom += GetItemHeight(0) * m_pCurItem->csProperties.GetSize(); + + // pobierz wsp�rz�dne tej kontrolki w stosunku do okna parenta +// CRect rcThisParent; +// GetWindowRect(&rcThisParent); +// GetParent()->ScreenToClient(&rcThisParent); + +// TempRect.OffsetRect(rcThisParent.left+2, rcThisParent.top+2); + m_pListBox->MoveWindow(TempRect); + + // Force the Expansion + OnComboBoxClick(); + break; + + } +} +void CPropertyListCtrl::OnEditLostFocus() +{ + // Get the text + CString csText; + m_pEditWnd->GetWindowText(csText); + + // Is the current item a text item + if(m_pCurItem->nType == ID_PROPERTY_TEXT) + { + // Did the text change + if(!m_bChanged) + return; + + m_pCurItem->csProperties.SetAt(0, csText); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + } + else + { + // Get the window that has the focus now + if(GetFocus() == m_pComboButton || !m_pListBox->GetCount()) + return; + + // Did the text change + if(!m_bChanged) + return; + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + + // Look for this text + m_bChanged = FALSE; + if( m_pListBox->FindStringExact(-1,csText) != LB_ERR) + return; + + // Add it and select it + m_pCurItem->nPropertySelected = m_pCurItem->csProperties.Add(csText); + } +} +void CPropertyListCtrl::OnEditChange() +{ + m_bChanged = TRUE; +} +void CPropertyListCtrl::OnFontPropertyClick() +{ + // Show the Dialog + CFontDialog FontDialog(&m_pCurItem->LogFont); + if(FontDialog.DoModal() != IDOK) + return; + + // Set the Font data + FontDialog.GetCurrentFont(&m_pCurItem->LogFont); + + // Redraw + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); +} +void CPropertyListCtrl::OnPathPropertyClick() +{ + // Look for a ending tag + CString csExt = "*"; + CString csPath = m_pCurItem->csProperties.GetAt(0); + int nPos = csPath.ReverseFind('.'); + if(nPos) + csExt = csPath.Right(csPath.GetLength() - nPos - 1); + + // Show the Dialog + CFileDialog QuizFileDlg(TRUE, "*", "*." + csExt, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, m_pCurItem->csProperties.GetAt(1) ); + QuizFileDlg.m_ofn.lpstrInitialDir = csPath; + if(QuizFileDlg.DoModal() != IDOK) + return; + + // Obtain the Path they selected + m_pCurItem->csProperties.SetAt(0, QuizFileDlg.GetPathName()); + + // Redraw + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); +} + +void CPropertyListCtrl::OnDirPropertyClick() +{ + CString strPath; + if (BrowseForFolder(m_pCurItem->csProperties.GetAt(1), &strPath)) + { + m_pCurItem->csProperties.SetAt(0, strPath); + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + } +} + +void CPropertyListCtrl::OnCustomPropertyClick() +{ + m_pCurItem->pfnCallback(m_pCurItem->lpParam, m_pCurItem->iParam, &m_Items, GetCurSel()); + RedrawWindow(); +} + +void CPropertyListCtrl::OnComboBoxClick() +{ + // Add the items + m_pListBox->ResetContent(); + + // Loop for all items + for( int nItem = 0; nItem < m_pCurItem->csProperties.GetSize(); nItem++) + m_pListBox->AddString(m_pCurItem->csProperties.GetAt(nItem)); + + // Select the correct item + m_pListBox->SetCurSel(m_pCurItem->nPropertySelected); + m_pListBox->SetTopIndex(m_pCurItem->nPropertySelected); + + // Show the List box + m_pListBox->ShowWindow(SW_NORMAL); +} +void CPropertyListCtrl::OnSelChange() +{ + // Set the new current item + m_pCurItem->nPropertySelected = m_pListBox->GetCurSel(); + + // Hide the Windows + m_pListBox->ShowWindow(SW_HIDE); + + if(m_pCurItem->bComboEditable) + m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(m_pCurItem->nPropertySelected)); + else + RedrawWindow(); + + // Send the message that a property has changed + GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); + m_pComboButton->SetFocus(); +} +void CPropertyListCtrl::OnListboxLostFocus() +{ + m_pListBox->ShowWindow(SW_HIDE); +} +void CPropertyListCtrl::OnLButtonDown(UINT nFlags, CPoint point) +{ + // is there an item at this point + BOOL bOutside; + /*UINT uItem =*/ ItemFromPoint(point, bOutside); + + // Is this outside the client + if(bOutside) + HideControls(); + + CListBox::OnLButtonDown(nFlags, point); +} +void CPropertyListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // Hide the Controls + HideControls(); + + CListBox::OnVScroll(nSBCode, nPos, pScrollBar); +} + +///////////////////////////////////////////////////////////////////////////// +// GUI User Functions +///////////////////////////////////////////////////////////////////////////// + +void CPropertyListCtrl::Init() +{ + // utw�rz czcionk� bazowan� na czcionce okna + LOGFONT lf; + GetFont()->GetLogFont(&lf); + + if(m_pTextFont) delete m_pTextFont; + if(m_pSelectedFont) delete m_pSelectedFont; + + m_pTextFont=new CFont(); + m_pTextFont->CreateFontIndirect(&lf); + + lf.lfWeight=FW_BOLD; + m_pSelectedFont=new CFont(); + m_pSelectedFont->CreateFontIndirect(&lf); + + m_bDeleteFont=TRUE; + + // Create the Border Pen + m_pBorderPen = new CPen(PS_SOLID, 1, m_crBorderColor); + + // Create the Selected Background brush + m_pBkHighlightBrush = new CBrush(m_crHighlightColor); + m_pBkBrush = new CBrush(m_crBkColor); + + // Set the row height - read text height + CClientDC dc(this); + dc.SelectObject(&m_pSelectedFont); + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); + + SetItemHeight(-1, MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY) ); +} + +void CPropertyListCtrl::SetFont(CFont* pFont) +{ + // Delete our font and set our font to theirs + if(m_pTextFont) delete m_pTextFont; + if(m_pSelectedFont) delete m_pSelectedFont; + m_pTextFont = pFont; + m_bDeleteFont = FALSE; + + // Figure out the text size + LOGFONT lpLogFont; + m_pTextFont->GetLogFont(&lpLogFont); + + // Set the font and redraw + CWnd::SetFont(m_pTextFont, FALSE); + + // Create the heading font with the bold attribute + lpLogFont.lfWeight = FW_BOLD; + m_pSelectedFont = new CFont(); + m_pSelectedFont->CreateFontIndirect(&lpLogFont); + + // Set the Row height + CClientDC dc(this); + dc.SelectObject(&m_pSelectedFont); + TEXTMETRIC tm; + dc.GetTextMetrics(&tm); + + SetItemHeight(-1, MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY) ); + + // ** IMPLEMENT LATER ?? ** + // Recalculate the Width Position +} + +void CPropertyListCtrl::SetLineStyle(COLORREF crColor, int nStyle) +{ + // Delete the old Pen + if(m_pBorderPen) delete m_pBorderPen; + + // Create the brush + m_pBorderPen = new CPen(nStyle, 1, crColor); + m_crBorderColor = crColor; +} +void CPropertyListCtrl::SetBkColor(COLORREF crColor) +{ + // Delete the old brush + if(m_pBkBrush) delete m_pBkBrush; + + // Create the brush + m_pBkBrush = new CBrush(crColor); + m_crBkColor = crColor; +} +void CPropertyListCtrl::SetPropertyBkColor(COLORREF crColor) +{ + // Delete the old brush + if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; + + // Create the brush + m_pBkPropertyBrush = new CBrush(crColor); + m_crPropertyBkColor = crColor; +} + +void CPropertyListCtrl::SetHighlightColor(COLORREF crColor) +{ + // Delete the old brush + if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; + + // Create the brush + m_pBkHighlightBrush = new CBrush(crColor); + m_crHighlightColor = crColor; +} + +///////////////////////////////////////////////////////////////////////////// +// Add Properties Functions +///////////////////////////////////////////////////////////////////////////// +BOOL CPropertyListCtrl::AddString(CString csText) +{ + // Call our function (assume its a text Item) + return AddString(csText, ID_PROPERTY_STATIC, _T("")); +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString) +{ + return AddString(GetResManager()->LoadString(nIDString)); +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, void (*pfnCallback)(LPVOID, int, CPtrList*, int), LPVOID lpParam, int iParam, int nPropertySelected, int nAlignment, BOOL bComboEditable) +{ + // Is this a valid Control type + if(nType > ID_PROPERTY_COMBO_LIST) + return FALSE; + + // load string + const TCHAR *pszText=GetResManager()->LoadString(nIDString); + + // Create a new Structure to hold it + PROPERTYITEM* pNewItem = new PROPERTYITEM; + pNewItem->nType = nType; + pNewItem->nAlignment = nAlignment; + pNewItem->pBrush = NULL; + pNewItem->bComboEditable = bComboEditable; + pNewItem->pfnCallback=pfnCallback; + pNewItem->iParam=iParam; + pNewItem->lpParam=lpParam; + + // Calculate the Width of the string based on the font set + CDC* pDC = GetDC(); + pDC->SelectObject(m_pSelectedFont); + CSize Size = pDC->GetTextExtent(pszText); + if(Size.cx + 10 > m_nWidestItem) + m_nWidestItem = Size.cx + 10; + ReleaseDC(pDC); + pNewItem->nWidth = Size.cx; + pNewItem->nPropertySelected = nPropertySelected; + + // Set Property + if(!SetProperty(pNewItem, nType, csData)) + { + delete pNewItem; + return FALSE; + } + + // Is the item set bigger than the number of properties + if(pNewItem->nPropertySelected > pNewItem->csProperties.GetSize()) + { + delete pNewItem; + return FALSE; + } + + // Add to the list + m_Items.AddTail(pNewItem); + + // Add the string to the list box + /*int nPos =*/ CListBox::AddString(pszText); + + // Create the Control if Needed + CreateControl(nType); + return TRUE; +} + +BOOL CPropertyListCtrl::AddString(CString csText, int nType, CString csData, int nPropertySelected, int nAlignment, BOOL bComboEditable) +{ + // Is this a valid Control type + if(nType > ID_PROPERTY_COMBO_LIST) + return FALSE; + + // Create a new Structure to hold it + PROPERTYITEM* pNewItem = new PROPERTYITEM; + pNewItem->nType = nType; + pNewItem->nAlignment = nAlignment; + pNewItem->pBrush = NULL; + pNewItem->bComboEditable = bComboEditable; + + // Calculate the Width of the string based on the font set + CDC* pDC = GetDC(); + pDC->SelectObject(m_pSelectedFont); + CSize Size = pDC->GetTextExtent(csText); + if(Size.cx + 10 > m_nWidestItem) + m_nWidestItem = Size.cx + 10; + ReleaseDC(pDC); + pNewItem->nWidth = Size.cx; + pNewItem->nPropertySelected = nPropertySelected; + + // Set Property + if(!SetProperty(pNewItem, nType, csData)) + { + delete pNewItem; + return FALSE; + } + + // Is the item set bigger than the number of properties + if(pNewItem->nPropertySelected > pNewItem->csProperties.GetSize()) + { + delete pNewItem; + return FALSE; + } + + // Add to the list + m_Items.AddTail(pNewItem); + + // Add the string to the list box + /*int nPos =*/ CListBox::AddString(csText); + + // Create the Control if Needed + CreateControl(nType); + return TRUE; +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, UINT nIDData, int nPropertySelected, int nAlignment, BOOL bComboEditable) +{ + return AddString(GetResManager()->LoadString(nIDString), nType, GetResManager()->LoadString(nIDData), nPropertySelected, nAlignment, bComboEditable); +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, int nPropertySelected, int nAlignment, BOOL bComboEditable) +{ + return AddString(GetResManager()->LoadString(nIDString), nType, csData, nPropertySelected, nAlignment, bComboEditable); +} + +BOOL CPropertyListCtrl::AddString(CString csText, COLORREF crColor, int nAlignment) +{ + // Create a new brush based on this color + m_pCurBrush = new CBrush(crColor); + + // Call the other functions + return AddString(csText, ID_PROPERTY_COLOR, _T(""), 0, nAlignment); +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString, COLORREF crColor, int nAlignment) +{ + return AddString(GetResManager()->LoadString(nIDString), crColor, nAlignment); +} + +BOOL CPropertyListCtrl::AddString(CString csText, CFont* pFont, int nAlignment) +{ + // Safe the Font + m_pCurFont = pFont; + + // Call the other functions + return AddString(csText, ID_PROPERTY_FONT, _T(""), 0, nAlignment); +} + +BOOL CPropertyListCtrl::AddString(UINT nIDString, CFont* pFont, int nAlignment) +{ + return AddString(GetResManager()->LoadString(nIDString), pFont, nAlignment); +} + +///////////////////////////////////////////////////////////////////////////// +// Helper Functions +///////////////////////////////////////////////////////////////////////////// +void CPropertyListCtrl::DrawItem(CDC* pDC, CRect ItemRect, BOOL bSelected) +{ + if (m_pCurDrawItem->nType != ID_PROPERTY_STATIC) + { + ///////////////////////////////////////// + // Paint the Background rectangle (Property Value) + if(m_pCurDrawItem->nType == ID_PROPERTY_COLOR) + pDC->SelectObject(m_pCurDrawItem->pBrush); + else + pDC->SelectObject(m_pBkBrush); + pDC->SelectObject(m_pBorderPen); + + // Draw the Rectangle + ItemRect.left = m_nWidestItem - 1; + ItemRect.top--; + ItemRect.right++; + pDC->Rectangle(ItemRect); + CRect OrginalRect = ItemRect; + + ///////////////////////////////////////// + // Draw the Property Text + pDC->SetBkMode(TRANSPARENT); + pDC->SelectObject(m_pBkBrush); + pDC->SelectObject(m_pTextFont); + pDC->SetTextColor(m_crTextColor); + DrawPropertyText(pDC, ItemRect); + + ///////////////////////////////////////// + // Paint the Background rectangle (Property Name) + if( bSelected ) + pDC->SelectObject(m_pBkHighlightBrush); + + // Draw the Rectangle + ItemRect.right = m_nWidestItem; + ItemRect.left = -1; + pDC->Rectangle(ItemRect); + + ///////////////////////////////////////// + // Paint the Property name Text + // Is this item selected? + if( bSelected ) + { + if(m_bBoldSelection) pDC->SelectObject(m_pSelectedFont); + pDC->SetTextColor(m_crTextHighlightColor); + m_pCurItem = m_pCurDrawItem; + m_CurRect = OrginalRect; + } + + // Draw the Text + ItemRect.left += 6; + ItemRect.right -= 5; + pDC->DrawText( m_csText, m_csText.GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|m_pCurDrawItem->nAlignment); + } + else + { + ///////////////////////////////////////// + // Paint the Background rectangle (Property Value) + pDC->SelectObject(m_pBkHighlightBrush); + pDC->SelectObject(m_pBorderPen); + pDC->SelectObject(m_pSelectedFont); + + // Draw the Rectangle + pDC->Rectangle(ItemRect); + CRect OrginalRect = ItemRect; + + ///////////////////////////////////////// + // Draw + pDC->SetBkMode(TRANSPARENT); + pDC->SetTextColor(m_crTextHighlightColor); + if (bSelected) + { + m_pCurItem = m_pCurDrawItem; + m_CurRect = OrginalRect; + } + + // Draw the Text + pDC->DrawText( m_csText, m_csText.GetLength(), ItemRect, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER); + } +} + +void CPropertyListCtrl::DrawPropertyText(CDC* pDC, CRect ItemRect) +{ + ItemRect.left += 5; + switch(m_pCurDrawItem->nType) + { + case ID_PROPERTY_BOOL: + case ID_PROPERTY_COMBO_LIST: + pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(m_pCurDrawItem->nPropertySelected), m_pCurDrawItem->csProperties.GetAt(m_pCurDrawItem->nPropertySelected).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); + break; + + case ID_PROPERTY_TEXT: + case ID_PROPERTY_PATH: + case ID_PROPERTY_DIR: + case ID_PROPERTY_CUSTOM: + pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(0), m_pCurDrawItem->csProperties.GetAt(0).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); + break; + case ID_PROPERTY_STATIC: + pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(0), m_pCurDrawItem->csProperties.GetAt(0).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); + break; + + case ID_PROPERTY_FONT: + if(m_pCurDrawItem->LogFont.lfHeight) + pDC->DrawText( m_pCurDrawItem->LogFont.lfFaceName, strlen(m_pCurDrawItem->LogFont.lfFaceName), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); + break; + } +} + +void CPropertyListCtrl::CreateControl(int nType) +{ + switch(nType) + { + // Edit Window + case ID_PROPERTY_TEXT: + if(!m_pEditWnd) + { + m_pEditWnd = new CEdit(); + m_pEditWnd->Create(WS_CHILD|ES_AUTOHSCROLL|ES_LEFT, CRect(0,0,100,100), this, ID_PROPERTY_TEXT); + m_pEditWnd->SetFont(m_pTextFont); + } + break; + + // Font Button + case ID_PROPERTY_FONT: + if(!m_pFontButton) + { + m_pFontButton = new CButton(); + m_pFontButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_FONT); + m_pFontButton->SetFont(m_pTextFont); + } + break; + + case ID_PROPERTY_PATH: + if(!m_pPathButton) + { + m_pPathButton = new CButton(); + m_pPathButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_PATH); + m_pPathButton->SetFont(m_pTextFont); + } + break; + + case ID_PROPERTY_DIR: + if(!m_pDirButton) + { + m_pDirButton = new CButton(); + m_pDirButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_DIR); + m_pDirButton->SetFont(m_pTextFont); + } + break; + + case ID_PROPERTY_CUSTOM: + if(!m_pCustomButton) + { + m_pCustomButton = new CButton(); + m_pCustomButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_CUSTOM); + m_pCustomButton->SetFont(m_pTextFont); + } + break; + + case ID_PROPERTY_COMBO_LIST: + if(!m_pEditWnd) + { + m_pEditWnd = new CEdit(); + m_pEditWnd->Create(WS_CHILD|ES_AUTOHSCROLL|ES_LEFT, CRect(0,0,100,100), this, ID_PROPERTY_TEXT); + m_pEditWnd->SetFont(m_pTextFont); + } + if(!m_pListBox) + { + m_pListBox = new CListBox(); + m_pListBox->Create(WS_CHILD|WS_BORDER|LBS_NOTIFY|WS_VSCROLL|LBS_HASSTRINGS, CRect(0,0,100,100), this, ID_PROPERTY_COMBO_LIST); + m_pListBox->SetFont(m_pTextFont); + + m_pComboButton = new CComboButton(); + m_pComboButton->Create(CRect(0,0,0,0), this, ID_PROPERTY_COMBO_BTN ); + } + break; + } +} + +BOOL CPropertyListCtrl::SetProperty(PROPERTYITEM* pPropertyItem, int nType, CString csData) +{ + switch(nType) + { + case ID_PROPERTY_BOOL: + case ID_PROPERTY_PATH: + case ID_PROPERTY_DIR: + ParseProperties(pPropertyItem, csData); + + // Is the item selected more than items in the array? + if(pPropertyItem->csProperties.GetSize() != 2 ) + return FALSE; + break; + + case ID_PROPERTY_TEXT: + case ID_PROPERTY_STATIC: + case ID_PROPERTY_CUSTOM: + pPropertyItem->csProperties.Add(csData); + break; + + case ID_PROPERTY_FONT: + memset(&pPropertyItem->LogFont, 0, sizeof(pPropertyItem->LogFont)); + if(m_pCurFont) + { + m_pCurFont->GetLogFont(&pPropertyItem->LogFont); + m_pCurFont = NULL; + } + break; + + case ID_PROPERTY_COLOR: + pPropertyItem->pBrush = m_pCurBrush; + break; + + case ID_PROPERTY_COMBO_LIST: + ParseProperties(pPropertyItem, csData); + break; + + } + + return TRUE; +} + +void CPropertyListCtrl::ParseProperties(PROPERTYITEM* pPropertyItem, CString csData) +{ + // Parse the Items + char* pText = csData.GetBuffer( csData.GetLength() ); + char* pWord; + char Separations[] = "!"; + + // Establish string and get the first token: + pWord = strtok( pText, Separations); + while( pWord != NULL ) + { + // Add this to the Array + pPropertyItem->csProperties.Add(pWord); + + // Get next token + pWord = strtok( NULL, Separations ); + } + + // Release the buffer + csData.ReleaseBuffer(); +} + +void CPropertyListCtrl::HideControls() +{ + // Hide the controls + if(m_pEditWnd) m_pEditWnd->ShowWindow(SW_HIDE); + if(m_pFontButton) m_pFontButton->ShowWindow(SW_HIDE); + if(m_pPathButton) m_pPathButton->ShowWindow(SW_HIDE); + if (m_pDirButton) m_pDirButton->ShowWindow(SW_HIDE); + if (m_pCustomButton) + m_pCustomButton->ShowWindow(SW_HIDE); + if(m_pListBox) m_pListBox->ShowWindow(SW_HIDE); + if(m_pComboButton) m_pComboButton->ShowWindow(SW_HIDE); +} + +///////////////////////////////////////////////////////////////////////////// +// Get Properties Functions +///////////////////////////////////////////////////////////////////////////// +bool CPropertyListCtrl::GetProperty(int nItem, CString* pText) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + if(pItem->nType != ID_PROPERTY_TEXT && pItem->nType != ID_PROPERTY_PATH && pItem->nType != ID_PROPERTY_DIR && pItem->nType != ID_PROPERTY_STATIC && pItem->nType != ID_PROPERTY_CUSTOM) + return false; + + // Copy the item + *pText = pItem->csProperties.GetAt(0); + return true; +} +bool CPropertyListCtrl::GetProperty(int nItem, bool* bValue) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + if(pItem->nType != ID_PROPERTY_BOOL) + return false; + + // Copy the item + *bValue = pItem->nPropertySelected != 0; + return true; +} +bool CPropertyListCtrl::GetProperty(int nItem, COLORREF* crColor) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + if(pItem->nType != ID_PROPERTY_COLOR) + return false; + + // Copy the item + LOGBRUSH LogBrush; + pItem->pBrush->GetLogBrush(&LogBrush); + *crColor = LogBrush.lbColor; + return true; +} +bool CPropertyListCtrl::GetProperty(int nItem, LOGFONT* LogFont) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + if(pItem->nType != ID_PROPERTY_FONT) + return false; + + // Copy the item + *LogFont = pItem->LogFont; + return true; +} +bool CPropertyListCtrl::GetProperty(int nItem, CStringArray* pArray, int* /*SelectedItem*/) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + if(pItem->nType != ID_PROPERTY_COMBO_LIST) + return false; + + // I do NOT want to send them a pointer to my array so I loop through and copy the item to thiers + for( int nString = 0; nString < pItem->csProperties.GetSize(); nString++) + pArray->Add(pItem->csProperties.GetAt(nString)); + return true; +} +bool CPropertyListCtrl::GetProperty(int nItem, int* SelectedItem, CString* pText) +{ + // is the item to high + if(nItem + 1 > GetCount()) + return false; + + // Make sure this item is the correct type + PROPERTYITEM* pItem; + pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); + + // Copy the item + *SelectedItem = pItem->nPropertySelected; + + // Do they want the text + if(pText != NULL && pItem->nType == ID_PROPERTY_COMBO_LIST) + *pText = pItem->csProperties.GetAt(pItem->nPropertySelected); + return true; +} Index: ch/PropertyListCtrl.cpp =================================================================== diff -u -N --- ch/PropertyListCtrl.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/PropertyListCtrl.cpp (revision 0) @@ -1,1265 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" -#include "PropertyListCtrl.h" -#include "dialogs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CComboButton -CComboButton::CComboButton() -{ -} - -CComboButton::~CComboButton() -{ - // Delete the objects created - delete m_pBkBrush; - delete m_pBlackBrush; -// delete m_pGrayPen; - delete m_pBkPen; -} - -BEGIN_MESSAGE_MAP(CComboButton, CButton) - //{{AFX_MSG_MAP(CComboButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CComboButton message handlers -BOOL CComboButton::Create( CRect Rect, CWnd* pParent, UINT uID) -{ - // Create the Brushes and Pens - m_pBkBrush = new CBrush( GetSysColor(COLOR_BTNFACE)); - m_pBkPen = new CPen( PS_SOLID, 1, GetSysColor(COLOR_BTNFACE)); -// m_pGrayPen = new CPen( PS_SOLID, 1, RGB(128,128,128)); - m_pBlackBrush = new CBrush(GetSysColor(COLOR_BTNTEXT)); - - // Create the CButton - if( !CButton::Create("", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, Rect, pParent, uID )) - return FALSE; - - return 0; -} - -///////////////////////////////////////////////////////////////////////////// -// Draw the Button -void CComboButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct ) -{ - CDC* prDC = CDC::FromHandle(lpDrawItemStruct->hDC); - CRect ButtonRect = lpDrawItemStruct->rcItem; - CMemDC dc(prDC, ButtonRect); - CMemDC *pDC=&dc; - - // Fill the Background - CBrush* pOldBrush = (CBrush*)pDC->SelectObject( m_pBkBrush ); - CPen* pOldPen = (CPen*)pDC->SelectObject(m_pBkPen); - pDC->Rectangle(ButtonRect); - - // Draw the Correct Border - if(lpDrawItemStruct->itemState & ODS_SELECTED) - { - pDC->DrawEdge(ButtonRect, EDGE_SUNKEN, BF_RECT); - ButtonRect.left++; - ButtonRect.right++; - ButtonRect.bottom++; - ButtonRect.top++; - } - else - pDC->DrawEdge(ButtonRect, EDGE_RAISED, BF_RECT); - - // Draw the Triangle - ButtonRect.left += 3; - ButtonRect.right -= 4; - ButtonRect.top += 5; - ButtonRect.bottom -= 5; - DrawTriangle(pDC, ButtonRect); - - // Return what was used - pDC->SelectObject( pOldPen ); - pDC->SelectObject( pOldBrush ); -} - -void CComboButton::DrawTriangle(CDC* pDC, CRect Rect) -{ - POINT ptArray[3]; - - // Figure out the Top left - ptArray[0].x = Rect.left; - ptArray[0].y = Rect.top; - ptArray[1].x = Rect.right; - ptArray[1].y = Rect.top; - ptArray[2].x = Rect.right - (Rect.Width() / 2); - ptArray[2].y = Rect.bottom; - - // Select the Brush and Draw the triangle - /*CBrush* pOldBrush = (CBrush*)*/pDC->SelectObject(m_pBlackBrush); - pDC->Polygon(ptArray, 3 ); -} -void CComboButton::MeasureItem(LPMEASUREITEMSTRUCT/* lpMeasureItemStruct*/) -{ -} - -///////////////////////////////////////////////////////////////////////////// -// CPropertyListCtrl -CPropertyListCtrl::CPropertyListCtrl() -{ - m_nWidestItem = 0; - m_bDeleteFont = TRUE; - m_bBoldSelection = TRUE; - - m_pBkBrush = NULL; - m_pBkPropertyBrush = NULL; - m_pEditWnd = NULL; - m_pFontButton = NULL; - m_pPathButton = NULL; - m_pDirButton=NULL; - m_pCustomButton=NULL; - m_pComboButton = NULL; - m_pListBox = NULL; - m_pBkHighlightBrush = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - m_pCurItem = NULL; - m_pCurFont = NULL; - m_pCurDrawItem = NULL; - m_pTextFont = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - - m_crBorderColor = RGB(192,192,192); - m_crBkColor = GetSysColor(COLOR_WINDOW); - m_crPropertyBkColor = m_crBkColor; - m_crTextColor = GetSysColor(COLOR_WINDOWTEXT); - m_crPropertyTextColor = m_crTextColor; - m_crHighlightColor = GetSysColor(COLOR_HIGHLIGHT); - m_crTextHighlightColor = GetSysColor(COLOR_HIGHLIGHTTEXT); -} - -CPropertyListCtrl::~CPropertyListCtrl() -{ - if(m_bDeleteFont) delete m_pTextFont; - - if(m_pEditWnd) delete m_pEditWnd; - if(m_pFontButton) delete m_pFontButton; - if(m_pPathButton) delete m_pPathButton; - if (m_pDirButton) delete m_pDirButton; - if (m_pCustomButton) - delete m_pCustomButton; - if(m_pListBox) delete m_pListBox; - if(m_pComboButton) delete m_pComboButton; - - if(m_pBkBrush) delete m_pBkBrush; - if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; - if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; - if(m_pSelectedFont) delete m_pSelectedFont; - if(m_pBorderPen) delete m_pBorderPen; - - // Clear items - Reset(); -} - -void CPropertyListCtrl::Reinit() -{ - ResetContent(); - - // Clean up - if(m_bDeleteFont) delete m_pTextFont; - - if(m_pEditWnd) delete m_pEditWnd; - if(m_pFontButton) delete m_pFontButton; - if(m_pPathButton) delete m_pPathButton; - if (m_pDirButton) delete m_pDirButton; - if (m_pCustomButton) - delete m_pCustomButton; - if(m_pListBox) delete m_pListBox; - if(m_pComboButton) delete m_pComboButton; - - if(m_pBkBrush) delete m_pBkBrush; - if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; - if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; - if(m_pSelectedFont) delete m_pSelectedFont; - if(m_pBorderPen) delete m_pBorderPen; - - // Clear items - Reset(); - - m_nWidestItem = 0; - m_bDeleteFont = TRUE; - m_bBoldSelection = TRUE; - - m_pBkBrush = NULL; - m_pBkPropertyBrush = NULL; - m_pEditWnd = NULL; - m_pFontButton = NULL; - m_pPathButton = NULL; - m_pDirButton=NULL; - m_pCustomButton=NULL; - m_pComboButton = NULL; - m_pListBox = NULL; - m_pBkHighlightBrush = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - m_pCurItem = NULL; - m_pCurFont = NULL; - m_pCurDrawItem = NULL; - m_pTextFont = NULL; - m_pSelectedFont = NULL; - m_pBorderPen = NULL; - - m_crBorderColor = RGB(192,192,192); - m_crBkColor = GetSysColor(COLOR_WINDOW); - m_crPropertyBkColor = m_crBkColor; - m_crTextColor = GetSysColor(COLOR_WINDOWTEXT); - m_crPropertyTextColor = m_crTextColor; - m_crHighlightColor = GetSysColor(COLOR_HIGHLIGHT); - m_crTextHighlightColor = GetSysColor(COLOR_HIGHLIGHTTEXT); - - Init(); -} - -void CPropertyListCtrl::Reset() -{ - // Clear the List - POSITION Pos = m_Items.GetHeadPosition(); - while(Pos) - { - m_pCurItem = (PROPERTYITEM*)m_Items.GetNext(Pos); - if(m_pCurItem->pBrush) - delete m_pCurItem->pBrush; - delete m_pCurItem; - } - m_Items.RemoveAll(); -} - -BEGIN_MESSAGE_MAP(CPropertyListCtrl, CListBox) - //{{AFX_MSG_MAP(CPropertyListCtrl) - ON_WM_CREATE() - ON_WM_CTLCOLOR_REFLECT() - ON_CONTROL_REFLECT(LBN_SELCHANGE, OnSelchange) - ON_WM_CTLCOLOR() - ON_CONTROL_REFLECT(LBN_DBLCLK, OnDblclk) - ON_EN_KILLFOCUS( ID_PROPERTY_TEXT, OnEditLostFocus ) - ON_EN_CHANGE( ID_PROPERTY_TEXT, OnEditChange ) - ON_BN_CLICKED( ID_PROPERTY_FONT, OnFontPropertyClick ) - ON_BN_CLICKED( ID_PROPERTY_PATH, OnPathPropertyClick ) - ON_BN_CLICKED( ID_PROPERTY_DIR, OnDirPropertyClick ) - ON_BN_CLICKED( ID_PROPERTY_CUSTOM, OnCustomPropertyClick ) - ON_BN_CLICKED( ID_PROPERTY_COMBO_BTN, OnComboBoxClick ) - ON_LBN_SELCHANGE(ID_PROPERTY_COMBO_LIST, OnSelChange) - ON_LBN_KILLFOCUS(ID_PROPERTY_COMBO_LIST, OnListboxLostFocus) - ON_WM_LBUTTONDOWN() - ON_WM_VSCROLL() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPropertyListCtrl message handlers - -HBRUSH CPropertyListCtrl::CtlColor(CDC* /*pDC*/, UINT/* nCtlColor*/) -{ - return (HBRUSH)m_pBkBrush->GetSafeHandle(); -} - -HBRUSH CPropertyListCtrl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) -{ - HBRUSH hbr = CListBox::OnCtlColor(pDC, pWnd, nCtlColor); - -/* if( nCtlColor == CTLCOLOR_EDIT) - { - pDC->SetBkColor(m_crPropertyBkColor); - pDC->SetTextColor(m_crPropertyTextColor); - }*/ - pDC->SetBkColor(m_crPropertyBkColor); - pDC->SetTextColor(m_crPropertyTextColor); - - if(m_pBkPropertyBrush) - return (HBRUSH)(m_pBkPropertyBrush->GetSafeHandle() ); - else - return hbr; -} -void CPropertyListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) -{ - // Make sure its a valid item - if( lpDrawItemStruct->itemID == LB_ERR ) - return; - - // Obtain the text for this item - m_csText.Empty(); - GetText(lpDrawItemStruct->itemID, m_csText); - - // Get the drawing DC - CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); - - // Set the Current member we are drawing - m_pCurDrawItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(lpDrawItemStruct->itemID)); - - // Obtain the Item Rect - CRect ItemRect(lpDrawItemStruct->rcItem); - - // Draw This item - DrawItem( pDC, ItemRect, lpDrawItemStruct->itemState & ODS_SELECTED); -} -void CPropertyListCtrl::MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/) -{ -} -void CPropertyListCtrl::OnDblclk() -{ - // Get the Course Position - POINT pPoint; - GetCursorPos(&pPoint); - - // Convert this rect to coordinates of the desktop - CRect TempRect = m_CurRect; - MapWindowPoints(GetDesktopWindow(), TempRect); - - // Display the Correct Control - switch(m_pCurItem->nType) - { - case ID_PROPERTY_BOOL: - // Is the Mouse in this area - if(TempRect.PtInRect(pPoint)) - { - // Reverse the Selection - m_pCurItem->nPropertySelected = !m_pCurItem->nPropertySelected; - - // Redraw this item - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - } - break; - - case ID_PROPERTY_FONT: - m_pFontButton->SetFocus(); - OnFontPropertyClick(); - break; - - case ID_PROPERTY_PATH: - m_pPathButton->SetFocus(); - OnPathPropertyClick(); - break; - - case ID_PROPERTY_DIR: - m_pDirButton->SetFocus(); - OnDirPropertyClick(); - break; - - case ID_PROPERTY_CUSTOM: - m_pCustomButton->SetFocus(); - OnCustomPropertyClick(); - break; - - case ID_PROPERTY_COLOR: - LOGBRUSH lb; - m_pCurItem->pBrush->GetLogBrush(&lb); - CColorDialog ColorDialog(lb.lbColor, 0, GetParent()); - if(ColorDialog.DoModal() != IDOK) - return; - - // Destroy the Brush and create a new one - if(m_pCurItem->pBrush) delete m_pCurItem->pBrush; - m_pCurItem->pBrush = new CBrush(ColorDialog.GetColor()); - - // Redraw the Widow (Theres probably a better way) - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - break; - } - -} -void CPropertyListCtrl::OnSelchange() -{ - HideControls(); - - // Display the Correct Control - CRect TempRect = m_CurRect; - TempRect.InflateRect(-1,-1); - switch(m_pCurItem->nType) - { - case ID_PROPERTY_TEXT: - TempRect.left += 1; - m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(0)); - m_pEditWnd->MoveWindow(TempRect); - m_pEditWnd->ShowWindow(SW_SHOWNORMAL); -// m_pEditWnd->SetFocus(); -// m_pEditWnd->SetSel(0,-1); - break; - - case ID_PROPERTY_FONT: - TempRect.left = TempRect.right - 17; - m_pFontButton->MoveWindow(TempRect); - m_pFontButton->ShowWindow(SW_SHOWNORMAL); - break; - - case ID_PROPERTY_PATH: - TempRect.left = TempRect.right - 17; - m_pPathButton->MoveWindow(TempRect); - m_pPathButton->ShowWindow(SW_SHOWNORMAL); - break; - - case ID_PROPERTY_DIR: - TempRect.left = TempRect.right - 17; - m_pDirButton->MoveWindow(TempRect); - m_pDirButton->ShowWindow(SW_SHOWNORMAL); - break; - - case ID_PROPERTY_CUSTOM: - TempRect.left = TempRect.right - 17; - m_pCustomButton->MoveWindow(TempRect); - m_pCustomButton->ShowWindow(SW_SHOWNORMAL); - break; - - case ID_PROPERTY_COMBO_LIST: - TempRect.left = TempRect.right - 17; - m_pComboButton->MoveWindow(TempRect); - m_pComboButton->ShowWindow(SW_SHOWNORMAL); - - TempRect.left = m_CurRect.left + 2; - TempRect.right -= 17; - if(m_pCurItem->bComboEditable) - { - m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(m_pCurItem->nPropertySelected)); -// m_pEditWnd->SetFocus(); -// m_pEditWnd->SetSel(0,-1); - m_pEditWnd->MoveWindow(TempRect); - m_pEditWnd->ShowWindow(SW_SHOWNORMAL); - } - - // Move the Lsit box -// TempRect.left--; - TempRect.right += 18; - TempRect.top = TempRect.bottom; - - // Set the Bottom Height - if(m_pCurItem->csProperties.GetSize() > 5) - TempRect.bottom += GetItemHeight(0) * 5; - else - TempRect.bottom += GetItemHeight(0) * m_pCurItem->csProperties.GetSize(); - - // pobierz wsp�rz�dne tej kontrolki w stosunku do okna parenta -// CRect rcThisParent; -// GetWindowRect(&rcThisParent); -// GetParent()->ScreenToClient(&rcThisParent); - -// TempRect.OffsetRect(rcThisParent.left+2, rcThisParent.top+2); - m_pListBox->MoveWindow(TempRect); - - // Force the Expansion - OnComboBoxClick(); - break; - - } -} -void CPropertyListCtrl::OnEditLostFocus() -{ - // Get the text - CString csText; - m_pEditWnd->GetWindowText(csText); - - // Is the current item a text item - if(m_pCurItem->nType == ID_PROPERTY_TEXT) - { - // Did the text change - if(!m_bChanged) - return; - - m_pCurItem->csProperties.SetAt(0, csText); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - } - else - { - // Get the window that has the focus now - if(GetFocus() == m_pComboButton || !m_pListBox->GetCount()) - return; - - // Did the text change - if(!m_bChanged) - return; - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - - // Look for this text - m_bChanged = FALSE; - if( m_pListBox->FindStringExact(-1,csText) != LB_ERR) - return; - - // Add it and select it - m_pCurItem->nPropertySelected = m_pCurItem->csProperties.Add(csText); - } -} -void CPropertyListCtrl::OnEditChange() -{ - m_bChanged = TRUE; -} -void CPropertyListCtrl::OnFontPropertyClick() -{ - // Show the Dialog - CFontDialog FontDialog(&m_pCurItem->LogFont); - if(FontDialog.DoModal() != IDOK) - return; - - // Set the Font data - FontDialog.GetCurrentFont(&m_pCurItem->LogFont); - - // Redraw - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); -} -void CPropertyListCtrl::OnPathPropertyClick() -{ - // Look for a ending tag - CString csExt = "*"; - CString csPath = m_pCurItem->csProperties.GetAt(0); - int nPos = csPath.ReverseFind('.'); - if(nPos) - csExt = csPath.Right(csPath.GetLength() - nPos - 1); - - // Show the Dialog - CFileDialog QuizFileDlg(TRUE, "*", "*." + csExt, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, m_pCurItem->csProperties.GetAt(1) ); - QuizFileDlg.m_ofn.lpstrInitialDir = csPath; - if(QuizFileDlg.DoModal() != IDOK) - return; - - // Obtain the Path they selected - m_pCurItem->csProperties.SetAt(0, QuizFileDlg.GetPathName()); - - // Redraw - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); -} - -void CPropertyListCtrl::OnDirPropertyClick() -{ - CString strPath; - if (BrowseForFolder(m_pCurItem->csProperties.GetAt(1), &strPath)) - { - m_pCurItem->csProperties.SetAt(0, strPath); - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - } -} - -void CPropertyListCtrl::OnCustomPropertyClick() -{ - m_pCurItem->pfnCallback(m_pCurItem->lpParam, m_pCurItem->iParam, &m_Items, GetCurSel()); - RedrawWindow(); -} - -void CPropertyListCtrl::OnComboBoxClick() -{ - // Add the items - m_pListBox->ResetContent(); - - // Loop for all items - for( int nItem = 0; nItem < m_pCurItem->csProperties.GetSize(); nItem++) - m_pListBox->AddString(m_pCurItem->csProperties.GetAt(nItem)); - - // Select the correct item - m_pListBox->SetCurSel(m_pCurItem->nPropertySelected); - m_pListBox->SetTopIndex(m_pCurItem->nPropertySelected); - - // Show the List box - m_pListBox->ShowWindow(SW_NORMAL); -} -void CPropertyListCtrl::OnSelChange() -{ - // Set the new current item - m_pCurItem->nPropertySelected = m_pListBox->GetCurSel(); - - // Hide the Windows - m_pListBox->ShowWindow(SW_HIDE); - - if(m_pCurItem->bComboEditable) - m_pEditWnd->SetWindowText(m_pCurItem->csProperties.GetAt(m_pCurItem->nPropertySelected)); - else - RedrawWindow(); - - // Send the message that a property has changed - GetParent()->PostMessage(ID_PROPERTY_CHANGED, GetCurSel(), m_pCurItem->nType); - m_pComboButton->SetFocus(); -} -void CPropertyListCtrl::OnListboxLostFocus() -{ - m_pListBox->ShowWindow(SW_HIDE); -} -void CPropertyListCtrl::OnLButtonDown(UINT nFlags, CPoint point) -{ - // is there an item at this point - BOOL bOutside; - /*UINT uItem =*/ ItemFromPoint(point, bOutside); - - // Is this outside the client - if(bOutside) - HideControls(); - - CListBox::OnLButtonDown(nFlags, point); -} -void CPropertyListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - // Hide the Controls - HideControls(); - - CListBox::OnVScroll(nSBCode, nPos, pScrollBar); -} - -///////////////////////////////////////////////////////////////////////////// -// GUI User Functions -///////////////////////////////////////////////////////////////////////////// - -void CPropertyListCtrl::Init() -{ - // utw�rz czcionk� bazowan� na czcionce okna - LOGFONT lf; - GetFont()->GetLogFont(&lf); - - if(m_pTextFont) delete m_pTextFont; - if(m_pSelectedFont) delete m_pSelectedFont; - - m_pTextFont=new CFont(); - m_pTextFont->CreateFontIndirect(&lf); - - lf.lfWeight=FW_BOLD; - m_pSelectedFont=new CFont(); - m_pSelectedFont->CreateFontIndirect(&lf); - - m_bDeleteFont=TRUE; - - // Create the Border Pen - m_pBorderPen = new CPen(PS_SOLID, 1, m_crBorderColor); - - // Create the Selected Background brush - m_pBkHighlightBrush = new CBrush(m_crHighlightColor); - m_pBkBrush = new CBrush(m_crBkColor); - - // Set the row height - read text height - CClientDC dc(this); - dc.SelectObject(&m_pSelectedFont); - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); - - SetItemHeight(-1, MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY) ); -} - -void CPropertyListCtrl::SetFont(CFont* pFont) -{ - // Delete our font and set our font to theirs - if(m_pTextFont) delete m_pTextFont; - if(m_pSelectedFont) delete m_pSelectedFont; - m_pTextFont = pFont; - m_bDeleteFont = FALSE; - - // Figure out the text size - LOGFONT lpLogFont; - m_pTextFont->GetLogFont(&lpLogFont); - - // Set the font and redraw - CWnd::SetFont(m_pTextFont, FALSE); - - // Create the heading font with the bold attribute - lpLogFont.lfWeight = FW_BOLD; - m_pSelectedFont = new CFont(); - m_pSelectedFont->CreateFontIndirect(&lpLogFont); - - // Set the Row height - CClientDC dc(this); - dc.SelectObject(&m_pSelectedFont); - TEXTMETRIC tm; - dc.GetTextMetrics(&tm); - - SetItemHeight(-1, MulDiv(tm.tmHeight+tm.tmExternalLeading, dc.GetDeviceCaps(LOGPIXELSY), tm.tmDigitizedAspectY) ); - - // ** IMPLEMENT LATER ?? ** - // Recalculate the Width Position -} - -void CPropertyListCtrl::SetLineStyle(COLORREF crColor, int nStyle) -{ - // Delete the old Pen - if(m_pBorderPen) delete m_pBorderPen; - - // Create the brush - m_pBorderPen = new CPen(nStyle, 1, crColor); - m_crBorderColor = crColor; -} -void CPropertyListCtrl::SetBkColor(COLORREF crColor) -{ - // Delete the old brush - if(m_pBkBrush) delete m_pBkBrush; - - // Create the brush - m_pBkBrush = new CBrush(crColor); - m_crBkColor = crColor; -} -void CPropertyListCtrl::SetPropertyBkColor(COLORREF crColor) -{ - // Delete the old brush - if(m_pBkPropertyBrush) delete m_pBkPropertyBrush; - - // Create the brush - m_pBkPropertyBrush = new CBrush(crColor); - m_crPropertyBkColor = crColor; -} - -void CPropertyListCtrl::SetHighlightColor(COLORREF crColor) -{ - // Delete the old brush - if(m_pBkHighlightBrush) delete m_pBkHighlightBrush; - - // Create the brush - m_pBkHighlightBrush = new CBrush(crColor); - m_crHighlightColor = crColor; -} - -///////////////////////////////////////////////////////////////////////////// -// Add Properties Functions -///////////////////////////////////////////////////////////////////////////// -BOOL CPropertyListCtrl::AddString(CString csText) -{ - // Call our function (assume its a text Item) - return AddString(csText, ID_PROPERTY_STATIC, _T("")); -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString) -{ - return AddString(GetResManager()->LoadString(nIDString)); -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, void (*pfnCallback)(LPVOID, int, CPtrList*, int), LPVOID lpParam, int iParam, int nPropertySelected, int nAlignment, BOOL bComboEditable) -{ - // Is this a valid Control type - if(nType > ID_PROPERTY_COMBO_LIST) - return FALSE; - - // load string - const TCHAR *pszText=GetResManager()->LoadString(nIDString); - - // Create a new Structure to hold it - PROPERTYITEM* pNewItem = new PROPERTYITEM; - pNewItem->nType = nType; - pNewItem->nAlignment = nAlignment; - pNewItem->pBrush = NULL; - pNewItem->bComboEditable = bComboEditable; - pNewItem->pfnCallback=pfnCallback; - pNewItem->iParam=iParam; - pNewItem->lpParam=lpParam; - - // Calculate the Width of the string based on the font set - CDC* pDC = GetDC(); - pDC->SelectObject(m_pSelectedFont); - CSize Size = pDC->GetTextExtent(pszText); - if(Size.cx + 10 > m_nWidestItem) - m_nWidestItem = Size.cx + 10; - ReleaseDC(pDC); - pNewItem->nWidth = Size.cx; - pNewItem->nPropertySelected = nPropertySelected; - - // Set Property - if(!SetProperty(pNewItem, nType, csData)) - { - delete pNewItem; - return FALSE; - } - - // Is the item set bigger than the number of properties - if(pNewItem->nPropertySelected > pNewItem->csProperties.GetSize()) - { - delete pNewItem; - return FALSE; - } - - // Add to the list - m_Items.AddTail(pNewItem); - - // Add the string to the list box - /*int nPos =*/ CListBox::AddString(pszText); - - // Create the Control if Needed - CreateControl(nType); - return TRUE; -} - -BOOL CPropertyListCtrl::AddString(CString csText, int nType, CString csData, int nPropertySelected, int nAlignment, BOOL bComboEditable) -{ - // Is this a valid Control type - if(nType > ID_PROPERTY_COMBO_LIST) - return FALSE; - - // Create a new Structure to hold it - PROPERTYITEM* pNewItem = new PROPERTYITEM; - pNewItem->nType = nType; - pNewItem->nAlignment = nAlignment; - pNewItem->pBrush = NULL; - pNewItem->bComboEditable = bComboEditable; - - // Calculate the Width of the string based on the font set - CDC* pDC = GetDC(); - pDC->SelectObject(m_pSelectedFont); - CSize Size = pDC->GetTextExtent(csText); - if(Size.cx + 10 > m_nWidestItem) - m_nWidestItem = Size.cx + 10; - ReleaseDC(pDC); - pNewItem->nWidth = Size.cx; - pNewItem->nPropertySelected = nPropertySelected; - - // Set Property - if(!SetProperty(pNewItem, nType, csData)) - { - delete pNewItem; - return FALSE; - } - - // Is the item set bigger than the number of properties - if(pNewItem->nPropertySelected > pNewItem->csProperties.GetSize()) - { - delete pNewItem; - return FALSE; - } - - // Add to the list - m_Items.AddTail(pNewItem); - - // Add the string to the list box - /*int nPos =*/ CListBox::AddString(csText); - - // Create the Control if Needed - CreateControl(nType); - return TRUE; -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, UINT nIDData, int nPropertySelected, int nAlignment, BOOL bComboEditable) -{ - return AddString(GetResManager()->LoadString(nIDString), nType, GetResManager()->LoadString(nIDData), nPropertySelected, nAlignment, bComboEditable); -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString, int nType, CString csData, int nPropertySelected, int nAlignment, BOOL bComboEditable) -{ - return AddString(GetResManager()->LoadString(nIDString), nType, csData, nPropertySelected, nAlignment, bComboEditable); -} - -BOOL CPropertyListCtrl::AddString(CString csText, COLORREF crColor, int nAlignment) -{ - // Create a new brush based on this color - m_pCurBrush = new CBrush(crColor); - - // Call the other functions - return AddString(csText, ID_PROPERTY_COLOR, _T(""), 0, nAlignment); -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString, COLORREF crColor, int nAlignment) -{ - return AddString(GetResManager()->LoadString(nIDString), crColor, nAlignment); -} - -BOOL CPropertyListCtrl::AddString(CString csText, CFont* pFont, int nAlignment) -{ - // Safe the Font - m_pCurFont = pFont; - - // Call the other functions - return AddString(csText, ID_PROPERTY_FONT, _T(""), 0, nAlignment); -} - -BOOL CPropertyListCtrl::AddString(UINT nIDString, CFont* pFont, int nAlignment) -{ - return AddString(GetResManager()->LoadString(nIDString), pFont, nAlignment); -} - -///////////////////////////////////////////////////////////////////////////// -// Helper Functions -///////////////////////////////////////////////////////////////////////////// -void CPropertyListCtrl::DrawItem(CDC* pDC, CRect ItemRect, BOOL bSelected) -{ - if (m_pCurDrawItem->nType != ID_PROPERTY_STATIC) - { - ///////////////////////////////////////// - // Paint the Background rectangle (Property Value) - if(m_pCurDrawItem->nType == ID_PROPERTY_COLOR) - pDC->SelectObject(m_pCurDrawItem->pBrush); - else - pDC->SelectObject(m_pBkBrush); - pDC->SelectObject(m_pBorderPen); - - // Draw the Rectangle - ItemRect.left = m_nWidestItem - 1; - ItemRect.top--; - ItemRect.right++; - pDC->Rectangle(ItemRect); - CRect OrginalRect = ItemRect; - - ///////////////////////////////////////// - // Draw the Property Text - pDC->SetBkMode(TRANSPARENT); - pDC->SelectObject(m_pBkBrush); - pDC->SelectObject(m_pTextFont); - pDC->SetTextColor(m_crTextColor); - DrawPropertyText(pDC, ItemRect); - - ///////////////////////////////////////// - // Paint the Background rectangle (Property Name) - if( bSelected ) - pDC->SelectObject(m_pBkHighlightBrush); - - // Draw the Rectangle - ItemRect.right = m_nWidestItem; - ItemRect.left = -1; - pDC->Rectangle(ItemRect); - - ///////////////////////////////////////// - // Paint the Property name Text - // Is this item selected? - if( bSelected ) - { - if(m_bBoldSelection) pDC->SelectObject(m_pSelectedFont); - pDC->SetTextColor(m_crTextHighlightColor); - m_pCurItem = m_pCurDrawItem; - m_CurRect = OrginalRect; - } - - // Draw the Text - ItemRect.left += 6; - ItemRect.right -= 5; - pDC->DrawText( m_csText, m_csText.GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX|m_pCurDrawItem->nAlignment); - } - else - { - ///////////////////////////////////////// - // Paint the Background rectangle (Property Value) - pDC->SelectObject(m_pBkHighlightBrush); - pDC->SelectObject(m_pBorderPen); - pDC->SelectObject(m_pSelectedFont); - - // Draw the Rectangle - pDC->Rectangle(ItemRect); - CRect OrginalRect = ItemRect; - - ///////////////////////////////////////// - // Draw - pDC->SetBkMode(TRANSPARENT); - pDC->SetTextColor(m_crTextHighlightColor); - if (bSelected) - { - m_pCurItem = m_pCurDrawItem; - m_CurRect = OrginalRect; - } - - // Draw the Text - pDC->DrawText( m_csText, m_csText.GetLength(), ItemRect, DT_NOPREFIX|DT_SINGLELINE|DT_VCENTER|DT_CENTER); - } -} - -void CPropertyListCtrl::DrawPropertyText(CDC* pDC, CRect ItemRect) -{ - ItemRect.left += 5; - switch(m_pCurDrawItem->nType) - { - case ID_PROPERTY_BOOL: - case ID_PROPERTY_COMBO_LIST: - pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(m_pCurDrawItem->nPropertySelected), m_pCurDrawItem->csProperties.GetAt(m_pCurDrawItem->nPropertySelected).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); - break; - - case ID_PROPERTY_TEXT: - case ID_PROPERTY_PATH: - case ID_PROPERTY_DIR: - case ID_PROPERTY_CUSTOM: - pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(0), m_pCurDrawItem->csProperties.GetAt(0).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); - break; - case ID_PROPERTY_STATIC: - pDC->DrawText( m_pCurDrawItem->csProperties.GetAt(0), m_pCurDrawItem->csProperties.GetAt(0).GetLength(), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); - break; - - case ID_PROPERTY_FONT: - if(m_pCurDrawItem->LogFont.lfHeight) - pDC->DrawText( m_pCurDrawItem->LogFont.lfFaceName, strlen(m_pCurDrawItem->LogFont.lfFaceName), ItemRect, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_NOPREFIX); - break; - } -} - -void CPropertyListCtrl::CreateControl(int nType) -{ - switch(nType) - { - // Edit Window - case ID_PROPERTY_TEXT: - if(!m_pEditWnd) - { - m_pEditWnd = new CEdit(); - m_pEditWnd->Create(WS_CHILD|ES_AUTOHSCROLL|ES_LEFT, CRect(0,0,100,100), this, ID_PROPERTY_TEXT); - m_pEditWnd->SetFont(m_pTextFont); - } - break; - - // Font Button - case ID_PROPERTY_FONT: - if(!m_pFontButton) - { - m_pFontButton = new CButton(); - m_pFontButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_FONT); - m_pFontButton->SetFont(m_pTextFont); - } - break; - - case ID_PROPERTY_PATH: - if(!m_pPathButton) - { - m_pPathButton = new CButton(); - m_pPathButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_PATH); - m_pPathButton->SetFont(m_pTextFont); - } - break; - - case ID_PROPERTY_DIR: - if(!m_pDirButton) - { - m_pDirButton = new CButton(); - m_pDirButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_DIR); - m_pDirButton->SetFont(m_pTextFont); - } - break; - - case ID_PROPERTY_CUSTOM: - if(!m_pCustomButton) - { - m_pCustomButton = new CButton(); - m_pCustomButton->Create("...", WS_CHILD|BS_PUSHBUTTON, CRect(0,0,100,100), this, ID_PROPERTY_CUSTOM); - m_pCustomButton->SetFont(m_pTextFont); - } - break; - - case ID_PROPERTY_COMBO_LIST: - if(!m_pEditWnd) - { - m_pEditWnd = new CEdit(); - m_pEditWnd->Create(WS_CHILD|ES_AUTOHSCROLL|ES_LEFT, CRect(0,0,100,100), this, ID_PROPERTY_TEXT); - m_pEditWnd->SetFont(m_pTextFont); - } - if(!m_pListBox) - { - m_pListBox = new CListBox(); - m_pListBox->Create(WS_CHILD|WS_BORDER|LBS_NOTIFY|WS_VSCROLL|LBS_HASSTRINGS, CRect(0,0,100,100), this, ID_PROPERTY_COMBO_LIST); - m_pListBox->SetFont(m_pTextFont); - - m_pComboButton = new CComboButton(); - m_pComboButton->Create(CRect(0,0,0,0), this, ID_PROPERTY_COMBO_BTN ); - } - break; - } -} - -BOOL CPropertyListCtrl::SetProperty(PROPERTYITEM* pPropertyItem, int nType, CString csData) -{ - switch(nType) - { - case ID_PROPERTY_BOOL: - case ID_PROPERTY_PATH: - case ID_PROPERTY_DIR: - ParseProperties(pPropertyItem, csData); - - // Is the item selected more than items in the array? - if(pPropertyItem->csProperties.GetSize() != 2 ) - return FALSE; - break; - - case ID_PROPERTY_TEXT: - case ID_PROPERTY_STATIC: - case ID_PROPERTY_CUSTOM: - pPropertyItem->csProperties.Add(csData); - break; - - case ID_PROPERTY_FONT: - memset(&pPropertyItem->LogFont, 0, sizeof(pPropertyItem->LogFont)); - if(m_pCurFont) - { - m_pCurFont->GetLogFont(&pPropertyItem->LogFont); - m_pCurFont = NULL; - } - break; - - case ID_PROPERTY_COLOR: - pPropertyItem->pBrush = m_pCurBrush; - break; - - case ID_PROPERTY_COMBO_LIST: - ParseProperties(pPropertyItem, csData); - break; - - } - - return TRUE; -} - -void CPropertyListCtrl::ParseProperties(PROPERTYITEM* pPropertyItem, CString csData) -{ - // Parse the Items - char* pText = csData.GetBuffer( csData.GetLength() ); - char* pWord; - char Separations[] = "!"; - - // Establish string and get the first token: - pWord = strtok( pText, Separations); - while( pWord != NULL ) - { - // Add this to the Array - pPropertyItem->csProperties.Add(pWord); - - // Get next token - pWord = strtok( NULL, Separations ); - } - - // Release the buffer - csData.ReleaseBuffer(); -} - -void CPropertyListCtrl::HideControls() -{ - // Hide the controls - if(m_pEditWnd) m_pEditWnd->ShowWindow(SW_HIDE); - if(m_pFontButton) m_pFontButton->ShowWindow(SW_HIDE); - if(m_pPathButton) m_pPathButton->ShowWindow(SW_HIDE); - if (m_pDirButton) m_pDirButton->ShowWindow(SW_HIDE); - if (m_pCustomButton) - m_pCustomButton->ShowWindow(SW_HIDE); - if(m_pListBox) m_pListBox->ShowWindow(SW_HIDE); - if(m_pComboButton) m_pComboButton->ShowWindow(SW_HIDE); -} - -///////////////////////////////////////////////////////////////////////////// -// Get Properties Functions -///////////////////////////////////////////////////////////////////////////// -bool CPropertyListCtrl::GetProperty(int nItem, CString* pText) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - if(pItem->nType != ID_PROPERTY_TEXT && pItem->nType != ID_PROPERTY_PATH && pItem->nType != ID_PROPERTY_DIR && pItem->nType != ID_PROPERTY_STATIC && pItem->nType != ID_PROPERTY_CUSTOM) - return false; - - // Copy the item - *pText = pItem->csProperties.GetAt(0); - return true; -} -bool CPropertyListCtrl::GetProperty(int nItem, bool* bValue) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - if(pItem->nType != ID_PROPERTY_BOOL) - return false; - - // Copy the item - *bValue = pItem->nPropertySelected != 0; - return true; -} -bool CPropertyListCtrl::GetProperty(int nItem, COLORREF* crColor) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - if(pItem->nType != ID_PROPERTY_COLOR) - return false; - - // Copy the item - LOGBRUSH LogBrush; - pItem->pBrush->GetLogBrush(&LogBrush); - *crColor = LogBrush.lbColor; - return true; -} -bool CPropertyListCtrl::GetProperty(int nItem, LOGFONT* LogFont) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - if(pItem->nType != ID_PROPERTY_FONT) - return false; - - // Copy the item - *LogFont = pItem->LogFont; - return true; -} -bool CPropertyListCtrl::GetProperty(int nItem, CStringArray* pArray, int* /*SelectedItem*/) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - if(pItem->nType != ID_PROPERTY_COMBO_LIST) - return false; - - // I do NOT want to send them a pointer to my array so I loop through and copy the item to thiers - for( int nString = 0; nString < pItem->csProperties.GetSize(); nString++) - pArray->Add(pItem->csProperties.GetAt(nString)); - return true; -} -bool CPropertyListCtrl::GetProperty(int nItem, int* SelectedItem, CString* pText) -{ - // is the item to high - if(nItem + 1 > GetCount()) - return false; - - // Make sure this item is the correct type - PROPERTYITEM* pItem; - pItem = (PROPERTYITEM*)m_Items.GetAt(m_Items.FindIndex(nItem)); - - // Copy the item - *SelectedItem = pItem->nPropertySelected; - - // Do they want the text - if(pText != NULL && pItem->nType == ID_PROPERTY_COMBO_LIST) - *pText = pItem->csProperties.GetAt(pItem->nPropertySelected); - return true; -} Index: src/ch/PropertyListCtrl.h =================================================================== diff -u -N --- src/ch/PropertyListCtrl.h (revision 0) +++ src/ch/PropertyListCtrl.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,231 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __PROPERTYLIST_H__ +#define __PROPERTYLIST_H__ + +#include "memdc.h" + +// Property Type +#define ID_PROPERTY_TEXT 1 +#define ID_PROPERTY_BOOL 2 +#define ID_PROPERTY_COLOR 3 +#define ID_PROPERTY_FONT 4 +#define ID_PROPERTY_PATH 5 +#define ID_PROPERTY_DIR 6 +#define ID_PROPERTY_CUSTOM 7 +#define ID_PROPERTY_STATIC 8 +#define ID_PROPERTY_COMBO_BTN 9 +#define ID_PROPERTY_COMBO_LIST 10 + +// Message ID to parent +#define ID_PROPERTY_CHANGED WM_USER+15 + +// Holds an item +typedef struct PropertyItem_t +{ + int nType; + int nWidth; + int nAlignment; + int nPropertySelected; + BOOL bComboEditable; + LOGFONT LogFont; + CBrush* pBrush; + CStringArray csProperties; + + // custom + void (*pfnCallback)(LPVOID, int, CPtrList*, int); + LPVOID lpParam; // ptr to the dialog + int iParam; // other data + +} PROPERTYITEM; + +///////////////////////////////////////////////////////////////////////////// +// CComboButton window +class CComboButton : public CButton +{ + void DrawTriangle(CDC* pDC, CRect Rect); + +// Construction +public: + BOOL Create( CRect Rect, CWnd* pParent, UINT uID); + CComboButton(); + +// Attributes +public: + CPen* m_pBkPen; +// CPen* m_pGrayPen; + CBrush* m_pBkBrush; + CBrush* m_pBlackBrush; + +// Operations +public: + + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct ); + virtual void MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CComboButton) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CComboButton(); + + // Generated message map functions +protected: + //{{AFX_MSG(CComboButton) + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// +// CPropertyListCtrl window +class CPropertyListCtrl : public CListBox +{ + int m_nWidestItem; + BOOL m_bDeleteFont; + BOOL m_bBoldSelection; + BOOL m_bChanged; + CPen* m_pBorderPen; + CRect m_CurRect; + CFont* m_pTextFont; + CFont* m_pSelectedFont; + CFont* m_pCurFont; + CString m_csText; + CBrush* m_pCurBrush; + CBrush* m_pBkBrush; + CBrush* m_pBkHighlightBrush; + CBrush* m_pBkPropertyBrush; + CButton* m_pFontButton; + CButton* m_pPathButton; + CButton* m_pDirButton; + CButton* m_pCustomButton; + CComboButton* m_pComboButton; + CListBox* m_pListBox; + + COLORREF m_crBorderColor; + COLORREF m_crBkColor; + COLORREF m_crTextColor; + COLORREF m_crTextHighlightColor; + COLORREF m_crHighlightColor; + COLORREF m_crPropertyBkColor; + COLORREF m_crPropertyTextColor; + + // Controls + CEdit* m_pEditWnd; + + // The item list + CPtrList m_Items; + PROPERTYITEM* m_pCurItem; + PROPERTYITEM* m_pCurDrawItem; + +// Construction +public: + CPropertyListCtrl(); + +// Attributes +private: + // Helper Functions + void DrawItem(CDC* pDC, CRect ItemRect, BOOL bSelected); + void DrawPropertyText(CDC* pDC, CRect ItemRect); + void CreateControl(int nType); + BOOL SetProperty(PROPERTYITEM* pPropertyItem, int nType, CString csData); + void ParseProperties(PROPERTYITEM* pPropertyItem, CString csData); +public: + void HideControls(); + +// Operations +public: + // GUI Functions + void SetFont(CFont* pFont); + void SetBkColor(COLORREF crColor); + void SetPropertyBkColor(COLORREF crColor); + void SetHighlightColor(COLORREF crColor); + void SetLineStyle(COLORREF crColor, int nStyle = PS_SOLID); + inline void SetBoldSelection(BOOL bBoldSelection) { m_bBoldSelection = bBoldSelection; }; + inline void SetTextColor(COLORREF crColor) { m_crTextColor = crColor; }; + inline void SetTextHighlightColor(COLORREF crColor) { m_crTextHighlightColor = crColor; }; + inline void SetPropertyTextColor(COLORREF crColor) { m_crPropertyTextColor = crColor; }; + + // Add the data + BOOL AddString(CString csText); + BOOL AddString(UINT nIDString); + + BOOL AddString(CString csText, int nType, CString csData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); + BOOL AddString(UINT nIDString, int nType, UINT nIDData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); + BOOL AddString(UINT nIDString, int nType, CString csData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); + BOOL AddString(UINT nIDString, int nType, CString csData, void (*pfnCallback)(LPVOID, int, CPtrList*, int), LPVOID lpParam, int iParam, int nPropertySelected, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); + + BOOL AddString(CString csText, COLORREF crColor, int nAlignment = DT_LEFT); + BOOL AddString(UINT nIDString, COLORREF crColor, int nAlignment = DT_LEFT); + + BOOL AddString(CString csText, CFont* pFont, int nAlignment = DT_LEFT); + BOOL AddString(UINT nIDString, CFont* pFont, int nAlignment = DT_LEFT); + + // Get the Data + bool GetProperty(int nItem, CString* pText); + bool GetProperty(int nItem, bool* bValue); + bool GetProperty(int nItem, COLORREF* crColor); + bool GetProperty(int nItem, LOGFONT* LogFont); + bool GetProperty(int nItem, CStringArray* pArray, int* /*SelectedItem = NULL*/); + bool GetProperty(int nItem, int* SelectedItem, CString* csText = NULL); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPropertyListCtrl) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + virtual void MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/); + //}}AFX_VIRTUAL + +// Implementation +public: + void Init(); + virtual ~CPropertyListCtrl(); + void Reset(); + void Reinit(); + + // Generated message map functions +protected: + //{{AFX_MSG(CPropertyListCtrl) + afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/); + afx_msg void OnSelchange(); + afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); + afx_msg void OnDblclk(); + afx_msg void OnEditLostFocus(); + afx_msg void OnEditChange(); + afx_msg void OnFontPropertyClick(); + afx_msg void OnPathPropertyClick(); + afx_msg void OnDirPropertyClick(); + afx_msg void OnCustomPropertyClick(); + afx_msg void OnComboBoxClick(); + afx_msg void OnSelChange(); + afx_msg void OnListboxLostFocus(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +#endif Index: ch/PropertyListCtrl.h =================================================================== diff -u -N --- ch/PropertyListCtrl.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/PropertyListCtrl.h (revision 0) @@ -1,231 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __PROPERTYLIST_H__ -#define __PROPERTYLIST_H__ - -#include "memdc.h" - -// Property Type -#define ID_PROPERTY_TEXT 1 -#define ID_PROPERTY_BOOL 2 -#define ID_PROPERTY_COLOR 3 -#define ID_PROPERTY_FONT 4 -#define ID_PROPERTY_PATH 5 -#define ID_PROPERTY_DIR 6 -#define ID_PROPERTY_CUSTOM 7 -#define ID_PROPERTY_STATIC 8 -#define ID_PROPERTY_COMBO_BTN 9 -#define ID_PROPERTY_COMBO_LIST 10 - -// Message ID to parent -#define ID_PROPERTY_CHANGED WM_USER+15 - -// Holds an item -typedef struct PropertyItem_t -{ - int nType; - int nWidth; - int nAlignment; - int nPropertySelected; - BOOL bComboEditable; - LOGFONT LogFont; - CBrush* pBrush; - CStringArray csProperties; - - // custom - void (*pfnCallback)(LPVOID, int, CPtrList*, int); - LPVOID lpParam; // ptr to the dialog - int iParam; // other data - -} PROPERTYITEM; - -///////////////////////////////////////////////////////////////////////////// -// CComboButton window -class CComboButton : public CButton -{ - void DrawTriangle(CDC* pDC, CRect Rect); - -// Construction -public: - BOOL Create( CRect Rect, CWnd* pParent, UINT uID); - CComboButton(); - -// Attributes -public: - CPen* m_pBkPen; -// CPen* m_pGrayPen; - CBrush* m_pBkBrush; - CBrush* m_pBlackBrush; - -// Operations -public: - - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct ); - virtual void MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CComboButton) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CComboButton(); - - // Generated message map functions -protected: - //{{AFX_MSG(CComboButton) - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// -// CPropertyListCtrl window -class CPropertyListCtrl : public CListBox -{ - int m_nWidestItem; - BOOL m_bDeleteFont; - BOOL m_bBoldSelection; - BOOL m_bChanged; - CPen* m_pBorderPen; - CRect m_CurRect; - CFont* m_pTextFont; - CFont* m_pSelectedFont; - CFont* m_pCurFont; - CString m_csText; - CBrush* m_pCurBrush; - CBrush* m_pBkBrush; - CBrush* m_pBkHighlightBrush; - CBrush* m_pBkPropertyBrush; - CButton* m_pFontButton; - CButton* m_pPathButton; - CButton* m_pDirButton; - CButton* m_pCustomButton; - CComboButton* m_pComboButton; - CListBox* m_pListBox; - - COLORREF m_crBorderColor; - COLORREF m_crBkColor; - COLORREF m_crTextColor; - COLORREF m_crTextHighlightColor; - COLORREF m_crHighlightColor; - COLORREF m_crPropertyBkColor; - COLORREF m_crPropertyTextColor; - - // Controls - CEdit* m_pEditWnd; - - // The item list - CPtrList m_Items; - PROPERTYITEM* m_pCurItem; - PROPERTYITEM* m_pCurDrawItem; - -// Construction -public: - CPropertyListCtrl(); - -// Attributes -private: - // Helper Functions - void DrawItem(CDC* pDC, CRect ItemRect, BOOL bSelected); - void DrawPropertyText(CDC* pDC, CRect ItemRect); - void CreateControl(int nType); - BOOL SetProperty(PROPERTYITEM* pPropertyItem, int nType, CString csData); - void ParseProperties(PROPERTYITEM* pPropertyItem, CString csData); -public: - void HideControls(); - -// Operations -public: - // GUI Functions - void SetFont(CFont* pFont); - void SetBkColor(COLORREF crColor); - void SetPropertyBkColor(COLORREF crColor); - void SetHighlightColor(COLORREF crColor); - void SetLineStyle(COLORREF crColor, int nStyle = PS_SOLID); - inline void SetBoldSelection(BOOL bBoldSelection) { m_bBoldSelection = bBoldSelection; }; - inline void SetTextColor(COLORREF crColor) { m_crTextColor = crColor; }; - inline void SetTextHighlightColor(COLORREF crColor) { m_crTextHighlightColor = crColor; }; - inline void SetPropertyTextColor(COLORREF crColor) { m_crPropertyTextColor = crColor; }; - - // Add the data - BOOL AddString(CString csText); - BOOL AddString(UINT nIDString); - - BOOL AddString(CString csText, int nType, CString csData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); - BOOL AddString(UINT nIDString, int nType, UINT nIDData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); - BOOL AddString(UINT nIDString, int nType, CString csData, int nPropertySelected = 0, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); - BOOL AddString(UINT nIDString, int nType, CString csData, void (*pfnCallback)(LPVOID, int, CPtrList*, int), LPVOID lpParam, int iParam, int nPropertySelected, int nAlignment = DT_LEFT, BOOL bComboEditable = FALSE); - - BOOL AddString(CString csText, COLORREF crColor, int nAlignment = DT_LEFT); - BOOL AddString(UINT nIDString, COLORREF crColor, int nAlignment = DT_LEFT); - - BOOL AddString(CString csText, CFont* pFont, int nAlignment = DT_LEFT); - BOOL AddString(UINT nIDString, CFont* pFont, int nAlignment = DT_LEFT); - - // Get the Data - bool GetProperty(int nItem, CString* pText); - bool GetProperty(int nItem, bool* bValue); - bool GetProperty(int nItem, COLORREF* crColor); - bool GetProperty(int nItem, LOGFONT* LogFont); - bool GetProperty(int nItem, CStringArray* pArray, int* /*SelectedItem = NULL*/); - bool GetProperty(int nItem, int* SelectedItem, CString* csText = NULL); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPropertyListCtrl) - public: - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - virtual void MeasureItem(LPMEASUREITEMSTRUCT /*lpMeasureItemStruct*/); - //}}AFX_VIRTUAL - -// Implementation -public: - void Init(); - virtual ~CPropertyListCtrl(); - void Reset(); - void Reinit(); - - // Generated message map functions -protected: - //{{AFX_MSG(CPropertyListCtrl) - afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/); - afx_msg void OnSelchange(); - afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); - afx_msg void OnDblclk(); - afx_msg void OnEditLostFocus(); - afx_msg void OnEditChange(); - afx_msg void OnFontPropertyClick(); - afx_msg void OnPathPropertyClick(); - afx_msg void OnDirPropertyClick(); - afx_msg void OnCustomPropertyClick(); - afx_msg void OnComboBoxClick(); - afx_msg void OnSelChange(); - afx_msg void OnListboxLostFocus(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -#endif Index: src/ch/RecentDlg.cpp =================================================================== diff -u -N --- src/ch/RecentDlg.cpp (revision 0) +++ src/ch/RecentDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,175 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "copy handler.h" +#include "RecentDlg.h" +#include "dialogs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CRecentDlg dialog + + +CRecentDlg::CRecentDlg(CWnd* pParent /*=NULL*/) + : CHLanguageDialog(CRecentDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CRecentDlg) + m_strPath = _T(""); + //}}AFX_DATA_INIT +} + + +void CRecentDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CRecentDlg) + DDX_Control(pDX, IDC_RECENT_LIST, m_ctlRecent); + DDX_Text(pDX, IDC_PATH_EDIT, m_strPath); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CRecentDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CRecentDlg) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_RECENT_LIST, OnItemchangedRecentList) + ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) + ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton) + ON_BN_CLICKED(IDC_CHANGE_BUTTON, OnChangeButton) + ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CRecentDlg message handlers + +BOOL CRecentDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // system image list + SHFILEINFO sfi; + m_himl = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + m_hliml=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX); + m_ctlRecent.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_himl); + m_ctlRecent.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hliml); + + // modify list style + m_ctlRecent.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); + + // update recent paths + for (int i=0;i<(int)m_cvRecent.size();i++) + { + sfi.iIcon=-1; + SHGetFileInfo(m_cvRecent.at(i), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlRecent.InsertItem(i, m_cvRecent.at(i), sfi.iIcon); + } + + return TRUE; +} + +void CRecentDlg::OnItemchangedRecentList(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_LISTVIEW* plv = (NM_LISTVIEW*)pNMHDR; + + // current selection + if (plv->iItem >= 0 && plv->iItem < (int)m_cvRecent.size()) + { + m_strPath=m_cvRecent.at(plv->iItem); + UpdateData(FALSE); + } + + *pResult = 0; +} + +void CRecentDlg::OnBrowseButton() +{ + CString strPath; + if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) + { + m_strPath=strPath; + UpdateData(FALSE); + } +} + +void CRecentDlg::OnAddButton() +{ + UpdateData(TRUE); + if (m_strPath.IsEmpty()) + return; + + // add to a table + m_cvRecent.push_back((const PTSTR)(LPCTSTR)m_strPath, true); + + // add to list with an icon + SHFILEINFO sfi; + sfi.iIcon=-1; + SHGetFileInfo(m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlRecent.InsertItem(m_cvRecent.size()-1, m_strPath, sfi.iIcon); +} + +void CRecentDlg::OnChangeButton() +{ + // read selection index + POSITION pos=m_ctlRecent.GetFirstSelectedItemPosition(); + if (pos) + { + // index + int iPos=m_ctlRecent.GetNextSelectedItem(pos); + + UpdateData(TRUE); + + if (m_strPath.IsEmpty()) + return; + + // array update + m_cvRecent.replace(m_cvRecent.begin()+iPos, (const PTSTR)(LPCTSTR)m_strPath, true, true); + + // list + SHFILEINFO sfi; + sfi.iIcon=-1; + SHGetFileInfo(m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + + m_ctlRecent.DeleteItem(iPos); + m_ctlRecent.InsertItem(iPos, m_strPath, sfi.iIcon); + } +} + +void CRecentDlg::OnDeleteButton() +{ + POSITION pos=m_ctlRecent.GetFirstSelectedItemPosition(); + int iPos=-1; + while (pos) + { + iPos=m_ctlRecent.GetNextSelectedItem(pos); + m_cvRecent.erase(m_cvRecent.begin()+iPos, true); + m_ctlRecent.DeleteItem(iPos); + } + + if (iPos != -1) + m_ctlRecent.SetItemState(iPos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); +} Index: ch/RecentDlg.cpp =================================================================== diff -u -N --- ch/RecentDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/RecentDlg.cpp (revision 0) @@ -1,175 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "copy handler.h" -#include "RecentDlg.h" -#include "dialogs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CRecentDlg dialog - - -CRecentDlg::CRecentDlg(CWnd* pParent /*=NULL*/) - : CHLanguageDialog(CRecentDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CRecentDlg) - m_strPath = _T(""); - //}}AFX_DATA_INIT -} - - -void CRecentDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CRecentDlg) - DDX_Control(pDX, IDC_RECENT_LIST, m_ctlRecent); - DDX_Text(pDX, IDC_PATH_EDIT, m_strPath); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CRecentDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CRecentDlg) - ON_NOTIFY(LVN_ITEMCHANGED, IDC_RECENT_LIST, OnItemchangedRecentList) - ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) - ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton) - ON_BN_CLICKED(IDC_CHANGE_BUTTON, OnChangeButton) - ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CRecentDlg message handlers - -BOOL CRecentDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // system image list - SHFILEINFO sfi; - m_himl = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - m_hliml=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX); - m_ctlRecent.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_himl); - m_ctlRecent.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hliml); - - // modify list style - m_ctlRecent.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); - - // update recent paths - for (int i=0;i<(int)m_cvRecent.size();i++) - { - sfi.iIcon=-1; - SHGetFileInfo(m_cvRecent.at(i), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlRecent.InsertItem(i, m_cvRecent.at(i), sfi.iIcon); - } - - return TRUE; -} - -void CRecentDlg::OnItemchangedRecentList(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_LISTVIEW* plv = (NM_LISTVIEW*)pNMHDR; - - // current selection - if (plv->iItem >= 0 && plv->iItem < (int)m_cvRecent.size()) - { - m_strPath=m_cvRecent.at(plv->iItem); - UpdateData(FALSE); - } - - *pResult = 0; -} - -void CRecentDlg::OnBrowseButton() -{ - CString strPath; - if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) - { - m_strPath=strPath; - UpdateData(FALSE); - } -} - -void CRecentDlg::OnAddButton() -{ - UpdateData(TRUE); - if (m_strPath.IsEmpty()) - return; - - // add to a table - m_cvRecent.push_back((const PTSTR)(LPCTSTR)m_strPath, true); - - // add to list with an icon - SHFILEINFO sfi; - sfi.iIcon=-1; - SHGetFileInfo(m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlRecent.InsertItem(m_cvRecent.size()-1, m_strPath, sfi.iIcon); -} - -void CRecentDlg::OnChangeButton() -{ - // read selection index - POSITION pos=m_ctlRecent.GetFirstSelectedItemPosition(); - if (pos) - { - // index - int iPos=m_ctlRecent.GetNextSelectedItem(pos); - - UpdateData(TRUE); - - if (m_strPath.IsEmpty()) - return; - - // array update - m_cvRecent.replace(m_cvRecent.begin()+iPos, (const PTSTR)(LPCTSTR)m_strPath, true, true); - - // list - SHFILEINFO sfi; - sfi.iIcon=-1; - SHGetFileInfo(m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - - m_ctlRecent.DeleteItem(iPos); - m_ctlRecent.InsertItem(iPos, m_strPath, sfi.iIcon); - } -} - -void CRecentDlg::OnDeleteButton() -{ - POSITION pos=m_ctlRecent.GetFirstSelectedItemPosition(); - int iPos=-1; - while (pos) - { - iPos=m_ctlRecent.GetNextSelectedItem(pos); - m_cvRecent.erase(m_cvRecent.begin()+iPos, true); - m_ctlRecent.DeleteItem(iPos); - } - - if (iPos != -1) - m_ctlRecent.SetItemState(iPos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); -} Index: src/ch/RecentDlg.h =================================================================== diff -u -N --- src/ch/RecentDlg.h (revision 0) +++ src/ch/RecentDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,72 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __RECENTDLG_H__ +#define __RECENTDLG_H__ + +#include "afxtempl.h" +#include "charvect.h" + +///////////////////////////////////////////////////////////////////////////// +// CRecentDlg dialog + +class CRecentDlg : public CHLanguageDialog +{ +// Construction +public: + CRecentDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CRecentDlg) + enum { IDD = IDD_RECENTEDIT_DIALOG }; + CListCtrl m_ctlRecent; + CString m_strPath; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CRecentDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +public: + char_vector m_cvRecent; + HIMAGELIST m_himl, m_hliml; + +protected: + + // Generated message map functions + //{{AFX_MSG(CRecentDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnItemchangedRecentList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnBrowseButton(); + afx_msg void OnAddButton(); + afx_msg void OnChangeButton(); + afx_msg void OnDeleteButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/RecentDlg.h =================================================================== diff -u -N --- ch/RecentDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/RecentDlg.h (revision 0) @@ -1,72 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __RECENTDLG_H__ -#define __RECENTDLG_H__ - -#include "afxtempl.h" -#include "charvect.h" - -///////////////////////////////////////////////////////////////////////////// -// CRecentDlg dialog - -class CRecentDlg : public CHLanguageDialog -{ -// Construction -public: - CRecentDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CRecentDlg) - enum { IDD = IDD_RECENTEDIT_DIALOG }; - CListCtrl m_ctlRecent; - CString m_strPath; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CRecentDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - char_vector m_cvRecent; - HIMAGELIST m_himl, m_hliml; - -protected: - - // Generated message map functions - //{{AFX_MSG(CRecentDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnItemchangedRecentList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnBrowseButton(); - afx_msg void OnAddButton(); - afx_msg void OnChangeButton(); - afx_msg void OnDeleteButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ReplaceFilesDlg.cpp =================================================================== diff -u -N --- src/ch/ReplaceFilesDlg.cpp (revision 0) +++ src/ch/ReplaceFilesDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,148 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "ReplaceFilesDlg.h" +#include "btnIDs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CReplaceFilesDlg dialog + + +CReplaceFilesDlg::CReplaceFilesDlg() + : CHLanguageDialog(CReplaceFilesDlg::IDD) +{ + //{{AFX_DATA_INIT(CReplaceFilesDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + + m_pfiSource=NULL; + m_pfiDest=NULL; + m_bEnableTimer=false; + m_iDefaultOption=ID_RECOPY; + m_iTime=30000; +} + + +void CReplaceFilesDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CReplaceFilesDlg) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CReplaceFilesDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CReplaceFilesDlg) + ON_BN_CLICKED(IDC_COPY_REST_BUTTON, OnCopyRestButton) + ON_BN_CLICKED(IDC_COPY_REST_ALL_BUTTON, OnCopyRestAllButton) + ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) + ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) + ON_BN_CLICKED(IDC_RECOPY_BUTTON, OnRecopyButton) + ON_BN_CLICKED(IDC_RECOPY_ALL_BUTTON, OnRecopyAllButton) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CReplaceFilesDlg message handlers + +BOOL CReplaceFilesDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // make on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + ASSERT(m_pfiSource); + ASSERT(m_pfiDest); + + // show attribs of src and dest + TCHAR xx[64]; + GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); + GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); + GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); + + GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); + GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); + GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); + + GetWindowText(m_strTitle); + + if (m_bEnableTimer) + SetTimer(1601, 1000, NULL); + + return TRUE; +} + +void CReplaceFilesDlg::OnCopyRestButton() +{ + EndDialog(ID_COPYREST); +} + +void CReplaceFilesDlg::OnCopyRestAllButton() +{ + EndDialog(ID_COPYRESTALL); +} + +void CReplaceFilesDlg::OnIgnoreButton() +{ + EndDialog(ID_IGNORE); +} + +void CReplaceFilesDlg::OnIgnoreAllButton() +{ + EndDialog(ID_IGNOREALL); +} + +void CReplaceFilesDlg::OnRecopyButton() +{ + EndDialog(ID_RECOPY); +} + +void CReplaceFilesDlg::OnRecopyAllButton() +{ + EndDialog(ID_RECOPYALL); +} + +void CReplaceFilesDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 1601) + { + m_iTime-=1000; + if (m_iTime < 0) + EndDialog(m_iDefaultOption); + + TCHAR xx[16]; + SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} Index: ch/ReplaceFilesDlg.cpp =================================================================== diff -u -N --- ch/ReplaceFilesDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplaceFilesDlg.cpp (revision 0) @@ -1,148 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "ReplaceFilesDlg.h" -#include "btnIDs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CReplaceFilesDlg dialog - - -CReplaceFilesDlg::CReplaceFilesDlg() - : CHLanguageDialog(CReplaceFilesDlg::IDD) -{ - //{{AFX_DATA_INIT(CReplaceFilesDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - m_pfiSource=NULL; - m_pfiDest=NULL; - m_bEnableTimer=false; - m_iDefaultOption=ID_RECOPY; - m_iTime=30000; -} - - -void CReplaceFilesDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CReplaceFilesDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CReplaceFilesDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CReplaceFilesDlg) - ON_BN_CLICKED(IDC_COPY_REST_BUTTON, OnCopyRestButton) - ON_BN_CLICKED(IDC_COPY_REST_ALL_BUTTON, OnCopyRestAllButton) - ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) - ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) - ON_BN_CLICKED(IDC_RECOPY_BUTTON, OnRecopyButton) - ON_BN_CLICKED(IDC_RECOPY_ALL_BUTTON, OnRecopyAllButton) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CReplaceFilesDlg message handlers - -BOOL CReplaceFilesDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // make on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - ASSERT(m_pfiSource); - ASSERT(m_pfiDest); - - // show attribs of src and dest - TCHAR xx[64]; - GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); - GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); - GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); - - GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); - GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); - GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); - - GetWindowText(m_strTitle); - - if (m_bEnableTimer) - SetTimer(1601, 1000, NULL); - - return TRUE; -} - -void CReplaceFilesDlg::OnCopyRestButton() -{ - EndDialog(ID_COPYREST); -} - -void CReplaceFilesDlg::OnCopyRestAllButton() -{ - EndDialog(ID_COPYRESTALL); -} - -void CReplaceFilesDlg::OnIgnoreButton() -{ - EndDialog(ID_IGNORE); -} - -void CReplaceFilesDlg::OnIgnoreAllButton() -{ - EndDialog(ID_IGNOREALL); -} - -void CReplaceFilesDlg::OnRecopyButton() -{ - EndDialog(ID_RECOPY); -} - -void CReplaceFilesDlg::OnRecopyAllButton() -{ - EndDialog(ID_RECOPYALL); -} - -void CReplaceFilesDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 1601) - { - m_iTime-=1000; - if (m_iTime < 0) - EndDialog(m_iDefaultOption); - - TCHAR xx[16]; - SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} Index: src/ch/ReplaceFilesDlg.h =================================================================== diff -u -N --- src/ch/ReplaceFilesDlg.h (revision 0) +++ src/ch/ReplaceFilesDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,75 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __REPLACEFILESDLG_H__ +#define __REPLACEFILESDLG_H__ + +#include "FileInfo.h" + +///////////////////////////////////////////////////////////////////////////// +// CReplaceFilesDlg dialog + +class CReplaceFilesDlg : public CHLanguageDialog +{ +// Construction +public: + CReplaceFilesDlg(); // standard constructor + + CFileInfo *m_pfiSource, *m_pfiDest; + + CString m_strTitle; + bool m_bEnableTimer; + int m_iTime; + int m_iDefaultOption; + +// Dialog Data + //{{AFX_DATA(CReplaceFilesDlg) + enum { IDD = IDD_FEEDBACK_REPLACE_FILES_DIALOG }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CReplaceFilesDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CReplaceFilesDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnCopyRestButton(); + afx_msg void OnCopyRestAllButton(); + afx_msg void OnIgnoreButton(); + afx_msg void OnIgnoreAllButton(); + afx_msg void OnRecopyButton(); + afx_msg void OnRecopyAllButton(); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ReplaceFilesDlg.h =================================================================== diff -u -N --- ch/ReplaceFilesDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplaceFilesDlg.h (revision 0) @@ -1,75 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __REPLACEFILESDLG_H__ -#define __REPLACEFILESDLG_H__ - -#include "FileInfo.h" - -///////////////////////////////////////////////////////////////////////////// -// CReplaceFilesDlg dialog - -class CReplaceFilesDlg : public CHLanguageDialog -{ -// Construction -public: - CReplaceFilesDlg(); // standard constructor - - CFileInfo *m_pfiSource, *m_pfiDest; - - CString m_strTitle; - bool m_bEnableTimer; - int m_iTime; - int m_iDefaultOption; - -// Dialog Data - //{{AFX_DATA(CReplaceFilesDlg) - enum { IDD = IDD_FEEDBACK_REPLACE_FILES_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CReplaceFilesDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CReplaceFilesDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnCopyRestButton(); - afx_msg void OnCopyRestAllButton(); - afx_msg void OnIgnoreButton(); - afx_msg void OnIgnoreAllButton(); - afx_msg void OnRecopyButton(); - afx_msg void OnRecopyAllButton(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ReplaceOnlyDlg.cpp =================================================================== diff -u -N --- src/ch/ReplaceOnlyDlg.cpp (revision 0) +++ src/ch/ReplaceOnlyDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,136 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "ReplaceOnlyDlg.h" +#include "btnIDs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CReplaceOnlyDlg dialog + + +CReplaceOnlyDlg::CReplaceOnlyDlg() + : CHLanguageDialog(CReplaceOnlyDlg::IDD) +{ + //{{AFX_DATA_INIT(CReplaceOnlyDlg) + m_strMessage = _T(""); + //}}AFX_DATA_INIT + m_pfiSource=NULL; + m_pfiDest=NULL; + m_bEnableTimer=false; + m_iDefaultOption=ID_RECOPY; + m_iTime=30000; +} + + +void CReplaceOnlyDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CReplaceOnlyDlg) + DDX_Text(pDX, IDC_MESSAGE_EDIT, m_strMessage); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CReplaceOnlyDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CReplaceOnlyDlg) + ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) + ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) + ON_BN_CLICKED(IDC_WAIT_BUTTON, OnWaitButton) + ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CReplaceOnlyDlg message handlers + +BOOL CReplaceOnlyDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // make on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + ASSERT(m_pfiSource); + ASSERT(m_pfiDest); + + // show attributes + TCHAR xx[64]; + GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); + GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); + GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); + + GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); + GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); + GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); + + // remember the title + GetWindowText(m_strTitle); + + if (m_bEnableTimer) + SetTimer(1601, 1000, NULL); + + return TRUE; +} + +void CReplaceOnlyDlg::OnIgnoreButton() +{ + EndDialog(ID_IGNORE); +} + +void CReplaceOnlyDlg::OnIgnoreAllButton() +{ + EndDialog(ID_IGNOREALL); +} + +void CReplaceOnlyDlg::OnWaitButton() +{ + EndDialog(ID_WAIT); +} + +void CReplaceOnlyDlg::OnRetryButton() +{ + EndDialog(ID_RETRY); +} + +void CReplaceOnlyDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 1601) + { + m_iTime-=1000; + if (m_iTime < 0) + EndDialog(m_iDefaultOption); + + TCHAR xx[16]; + SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} Index: ch/ReplaceOnlyDlg.cpp =================================================================== diff -u -N --- ch/ReplaceOnlyDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplaceOnlyDlg.cpp (revision 0) @@ -1,136 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "ReplaceOnlyDlg.h" -#include "btnIDs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CReplaceOnlyDlg dialog - - -CReplaceOnlyDlg::CReplaceOnlyDlg() - : CHLanguageDialog(CReplaceOnlyDlg::IDD) -{ - //{{AFX_DATA_INIT(CReplaceOnlyDlg) - m_strMessage = _T(""); - //}}AFX_DATA_INIT - m_pfiSource=NULL; - m_pfiDest=NULL; - m_bEnableTimer=false; - m_iDefaultOption=ID_RECOPY; - m_iTime=30000; -} - - -void CReplaceOnlyDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CReplaceOnlyDlg) - DDX_Text(pDX, IDC_MESSAGE_EDIT, m_strMessage); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CReplaceOnlyDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CReplaceOnlyDlg) - ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) - ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) - ON_BN_CLICKED(IDC_WAIT_BUTTON, OnWaitButton) - ON_BN_CLICKED(IDC_RETRY_BUTTON, OnRetryButton) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CReplaceOnlyDlg message handlers - -BOOL CReplaceOnlyDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // make on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - ASSERT(m_pfiSource); - ASSERT(m_pfiDest); - - // show attributes - TCHAR xx[64]; - GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); - GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); - GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); - - GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); - GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); - GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); - - // remember the title - GetWindowText(m_strTitle); - - if (m_bEnableTimer) - SetTimer(1601, 1000, NULL); - - return TRUE; -} - -void CReplaceOnlyDlg::OnIgnoreButton() -{ - EndDialog(ID_IGNORE); -} - -void CReplaceOnlyDlg::OnIgnoreAllButton() -{ - EndDialog(ID_IGNOREALL); -} - -void CReplaceOnlyDlg::OnWaitButton() -{ - EndDialog(ID_WAIT); -} - -void CReplaceOnlyDlg::OnRetryButton() -{ - EndDialog(ID_RETRY); -} - -void CReplaceOnlyDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 1601) - { - m_iTime-=1000; - if (m_iTime < 0) - EndDialog(m_iDefaultOption); - - TCHAR xx[16]; - SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} Index: src/ch/ReplaceOnlyDlg.h =================================================================== diff -u -N --- src/ch/ReplaceOnlyDlg.h (revision 0) +++ src/ch/ReplaceOnlyDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,73 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __REPLACEONLYDLG_H__ +#define __REPLACEONLYDLG_H__ + +#include "FileInfo.h" + +///////////////////////////////////////////////////////////////////////////// +// CReplaceOnlyDlg dialog + +class CReplaceOnlyDlg : public CHLanguageDialog +{ +// Construction +public: + CReplaceOnlyDlg(); // standard constructor + + CFileInfo *m_pfiSource, *m_pfiDest; + + CString m_strTitle; + bool m_bEnableTimer; + int m_iTime; + int m_iDefaultOption; + +// Dialog Data + //{{AFX_DATA(CReplaceOnlyDlg) + enum { IDD = IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG }; + CString m_strMessage; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CReplaceOnlyDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CReplaceOnlyDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnIgnoreButton(); + afx_msg void OnIgnoreAllButton(); + afx_msg void OnWaitButton(); + afx_msg void OnRetryButton(); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ReplaceOnlyDlg.h =================================================================== diff -u -N --- ch/ReplaceOnlyDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplaceOnlyDlg.h (revision 0) @@ -1,73 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __REPLACEONLYDLG_H__ -#define __REPLACEONLYDLG_H__ - -#include "FileInfo.h" - -///////////////////////////////////////////////////////////////////////////// -// CReplaceOnlyDlg dialog - -class CReplaceOnlyDlg : public CHLanguageDialog -{ -// Construction -public: - CReplaceOnlyDlg(); // standard constructor - - CFileInfo *m_pfiSource, *m_pfiDest; - - CString m_strTitle; - bool m_bEnableTimer; - int m_iTime; - int m_iDefaultOption; - -// Dialog Data - //{{AFX_DATA(CReplaceOnlyDlg) - enum { IDD = IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG }; - CString m_strMessage; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CReplaceOnlyDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CReplaceOnlyDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnIgnoreButton(); - afx_msg void OnIgnoreAllButton(); - afx_msg void OnWaitButton(); - afx_msg void OnRetryButton(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ReplacePathsDlg.cpp =================================================================== diff -u -N --- src/ch/ReplacePathsDlg.cpp (revision 0) +++ src/ch/ReplacePathsDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,106 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "ReplacePathsDlg.h" +#include "dialogs.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CReplacePathsDlg dialog + + +CReplacePathsDlg::CReplacePathsDlg() + : CHLanguageDialog(CReplacePathsDlg::IDD) +{ + //{{AFX_DATA_INIT(CReplacePathsDlg) + m_strDest = _T(""); + m_strSource = _T(""); + //}}AFX_DATA_INIT +} + + +void CReplacePathsDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CReplacePathsDlg) + DDX_Control(pDX, IDC_PATHS_LIST, m_ctlPathsList); + DDX_Text(pDX, IDC_DESTINATION_EDIT, m_strDest); + DDX_Text(pDX, IDC_SOURCE_EDIT, m_strSource); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CReplacePathsDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CReplacePathsDlg) + ON_LBN_SELCHANGE(IDC_PATHS_LIST, OnSelchangePathsList) + ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CReplacePathsDlg message handlers + +BOOL CReplacePathsDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + for (int i=0;iGetClipboardDataSize();i++) + m_ctlPathsList.AddString(m_pTask->GetClipboardData(i)->GetPath()); + + return TRUE; +} + +void CReplacePathsDlg::OnSelchangePathsList() +{ + int iSel=m_ctlPathsList.GetCurSel(); + if (iSel == LB_ERR) + return; + + m_ctlPathsList.GetText(iSel, m_strSource); + UpdateData(FALSE); +} + +void CReplacePathsDlg::OnOK() +{ + UpdateData(TRUE); + if (m_strSource.IsEmpty()) + MsgBox(IDS_SOURCESTRINGMISSING_STRING); + else + CHLanguageDialog::OnOK(); +} + +void CReplacePathsDlg::OnBrowseButton() +{ + CString strPath; + if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) + { + UpdateData(TRUE); + m_strDest=strPath; + UpdateData(FALSE); + } +} Index: ch/ReplacePathsDlg.cpp =================================================================== diff -u -N --- ch/ReplacePathsDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplacePathsDlg.cpp (revision 0) @@ -1,106 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "ReplacePathsDlg.h" -#include "dialogs.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CReplacePathsDlg dialog - - -CReplacePathsDlg::CReplacePathsDlg() - : CHLanguageDialog(CReplacePathsDlg::IDD) -{ - //{{AFX_DATA_INIT(CReplacePathsDlg) - m_strDest = _T(""); - m_strSource = _T(""); - //}}AFX_DATA_INIT -} - - -void CReplacePathsDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CReplacePathsDlg) - DDX_Control(pDX, IDC_PATHS_LIST, m_ctlPathsList); - DDX_Text(pDX, IDC_DESTINATION_EDIT, m_strDest); - DDX_Text(pDX, IDC_SOURCE_EDIT, m_strSource); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CReplacePathsDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CReplacePathsDlg) - ON_LBN_SELCHANGE(IDC_PATHS_LIST, OnSelchangePathsList) - ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CReplacePathsDlg message handlers - -BOOL CReplacePathsDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - for (int i=0;iGetClipboardDataSize();i++) - m_ctlPathsList.AddString(m_pTask->GetClipboardData(i)->GetPath()); - - return TRUE; -} - -void CReplacePathsDlg::OnSelchangePathsList() -{ - int iSel=m_ctlPathsList.GetCurSel(); - if (iSel == LB_ERR) - return; - - m_ctlPathsList.GetText(iSel, m_strSource); - UpdateData(FALSE); -} - -void CReplacePathsDlg::OnOK() -{ - UpdateData(TRUE); - if (m_strSource.IsEmpty()) - MsgBox(IDS_SOURCESTRINGMISSING_STRING); - else - CHLanguageDialog::OnOK(); -} - -void CReplacePathsDlg::OnBrowseButton() -{ - CString strPath; - if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) - { - UpdateData(TRUE); - m_strDest=strPath; - UpdateData(FALSE); - } -} Index: src/ch/ReplacePathsDlg.h =================================================================== diff -u -N --- src/ch/ReplacePathsDlg.h (revision 0) +++ src/ch/ReplacePathsDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,67 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __REPLACEPATHSDLG_H__ +#define __REPLACEPATHSDLG_H__ + +#include "structs.h" + +///////////////////////////////////////////////////////////////////////////// +// CReplacePathsDlg dialog + +class CReplacePathsDlg : public CHLanguageDialog +{ +// Construction +public: + CReplacePathsDlg(); // standard constructor + + CTask* m_pTask; +// Dialog Data + //{{AFX_DATA(CReplacePathsDlg) + enum { IDD = IDD_REPLACE_PATHS_DIALOG }; + CListBox m_ctlPathsList; + CString m_strDest; + CString m_strSource; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CReplacePathsDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CReplacePathsDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnSelchangePathsList(); + virtual void OnOK(); + afx_msg void OnBrowseButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ReplacePathsDlg.h =================================================================== diff -u -N --- ch/ReplacePathsDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ReplacePathsDlg.h (revision 0) @@ -1,67 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __REPLACEPATHSDLG_H__ -#define __REPLACEPATHSDLG_H__ - -#include "structs.h" - -///////////////////////////////////////////////////////////////////////////// -// CReplacePathsDlg dialog - -class CReplacePathsDlg : public CHLanguageDialog -{ -// Construction -public: - CReplacePathsDlg(); // standard constructor - - CTask* m_pTask; -// Dialog Data - //{{AFX_DATA(CReplacePathsDlg) - enum { IDD = IDD_REPLACE_PATHS_DIALOG }; - CListBox m_ctlPathsList; - CString m_strDest; - CString m_strSource; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CReplacePathsDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CReplacePathsDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnSelchangePathsList(); - virtual void OnOK(); - afx_msg void OnBrowseButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ResourceManager.cpp =================================================================== diff -u -N --- src/ch/ResourceManager.cpp (revision 0) +++ src/ch/ResourceManager.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,501 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "IniFile.h" +#include "ResourceManager.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +CLangData::CLangData(const CLangData& ld) +{ + szDefString=0; + pszFilename=NULL; + pszLngName=NULL; + pszBaseFile=NULL; + pszFontFace=NULL; + pszHelpName=NULL; + pszAuthor=NULL; + pszVersion=NULL; + pszStrings=NULL; + tCount=0; + + SetFilename(ld.GetFilename(true)); + SetLangName(ld.GetLangName()); + SetLangCode(ld.GetLangCode()); + SetFontFace(ld.GetFontFace()); + SetCharset(ld.GetCharset()); + SetPointSize(ld.GetPointSize()); + SetDirection(ld.GetDirection()); + SetHelpName(ld.GetHelpName()); + SetAuthor(ld.GetAuthor()); + SetVersion(ld.GetVersion()); + + SetStringData(ld.pszStrings, ld.tCount); +} + +bool CLangData::ReadInfo(PCTSTR pszFile) +{ + try + { + CIniFile file; + file.Open(pszFile, _T("Info"), true); + + TCHAR szData[512]; + SetLangName(file.GetString(_T("000"), _T("Info"), _T("Lang Name"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetLangCode((WORD)file.GetInt(_T("000"), _T("Info"), _T("Lang Code"), 0, szData)); + if (file.IsDefault()) + return false; + SetBaseFile(file.GetString(_T("000"), _T("Info"), _T("Base Language"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetFontFace(file.GetString(_T("000"), _T("Info"), _T("Font Face"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetCharset((BYTE)file.GetInt(_T("000"), _T("Info"), _T("Charset"), 0, szData)); + if (file.IsDefault()) + return false; + SetPointSize((WORD)file.GetInt(_T("000"), _T("Info"), _T("Size"), 0, szData)); + if (file.IsDefault()) + return false; + SetDirection(file.GetBool(_T("000"), _T("Info"), _T("RTL reading order"), false, szData)); + if (file.IsDefault()) + return false; + SetHelpName(file.GetString(_T("000"), _T("Info"), _T("Help name"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetAuthor(file.GetString(_T("000"), _T("Info"), _T("Author"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetVersion(file.GetString(_T("000"), _T("Info"), _T("Version"), szData, _T(""))); + if (file.IsDefault()) + return false; + + SetFilename(pszFile); + + return true; + } + catch(...) + { + return false; + } +} + +bool CLangData::ReadTranslation(PCTSTR pszFile, bool bUpdate) +{ + try + { + // load data from file + CIniFile file; + file.Open(pszFile, NULL, true); + + TCHAR szData[512]; + if (!bUpdate) + { + // std data + SetLangName(file.GetString(_T("000"), _T("Info"), _T("Lang Name"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetLangCode((WORD)file.GetInt(_T("000"), _T("Info"), _T("Lang Code"), 0, szData)); + if (file.IsDefault()) + return false; + SetBaseFile(file.GetString(_T("000"), _T("Info"), _T("Base Language"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetFontFace(file.GetString(_T("000"), _T("Info"), _T("Font Face"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetCharset((BYTE)file.GetInt(_T("000"), _T("Info"), _T("Charset"), 0, szData)); + if (file.IsDefault()) + return false; + SetPointSize((WORD)file.GetInt(_T("000"), _T("Info"), _T("Size"), 0, szData)); + if (file.IsDefault()) + return false; + SetDirection(file.GetBool(_T("000"), _T("Info"), _T("RTL reading order"), false, szData)); + if (file.IsDefault()) + return false; + SetHelpName(file.GetString(_T("000"), _T("Info"), _T("Help name"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetAuthor(file.GetString(_T("000"), _T("Info"), _T("Author"), szData, _T(""))); + if (file.IsDefault()) + return false; + SetVersion(file.GetString(_T("000"), _T("Info"), _T("Version"), szData, _T(""))); + if (file.IsDefault()) + return false; + } + + // read strings section + const _PROFILE* pcfg=file.GetProfile(_T("000")); + if (pcfg) + { + // enum through the sections + size_t tSkipped=(size_t)-1; + WORD wHiID, wLoID; + size_t tDataCount=0; + + // 1st phase - count data length + vector<_SECTION*>::const_iterator sit; + for (sit=pcfg->vSections.begin();sit != pcfg->vSections.end();sit++) + { + // skip "Info" section + if (tSkipped == -1 && _tcscmp((*sit)->pszSectionName, _T("Info")) == 0) + { + tSkipped=sit-pcfg->vSections.begin(); + continue; + } + + // now translate all the section of form [000] to the ID's, enum through the entries + for (vector<_ENTRY*>::iterator it=(*sit)->vEntries.begin();it != (*sit)->vEntries.end();it++) + { + if (!bUpdate || m_mStrings.find((_ttoi((*sit)->pszSectionName) << 16) | (_ttoi((*it)->pszKey))) == m_mStrings.end()) + tDataCount+=_tcslen((*it)->pszValue)+1; + } + } + + // allocate the buffer for all data + size_t tOffset=0; + if (bUpdate) + { + if (tDataCount == 0) + return true; + + // we need to reallocate the buffer + TCHAR* pszData=new TCHAR[tCount+tDataCount]; + memcpy(pszData, pszStrings, tCount*sizeof(TCHAR)); + + delete [] pszStrings; + pszStrings=pszData; + + tOffset=tCount; + tCount+=tDataCount; + } + else + { + // delete old settings + delete [] pszStrings; + m_mStrings.clear(); + + tCount=tDataCount; + pszStrings=new TCHAR[tDataCount]; + } + + // 2nd phase - copy all the data + for (sit=pcfg->vSections.begin();sit != pcfg->vSections.end();sit++) + { + // skip "Info" section + if (tSkipped == (size_t)(sit-pcfg->vSections.begin())) + continue; + + // now translate all the section of form [000] to the ID's, enum through the entries + wHiID=(WORD)_ttoi((*sit)->pszSectionName); + for (vector<_ENTRY*>::iterator it=(*sit)->vEntries.begin();it != (*sit)->vEntries.end();it++) + { + // add to the map + wLoID=(WORD)_ttoi((*it)->pszKey); + if (!bUpdate || m_mStrings.find((wHiID << 16) | wLoID) == m_mStrings.end()) + { + m_mStrings.insert(strings_map::value_type((((DWORD)wHiID) << 16 | wLoID), tOffset)); + + // copy string + _tcscpy(pszStrings+tOffset, (*it)->pszValue); + tOffset+=_tcslen(pszStrings+tOffset)+1; + } + } + } + } + + // free unneded data + file.Close(); + + if (!bUpdate) + { + // remember the filename + SetFilename(pszFile); + + // establish path to the base file + if (_tcslen(GetBaseFile()) != 0) + { + TCHAR* pszName=_tcsrchr(pszFile, _T('\\')); + if (pszName) + { + _tcsncpy(szData, pszFile, pszName-pszFile+1); + _tcscpy(szData+(pszName-pszFile+1), GetBaseFile()); + TRACE("Base (update) path=%s\n", szData); + ReadTranslation(szData, true); + } + } + } + + return true; + } + catch(...) + { + return false; + } +} + +PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID) +{ + strings_map::iterator it=m_mStrings.find((wHiID << 16) | wLoID); + if (it != m_mStrings.end()) + return pszStrings+(*it).second; + else + return &szDefString; +} + +void CLangData::SetFilename(PCTSTR psz) +{ + if (pszFilename) + delete [] pszFilename; + + // copy + pszFilename=new TCHAR[_tcslen(psz)+1]; + _tcscpy(pszFilename, psz); +} + +PCTSTR CLangData::GetFilename(bool bFullPath) const +{ + if (bFullPath) + return pszFilename; + else + { + TCHAR *pszFnd=_tcsrchr(pszFilename, _T('\\')); + if (pszFnd) + return pszFnd+1; + else + return pszFilename; + } +} + +void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc) +{ + if (*ppszDst) + delete [] (*ppszDst); + const TCHAR* pszLast=NULL; + if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != NULL) + pszLast++; + else + pszLast=pszSrc; + + // copy + *ppszDst=new TCHAR[_tcslen(pszLast)+1]; + _tcscpy(*ppszDst, pszLast); +} + +// requires the param with ending '\\' +void CResourceManager::Scan(LPCTSTR pszFolder, vector* pvData) +{ + TCHAR szPath[_MAX_PATH]; + _tcscpy(szPath, pszFolder); + _tcscat(szPath, _T("*.lng")); + + WIN32_FIND_DATA wfd; + HANDLE hFind=::FindFirstFile(szPath, &wfd); + BOOL bFound=TRUE; + CLangData ld; + while (bFound && hFind != INVALID_HANDLE_VALUE) + { + if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + _tcscpy(szPath, pszFolder); + _tcscat(szPath, wfd.cFileName); + if (ld.ReadInfo(szPath)) + pvData->push_back(ld); + } + + bFound=::FindNextFile(hFind, &wfd); + } + + if (hFind != INVALID_HANDLE_VALUE) + ::FindClose(hFind); +} + +bool CResourceManager::SetLanguage(PCTSTR pszPath) +{ + EnterCriticalSection(&m_cs); + WORD wOldLang=m_ld.GetLangCode(); + bool bRet=m_ld.ReadTranslation(pszPath); + WORD wNewLang=m_ld.GetLangCode(); + LeaveCriticalSection(&m_cs); + if (!bRet) + return false; + + // update registered dialog boxes + list::iterator it=m_lhDialogs.begin(); + while (it != m_lhDialogs.end()) + { + if (::IsWindow((*it)->m_hWnd)) + (*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); + it++; + } + + // send the notification stuff to the others + if (m_pfnCallback) + (*m_pfnCallback)(ROT_EVERYWHERE, WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); + + return bRet; +} + +HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName) +{ + EnterCriticalSection(&m_cs); + + // find resource + HGLOBAL hRet=NULL; + HRSRC hr=FindResource(m_hRes, pszName, pszType); + if (hr) + hRet=::LoadResource(m_hRes, hr); + + LeaveCriticalSection(&m_cs); + return hRet; +} + +HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName) +{ + return ::LoadAccelerators(m_hRes, pszName); +} + +HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName) +{ + return ::LoadBitmap(m_hRes, pszName); +} + +HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName) +{ + return ::LoadCursor(m_hRes, pszName); +} + +HICON CResourceManager::LoadIcon(LPCTSTR pszName) +{ + return ::LoadIcon(m_hRes, pszName); +} + +void CResourceManager::UpdateMenu(HMENU hMenu, WORD wMenuID) +{ + // change the strings inside the menu to the one from txt res file + int iCount=::GetMenuItemCount(hMenu); + MENUITEMINFO mif; + WORD wLoID; + TCHAR szItem[1024]; + for (int i=0;i::const_iterator sit; - for (sit=pcfg->vSections.begin();sit != pcfg->vSections.end();sit++) - { - // skip "Info" section - if (tSkipped == -1 && _tcscmp((*sit)->pszSectionName, _T("Info")) == 0) - { - tSkipped=sit-pcfg->vSections.begin(); - continue; - } - - // now translate all the section of form [000] to the ID's, enum through the entries - for (vector<_ENTRY*>::iterator it=(*sit)->vEntries.begin();it != (*sit)->vEntries.end();it++) - { - if (!bUpdate || m_mStrings.find((_ttoi((*sit)->pszSectionName) << 16) | (_ttoi((*it)->pszKey))) == m_mStrings.end()) - tDataCount+=_tcslen((*it)->pszValue)+1; - } - } - - // allocate the buffer for all data - size_t tOffset=0; - if (bUpdate) - { - if (tDataCount == 0) - return true; - - // we need to reallocate the buffer - TCHAR* pszData=new TCHAR[tCount+tDataCount]; - memcpy(pszData, pszStrings, tCount*sizeof(TCHAR)); - - delete [] pszStrings; - pszStrings=pszData; - - tOffset=tCount; - tCount+=tDataCount; - } - else - { - // delete old settings - delete [] pszStrings; - m_mStrings.clear(); - - tCount=tDataCount; - pszStrings=new TCHAR[tDataCount]; - } - - // 2nd phase - copy all the data - for (sit=pcfg->vSections.begin();sit != pcfg->vSections.end();sit++) - { - // skip "Info" section - if (tSkipped == (size_t)(sit-pcfg->vSections.begin())) - continue; - - // now translate all the section of form [000] to the ID's, enum through the entries - wHiID=(WORD)_ttoi((*sit)->pszSectionName); - for (vector<_ENTRY*>::iterator it=(*sit)->vEntries.begin();it != (*sit)->vEntries.end();it++) - { - // add to the map - wLoID=(WORD)_ttoi((*it)->pszKey); - if (!bUpdate || m_mStrings.find((wHiID << 16) | wLoID) == m_mStrings.end()) - { - m_mStrings.insert(strings_map::value_type((((DWORD)wHiID) << 16 | wLoID), tOffset)); - - // copy string - _tcscpy(pszStrings+tOffset, (*it)->pszValue); - tOffset+=_tcslen(pszStrings+tOffset)+1; - } - } - } - } - - // free unneded data - file.Close(); - - if (!bUpdate) - { - // remember the filename - SetFilename(pszFile); - - // establish path to the base file - if (_tcslen(GetBaseFile()) != 0) - { - TCHAR* pszName=_tcsrchr(pszFile, _T('\\')); - if (pszName) - { - _tcsncpy(szData, pszFile, pszName-pszFile+1); - _tcscpy(szData+(pszName-pszFile+1), GetBaseFile()); - TRACE("Base (update) path=%s\n", szData); - ReadTranslation(szData, true); - } - } - } - - return true; - } - catch(...) - { - return false; - } -} - -PCTSTR CLangData::GetString(WORD wHiID, WORD wLoID) -{ - strings_map::iterator it=m_mStrings.find((wHiID << 16) | wLoID); - if (it != m_mStrings.end()) - return pszStrings+(*it).second; - else - return &szDefString; -} - -void CLangData::SetFilename(PCTSTR psz) -{ - if (pszFilename) - delete [] pszFilename; - - // copy - pszFilename=new TCHAR[_tcslen(psz)+1]; - _tcscpy(pszFilename, psz); -} - -PCTSTR CLangData::GetFilename(bool bFullPath) const -{ - if (bFullPath) - return pszFilename; - else - { - TCHAR *pszFnd=_tcsrchr(pszFilename, _T('\\')); - if (pszFnd) - return pszFnd+1; - else - return pszFilename; - } -} - -void CLangData::SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc) -{ - if (*ppszDst) - delete [] (*ppszDst); - const TCHAR* pszLast=NULL; - if ( (pszLast=_tcsrchr(pszSrc, _T('\\'))) != NULL) - pszLast++; - else - pszLast=pszSrc; - - // copy - *ppszDst=new TCHAR[_tcslen(pszLast)+1]; - _tcscpy(*ppszDst, pszLast); -} - -// requires the param with ending '\\' -void CResourceManager::Scan(LPCTSTR pszFolder, vector* pvData) -{ - TCHAR szPath[_MAX_PATH]; - _tcscpy(szPath, pszFolder); - _tcscat(szPath, _T("*.lng")); - - WIN32_FIND_DATA wfd; - HANDLE hFind=::FindFirstFile(szPath, &wfd); - BOOL bFound=TRUE; - CLangData ld; - while (bFound && hFind != INVALID_HANDLE_VALUE) - { - if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - _tcscpy(szPath, pszFolder); - _tcscat(szPath, wfd.cFileName); - if (ld.ReadInfo(szPath)) - pvData->push_back(ld); - } - - bFound=::FindNextFile(hFind, &wfd); - } - - if (hFind != INVALID_HANDLE_VALUE) - ::FindClose(hFind); -} - -bool CResourceManager::SetLanguage(PCTSTR pszPath) -{ - EnterCriticalSection(&m_cs); - WORD wOldLang=m_ld.GetLangCode(); - bool bRet=m_ld.ReadTranslation(pszPath); - WORD wNewLang=m_ld.GetLangCode(); - LeaveCriticalSection(&m_cs); - if (!bRet) - return false; - - // update registered dialog boxes - list::iterator it=m_lhDialogs.begin(); - while (it != m_lhDialogs.end()) - { - if (::IsWindow((*it)->m_hWnd)) - (*it)->PostMessage(WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); - it++; - } - - // send the notification stuff to the others - if (m_pfnCallback) - (*m_pfnCallback)(ROT_EVERYWHERE, WM_RMNOTIFY, RMNT_LANGCHANGE, (LPARAM)(wOldLang << 16 | wNewLang)); - - return bRet; -} - -HGLOBAL CResourceManager::LoadResource(LPCTSTR pszType, LPCTSTR pszName) -{ - EnterCriticalSection(&m_cs); - - // find resource - HGLOBAL hRet=NULL; - HRSRC hr=FindResource(m_hRes, pszName, pszType); - if (hr) - hRet=::LoadResource(m_hRes, hr); - - LeaveCriticalSection(&m_cs); - return hRet; -} - -HACCEL CResourceManager::LoadAccelerators(LPCTSTR pszName) -{ - return ::LoadAccelerators(m_hRes, pszName); -} - -HBITMAP CResourceManager::LoadBitmap(LPCTSTR pszName) -{ - return ::LoadBitmap(m_hRes, pszName); -} - -HCURSOR CResourceManager::LoadCursor(LPCTSTR pszName) -{ - return ::LoadCursor(m_hRes, pszName); -} - -HICON CResourceManager::LoadIcon(LPCTSTR pszName) -{ - return ::LoadIcon(m_hRes, pszName); -} - -void CResourceManager::UpdateMenu(HMENU hMenu, WORD wMenuID) -{ - // change the strings inside the menu to the one from txt res file - int iCount=::GetMenuItemCount(hMenu); - MENUITEMINFO mif; - WORD wLoID; - TCHAR szItem[1024]; - for (int i=0;i +#include +#include +#include "af_defs.h" + +using namespace std; + +///////////////////////////////////////////////////////////////////////// +// types of notifications +// RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language +#define RMNT_LANGCHANGE 0x0001 + +/////////////////////////////////////////////////////////// +// language description structure +typedef map strings_map; + +class CLangData +{ +public: +// construction/destruction + CLangData() { szDefString=0; pszFilename=NULL; pszLngName=NULL; pszBaseFile=NULL; pszFontFace=NULL; pszHelpName=NULL; pszAuthor=NULL; pszVersion=NULL; pszStrings=NULL; tCount=0; } + ~CLangData() { delete [] pszFilename; delete [] pszLngName; delete [] pszBaseFile; delete [] pszFontFace; delete [] pszHelpName; delete [] pszAuthor; delete [] pszVersion; delete [] pszStrings; }; + CLangData(const CLangData& ld); + +protected: + void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc); + +public: +// operations + bool ReadInfo(PCTSTR pszFile); + bool ReadTranslation(PCTSTR pszFile, bool bUpdate=false); + + PCTSTR GetString(WORD wHiID, WORD wLoID); + +// attributes + void SetFilename(PCTSTR psz); + PCTSTR GetFilename(bool bFullPath) const; + + void SetLangName(PCTSTR psz) { if (pszLngName) delete [] pszLngName; pszLngName=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszLngName, psz); }; + PCTSTR GetLangName() const { return pszLngName; }; + + void SetBaseFile(PCTSTR psz) { SetFnameData(&pszBaseFile, psz); }; + PCTSTR GetBaseFile() const { return pszBaseFile; }; + + void SetLangCode(WORD wLang) { wLangCode=wLang; }; + WORD GetLangCode() const { return wLangCode; }; + + void SetFontFace(PCTSTR psz) { if (pszFontFace) delete [] pszFontFace; pszFontFace=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszFontFace, psz); }; + PCTSTR GetFontFace() const { return pszFontFace; }; + + void SetCharset(BYTE byChar) { byCharset=byChar; }; + BYTE GetCharset() const { return byCharset; }; + + void SetPointSize(WORD wSize) { wPointSize=wSize; }; + WORD GetPointSize() const { return wPointSize; }; + + void SetDirection(bool brtl) { bRTL=brtl; }; + bool GetDirection() const { return bRTL; }; + + void SetHelpName(PCTSTR psz) { SetFnameData(&pszHelpName, psz); }; + PCTSTR GetHelpName() const { return pszHelpName; }; + + void SetAuthor(PCTSTR psz) { if (pszAuthor) delete [] pszAuthor; pszAuthor=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszAuthor, psz); }; + PCTSTR GetAuthor() const { return pszAuthor; }; + + void SetVersion(PCTSTR psz) { if (pszVersion) delete [] pszVersion; pszVersion=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszVersion, psz); }; + PCTSTR GetVersion() const { return pszVersion; }; + + void SetStringData(PCTSTR psz, size_t tCnt) { tCount=tCnt; if (pszStrings) delete [] pszStrings; if (tCount > 0) { pszStrings=new TCHAR[tCnt]; memcpy(pszStrings, psz, tCnt*sizeof(TCHAR)); } }; + +public: + TCHAR *pszFilename; // file name of the language data (with path) + TCHAR *pszLngName; // name of the language (ie. Chinese (PRC)) + TCHAR *pszBaseFile; // file with base language data (wo path) + TCHAR *pszFontFace; // face name of the font that will be used in dialogs + WORD wLangCode; // language code + WORD wPointSize; // font point size + TCHAR *pszHelpName; // help name (wo the directory) for this language + TCHAR *pszAuthor; // author name + TCHAR *pszVersion; // version of this file + BYTE byCharset; // charset for use with the font + bool bRTL; // does the language require right-to-left reading order ? + + // strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0) + strings_map m_mStrings; // maps string ID to the offset in pszStrings + TCHAR *pszStrings; // contains all the strings - NULL separated + size_t tCount; // length of the string table + TCHAR szDefString; // default empty string +}; + +///////////////////////////////////////////////////////////////////////////////////// + +class CResourceManager +{ +public: + CResourceManager() { m_pfnCallback=NULL; m_hRes=NULL; InitializeCriticalSection(&m_cs); }; + ~CResourceManager() { DeleteCriticalSection(&m_cs); }; + + void Init(HMODULE hrc) { m_hRes=hrc; }; + + void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; + + void Scan(LPCTSTR pszFolder, vector* pvData); + bool SetLanguage(PCTSTR pszPath); + + // loading functions + HGLOBAL LoadResource(LPCTSTR pszType, LPCTSTR pszName); + HACCEL LoadAccelerators(LPCTSTR pszName); + HBITMAP LoadBitmap(LPCTSTR pszName); + HCURSOR LoadCursor(LPCTSTR pszName); + HICON LoadIcon(LPCTSTR pszName); + HANDLE LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad); + HMENU LoadMenu(LPCTSTR pszName); + LPDLGTEMPLATE LoadDialog(LPCTSTR pszName); + + PCTSTR LoadString(UINT uiID); + PCTSTR LoadString(WORD wGroup, WORD wID); + PTSTR LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax); + + // res updating functions + void UpdateMenu(HMENU hMenu, WORD wMenuID); + +public: + CLangData m_ld; // current language data + list m_lhDialogs; // currently displayed dialog boxes (even hidden) + + HMODULE m_hRes; + PFNNOTIFYCALLBACK m_pfnCallback; +// UINT m_uiMsg; + CRITICAL_SECTION m_cs; +}; + +#endif \ No newline at end of file Index: ch/ResourceManager.h =================================================================== diff -u -N --- ch/ResourceManager.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/ResourceManager.h (revision 0) @@ -1,155 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __RESOURCEMANAGER_H__ -#define __RESOURCEMANAGER_H__ - -#include -#include -#include -#include "af_defs.h" - -using namespace std; - -///////////////////////////////////////////////////////////////////////// -// types of notifications -// RMNT_LANGCHANGE, LPARAM - HIWORD - old language, LOWORD - new language -#define RMNT_LANGCHANGE 0x0001 - -/////////////////////////////////////////////////////////// -// language description structure -typedef map strings_map; - -class CLangData -{ -public: -// construction/destruction - CLangData() { szDefString=0; pszFilename=NULL; pszLngName=NULL; pszBaseFile=NULL; pszFontFace=NULL; pszHelpName=NULL; pszAuthor=NULL; pszVersion=NULL; pszStrings=NULL; tCount=0; } - ~CLangData() { delete [] pszFilename; delete [] pszLngName; delete [] pszBaseFile; delete [] pszFontFace; delete [] pszHelpName; delete [] pszAuthor; delete [] pszVersion; delete [] pszStrings; }; - CLangData(const CLangData& ld); - -protected: - void SetFnameData(PTSTR *ppszDst, PCTSTR pszSrc); - -public: -// operations - bool ReadInfo(PCTSTR pszFile); - bool ReadTranslation(PCTSTR pszFile, bool bUpdate=false); - - PCTSTR GetString(WORD wHiID, WORD wLoID); - -// attributes - void SetFilename(PCTSTR psz); - PCTSTR GetFilename(bool bFullPath) const; - - void SetLangName(PCTSTR psz) { if (pszLngName) delete [] pszLngName; pszLngName=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszLngName, psz); }; - PCTSTR GetLangName() const { return pszLngName; }; - - void SetBaseFile(PCTSTR psz) { SetFnameData(&pszBaseFile, psz); }; - PCTSTR GetBaseFile() const { return pszBaseFile; }; - - void SetLangCode(WORD wLang) { wLangCode=wLang; }; - WORD GetLangCode() const { return wLangCode; }; - - void SetFontFace(PCTSTR psz) { if (pszFontFace) delete [] pszFontFace; pszFontFace=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszFontFace, psz); }; - PCTSTR GetFontFace() const { return pszFontFace; }; - - void SetCharset(BYTE byChar) { byCharset=byChar; }; - BYTE GetCharset() const { return byCharset; }; - - void SetPointSize(WORD wSize) { wPointSize=wSize; }; - WORD GetPointSize() const { return wPointSize; }; - - void SetDirection(bool brtl) { bRTL=brtl; }; - bool GetDirection() const { return bRTL; }; - - void SetHelpName(PCTSTR psz) { SetFnameData(&pszHelpName, psz); }; - PCTSTR GetHelpName() const { return pszHelpName; }; - - void SetAuthor(PCTSTR psz) { if (pszAuthor) delete [] pszAuthor; pszAuthor=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszAuthor, psz); }; - PCTSTR GetAuthor() const { return pszAuthor; }; - - void SetVersion(PCTSTR psz) { if (pszVersion) delete [] pszVersion; pszVersion=new TCHAR[_tcslen(psz)+1]; _tcscpy(pszVersion, psz); }; - PCTSTR GetVersion() const { return pszVersion; }; - - void SetStringData(PCTSTR psz, size_t tCnt) { tCount=tCnt; if (pszStrings) delete [] pszStrings; if (tCount > 0) { pszStrings=new TCHAR[tCnt]; memcpy(pszStrings, psz, tCnt*sizeof(TCHAR)); } }; - -public: - TCHAR *pszFilename; // file name of the language data (with path) - TCHAR *pszLngName; // name of the language (ie. Chinese (PRC)) - TCHAR *pszBaseFile; // file with base language data (wo path) - TCHAR *pszFontFace; // face name of the font that will be used in dialogs - WORD wLangCode; // language code - WORD wPointSize; // font point size - TCHAR *pszHelpName; // help name (wo the directory) for this language - TCHAR *pszAuthor; // author name - TCHAR *pszVersion; // version of this file - BYTE byCharset; // charset for use with the font - bool bRTL; // does the language require right-to-left reading order ? - - // strings (for controls in dialog boxes the ID contains hi:dlg ID, lo:ctrl ID, for strings hi part is 0) - strings_map m_mStrings; // maps string ID to the offset in pszStrings - TCHAR *pszStrings; // contains all the strings - NULL separated - size_t tCount; // length of the string table - TCHAR szDefString; // default empty string -}; - -///////////////////////////////////////////////////////////////////////////////////// - -class CResourceManager -{ -public: - CResourceManager() { m_pfnCallback=NULL; m_hRes=NULL; InitializeCriticalSection(&m_cs); }; - ~CResourceManager() { DeleteCriticalSection(&m_cs); }; - - void Init(HMODULE hrc) { m_hRes=hrc; }; - - void SetCallback(PFNNOTIFYCALLBACK pfn) { m_pfnCallback=pfn; }; - - void Scan(LPCTSTR pszFolder, vector* pvData); - bool SetLanguage(PCTSTR pszPath); - - // loading functions - HGLOBAL LoadResource(LPCTSTR pszType, LPCTSTR pszName); - HACCEL LoadAccelerators(LPCTSTR pszName); - HBITMAP LoadBitmap(LPCTSTR pszName); - HCURSOR LoadCursor(LPCTSTR pszName); - HICON LoadIcon(LPCTSTR pszName); - HANDLE LoadImage(LPCTSTR lpszName, UINT uType, int cxDesired, int cyDesired, UINT fuLoad); - HMENU LoadMenu(LPCTSTR pszName); - LPDLGTEMPLATE LoadDialog(LPCTSTR pszName); - - PCTSTR LoadString(UINT uiID); - PCTSTR LoadString(WORD wGroup, WORD wID); - PTSTR LoadStringCopy(UINT uiID, PTSTR pszStr, UINT uiMax); - - // res updating functions - void UpdateMenu(HMENU hMenu, WORD wMenuID); - -public: - CLangData m_ld; // current language data - list m_lhDialogs; // currently displayed dialog boxes (even hidden) - - HMODULE m_hRes; - PFNNOTIFYCALLBACK m_pfnCallback; -// UINT m_uiMsg; - CRITICAL_SECTION m_cs; -}; - -#endif \ No newline at end of file Index: src/ch/ShortcutsDlg.cpp =================================================================== diff -u -N --- src/ch/ShortcutsDlg.cpp (revision 0) +++ src/ch/ShortcutsDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,357 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "copy handler.h" +#include "ShortcutsDlg.h" +#include "dialogs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CShortcutsDlg dialog + + +CShortcutsDlg::CShortcutsDlg(CWnd* pParent /*=NULL*/) + : CHLanguageDialog(CShortcutsDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CShortcutsDlg) + m_strName = _T(""); + //}}AFX_DATA_INIT + m_bActualisation=false; +} + + +void CShortcutsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CShortcutsDlg) + DDX_Control(pDX, IDC_PATH_COMBOBOXEX, m_ctlPath); + DDX_Control(pDX, IDC_SHORTCUT_LIST, m_ctlShortcuts); + DDX_Text(pDX, IDC_NAME_EDIT, m_strName); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CShortcutsDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CShortcutsDlg) + ON_NOTIFY(LVN_ITEMCHANGED, IDC_SHORTCUT_LIST, OnItemchangedShortcutList) + ON_CBN_EDITCHANGE(IDC_PATH_COMBOBOXEX, OnEditchangePathComboboxex) + ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton) + ON_BN_CLICKED(IDC_CHANGE_BUTTON, OnChangeButton) + ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) + ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) + ON_BN_CLICKED(IDC_UP_BUTTON, OnUpButton) + ON_BN_CLICKED(IDC_DOWN_BUTTON, OnDownButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CShortcutsDlg message handlers + +BOOL CShortcutsDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // system image list + SHFILEINFO sfi; + m_himl = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + m_hliml=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), + SHGFI_SYSICONINDEX); + m_ctlPath.SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)m_himl); + m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_himl); + m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hliml); + + // copy all of the recent paths to combo + COMBOBOXEXITEM cbi; + cbi.mask=CBEIF_IMAGE | CBEIF_TEXT; + + for (int i=0;i<(int)m_pcvRecent->size();i++) + { + cbi.iItem=i; + cbi.pszText=m_pcvRecent->at(i); + sfi.iIcon=-1; + SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + cbi.iImage=sfi.iIcon; + + m_ctlPath.InsertItem(&cbi); + } + + // create columns in shortcuts list + LVCOLUMN lvc; + lvc.mask=LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT; + lvc.iSubItem=-1; + lvc.cx=100; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_SHORTCUTNAME_STRING); + m_ctlShortcuts.InsertColumn(0, &lvc); + lvc.iSubItem=0; + lvc.cx=200; + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_SHORTCUTPATH_STRING); + m_ctlShortcuts.InsertColumn(1, &lvc); + + // modify list style + m_ctlShortcuts.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); + + // update shortcut list + CShortcut sc; + for (i=0;i<(int)m_cvShortcuts.size();i++) + { + sc=CString(m_cvShortcuts.at(i)); + sfi.iIcon=-1; + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.InsertItem(i, sc.m_strName, sfi.iIcon); + m_ctlShortcuts.SetItem(i, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + } + + return TRUE; +} + +void CShortcutsDlg::OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult) +{ + NM_LISTVIEW* plv = (NM_LISTVIEW*)pNMHDR; + + // current selection + if (plv->iItem >= 0 && plv->iItem < (int)m_cvShortcuts.size()) + { + CShortcut sc(CString(m_cvShortcuts.at(plv->iItem))); + m_strName=sc.m_strName; + UpdateData(FALSE); + SetComboPath(sc.m_strPath); + } + + *pResult = 0; +} + +void CShortcutsDlg::SetComboPath(LPCTSTR lpszPath) +{ + // unselect + m_ctlPath.SetCurSel(-1); + + SHFILEINFO sfi; + sfi.iIcon=-1; + + COMBOBOXEXITEM cbi; + + cbi.mask=CBEIF_TEXT | CBEIF_IMAGE; + cbi.iItem=-1; + cbi.pszText=(LPTSTR)lpszPath; + SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + cbi.iImage=sfi.iIcon; + + m_ctlPath.SetItem(&cbi); +} + +void CShortcutsDlg::UpdateComboIcon() +{ + // get combo text + COMBOBOXEXITEM cbi; + TCHAR szPath[_MAX_PATH]; + cbi.mask=CBEIF_TEXT; + cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; + cbi.pszText=szPath; + cbi.cchTextMax=_MAX_PATH; + + if (!m_ctlPath.GetItem(&cbi)) + return; + + // unselect + m_ctlPath.SetCurSel(-1); + + // icon update + SHFILEINFO sfi; + sfi.iIcon=-1; + + cbi.mask |= CBEIF_IMAGE; + cbi.iItem=-1; + + CString str=(LPCTSTR)szPath; + if (str.Left(2) != _T("\\\\") || str.Find(_T('\\'), 2) != -1) + SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); + + cbi.iImage=sfi.iIcon; + + m_ctlPath.SetItem(&cbi); + + // unselect text + CEdit* pEdit=m_ctlPath.GetEditCtrl(); + if (!pEdit) + return; + + pEdit->SetSel(-1, -1); +} + +void CShortcutsDlg::OnEditchangePathComboboxex() +{ + if (m_bActualisation) + return; + m_bActualisation=true; + UpdateComboIcon(); + m_bActualisation=false; +} + +void CShortcutsDlg::OnAddButton() +{ + // create new shortcut + UpdateData(TRUE); + CShortcut sc; + sc.m_strName=m_strName; + m_ctlPath.GetWindowText(sc.m_strPath); + + // add to an array + m_cvShortcuts.push_back((const PTSTR)(LPCTSTR)(CString)sc, true); + + // add with an icon + SHFILEINFO sfi; + sfi.iIcon=-1; + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.InsertItem(m_cvShortcuts.size()-1, sc.m_strName, sfi.iIcon); + m_ctlShortcuts.SetItem(m_cvShortcuts.size()-1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); +} + +void CShortcutsDlg::OnChangeButton() +{ + // get selection index + POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); + if (pos) + { + // index + int iPos=m_ctlShortcuts.GetNextSelectedItem(pos); + + // get new shortcut + UpdateData(TRUE); + CShortcut sc; + sc.m_strName=m_strName; + m_ctlPath.GetWindowText(sc.m_strPath); + + // array update + m_cvShortcuts.replace(m_cvShortcuts.begin()+iPos, (const PTSTR)(LPCTSTR)(CString)sc, true, true); + + // list + SHFILEINFO sfi; + sfi.iIcon=-1; + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + + m_ctlShortcuts.DeleteItem(iPos); + + m_ctlShortcuts.InsertItem(iPos, sc.m_strName, sfi.iIcon); + m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + } +} + +void CShortcutsDlg::OnDeleteButton() +{ + POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); + int iPos=-1; + while (pos) + { + iPos=m_ctlShortcuts.GetNextSelectedItem(pos); + m_cvShortcuts.erase(m_cvShortcuts.begin()+iPos, true); + m_ctlShortcuts.DeleteItem(iPos); + } + + if (iPos != -1) + m_ctlShortcuts.SetItemState(iPos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); +} + +void CShortcutsDlg::OnBrowseButton() +{ + CString strPath; + if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) + SetComboPath(strPath); +} + +void CShortcutsDlg::OnUpButton() +{ + POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); + int iPos=-1; + CShortcut sc; + while (pos) + { + // get current selected item + iPos=m_ctlShortcuts.GetNextSelectedItem(pos); + + // if the first element is trying to go up to nowhere + if (iPos == 0) + break; + + // swap data in m_ascShortcuts + m_cvShortcuts.swap_items(m_cvShortcuts.begin()+iPos-1, m_cvShortcuts.begin()+iPos); + + // do the same with list + SHFILEINFO sfi; + sfi.iIcon=-1; + + sc=CString(m_cvShortcuts.at(iPos-1)); + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.SetItem(iPos-1, -1, LVIF_TEXT | LVIF_IMAGE , sc.m_strName, sfi.iIcon, 0, 0, 0); + m_ctlShortcuts.SetItem(iPos-1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + + sfi.iIcon=-1; + sc=CString(m_cvShortcuts.at(iPos)); + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.SetItem(iPos, -1, LVIF_TEXT | LVIF_IMAGE, sc.m_strName, sfi.iIcon, 0, 0, 0); + m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + + m_ctlShortcuts.SetItemState(iPos, 0, LVIS_SELECTED | LVIS_FOCUSED); + m_ctlShortcuts.SetItemState(iPos-1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + } +} + +void CShortcutsDlg::OnDownButton() +{ + POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); + int iPos=-1; + CShortcut sc; + while (pos) + { + // get current selected item + iPos=m_ctlShortcuts.GetNextSelectedItem(pos); + + // if the last element is trying to go down to nowhere + if (iPos == m_ctlShortcuts.GetItemCount()-1) + break; + + // swap data in m_ascShortcuts + m_cvShortcuts.swap_items(m_cvShortcuts.begin()+iPos, m_cvShortcuts.begin()+iPos+1); + + // do the same with list + SHFILEINFO sfi; + sfi.iIcon=-1; + + sc=CString(m_cvShortcuts.at(iPos)); + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.SetItem(iPos, -1, LVIF_TEXT | LVIF_IMAGE , sc.m_strName, sfi.iIcon, 0, 0, 0); + m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + + sfi.iIcon=-1; + sc=CString(m_cvShortcuts.at(iPos+1)); + SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); + m_ctlShortcuts.SetItem(iPos+1, -1, LVIF_TEXT | LVIF_IMAGE, sc.m_strName, sfi.iIcon, 0, 0, 0); + m_ctlShortcuts.SetItem(iPos+1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); + + m_ctlShortcuts.SetItemState(iPos, 0, LVIS_SELECTED | LVIS_FOCUSED); + m_ctlShortcuts.SetItemState(iPos+1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + } +} Index: ch/ShortcutsDlg.cpp =================================================================== diff -u -N --- ch/ShortcutsDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ShortcutsDlg.cpp (revision 0) @@ -1,357 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "copy handler.h" -#include "ShortcutsDlg.h" -#include "dialogs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CShortcutsDlg dialog - - -CShortcutsDlg::CShortcutsDlg(CWnd* pParent /*=NULL*/) - : CHLanguageDialog(CShortcutsDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CShortcutsDlg) - m_strName = _T(""); - //}}AFX_DATA_INIT - m_bActualisation=false; -} - - -void CShortcutsDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CShortcutsDlg) - DDX_Control(pDX, IDC_PATH_COMBOBOXEX, m_ctlPath); - DDX_Control(pDX, IDC_SHORTCUT_LIST, m_ctlShortcuts); - DDX_Text(pDX, IDC_NAME_EDIT, m_strName); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CShortcutsDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CShortcutsDlg) - ON_NOTIFY(LVN_ITEMCHANGED, IDC_SHORTCUT_LIST, OnItemchangedShortcutList) - ON_CBN_EDITCHANGE(IDC_PATH_COMBOBOXEX, OnEditchangePathComboboxex) - ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton) - ON_BN_CLICKED(IDC_CHANGE_BUTTON, OnChangeButton) - ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) - ON_BN_CLICKED(IDC_BROWSE_BUTTON, OnBrowseButton) - ON_BN_CLICKED(IDC_UP_BUTTON, OnUpButton) - ON_BN_CLICKED(IDC_DOWN_BUTTON, OnDownButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CShortcutsDlg message handlers - -BOOL CShortcutsDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // system image list - SHFILEINFO sfi; - m_himl = (HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - m_hliml=(HIMAGELIST)SHGetFileInfo(_T("C:\\"), FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), - SHGFI_SYSICONINDEX); - m_ctlPath.SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)m_himl); - m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_SMALL, (LPARAM)m_himl); - m_ctlShortcuts.SendMessage(LVM_SETIMAGELIST, (WPARAM)LVSIL_NORMAL, (LPARAM)m_hliml); - - // copy all of the recent paths to combo - COMBOBOXEXITEM cbi; - cbi.mask=CBEIF_IMAGE | CBEIF_TEXT; - - for (int i=0;i<(int)m_pcvRecent->size();i++) - { - cbi.iItem=i; - cbi.pszText=m_pcvRecent->at(i); - sfi.iIcon=-1; - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - cbi.iImage=sfi.iIcon; - - m_ctlPath.InsertItem(&cbi); - } - - // create columns in shortcuts list - LVCOLUMN lvc; - lvc.mask=LVCF_SUBITEM | LVCF_WIDTH | LVCF_TEXT; - lvc.iSubItem=-1; - lvc.cx=100; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_SHORTCUTNAME_STRING); - m_ctlShortcuts.InsertColumn(0, &lvc); - lvc.iSubItem=0; - lvc.cx=200; - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_SHORTCUTPATH_STRING); - m_ctlShortcuts.InsertColumn(1, &lvc); - - // modify list style - m_ctlShortcuts.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_INFOTIP | LVS_EX_UNDERLINEHOT); - - // update shortcut list - CShortcut sc; - for (i=0;i<(int)m_cvShortcuts.size();i++) - { - sc=CString(m_cvShortcuts.at(i)); - sfi.iIcon=-1; - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.InsertItem(i, sc.m_strName, sfi.iIcon); - m_ctlShortcuts.SetItem(i, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - } - - return TRUE; -} - -void CShortcutsDlg::OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult) -{ - NM_LISTVIEW* plv = (NM_LISTVIEW*)pNMHDR; - - // current selection - if (plv->iItem >= 0 && plv->iItem < (int)m_cvShortcuts.size()) - { - CShortcut sc(CString(m_cvShortcuts.at(plv->iItem))); - m_strName=sc.m_strName; - UpdateData(FALSE); - SetComboPath(sc.m_strPath); - } - - *pResult = 0; -} - -void CShortcutsDlg::SetComboPath(LPCTSTR lpszPath) -{ - // unselect - m_ctlPath.SetCurSel(-1); - - SHFILEINFO sfi; - sfi.iIcon=-1; - - COMBOBOXEXITEM cbi; - - cbi.mask=CBEIF_TEXT | CBEIF_IMAGE; - cbi.iItem=-1; - cbi.pszText=(LPTSTR)lpszPath; - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - cbi.iImage=sfi.iIcon; - - m_ctlPath.SetItem(&cbi); -} - -void CShortcutsDlg::UpdateComboIcon() -{ - // get combo text - COMBOBOXEXITEM cbi; - TCHAR szPath[_MAX_PATH]; - cbi.mask=CBEIF_TEXT; - cbi.iItem=m_ctlPath.GetCurSel()/*-1*/; - cbi.pszText=szPath; - cbi.cchTextMax=_MAX_PATH; - - if (!m_ctlPath.GetItem(&cbi)) - return; - - // unselect - m_ctlPath.SetCurSel(-1); - - // icon update - SHFILEINFO sfi; - sfi.iIcon=-1; - - cbi.mask |= CBEIF_IMAGE; - cbi.iItem=-1; - - CString str=(LPCTSTR)szPath; - if (str.Left(2) != _T("\\\\") || str.Find(_T('\\'), 2) != -1) - SHGetFileInfo(cbi.pszText, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SMALLICON | SHGFI_SYSICONINDEX); - - cbi.iImage=sfi.iIcon; - - m_ctlPath.SetItem(&cbi); - - // unselect text - CEdit* pEdit=m_ctlPath.GetEditCtrl(); - if (!pEdit) - return; - - pEdit->SetSel(-1, -1); -} - -void CShortcutsDlg::OnEditchangePathComboboxex() -{ - if (m_bActualisation) - return; - m_bActualisation=true; - UpdateComboIcon(); - m_bActualisation=false; -} - -void CShortcutsDlg::OnAddButton() -{ - // create new shortcut - UpdateData(TRUE); - CShortcut sc; - sc.m_strName=m_strName; - m_ctlPath.GetWindowText(sc.m_strPath); - - // add to an array - m_cvShortcuts.push_back((const PTSTR)(LPCTSTR)(CString)sc, true); - - // add with an icon - SHFILEINFO sfi; - sfi.iIcon=-1; - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.InsertItem(m_cvShortcuts.size()-1, sc.m_strName, sfi.iIcon); - m_ctlShortcuts.SetItem(m_cvShortcuts.size()-1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); -} - -void CShortcutsDlg::OnChangeButton() -{ - // get selection index - POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); - if (pos) - { - // index - int iPos=m_ctlShortcuts.GetNextSelectedItem(pos); - - // get new shortcut - UpdateData(TRUE); - CShortcut sc; - sc.m_strName=m_strName; - m_ctlPath.GetWindowText(sc.m_strPath); - - // array update - m_cvShortcuts.replace(m_cvShortcuts.begin()+iPos, (const PTSTR)(LPCTSTR)(CString)sc, true, true); - - // list - SHFILEINFO sfi; - sfi.iIcon=-1; - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - - m_ctlShortcuts.DeleteItem(iPos); - - m_ctlShortcuts.InsertItem(iPos, sc.m_strName, sfi.iIcon); - m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - } -} - -void CShortcutsDlg::OnDeleteButton() -{ - POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); - int iPos=-1; - while (pos) - { - iPos=m_ctlShortcuts.GetNextSelectedItem(pos); - m_cvShortcuts.erase(m_cvShortcuts.begin()+iPos, true); - m_ctlShortcuts.DeleteItem(iPos); - } - - if (iPos != -1) - m_ctlShortcuts.SetItemState(iPos, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); -} - -void CShortcutsDlg::OnBrowseButton() -{ - CString strPath; - if (BrowseForFolder(GetResManager()->LoadString(IDS_BROWSE_STRING), &strPath)) - SetComboPath(strPath); -} - -void CShortcutsDlg::OnUpButton() -{ - POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); - int iPos=-1; - CShortcut sc; - while (pos) - { - // get current selected item - iPos=m_ctlShortcuts.GetNextSelectedItem(pos); - - // if the first element is trying to go up to nowhere - if (iPos == 0) - break; - - // swap data in m_ascShortcuts - m_cvShortcuts.swap_items(m_cvShortcuts.begin()+iPos-1, m_cvShortcuts.begin()+iPos); - - // do the same with list - SHFILEINFO sfi; - sfi.iIcon=-1; - - sc=CString(m_cvShortcuts.at(iPos-1)); - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.SetItem(iPos-1, -1, LVIF_TEXT | LVIF_IMAGE , sc.m_strName, sfi.iIcon, 0, 0, 0); - m_ctlShortcuts.SetItem(iPos-1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - - sfi.iIcon=-1; - sc=CString(m_cvShortcuts.at(iPos)); - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.SetItem(iPos, -1, LVIF_TEXT | LVIF_IMAGE, sc.m_strName, sfi.iIcon, 0, 0, 0); - m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - - m_ctlShortcuts.SetItemState(iPos, 0, LVIS_SELECTED | LVIS_FOCUSED); - m_ctlShortcuts.SetItemState(iPos-1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - } -} - -void CShortcutsDlg::OnDownButton() -{ - POSITION pos=m_ctlShortcuts.GetFirstSelectedItemPosition(); - int iPos=-1; - CShortcut sc; - while (pos) - { - // get current selected item - iPos=m_ctlShortcuts.GetNextSelectedItem(pos); - - // if the last element is trying to go down to nowhere - if (iPos == m_ctlShortcuts.GetItemCount()-1) - break; - - // swap data in m_ascShortcuts - m_cvShortcuts.swap_items(m_cvShortcuts.begin()+iPos, m_cvShortcuts.begin()+iPos+1); - - // do the same with list - SHFILEINFO sfi; - sfi.iIcon=-1; - - sc=CString(m_cvShortcuts.at(iPos)); - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.SetItem(iPos, -1, LVIF_TEXT | LVIF_IMAGE , sc.m_strName, sfi.iIcon, 0, 0, 0); - m_ctlShortcuts.SetItem(iPos, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - - sfi.iIcon=-1; - sc=CString(m_cvShortcuts.at(iPos+1)); - SHGetFileInfo(sc.m_strPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(sfi), SHGFI_SYSICONINDEX | SHGFI_LARGEICON); - m_ctlShortcuts.SetItem(iPos+1, -1, LVIF_TEXT | LVIF_IMAGE, sc.m_strName, sfi.iIcon, 0, 0, 0); - m_ctlShortcuts.SetItem(iPos+1, 1, LVIF_TEXT, sc.m_strPath, 0, 0, 0, 0); - - m_ctlShortcuts.SetItemState(iPos, 0, LVIS_SELECTED | LVIS_FOCUSED); - m_ctlShortcuts.SetItemState(iPos+1, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - } -} Index: src/ch/ShutdownDlg.cpp =================================================================== diff -u -N --- src/ch/ShutdownDlg.cpp (revision 0) +++ src/ch/ShutdownDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,103 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "copy handler.h" +#include "ShutdownDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CShutdownDlg dialog + + +CShutdownDlg::CShutdownDlg() + : CHLanguageDialog(CShutdownDlg::IDD) +{ + //{{AFX_DATA_INIT(CShutdownDlg) + m_strTime = _T(""); + //}}AFX_DATA_INIT +} + + +void CShutdownDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CShutdownDlg) + DDX_Control(pDX, IDC_TIME_PROGRESS, m_ctlProgress); + DDX_Text(pDX, IDC_TIME_STATIC, m_strTime); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CShutdownDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CShutdownDlg) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CShutdownDlg message handlers + +BOOL CShutdownDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // make on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + // init progress + m_iTime=m_iOverallTime; + m_ctlProgress.SetRange32(0, m_iOverallTime); + + // init timer + SetTimer(6678, 200, NULL); + + return TRUE; +} + +void CShutdownDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 6678) + { + m_iTime-=200; + if (m_iTime < 0) + m_iTime=0; + + m_ctlProgress.SetPos(m_iOverallTime-m_iTime); + FormatTimeString(m_iTime, &m_strTime); + UpdateData(FALSE); + + if (m_iTime == 0) + EndDialog(IDOK); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} + +void CShutdownDlg::FormatTimeString(int iTime, CString *pstrData) +{ + _stprintf(pstrData->GetBuffer(32), _T("%lu s."), iTime/1000); + pstrData->ReleaseBuffer(); +} Index: ch/ShutdownDlg.cpp =================================================================== diff -u -N --- ch/ShutdownDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ShutdownDlg.cpp (revision 0) @@ -1,103 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "copy handler.h" -#include "ShutdownDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CShutdownDlg dialog - - -CShutdownDlg::CShutdownDlg() - : CHLanguageDialog(CShutdownDlg::IDD) -{ - //{{AFX_DATA_INIT(CShutdownDlg) - m_strTime = _T(""); - //}}AFX_DATA_INIT -} - - -void CShutdownDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CShutdownDlg) - DDX_Control(pDX, IDC_TIME_PROGRESS, m_ctlProgress); - DDX_Text(pDX, IDC_TIME_STATIC, m_strTime); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CShutdownDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CShutdownDlg) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CShutdownDlg message handlers - -BOOL CShutdownDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // make on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - // init progress - m_iTime=m_iOverallTime; - m_ctlProgress.SetRange32(0, m_iOverallTime); - - // init timer - SetTimer(6678, 200, NULL); - - return TRUE; -} - -void CShutdownDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 6678) - { - m_iTime-=200; - if (m_iTime < 0) - m_iTime=0; - - m_ctlProgress.SetPos(m_iOverallTime-m_iTime); - FormatTimeString(m_iTime, &m_strTime); - UpdateData(FALSE); - - if (m_iTime == 0) - EndDialog(IDOK); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} - -void CShutdownDlg::FormatTimeString(int iTime, CString *pstrData) -{ - _stprintf(pstrData->GetBuffer(32), _T("%lu s."), iTime/1000); - pstrData->ReleaseBuffer(); -} Index: src/ch/ShutdownDlg.h =================================================================== diff -u -N --- src/ch/ShutdownDlg.h (revision 0) +++ src/ch/ShutdownDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,65 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __SHUTDOWNDLG_H__ +#define __SHUTDOWNDLG_H__ + +///////////////////////////////////////////////////////////////////////////// +// CShutdownDlg dialog + +class CShutdownDlg : public CHLanguageDialog +{ +// Construction +public: + CShutdownDlg(); // standard constructor + + int m_iOverallTime; + +// Dialog Data + //{{AFX_DATA(CShutdownDlg) + enum { IDD = IDD_SHUTDOWN_DIALOG }; + CProgressCtrl m_ctlProgress; + CString m_strTime; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CShutdownDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + void FormatTimeString(int iTime, CString* pstrData); + int m_iTime; // czas w sekundach + + // Generated message map functions + //{{AFX_MSG(CShutdownDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ShutdownDlg.h =================================================================== diff -u -N --- ch/ShutdownDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ShutdownDlg.h (revision 0) @@ -1,65 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __SHUTDOWNDLG_H__ -#define __SHUTDOWNDLG_H__ - -///////////////////////////////////////////////////////////////////////////// -// CShutdownDlg dialog - -class CShutdownDlg : public CHLanguageDialog -{ -// Construction -public: - CShutdownDlg(); // standard constructor - - int m_iOverallTime; - -// Dialog Data - //{{AFX_DATA(CShutdownDlg) - enum { IDD = IDD_SHUTDOWN_DIALOG }; - CProgressCtrl m_ctlProgress; - CString m_strTime; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CShutdownDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - void FormatTimeString(int iTime, CString* pstrData); - int m_iTime; // czas w sekundach - - // Generated message map functions - //{{AFX_MSG(CShutdownDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/SmallReplaceFilesDlg.cpp =================================================================== diff -u -N --- src/ch/SmallReplaceFilesDlg.cpp (revision 0) +++ src/ch/SmallReplaceFilesDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,134 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "resource.h" +#include "SmallReplaceFilesDlg.h" +#include "btnIDs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CSmallReplaceFilesDlg dialog + + +CSmallReplaceFilesDlg::CSmallReplaceFilesDlg() + : CHLanguageDialog(CSmallReplaceFilesDlg::IDD) +{ + //{{AFX_DATA_INIT(CSmallReplaceFilesDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + // zeruj zmienne + m_pfiSource=NULL; + m_pfiDest=NULL; + m_bEnableTimer=false; + m_iDefaultOption=ID_RECOPY; + m_iTime=30000; +} + +void CSmallReplaceFilesDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSmallReplaceFilesDlg) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CSmallReplaceFilesDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CSmallReplaceFilesDlg) + ON_BN_CLICKED(IDC_RECOPY_BUTTON, OnRecopyButton) + ON_BN_CLICKED(IDC_RECOPY_ALL_BUTTON, OnRecopyAllButton) + ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) + ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) + ON_WM_TIMER() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSmallReplaceFilesDlg message handlers + +BOOL CSmallReplaceFilesDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // set on top + SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); + + ASSERT(m_pfiSource); + ASSERT(m_pfiDest); + + // show attributes + TCHAR xx[64]; + GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); + GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); + GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); + + GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); + GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); + GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); + GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); + + GetWindowText(m_strTitle); + + if (m_bEnableTimer) + SetTimer(1601, 1000, NULL); + + return TRUE; +} + +void CSmallReplaceFilesDlg::OnRecopyButton() +{ + EndDialog(ID_RECOPY); +} + +void CSmallReplaceFilesDlg::OnRecopyAllButton() +{ + EndDialog(ID_RECOPYALL); +} + +void CSmallReplaceFilesDlg::OnIgnoreButton() +{ + EndDialog(ID_IGNORE); +} + +void CSmallReplaceFilesDlg::OnIgnoreAllButton() +{ + EndDialog(ID_IGNOREALL); +} + +void CSmallReplaceFilesDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 1601) + { + m_iTime-=1000; + if (m_iTime < 0) + EndDialog(m_iDefaultOption); + + TCHAR xx[16]; + SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} Index: ch/SmallReplaceFilesDlg.cpp =================================================================== diff -u -N --- ch/SmallReplaceFilesDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/SmallReplaceFilesDlg.cpp (revision 0) @@ -1,134 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "resource.h" -#include "SmallReplaceFilesDlg.h" -#include "btnIDs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSmallReplaceFilesDlg dialog - - -CSmallReplaceFilesDlg::CSmallReplaceFilesDlg() - : CHLanguageDialog(CSmallReplaceFilesDlg::IDD) -{ - //{{AFX_DATA_INIT(CSmallReplaceFilesDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - // zeruj zmienne - m_pfiSource=NULL; - m_pfiDest=NULL; - m_bEnableTimer=false; - m_iDefaultOption=ID_RECOPY; - m_iTime=30000; -} - -void CSmallReplaceFilesDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSmallReplaceFilesDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CSmallReplaceFilesDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CSmallReplaceFilesDlg) - ON_BN_CLICKED(IDC_RECOPY_BUTTON, OnRecopyButton) - ON_BN_CLICKED(IDC_RECOPY_ALL_BUTTON, OnRecopyAllButton) - ON_BN_CLICKED(IDC_IGNORE_BUTTON, OnIgnoreButton) - ON_BN_CLICKED(IDC_IGNORE_ALL_BUTTON, OnIgnoreAllButton) - ON_WM_TIMER() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSmallReplaceFilesDlg message handlers - -BOOL CSmallReplaceFilesDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // set on top - SetWindowPos(&wndNoTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE /*| SWP_SHOWWINDOW*/); - - ASSERT(m_pfiSource); - ASSERT(m_pfiDest); - - // show attributes - TCHAR xx[64]; - GetDlgItem(IDC_FILENAME_EDIT)->SetWindowText(m_pfiSource->GetFullFilePath()); - GetDlgItem(IDC_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiSource->GetLength64(), xx, 10)); - GetDlgItem(IDC_CREATETIME_EDIT)->SetWindowText(m_pfiSource->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_MODIFY_TIME_EDIT)->SetWindowText(m_pfiSource->GetLastWriteTime().Format(_T("%x %X"))); - - GetDlgItem(IDC_DEST_FILENAME_EDIT)->SetWindowText(m_pfiDest->GetFullFilePath()); - GetDlgItem(IDC_DEST_FILESIZE_EDIT)->SetWindowText(_i64tot(m_pfiDest->GetLength64(), xx, 10)); - GetDlgItem(IDC_DEST_CREATETIME_EDIT)->SetWindowText(m_pfiDest->GetCreationTime().Format(_T("%x %X"))); - GetDlgItem(IDC_DEST_MODIFYTIME_EDIT)->SetWindowText(m_pfiDest->GetLastWriteTime().Format(_T("%x %X"))); - - GetWindowText(m_strTitle); - - if (m_bEnableTimer) - SetTimer(1601, 1000, NULL); - - return TRUE; -} - -void CSmallReplaceFilesDlg::OnRecopyButton() -{ - EndDialog(ID_RECOPY); -} - -void CSmallReplaceFilesDlg::OnRecopyAllButton() -{ - EndDialog(ID_RECOPYALL); -} - -void CSmallReplaceFilesDlg::OnIgnoreButton() -{ - EndDialog(ID_IGNORE); -} - -void CSmallReplaceFilesDlg::OnIgnoreAllButton() -{ - EndDialog(ID_IGNOREALL); -} - -void CSmallReplaceFilesDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 1601) - { - m_iTime-=1000; - if (m_iTime < 0) - EndDialog(m_iDefaultOption); - - TCHAR xx[16]; - SetWindowText(m_strTitle+_T(" [")+CString(_itot(m_iTime/1000, xx, 10))+_T("]")); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} Index: src/ch/SmallReplaceFilesDlg.h =================================================================== diff -u -N --- src/ch/SmallReplaceFilesDlg.h (revision 0) +++ src/ch/SmallReplaceFilesDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,71 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __SMALLREPLACEFILESDLG_H__ +#define __SMALLREPLACEFILESDLG_H__ + +#include "FileInfo.h" + +///////////////////////////////////////////////////////////////////////////// +// CSmallReplaceFilesDlg dialog + +class CSmallReplaceFilesDlg : public CHLanguageDialog +{ +// Construction +public: + CSmallReplaceFilesDlg(); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSmallReplaceFilesDlg) + enum { IDD = IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + CFileInfo *m_pfiSource, *m_pfiDest; + + CString m_strTitle; + bool m_bEnableTimer; + int m_iTime; + int m_iDefaultOption; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSmallReplaceFilesDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSmallReplaceFilesDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnRecopyButton(); + afx_msg void OnRecopyAllButton(); + afx_msg void OnIgnoreButton(); + afx_msg void OnIgnoreAllButton(); + afx_msg void OnTimer(UINT nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/SmallReplaceFilesDlg.h =================================================================== diff -u -N --- ch/SmallReplaceFilesDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/SmallReplaceFilesDlg.h (revision 0) @@ -1,71 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __SMALLREPLACEFILESDLG_H__ -#define __SMALLREPLACEFILESDLG_H__ - -#include "FileInfo.h" - -///////////////////////////////////////////////////////////////////////////// -// CSmallReplaceFilesDlg dialog - -class CSmallReplaceFilesDlg : public CHLanguageDialog -{ -// Construction -public: - CSmallReplaceFilesDlg(); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSmallReplaceFilesDlg) - enum { IDD = IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - CFileInfo *m_pfiSource, *m_pfiDest; - - CString m_strTitle; - bool m_bEnableTimer; - int m_iTime; - int m_iDefaultOption; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSmallReplaceFilesDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSmallReplaceFilesDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnRecopyButton(); - afx_msg void OnRecopyAllButton(); - afx_msg void OnIgnoreButton(); - afx_msg void OnIgnoreAllButton(); - afx_msg void OnTimer(UINT nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/StaticEx.cpp =================================================================== diff -u -N --- src/ch/StaticEx.cpp (revision 0) +++ src/ch/StaticEx.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,353 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "StaticEx.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define STATICEX_CLASS _T("STATICEX") + +LRESULT CALLBACK StaticExWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + STATICEXSETTINGS* pSettings=(STATICEXSETTINGS*)GetWindowLongPtr(hwnd, 0); + switch (uMsg) + { + case WM_NCCREATE: + { + STATICEXSETTINGS* pSett=new STATICEXSETTINGS; + pSett->hFontNormal=NULL; + pSett->hFontUnderline=NULL; + pSett->pszLink=NULL; + pSett->pszText=NULL; + pSett->bActive=false; + pSett->bDown=false; + pSett->hLink=NULL; + pSett->hNormal=NULL; + pSett->rcText.left=0; + pSett->rcText.right=0; + pSett->rcText.top=0; + pSett->rcText.bottom=0; + ::SetWindowLongPtr(hwnd, 0, (LONG_PTR)pSett); + + // create cursors + pSett->hNormal=::LoadCursor(NULL, IDC_ARROW); + pSett->hLink=::LoadCursor(NULL, IDC_HAND); + + break; + } + case WM_CREATE: + { + CREATESTRUCT* pcs=(CREATESTRUCT*)lParam; + + TCHAR* pSep=_tcsrchr(pcs->lpszName, _T('|')); + + if (!(pcs->style & SES_LINK) || pSep == NULL || pSep-pcs->lpszName < 0) + { + pSettings->pszText=new TCHAR[_tcslen(pcs->lpszName)+1]; + _tcscpy(pSettings->pszText, pcs->lpszName); + pSettings->pszLink=NULL; + } + else + { + pSettings->pszText=new TCHAR[pSep-pcs->lpszName+1]; + _tcsncpy(pSettings->pszText, pcs->lpszName, pSep-pcs->lpszName); + pSettings->pszText[pSep-pcs->lpszName]=_T('\0'); + pSep++; + pSettings->pszLink=new TCHAR[_tcslen(pSep)+1]; + _tcscpy(pSettings->pszLink, pSep); + } + + break; + } + case WM_NCDESTROY: + { + if (pSettings->hFontNormal) + DeleteObject(pSettings->hFontNormal); + if (pSettings->hFontUnderline) + DeleteObject(pSettings->hFontUnderline); + if (pSettings->hLink) + DeleteObject(pSettings->hLink); + if (pSettings->hNormal) + DeleteObject(pSettings->hNormal); + delete [] pSettings->pszLink; + delete [] pSettings->pszText; + + delete pSettings; + break; + } + case WM_SETFONT: + { + // delete old fonts + if (pSettings->hFontNormal) + DeleteObject(pSettings->hFontNormal); + if (pSettings->hFontUnderline) + DeleteObject(pSettings->hFontUnderline); + + // new font - create a font based on it (the normal and the underlined one) + HFONT hfont=(HFONT)wParam; + LOGFONT lf; + if (GetObject(hfont, sizeof(LOGFONT), &lf) != 0) + { + // size + if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LARGE) + lf.lfHeight=(long)(lf.lfHeight*1.25); + + // create a font + if (::GetWindowLong(hwnd, GWL_STYLE) & SES_BOLD) + lf.lfWeight=FW_BOLD; + pSettings->hFontNormal=CreateFontIndirect(&lf); + lf.lfUnderline=TRUE; + pSettings->hFontUnderline=CreateFontIndirect(&lf); + } + else + { + pSettings->hFontNormal=NULL; + pSettings->hFontUnderline=NULL; + } + + break; + } + case WM_SETTEXT: + { + // delete the old font + delete [] pSettings->pszText; + delete [] pSettings->pszLink; + + // style + LONG lStyle=::GetWindowLong(hwnd, GWL_STYLE); + + LPCTSTR psz=(LPCTSTR)lParam; + TCHAR* pSep=_tcsrchr(psz, _T('|')); + + if (!(lStyle & SES_LINK) || pSep == NULL || pSep-psz < 0) + { + pSettings->pszText=new TCHAR[_tcslen(psz)+1]; + _tcscpy(pSettings->pszText, psz); + pSettings->pszLink=NULL; + } + else + { + pSettings->pszText=new TCHAR[pSep-psz+1]; + _tcsncpy(pSettings->pszText, psz, pSep-psz); + pSettings->pszText[pSep-psz]=_T('\0'); + pSep++; + pSettings->pszLink=new TCHAR[_tcslen(pSep)+1]; + _tcscpy(pSettings->pszLink, pSep); + } + + ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + break; + } + case WM_ERASEBKGND: + { + return (LRESULT)FALSE; + break; + } + case WM_PAINT: + { + // draw anything + PAINTSTRUCT ps; + HDC hDC=BeginPaint(hwnd, &ps); + + // flicker-free drawing + HDC hdc=::CreateCompatibleDC(hDC); + HBITMAP hBmp=::CreateCompatibleBitmap(hDC, ps.rcPaint.right-ps.rcPaint.left+1, ps.rcPaint.bottom-ps.rcPaint.top+1); + HBITMAP hOldBitmap=(HBITMAP)::SelectObject(hdc, hBmp); + ::SetWindowOrgEx(hdc, ps.rcPaint.left, ps.rcPaint.top, NULL); + + // paint the background + ::FillRect(hdc, &ps.rcPaint, (HBRUSH)::SendMessage((HWND)::GetWindowLong(hwnd, GWL_HWNDPARENT), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd)); + + // size of the all control + RECT rcCtl; + ::GetClientRect(hwnd, &rcCtl); + + // draw text + DWORD dwFlags=DT_LEFT | DT_VCENTER | (::GetWindowLong(hwnd, GWL_STYLE) & SES_PATHELLIPSIS ? DT_PATH_ELLIPSIS : 0) + | (::GetWindowLong(hwnd, GWL_STYLE) & SES_ELLIPSIS ? DT_END_ELLIPSIS : 0) + | (::GetWindowLong(hwnd, GWL_STYLE) & SES_WORDBREAK ? DT_WORDBREAK : 0); + + pSettings->rcText=rcCtl; + if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK) + { + HFONT hOld=(HFONT)::SelectObject(hdc, pSettings->hFontUnderline); + ::SetBkMode(hdc, TRANSPARENT); + + COLORREF crColor=(pSettings->bActive ? (RGB(255, 0, 0)) : (RGB(0, 0, 255))); + ::SetTextColor(hdc, crColor); + + if (pSettings->pszText) + { + DrawText(hdc, pSettings->pszText, -1, &pSettings->rcText, dwFlags | DT_CALCRECT); + DrawText(hdc, pSettings->pszText, -1, &rcCtl, dwFlags); + } + else + { + pSettings->rcText.left=0; + pSettings->rcText.right=0; + pSettings->rcText.top=0; + pSettings->rcText.bottom=0; + } + + ::SelectObject(hdc, hOld); + } + else + { + // aesthetics + rcCtl.left+=3; + rcCtl.right-=3; + + // draw + HFONT hOld=(HFONT)::SelectObject(hdc, pSettings->hFontNormal); + ::SetBkMode(hdc, TRANSPARENT); + ::SetTextColor(hdc, ::GetSysColor(COLOR_BTNTEXT)); + + if (pSettings->pszText) + { + DWORD dwMod=(::GetWindowLong(hwnd, GWL_STYLE) & SES_RALIGN) ? DT_RIGHT : 0; + DrawText(hdc, pSettings->pszText, -1, &pSettings->rcText, dwFlags | DT_CALCRECT | dwMod); + DrawText(hdc, pSettings->pszText, -1, &rcCtl, dwFlags | dwMod); + } + else + { + pSettings->rcText.left=0; + pSettings->rcText.right=0; + pSettings->rcText.top=0; + pSettings->rcText.bottom=0; + } + + ::SelectObject(hdc, hOld); + } + + // free the compatible dc + ::BitBlt(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left+1, ps.rcPaint.bottom-ps.rcPaint.top+1, + hdc, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); + ::SelectObject(hdc, hOldBitmap); + ::DeleteObject(hBmp); + ::DeleteDC(hdc); + + EndPaint(hwnd, &ps); + + break; + } + case WM_MOUSEMOVE: + { + if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK) + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + + if (pSettings->bActive) + { + if (!::PtInRect(&pSettings->rcText, pt)) + { + pSettings->bActive=false; + ::ReleaseCapture(); + ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + + ::SetCursor(pSettings->hNormal); + } + } + else + { + if (::PtInRect(&pSettings->rcText, pt)) + { + pSettings->bActive=true; + ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); + ::SetCapture(hwnd); + ::SetCursor(pSettings->hLink); + } + } + } + break; + } + case WM_LBUTTONDOWN: + { + pSettings->bDown=true; + break; + } + case WM_LBUTTONUP: + { + POINT pt={ LOWORD(lParam), HIWORD(lParam) }; + if (pSettings->bDown && ::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK && ::PtInRect(&pSettings->rcText, pt)) + { + if (::GetWindowLong(hwnd, GWL_STYLE) & SES_NOTIFY) + { + ::SendMessage((HWND)::GetWindowLong(hwnd, GWL_HWNDPARENT), WM_COMMAND, (WPARAM)(SEN_CLICKED << 16 | ::GetWindowLong(hwnd, GWL_ID)), (LPARAM)hwnd); + } + else + { + + TRACE("Executing %s...\n", pSettings->pszLink); + ShellExecute(NULL, "open", pSettings->pszLink, NULL, NULL, SW_SHOWNORMAL); + } + } + pSettings->bDown=false; + + break; + } + case WM_CANCELMODE: + { + pSettings->bActive=false; + pSettings->bDown=false; + break; + } + case SEM_GETLINK: + { + // wParam - count + // lParam - addr of a buffer + if (pSettings->pszLink) + _tcsncpy((PTSTR)lParam, pSettings->pszLink, (int)wParam); + else + _tcscpy((PTSTR)lParam, _T("")); + + return (LRESULT)TRUE; + break; + } + } + + return ::DefWindowProc(hwnd, uMsg, wParam, lParam); +} + +bool RegisterStaticExControl(HINSTANCE hInstance) +{ + WNDCLASS wndcls; + + if (!(::GetClassInfo(hInstance, STATICEX_CLASS, &wndcls))) + { + // need to register a new class + wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; + wndcls.lpfnWndProc = ::StaticExWndProc; + wndcls.cbClsExtra = 0; + wndcls.cbWndExtra = sizeof(STATICEXSETTINGS*); + wndcls.hInstance = hInstance; + wndcls.hIcon = NULL; + wndcls.hCursor = NULL; // will load each time needed + wndcls.hbrBackground = NULL; + wndcls.lpszMenuName = NULL; + wndcls.lpszClassName = STATICEX_CLASS; + + if (!RegisterClass(&wndcls)) + return false; + } + + return true; +} Index: ch/StaticEx.cpp =================================================================== diff -u -N --- ch/StaticEx.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StaticEx.cpp (revision 0) @@ -1,353 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "StaticEx.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#define STATICEX_CLASS _T("STATICEX") - -LRESULT CALLBACK StaticExWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - STATICEXSETTINGS* pSettings=(STATICEXSETTINGS*)GetWindowLongPtr(hwnd, 0); - switch (uMsg) - { - case WM_NCCREATE: - { - STATICEXSETTINGS* pSett=new STATICEXSETTINGS; - pSett->hFontNormal=NULL; - pSett->hFontUnderline=NULL; - pSett->pszLink=NULL; - pSett->pszText=NULL; - pSett->bActive=false; - pSett->bDown=false; - pSett->hLink=NULL; - pSett->hNormal=NULL; - pSett->rcText.left=0; - pSett->rcText.right=0; - pSett->rcText.top=0; - pSett->rcText.bottom=0; - ::SetWindowLongPtr(hwnd, 0, (LONG_PTR)pSett); - - // create cursors - pSett->hNormal=::LoadCursor(NULL, IDC_ARROW); - pSett->hLink=::LoadCursor(NULL, IDC_HAND); - - break; - } - case WM_CREATE: - { - CREATESTRUCT* pcs=(CREATESTRUCT*)lParam; - - TCHAR* pSep=_tcsrchr(pcs->lpszName, _T('|')); - - if (!(pcs->style & SES_LINK) || pSep == NULL || pSep-pcs->lpszName < 0) - { - pSettings->pszText=new TCHAR[_tcslen(pcs->lpszName)+1]; - _tcscpy(pSettings->pszText, pcs->lpszName); - pSettings->pszLink=NULL; - } - else - { - pSettings->pszText=new TCHAR[pSep-pcs->lpszName+1]; - _tcsncpy(pSettings->pszText, pcs->lpszName, pSep-pcs->lpszName); - pSettings->pszText[pSep-pcs->lpszName]=_T('\0'); - pSep++; - pSettings->pszLink=new TCHAR[_tcslen(pSep)+1]; - _tcscpy(pSettings->pszLink, pSep); - } - - break; - } - case WM_NCDESTROY: - { - if (pSettings->hFontNormal) - DeleteObject(pSettings->hFontNormal); - if (pSettings->hFontUnderline) - DeleteObject(pSettings->hFontUnderline); - if (pSettings->hLink) - DeleteObject(pSettings->hLink); - if (pSettings->hNormal) - DeleteObject(pSettings->hNormal); - delete [] pSettings->pszLink; - delete [] pSettings->pszText; - - delete pSettings; - break; - } - case WM_SETFONT: - { - // delete old fonts - if (pSettings->hFontNormal) - DeleteObject(pSettings->hFontNormal); - if (pSettings->hFontUnderline) - DeleteObject(pSettings->hFontUnderline); - - // new font - create a font based on it (the normal and the underlined one) - HFONT hfont=(HFONT)wParam; - LOGFONT lf; - if (GetObject(hfont, sizeof(LOGFONT), &lf) != 0) - { - // size - if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LARGE) - lf.lfHeight=(long)(lf.lfHeight*1.25); - - // create a font - if (::GetWindowLong(hwnd, GWL_STYLE) & SES_BOLD) - lf.lfWeight=FW_BOLD; - pSettings->hFontNormal=CreateFontIndirect(&lf); - lf.lfUnderline=TRUE; - pSettings->hFontUnderline=CreateFontIndirect(&lf); - } - else - { - pSettings->hFontNormal=NULL; - pSettings->hFontUnderline=NULL; - } - - break; - } - case WM_SETTEXT: - { - // delete the old font - delete [] pSettings->pszText; - delete [] pSettings->pszLink; - - // style - LONG lStyle=::GetWindowLong(hwnd, GWL_STYLE); - - LPCTSTR psz=(LPCTSTR)lParam; - TCHAR* pSep=_tcsrchr(psz, _T('|')); - - if (!(lStyle & SES_LINK) || pSep == NULL || pSep-psz < 0) - { - pSettings->pszText=new TCHAR[_tcslen(psz)+1]; - _tcscpy(pSettings->pszText, psz); - pSettings->pszLink=NULL; - } - else - { - pSettings->pszText=new TCHAR[pSep-psz+1]; - _tcsncpy(pSettings->pszText, psz, pSep-psz); - pSettings->pszText[pSep-psz]=_T('\0'); - pSep++; - pSettings->pszLink=new TCHAR[_tcslen(pSep)+1]; - _tcscpy(pSettings->pszLink, pSep); - } - - ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - break; - } - case WM_ERASEBKGND: - { - return (LRESULT)FALSE; - break; - } - case WM_PAINT: - { - // draw anything - PAINTSTRUCT ps; - HDC hDC=BeginPaint(hwnd, &ps); - - // flicker-free drawing - HDC hdc=::CreateCompatibleDC(hDC); - HBITMAP hBmp=::CreateCompatibleBitmap(hDC, ps.rcPaint.right-ps.rcPaint.left+1, ps.rcPaint.bottom-ps.rcPaint.top+1); - HBITMAP hOldBitmap=(HBITMAP)::SelectObject(hdc, hBmp); - ::SetWindowOrgEx(hdc, ps.rcPaint.left, ps.rcPaint.top, NULL); - - // paint the background - ::FillRect(hdc, &ps.rcPaint, (HBRUSH)::SendMessage((HWND)::GetWindowLong(hwnd, GWL_HWNDPARENT), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd)); - - // size of the all control - RECT rcCtl; - ::GetClientRect(hwnd, &rcCtl); - - // draw text - DWORD dwFlags=DT_LEFT | DT_VCENTER | (::GetWindowLong(hwnd, GWL_STYLE) & SES_PATHELLIPSIS ? DT_PATH_ELLIPSIS : 0) - | (::GetWindowLong(hwnd, GWL_STYLE) & SES_ELLIPSIS ? DT_END_ELLIPSIS : 0) - | (::GetWindowLong(hwnd, GWL_STYLE) & SES_WORDBREAK ? DT_WORDBREAK : 0); - - pSettings->rcText=rcCtl; - if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK) - { - HFONT hOld=(HFONT)::SelectObject(hdc, pSettings->hFontUnderline); - ::SetBkMode(hdc, TRANSPARENT); - - COLORREF crColor=(pSettings->bActive ? (RGB(255, 0, 0)) : (RGB(0, 0, 255))); - ::SetTextColor(hdc, crColor); - - if (pSettings->pszText) - { - DrawText(hdc, pSettings->pszText, -1, &pSettings->rcText, dwFlags | DT_CALCRECT); - DrawText(hdc, pSettings->pszText, -1, &rcCtl, dwFlags); - } - else - { - pSettings->rcText.left=0; - pSettings->rcText.right=0; - pSettings->rcText.top=0; - pSettings->rcText.bottom=0; - } - - ::SelectObject(hdc, hOld); - } - else - { - // aesthetics - rcCtl.left+=3; - rcCtl.right-=3; - - // draw - HFONT hOld=(HFONT)::SelectObject(hdc, pSettings->hFontNormal); - ::SetBkMode(hdc, TRANSPARENT); - ::SetTextColor(hdc, ::GetSysColor(COLOR_BTNTEXT)); - - if (pSettings->pszText) - { - DWORD dwMod=(::GetWindowLong(hwnd, GWL_STYLE) & SES_RALIGN) ? DT_RIGHT : 0; - DrawText(hdc, pSettings->pszText, -1, &pSettings->rcText, dwFlags | DT_CALCRECT | dwMod); - DrawText(hdc, pSettings->pszText, -1, &rcCtl, dwFlags | dwMod); - } - else - { - pSettings->rcText.left=0; - pSettings->rcText.right=0; - pSettings->rcText.top=0; - pSettings->rcText.bottom=0; - } - - ::SelectObject(hdc, hOld); - } - - // free the compatible dc - ::BitBlt(ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right-ps.rcPaint.left+1, ps.rcPaint.bottom-ps.rcPaint.top+1, - hdc, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); - ::SelectObject(hdc, hOldBitmap); - ::DeleteObject(hBmp); - ::DeleteDC(hdc); - - EndPaint(hwnd, &ps); - - break; - } - case WM_MOUSEMOVE: - { - if (::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK) - { - POINT pt = { LOWORD(lParam), HIWORD(lParam) }; - - if (pSettings->bActive) - { - if (!::PtInRect(&pSettings->rcText, pt)) - { - pSettings->bActive=false; - ::ReleaseCapture(); - ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - - ::SetCursor(pSettings->hNormal); - } - } - else - { - if (::PtInRect(&pSettings->rcText, pt)) - { - pSettings->bActive=true; - ::RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE); - ::SetCapture(hwnd); - ::SetCursor(pSettings->hLink); - } - } - } - break; - } - case WM_LBUTTONDOWN: - { - pSettings->bDown=true; - break; - } - case WM_LBUTTONUP: - { - POINT pt={ LOWORD(lParam), HIWORD(lParam) }; - if (pSettings->bDown && ::GetWindowLong(hwnd, GWL_STYLE) & SES_LINK && ::PtInRect(&pSettings->rcText, pt)) - { - if (::GetWindowLong(hwnd, GWL_STYLE) & SES_NOTIFY) - { - ::SendMessage((HWND)::GetWindowLong(hwnd, GWL_HWNDPARENT), WM_COMMAND, (WPARAM)(SEN_CLICKED << 16 | ::GetWindowLong(hwnd, GWL_ID)), (LPARAM)hwnd); - } - else - { - - TRACE("Executing %s...\n", pSettings->pszLink); - ShellExecute(NULL, "open", pSettings->pszLink, NULL, NULL, SW_SHOWNORMAL); - } - } - pSettings->bDown=false; - - break; - } - case WM_CANCELMODE: - { - pSettings->bActive=false; - pSettings->bDown=false; - break; - } - case SEM_GETLINK: - { - // wParam - count - // lParam - addr of a buffer - if (pSettings->pszLink) - _tcsncpy((PTSTR)lParam, pSettings->pszLink, (int)wParam); - else - _tcscpy((PTSTR)lParam, _T("")); - - return (LRESULT)TRUE; - break; - } - } - - return ::DefWindowProc(hwnd, uMsg, wParam, lParam); -} - -bool RegisterStaticExControl(HINSTANCE hInstance) -{ - WNDCLASS wndcls; - - if (!(::GetClassInfo(hInstance, STATICEX_CLASS, &wndcls))) - { - // need to register a new class - wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; - wndcls.lpfnWndProc = ::StaticExWndProc; - wndcls.cbClsExtra = 0; - wndcls.cbWndExtra = sizeof(STATICEXSETTINGS*); - wndcls.hInstance = hInstance; - wndcls.hIcon = NULL; - wndcls.hCursor = NULL; // will load each time needed - wndcls.hbrBackground = NULL; - wndcls.lpszMenuName = NULL; - wndcls.lpszClassName = STATICEX_CLASS; - - if (!RegisterClass(&wndcls)) - return false; - } - - return true; -} Index: src/ch/StaticEx.h =================================================================== diff -u -N --- src/ch/StaticEx.h (revision 0) +++ src/ch/StaticEx.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,56 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __STATICEX_H__ +#define __STATICEX_H__ + +// styles +#define SES_LINK 0x0001 /* link instead of common static */ +#define SES_NOTIFY 0x0002 /* notifies parent about mouse messages */ +#define SES_PATHELLIPSIS 0x0004 +#define SES_ELLIPSIS 0x0008 +#define SES_BOLD 0x0010 +#define SES_LARGE 0x0020 +#define SES_RALIGN 0x0040 /* incompatible with SES_LINK */ +#define SES_WORDBREAK 0x0080 + +// messages +#define SEM_GETLINK (WM_USER+16) /* wParam - cnt of chars to copy, lParam - addr of text */ + +#define SEN_CLICKED 0x0001 + +bool RegisterStaticExControl(HINSTANCE hInstance); + +struct STATICEXSETTINGS +{ + HFONT hFontNormal; + HFONT hFontUnderline; + + HCURSOR hNormal; + HCURSOR hLink; + + bool bDown; // specifies if the mouse button has been pressed + bool bActive; // is the link hovered ? + RECT rcText; // current text position and size + + TCHAR *pszText; + TCHAR *pszLink; +}; + +#endif \ No newline at end of file Index: ch/StaticEx.h =================================================================== diff -u -N --- ch/StaticEx.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StaticEx.h (revision 0) @@ -1,56 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __STATICEX_H__ -#define __STATICEX_H__ - -// styles -#define SES_LINK 0x0001 /* link instead of common static */ -#define SES_NOTIFY 0x0002 /* notifies parent about mouse messages */ -#define SES_PATHELLIPSIS 0x0004 -#define SES_ELLIPSIS 0x0008 -#define SES_BOLD 0x0010 -#define SES_LARGE 0x0020 -#define SES_RALIGN 0x0040 /* incompatible with SES_LINK */ -#define SES_WORDBREAK 0x0080 - -// messages -#define SEM_GETLINK (WM_USER+16) /* wParam - cnt of chars to copy, lParam - addr of text */ - -#define SEN_CLICKED 0x0001 - -bool RegisterStaticExControl(HINSTANCE hInstance); - -struct STATICEXSETTINGS -{ - HFONT hFontNormal; - HFONT hFontUnderline; - - HCURSOR hNormal; - HCURSOR hLink; - - bool bDown; // specifies if the mouse button has been pressed - bool bActive; // is the link hovered ? - RECT rcText; // current text position and size - - TCHAR *pszText; - TCHAR *pszLink; -}; - -#endif \ No newline at end of file Index: src/ch/StatusDlg.cpp =================================================================== diff -u -N --- src/ch/StatusDlg.cpp (revision 0) +++ src/ch/StatusDlg.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,977 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "Copy Handler.h" +#include "resource.h" +#include "StatusDlg.h" +#include "BufferSizeDlg.h" +#include "ReplacePathsDlg.h" +#include "StringHelpers.h" +#include "StaticEx.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +bool CStatusDlg::m_bLock=false; + +///////////////////////////////////////////////////////////////////////////// +// CStatusDlg dialog + +CStatusDlg::CStatusDlg(CTaskArray* pTasks, CWnd* pParent /*=NULL*/) + : CHLanguageDialog(CStatusDlg::IDD, pParent, &m_bLock) +{ + //{{AFX_DATA_INIT(CStatusDlg) + //}}AFX_DATA_INIT + m_i64LastProcessed=0; + m_i64LastAllTasksProcessed=0; + m_pTasks=pTasks; + m_dwLastUpdate=0; + + RegisterStaticExControl(AfxGetInstanceHandle()); +} + +CStatusDlg::~CStatusDlg() +{ + +} + +void CStatusDlg::DoDataExchange(CDataExchange* pDX) +{ + CHLanguageDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CStatusDlg) + DDX_Control(pDX, IDC_ERRORS_EDIT, m_ctlErrors); + DDX_Control(pDX, IDC_TASK_PROGRESS, m_ctlCurrentProgress); + DDX_Control(pDX, IDC_STATUS_LIST, m_ctlStatusList); + DDX_Control(pDX, IDC_ALL_PROGRESS, m_ctlProgressAll); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CStatusDlg, CHLanguageDialog) + //{{AFX_MSG_MAP(CStatusDlg) + ON_WM_TIMER() + ON_BN_CLICKED(IDC_PAUSE_BUTTON, OnPauseButton) + ON_BN_CLICKED(IDC_CANCEL_BUTTON, OnCancelButton) + ON_BN_CLICKED(IDC_ROLL_UNROLL_BUTTON, OnRollUnrollButton) + ON_BN_CLICKED(IDC_SET_PRIORITY_BUTTON, OnSetPriorityButton) + ON_BN_CLICKED(IDC_SET_BUFFERSIZE_BUTTON, OnSetBuffersizeButton) + ON_BN_CLICKED(IDC_START_ALL_BUTTON, OnStartAllButton) + ON_BN_CLICKED(IDC_RESTART_BUTTON, OnRestartButton) + ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) + ON_BN_CLICKED(IDC_PAUSE_ALL_BUTTON, OnPauseAllButton) + ON_BN_CLICKED(IDC_RESTART_ALL_BUTTON, OnRestartAllButton) + ON_BN_CLICKED(IDC_CANCEL_ALL_BUTTON, OnCancelAllButton) + ON_BN_CLICKED(IDC_REMOVE_FINISHED_BUTTON, OnRemoveFinishedButton) + ON_NOTIFY(LVN_KEYDOWN, IDC_STATUS_LIST, OnKeydownStatusList) + ON_NOTIFY(LVN_CHANGEDSELECTION, IDC_STATUS_LIST, OnSelectionChanged) + ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton) + ON_COMMAND(ID_POPUP_REPLACE_PATHS, OnPopupReplacePaths) + ON_BN_CLICKED(IDC_SHOW_LOG_BUTTON, OnShowLogButton) + ON_BN_CLICKED(IDC_STICK_BUTTON, OnStickButton) + ON_BN_CLICKED(IDC_RESUME_BUTTON, OnResumeButton) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CStatusDlg message handlers + +BOOL CStatusDlg::OnInitDialog() +{ + CHLanguageDialog::OnInitDialog(); + + // get size of list ctrl + CRect rcList; + m_ctlStatusList.GetWindowRect(&rcList); + int iWidth=rcList.Width(); + + // set additional styles + m_ctlStatusList.SetExtendedStyle(m_ctlStatusList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); + + // add columns + LVCOLUMN lvc; + lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; + lvc.fmt=LVCFMT_LEFT; + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSTATUS_STRING); /*_T("Status")*/; + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.27*iWidth); + lvc.iSubItem=-1; + m_ctlStatusList.InsertColumn(1, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSOURCE_STRING);/*_T("File");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.3*iWidth); + lvc.iSubItem=0; + m_ctlStatusList.InsertColumn(2, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNDESTINATION_STRING);/*_T("To:");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.27*iWidth); + lvc.iSubItem=1; + m_ctlStatusList.InsertColumn(3, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNPROGRESS_STRING);/*_T("Progress");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.15*iWidth); + lvc.iSubItem=2; + m_ctlStatusList.InsertColumn(4, &lvc); + + // images + m_images.Create(16, 16, ILC_COLOR16 | ILC_MASK, 0, 3); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_WORKING_ICON))); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ERROR_ICON))); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_PAUSED_ICON))); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_FINISHED_ICON))); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_CANCELLED_ICON))); + m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_WAITING_ICON))); + + m_ctlStatusList.SetImageList(&m_images, LVSIL_SMALL); + + // set fixed progresses ranges + m_ctlCurrentProgress.SetRange32(0, 100); + m_ctlProgressAll.SetRange32(0, 100); + + // change the size of a dialog + ApplyDisplayDetails(true); +// ApplyButtonsState(); +// EnableControls(false); + + // refresh data + RefreshStatus(); + + // select needed element + int i=0; + while (i < m_pTasks->GetSize()) + { + if (m_pTasks->GetAt(i) == m_pInitialSelection) + { + m_ctlStatusList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); + break; + } + + i++; + }; + + // refresh data timer + SetTimer(777, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL), NULL); + + return TRUE; +} + +void CStatusDlg::EnableControls(bool bEnable) +{ + // enable/disable controls + GetDlgItem(IDC_SET_BUFFERSIZE_BUTTON)->EnableWindow(bEnable); + GetDlgItem(IDC_SET_PRIORITY_BUTTON)->EnableWindow(bEnable); + + if (!bEnable) + { + // get rid of text id disabling + GetDlgItem(IDC_OPERATION_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYOPERATIONTEXT_STRING)); + GetDlgItem(IDC_SOURCE_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYSOURCETEXT_STRING)); + GetDlgItem(IDC_DESTINATION_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYDESTINATIONTEXT_STRING)); + GetDlgItem(IDC_BUFFERSIZE_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYBUFFERSIZETEXT_STRING)); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYPRIORITYTEXT_STRING)); + + const TCHAR *pszText=GetResManager()->LoadString(IDS_EMPTYERRORTEXT_STRING); + m_ctlErrors.GetWindowText(m_strTemp); + if (m_strTemp != pszText) + m_ctlErrors.SetWindowText(pszText); + + GetDlgItem(IDC_PROGRESS_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYPROCESSEDTEXT_STRING)); + GetDlgItem(IDC_TRANSFER_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYTRANSFERTEXT_STRING)); + GetDlgItem(IDC_TIME_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYTIMETEXT_STRING)); + GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYASSOCFILE_STRING)); + + m_ctlCurrentProgress.SetPos(0); + } +} + +void CStatusDlg::OnTimer(UINT nIDEvent) +{ + if (nIDEvent == 777) // refreshing data + { + // turn off timer for some time + KillTimer(777); + + RefreshStatus(); + + // reenable + SetTimer(777, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL), NULL); + } + + CHLanguageDialog::OnTimer(nIDEvent); +} + +void CStatusDlg::AddTaskInfo(int nPos, CTask *pTask, DWORD dwCurrentTime) +{ + // index to string + _itot(nPos, m_szData, 10); + + // get data snapshot from task + pTask->GetSnapshot(&td); + + // index subitem + lvi.mask=LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + lvi.iItem=nPos; + lvi.iSubItem=0; + lvi.pszText=td.m_szStatusText; + lvi.cchTextMax=lstrlen(lvi.pszText); + lvi.lParam=reinterpret_cast(pTask); + lvi.iImage=GetImageFromStatus(td.m_uiStatus); + if (nPos < m_ctlStatusList.GetItemCount()) + m_ctlStatusList.SetItem(&lvi); + else + m_ctlStatusList.InsertItem(&lvi); + + // status subitem + lvi.mask=LVIF_TEXT; // zmie� mask� + lvi.iSubItem=1; + m_strTemp=td.m_fi.GetFileName(); + lvi.pszText=m_strTemp.GetBuffer(0); + m_strTemp.ReleaseBuffer(); + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlStatusList.SetItem(&lvi); + + // insert 'file' subitem + lvi.iSubItem=2; + m_strTemp=td.m_pdpDestPath->GetPath(); + lvi.pszText=m_strTemp.GetBuffer(0); + m_strTemp.ReleaseBuffer(); + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlStatusList.SetItem(&lvi); + + // insert dest subitem + lvi.iSubItem=3; + _itot( td.m_nPercent, m_szData, 10 ); + _tcscat(m_szData, _T(" %")); + lvi.pszText=m_szData; + lvi.cchTextMax=lstrlen(lvi.pszText); + m_ctlStatusList.SetItem(&lvi); + + // right side update + if (pTask == pSelectedItem && GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) + { + // data that can be changed by a thread + GetDlgItem(IDC_OPERATION_STATIC)->SetWindowText(td.m_szStatusText); // operation + GetDlgItem(IDC_SOURCE_STATIC)->SetWindowText(td.m_fi.GetFullFilePath()); // src object + + // error message + if ( (td.m_uiStatus & ST_WORKING_MASK) == ST_ERROR ) + { + m_ctlErrors.GetWindowText(m_strTemp); + if (m_strTemp != td.m_strErrorDesc) + m_ctlErrors.SetWindowText(td.m_strErrorDesc); + } + else + { + const TCHAR *pszText=GetResManager()->LoadString(IDS_EMPTYERRORTEXT_STRING); + + m_ctlErrors.GetWindowText(m_strTemp2); + if (m_strTemp2 != pszText) + m_ctlErrors.SetWindowText(pszText); + } + + // count of processed data/overall count of data + _stprintf(m_szData, _T("%d/%d ("), td.m_iIndex, td.m_iSize); + m_strTemp=CString(m_szData); + m_strTemp+=GetSizeString(td.m_iProcessedSize, m_szData)+CString(_T("/")); + m_strTemp+=GetSizeString(td.m_iSizeAll, m_szData)+CString(_T(")")); + _stprintf(m_szData, _T(" (%s%d/%d)"), GetResManager()->LoadString(IDS_CURRENTPASS_STRING), td.m_ucCurrentCopy, td.m_ucCopies); + m_strTemp+=m_szData; + GetDlgItem(IDC_PROGRESS_STATIC)->SetWindowText(m_strTemp); + + // transfer + if (m_i64LastProcessed == 0) // if first time - show average + m_strTemp=GetSizeString( td.m_lTimeElapsed ? td.m_iProcessedSize/td.m_lTimeElapsed : 0, m_szData ); // last avg + else + if ( (dwCurrentTime-m_dwLastUpdate) != 0) + m_strTemp=GetSizeString( (static_cast(td.m_iProcessedSize) - static_cast(m_i64LastProcessed))/(static_cast(dwCurrentTime-m_dwLastUpdate)/1000.0), m_szData ); + else + m_strTemp=GetSizeString( 0I64, m_szData ); + + // avg transfer + GetDlgItem(IDC_TRANSFER_STATIC)->SetWindowText(m_strTemp+_T("/s (")+CString(GetResManager()->LoadString(IDS_AVERAGEWORD_STRING)) + +CString(GetSizeString(td.m_lTimeElapsed ? td.m_iProcessedSize/td.m_lTimeElapsed : 0, m_szData))+_T("/s )") + ); + + // elapsed time/estimated time + FormatTime(td.m_lTimeElapsed, m_szTimeBuffer1); + FormatTime( (td.m_iProcessedSize == 0) ? 0 : static_cast((static_cast<__int64>(td.m_iSizeAll)*static_cast<__int64>(td.m_lTimeElapsed))/td.m_iProcessedSize), m_szTimeBuffer2); + + _stprintf(m_szData, _T("%s / %s"), m_szTimeBuffer1, m_szTimeBuffer2); + GetDlgItem(IDC_TIME_STATIC)->SetWindowText(m_szData); + + // remember current processed data (used for calculating transfer) + m_i64LastProcessed=td.m_iProcessedSize; + + // set progress + m_ctlCurrentProgress.SetPos(td.m_nPercent); + + SetBufferSizesString(td.m_pbsSizes->m_auiSizes[td.m_iCurrentBufferIndex], td.m_iCurrentBufferIndex); + + // data that can be changed only by user from outside the thread + // refresh only when there are new selected item +// if (pTask != m_pLastSelected) + { + GetDlgItem(IDC_DESTINATION_STATIC)->SetWindowText(td.m_pdpDestPath->GetPath()); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(td.m_nPriority))); + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, m_strTemp.GetBuffer(1024), 1024); + m_strTemp.ReleaseBuffer(); + GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(m_strTemp+*td.m_pstrUniqueName+_T(".atd (.atp, .log)")); + } + + // refresh m_pLastSelected + m_pLastSelected=pTask; + } +} + +void CStatusDlg::OnSetBuffersizeButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + CBufferSizeDlg dlg; + dlg.m_bsSizes=*pTask->GetBufferSizes(); + dlg.m_iActiveIndex=pTask->GetCurrentBufferIndex(); + if (dlg.DoModal() == IDOK) + { + // if the task has been deleted - skip + if ( pTask != GetSelectedItemPointer() ) + { + TRACE("Task were finished and deleted when trying to change buffer sizes"); + return; + } + + TRACE("bOnlyDefault=%d\n", dlg.m_bsSizes.m_bOnlyDefault); + pTask->SetBufferSizes(&dlg.m_bsSizes); + } +} + +CTask* CStatusDlg::GetSelectedItemPointer() +{ +// TRACE("inside GetSelectedItemPointer()\n"); + // returns ptr to a CTask for a given element in listview + if (m_ctlStatusList.GetSelectedCount() == 1) + { + POSITION pos=m_ctlStatusList.GetFirstSelectedItemPosition(); + int nPos=m_ctlStatusList.GetNextSelectedItem(pos); + CTask* pSelectedItem=reinterpret_cast(m_ctlStatusList.GetItemData(nPos)); +// if (AfxIsValidAddress(pSelectedItem, sizeof(CTask))) + return pSelectedItem; + } +// TRACE("exiting GetSelectedItemPointer()\n"); + + return NULL; +} + +void CStatusDlg::OnRollUnrollButton() +{ + // change settings in config dialog + GetConfig()->SetBoolValue(PP_STATUSSHOWDETAILS, !GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)); + + ApplyDisplayDetails(); +} + +void CStatusDlg::ApplyDisplayDetails(bool bInitial) +{ + // get coord of screen and window + CRect rcScreen, rect; + SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0); + GetWindowRect(&rect); + + bool bDetails=GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS); + + // stick cause + if (rect.right == rcScreen.right && rect.bottom == rcScreen.bottom) + bInitial=true; + + GetDlgItem(IDC_ROLL_UNROLL_BUTTON)->SetWindowText(bDetails ? _T("<<") : _T(">>")); + + CRect list, progress; + m_ctlProgressAll.GetWindowRect(&progress); + ScreenToClient(&progress); + m_ctlStatusList.GetWindowRect(&list); + ScreenToClient(&list); + + // set dialog size + CRect destRect; + if (!bInitial) + { + destRect.left=0; + destRect.top=0; + destRect.right=bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER); + destRect.bottom=rect.Height(); + SetWindowPos(NULL, destRect.left, destRect.top, destRect.right, destRect.bottom, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); + } + else + { + SetWindowPos(NULL, rcScreen.right-(bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER)), + rcScreen.bottom-rect.Height(), (bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER)), + rect.Height(), SWP_NOOWNERZORDER | SWP_NOZORDER); + } +} + +void CStatusDlg::ApplyButtonsState() +{ + // remember ptr to CTask + pSelectedItem=GetSelectedItemPointer(); + bool bShowLog=GetConfig()->GetBoolValue(PP_CMCREATELOG); + + // set status of buttons pause/resume/cancel + if (pSelectedItem != NULL) + { + GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(true); + GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(bShowLog); + GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(true); + + if (pSelectedItem->GetStatus(ST_STEP_MASK) == ST_FINISHED + || pSelectedItem->GetStatus(ST_STEP_MASK) == ST_CANCELLED) + { + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); + } + else + { + // pause/resume + if (pSelectedItem->GetStatus(ST_WORKING_MASK) & ST_PAUSED) + { + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); + } + else + { + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(true); + if (pSelectedItem->GetStatus(ST_WAITING_MASK) & ST_WAITING) + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); + else + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); + } + + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(true); + } + } + else + { + GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(false); + } +} + +void CStatusDlg::OnSetPriorityButton() +{ + CMenu menu; + HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_PRIORITY_MENU)); + if (!menu.Attach(hMenu)) + { + DestroyMenu(hMenu); + return; + } + + CMenu* pPopup = menu.GetSubMenu(0); + ASSERT(pPopup != NULL); + + // set point in which to set menu + CRect rect; + GetDlgItem(IDC_SET_PRIORITY_BUTTON)->GetWindowRect(&rect); + + pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right+1, rect.top, this); +} + +BOOL CStatusDlg::OnCommand(WPARAM wParam, LPARAM lParam) +{ + if (HIWORD(wParam) == 0) + { + if (LOWORD(wParam) >= ID_POPUP_TIME_CRITICAL && LOWORD(wParam) <= ID_POPUP_IDLE) + { + // processing priority + if ( (pSelectedItem=GetSelectedItemPointer()) == NULL ) + return CHLanguageDialog::OnCommand(wParam, lParam); + + switch (LOWORD(wParam)) + { + case ID_POPUP_TIME_CRITICAL: + pSelectedItem->SetPriority(THREAD_PRIORITY_TIME_CRITICAL); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_TIME_CRITICAL))); + break; + case ID_POPUP_HIGHEST: + pSelectedItem->SetPriority(THREAD_PRIORITY_HIGHEST); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_HIGHEST))); + break; + case ID_POPUP_ABOVE_NORMAL: + pSelectedItem->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_ABOVE_NORMAL))); + break; + case ID_POPUP_NORMAL: + pSelectedItem->SetPriority(THREAD_PRIORITY_NORMAL); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_NORMAL))); + break; + case ID_POPUP_BELOW_NORMAL: + pSelectedItem->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_BELOW_NORMAL))); + break; + case ID_POPUP_LOWEST: + pSelectedItem->SetPriority(THREAD_PRIORITY_LOWEST); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_LOWEST))); + break; + case ID_POPUP_IDLE: + pSelectedItem->SetPriority(THREAD_PRIORITY_IDLE); + GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_IDLE))); + break; + } + } + } + return CHLanguageDialog::OnCommand(wParam, lParam); +} + +void CStatusDlg::OnPauseButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + TRACE("PauseProcessing call...\n"); + pTask->PauseProcessing(); + + RefreshStatus(); +} + +void CStatusDlg::OnResumeButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + TRACE("ResumeProcessing call "); + if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) + { + TRACE("by setting force flag\n"); + pTask->SetForceFlag(); + } + else + { + TRACE("by function ResumeProcessing\n"); + pTask->ResumeProcessing(); + } + + RefreshStatus(); +} + +void CStatusDlg::OnCancelButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) != NULL ) + { + TRACE("CancelProcessing call...\n"); + pTask->CancelProcessing(); + } + RefreshStatus(); +} + +void CStatusDlg::OnRestartButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + TRACE("RestartProcessing call...\n"); + pTask->RestartProcessing(); + RefreshStatus(); +} + +void CStatusDlg::OnDeleteButton() +{ + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + UINT uiStatus=pTask->GetStatus(ST_STEP_MASK); + if ( (uiStatus & ST_STEP_MASK) != ST_FINISHED && (uiStatus & ST_STEP_MASK) != ST_CANCELLED ) + { + // ask if cancel + if (MsgBox(IDS_CONFIRMCANCEL_STRING, MB_OKCANCEL | MB_ICONQUESTION) == IDOK) + { + // cancel + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + pTask->CancelProcessing(); + } + else + return; + } + + m_pTasks->RemoveFinished(&pTask); + RefreshStatus(); +} + +void CStatusDlg::OnPauseAllButton() +{ + TRACE("Pause All...\n"); + m_pTasks->TasksPauseProcessing(); + RefreshStatus(); +} + +void CStatusDlg::OnStartAllButton() +{ + TRACE("Resume Processing...\n"); + m_pTasks->TasksResumeProcessing(); + RefreshStatus(); +} + +void CStatusDlg::OnRestartAllButton() +{ + TRACE("Restart Processing...\n"); + m_pTasks->TasksRestartProcessing(); + RefreshStatus(); +} + +void CStatusDlg::OnCancelAllButton() +{ + TRACE("Cancel Processing...\n"); + m_pTasks->TasksCancelProcessing(); + RefreshStatus(); +} + +void CStatusDlg::OnRemoveFinishedButton() +{ + m_pTasks->RemoveAllFinished(); + RefreshStatus(); +} + +void CStatusDlg::OnKeydownStatusList(NMHDR* pNMHDR, LRESULT* pResult) +{ + LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR; + switch (pLVKeyDow->wVKey) + { + case VK_DELETE: + OnDeleteButton(); + break; + case VK_SPACE: + { + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL ) + return; + + if (pTask->GetStatus(ST_WORKING_MASK) & ST_PAUSED) + OnResumeButton(); + else + OnPauseButton(); + break; + } + } + + *pResult = 0; +} + +int CStatusDlg::GetImageFromStatus(UINT nStatus) +{ + if ( (nStatus & ST_STEP_MASK) == ST_CANCELLED ) + return 4; + if ( (nStatus & ST_STEP_MASK) == ST_FINISHED ) + return 3; + if ( (nStatus & ST_WAITING_MASK) == ST_WAITING ) + return 5; + if ( (nStatus & ST_WORKING_MASK) == ST_PAUSED ) + return 2; + if ( (nStatus & ST_WORKING_MASK) == ST_ERROR ) + return 1; + return 0; +} + +LPTSTR CStatusDlg::FormatTime(long lSeconds, LPTSTR lpszBuffer) +{ + long lDays=lSeconds/86400; + lSeconds%=86400; + long lHours=lSeconds/3600; + lSeconds%=3600; + long lMinutes=lSeconds/60; + lSeconds%=60; + + if (lDays != 0) + _stprintf(lpszBuffer, _T("%02d:%02d:%02d:%02d"), lDays, lHours, lMinutes, lSeconds); + else + if (lHours != 0) + _stprintf(lpszBuffer, _T("%02d:%02d:%02d"), lHours, lMinutes, lSeconds); + else + _stprintf(lpszBuffer, _T("%02d:%02d"), lMinutes, lSeconds); + + return lpszBuffer; +} + +void CStatusDlg::RefreshStatus() +{ + // remember address of a current selection + pSelectedItem=GetSelectedItemPointer(); + + // current time + DWORD dwCurrentTime=GetTickCount(); + + // get rid of item after the current part + m_ctlStatusList.LimitItems(m_pTasks->GetSize()); + + // add task info + for (int i=0;iGetSize();i++) + AddTaskInfo(i, m_pTasks->GetAt(i), dwCurrentTime); + + // percent + int nPercent=m_pTasks->GetPercent(); + + // set title + if (m_pTasks->GetSize() != 0) + _stprintf(m_szData, _T("%s [%d %%]"), GetResManager()->LoadString(IDS_STATUSTITLE_STRING), m_pTasks->GetPercent()); + else + _tcscpy(m_szData, GetResManager()->LoadString(IDS_STATUSTITLE_STRING)); + + // if changed + GetWindowText(m_strTemp); + if (m_strTemp != CString(m_szData)) + SetWindowText(m_szData); + + // refresh overall progress + if (GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) + { + m_ctlProgressAll.SetPos(nPercent); + + // progress - count of processed data/count of data + m_strTemp=GetSizeString(m_pTasks->GetPosition(), m_szData)+CString(_T("/")); + m_strTemp+=GetSizeString(m_pTasks->GetRange(), m_szData); + GetDlgItem(IDC_OVERALL_PROGRESS_STATIC)->SetWindowText(m_strTemp); + + // transfer + if (m_i64LastAllTasksProcessed == 0) + m_i64LastAllTasksProcessed=m_pTasks->GetPosition(); + + if (dwCurrentTime-m_dwLastUpdate != 0) + m_strTemp=GetSizeString( (static_cast(m_pTasks->GetPosition()) - static_cast(m_i64LastAllTasksProcessed))/static_cast(static_cast(dwCurrentTime-m_dwLastUpdate)/1000.0), m_szData ); + else + m_strTemp=GetSizeString( 0I64, m_szData ); + + GetDlgItem(IDC_OVERALL_TRANSFER_STATIC)->SetWindowText(m_strTemp+_T("/s")); + m_i64LastAllTasksProcessed=m_pTasks->GetPosition(); + m_dwLastUpdate=dwCurrentTime; + } + + // if selection's missing - hide controls + if (m_ctlStatusList.GetSelectedCount() == 0) + { + EnableControls(false); + m_pLastSelected=NULL; + m_i64LastProcessed=0; + } + else + EnableControls(); // enable controls + + // apply state of the resume, cancel, ... buttons + ApplyButtonsState(); +} + +void CStatusDlg::OnSelectionChanged(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/) +{ + TRACE("Received LVN_CHANGEDSELECTION\n"); + RefreshStatus(); +} + +void CStatusDlg::OnCancel() +{ + PostCloseMessage(); + CHLanguageDialog::OnCancel(); +} + +void CStatusDlg::OnAdvancedButton() +{ + CMenu menu; + HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_ADVANCED_MENU)); + if (!menu.Attach(hMenu)) + { + DestroyMenu(hMenu); + return; + } + + CMenu* pPopup = menu.GetSubMenu(0); + ASSERT(pPopup != NULL); + + // get the point to show menu at + CRect rect; + GetDlgItem(IDC_ADVANCED_BUTTON)->GetWindowRect(&rect); + + pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right+1, rect.top, this); +} + +void CStatusDlg::OnPopupReplacePaths() +{ + // check if there's a selection currently + if ( (pSelectedItem=GetSelectedItemPointer()) != NULL ) + { + if (pSelectedItem->GetStatus(ST_WORKING_MASK) & ST_PAUSED) + { + bool bContinue=false; + if (pSelectedItem->GetStatus(ST_WORKING_MASK) == ST_ERROR) + { + pSelectedItem->PauseProcessing(); + bContinue=true; + } + + // assuming here that there's selection and task is paused + CReplacePathsDlg dlg; + dlg.m_pTask=pSelectedItem; + if (dlg.DoModal() == IDOK) + { + // change 'no case' + int iClipboard=pSelectedItem->ReplaceClipboardStrings(dlg.m_strSource, dlg.m_strDest); + + CString strStats; + strStats.Format(IDS_REPLACEPATHSTEXT_STRING, iClipboard); + AfxMessageBox(strStats); + } + + // resume if earlier was an error + if (bContinue) + pSelectedItem->ResumeProcessing(); + } + else + MsgBox(IDS_TASKNOTPAUSED_STRING); + } + else + MsgBox(IDS_TASKNOTSELECTED_STRING); +} + +void CStatusDlg::OnShowLogButton() +{ + // show log + CTask* pTask; + if ( (pTask=GetSelectedItemPointer()) == NULL || !GetConfig()->GetBoolValue(PP_CMCREATELOG)) + return; + + // call what's needed + TCHAR szExec[1024]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szExec, 1024); + GetApp()->ExpandPath(szExec); + unsigned long lResult=(unsigned long)(ShellExecute(this->m_hWnd, _T("open"), _T("notepad.exe"), + CString(szExec)+pTask->GetUniqueName()+_T(".log"), szExec, SW_SHOWNORMAL)); + if (lResult < 32) + { + CString str=CString(szExec)+pTask->GetUniqueName()+_T(".log"); + _stprintf(szExec, GetResManager()->LoadString(IDS_SHELLEXECUTEERROR_STRING), lResult, str); + AfxMessageBox(szExec); + } +} + +LRESULT CStatusDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_UPDATESTATUS) + { + TRACE("Received WM_UPDATESTATUS\n"); + RefreshStatus(); + } + return CHLanguageDialog::WindowProc(message, wParam, lParam); +} + +void CStatusDlg::OnStickButton() +{ + ApplyDisplayDetails(true); +} + +void CStatusDlg::SetBufferSizesString(UINT uiValue, int iIndex) +{ + TCHAR szData[1024]; + switch (iIndex) + { + case BI_DEFAULT: + GetResManager()->LoadStringCopy(IDS_BSDEFAULT_STRING, szData, 256); + break; + case BI_ONEDISK: + GetResManager()->LoadStringCopy(IDS_BSONEDISK_STRING, szData, 256); + break; + case BI_TWODISKS: + GetResManager()->LoadStringCopy(IDS_BSTWODISKS_STRING, szData, 256); + break; + case BI_CD: + GetResManager()->LoadStringCopy(IDS_BSCD_STRING, szData, 256); + break; + case BI_LAN: + GetResManager()->LoadStringCopy(IDS_BSLAN_STRING, szData, 256); + break; + } + + _tcscat(szData, GetSizeString((__int64)uiValue, m_szData)); + + GetDlgItem(IDC_BUFFERSIZE_STATIC)->SetWindowText(szData); +} + +void CStatusDlg::PostCloseMessage() +{ + GetParent()->PostMessage(WM_STATUSCLOSING); +} + +void CStatusDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) +{ + // remove all columns + int iCnt=m_ctlStatusList.GetHeaderCtrl()->GetItemCount(); + + // Delete all of the columns. + for (int i=0;iLoadString(IDS_COLUMNSTATUS_STRING); /*_T("Status")*/; + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.27*iWidth); + lvc.iSubItem=-1; + m_ctlStatusList.InsertColumn(1, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSOURCE_STRING);/*_T("File");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.3*iWidth); + lvc.iSubItem=0; + m_ctlStatusList.InsertColumn(2, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNDESTINATION_STRING);/*_T("To:");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.27*iWidth); + lvc.iSubItem=1; + m_ctlStatusList.InsertColumn(3, &lvc); + + lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNPROGRESS_STRING);/*_T("Progress");*/ + lvc.cchTextMax = lstrlen(lvc.pszText); + lvc.cx = static_cast(0.15*iWidth); + lvc.iSubItem=2; + m_ctlStatusList.InsertColumn(4, &lvc); + + RefreshStatus(); +} Index: ch/StatusDlg.cpp =================================================================== diff -u -N --- ch/StatusDlg.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StatusDlg.cpp (revision 0) @@ -1,977 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "Copy Handler.h" -#include "resource.h" -#include "StatusDlg.h" -#include "BufferSizeDlg.h" -#include "ReplacePathsDlg.h" -#include "StringHelpers.h" -#include "StaticEx.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -bool CStatusDlg::m_bLock=false; - -///////////////////////////////////////////////////////////////////////////// -// CStatusDlg dialog - -CStatusDlg::CStatusDlg(CTaskArray* pTasks, CWnd* pParent /*=NULL*/) - : CHLanguageDialog(CStatusDlg::IDD, pParent, &m_bLock) -{ - //{{AFX_DATA_INIT(CStatusDlg) - //}}AFX_DATA_INIT - m_i64LastProcessed=0; - m_i64LastAllTasksProcessed=0; - m_pTasks=pTasks; - m_dwLastUpdate=0; - - RegisterStaticExControl(AfxGetInstanceHandle()); -} - -CStatusDlg::~CStatusDlg() -{ - -} - -void CStatusDlg::DoDataExchange(CDataExchange* pDX) -{ - CHLanguageDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CStatusDlg) - DDX_Control(pDX, IDC_ERRORS_EDIT, m_ctlErrors); - DDX_Control(pDX, IDC_TASK_PROGRESS, m_ctlCurrentProgress); - DDX_Control(pDX, IDC_STATUS_LIST, m_ctlStatusList); - DDX_Control(pDX, IDC_ALL_PROGRESS, m_ctlProgressAll); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CStatusDlg, CHLanguageDialog) - //{{AFX_MSG_MAP(CStatusDlg) - ON_WM_TIMER() - ON_BN_CLICKED(IDC_PAUSE_BUTTON, OnPauseButton) - ON_BN_CLICKED(IDC_CANCEL_BUTTON, OnCancelButton) - ON_BN_CLICKED(IDC_ROLL_UNROLL_BUTTON, OnRollUnrollButton) - ON_BN_CLICKED(IDC_SET_PRIORITY_BUTTON, OnSetPriorityButton) - ON_BN_CLICKED(IDC_SET_BUFFERSIZE_BUTTON, OnSetBuffersizeButton) - ON_BN_CLICKED(IDC_START_ALL_BUTTON, OnStartAllButton) - ON_BN_CLICKED(IDC_RESTART_BUTTON, OnRestartButton) - ON_BN_CLICKED(IDC_DELETE_BUTTON, OnDeleteButton) - ON_BN_CLICKED(IDC_PAUSE_ALL_BUTTON, OnPauseAllButton) - ON_BN_CLICKED(IDC_RESTART_ALL_BUTTON, OnRestartAllButton) - ON_BN_CLICKED(IDC_CANCEL_ALL_BUTTON, OnCancelAllButton) - ON_BN_CLICKED(IDC_REMOVE_FINISHED_BUTTON, OnRemoveFinishedButton) - ON_NOTIFY(LVN_KEYDOWN, IDC_STATUS_LIST, OnKeydownStatusList) - ON_NOTIFY(LVN_CHANGEDSELECTION, IDC_STATUS_LIST, OnSelectionChanged) - ON_BN_CLICKED(IDC_ADVANCED_BUTTON, OnAdvancedButton) - ON_COMMAND(ID_POPUP_REPLACE_PATHS, OnPopupReplacePaths) - ON_BN_CLICKED(IDC_SHOW_LOG_BUTTON, OnShowLogButton) - ON_BN_CLICKED(IDC_STICK_BUTTON, OnStickButton) - ON_BN_CLICKED(IDC_RESUME_BUTTON, OnResumeButton) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CStatusDlg message handlers - -BOOL CStatusDlg::OnInitDialog() -{ - CHLanguageDialog::OnInitDialog(); - - // get size of list ctrl - CRect rcList; - m_ctlStatusList.GetWindowRect(&rcList); - int iWidth=rcList.Width(); - - // set additional styles - m_ctlStatusList.SetExtendedStyle(m_ctlStatusList.GetExtendedStyle() | LVS_EX_FULLROWSELECT); - - // add columns - LVCOLUMN lvc; - lvc.mask=LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; - lvc.fmt=LVCFMT_LEFT; - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSTATUS_STRING); /*_T("Status")*/; - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.27*iWidth); - lvc.iSubItem=-1; - m_ctlStatusList.InsertColumn(1, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSOURCE_STRING);/*_T("File");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.3*iWidth); - lvc.iSubItem=0; - m_ctlStatusList.InsertColumn(2, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNDESTINATION_STRING);/*_T("To:");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.27*iWidth); - lvc.iSubItem=1; - m_ctlStatusList.InsertColumn(3, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNPROGRESS_STRING);/*_T("Progress");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.15*iWidth); - lvc.iSubItem=2; - m_ctlStatusList.InsertColumn(4, &lvc); - - // images - m_images.Create(16, 16, ILC_COLOR16 | ILC_MASK, 0, 3); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_WORKING_ICON))); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_ERROR_ICON))); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_PAUSED_ICON))); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_FINISHED_ICON))); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_CANCELLED_ICON))); - m_images.Add(AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_WAITING_ICON))); - - m_ctlStatusList.SetImageList(&m_images, LVSIL_SMALL); - - // set fixed progresses ranges - m_ctlCurrentProgress.SetRange32(0, 100); - m_ctlProgressAll.SetRange32(0, 100); - - // change the size of a dialog - ApplyDisplayDetails(true); -// ApplyButtonsState(); -// EnableControls(false); - - // refresh data - RefreshStatus(); - - // select needed element - int i=0; - while (i < m_pTasks->GetSize()) - { - if (m_pTasks->GetAt(i) == m_pInitialSelection) - { - m_ctlStatusList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); - break; - } - - i++; - }; - - // refresh data timer - SetTimer(777, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL), NULL); - - return TRUE; -} - -void CStatusDlg::EnableControls(bool bEnable) -{ - // enable/disable controls - GetDlgItem(IDC_SET_BUFFERSIZE_BUTTON)->EnableWindow(bEnable); - GetDlgItem(IDC_SET_PRIORITY_BUTTON)->EnableWindow(bEnable); - - if (!bEnable) - { - // get rid of text id disabling - GetDlgItem(IDC_OPERATION_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYOPERATIONTEXT_STRING)); - GetDlgItem(IDC_SOURCE_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYSOURCETEXT_STRING)); - GetDlgItem(IDC_DESTINATION_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYDESTINATIONTEXT_STRING)); - GetDlgItem(IDC_BUFFERSIZE_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYBUFFERSIZETEXT_STRING)); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYPRIORITYTEXT_STRING)); - - const TCHAR *pszText=GetResManager()->LoadString(IDS_EMPTYERRORTEXT_STRING); - m_ctlErrors.GetWindowText(m_strTemp); - if (m_strTemp != pszText) - m_ctlErrors.SetWindowText(pszText); - - GetDlgItem(IDC_PROGRESS_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYPROCESSEDTEXT_STRING)); - GetDlgItem(IDC_TRANSFER_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYTRANSFERTEXT_STRING)); - GetDlgItem(IDC_TIME_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYTIMETEXT_STRING)); - GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(GetResManager()->LoadString(IDS_EMPTYASSOCFILE_STRING)); - - m_ctlCurrentProgress.SetPos(0); - } -} - -void CStatusDlg::OnTimer(UINT nIDEvent) -{ - if (nIDEvent == 777) // refreshing data - { - // turn off timer for some time - KillTimer(777); - - RefreshStatus(); - - // reenable - SetTimer(777, GetConfig()->GetIntValue(PP_STATUSREFRESHINTERVAL), NULL); - } - - CHLanguageDialog::OnTimer(nIDEvent); -} - -void CStatusDlg::AddTaskInfo(int nPos, CTask *pTask, DWORD dwCurrentTime) -{ - // index to string - _itot(nPos, m_szData, 10); - - // get data snapshot from task - pTask->GetSnapshot(&td); - - // index subitem - lvi.mask=LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; - lvi.iItem=nPos; - lvi.iSubItem=0; - lvi.pszText=td.m_szStatusText; - lvi.cchTextMax=lstrlen(lvi.pszText); - lvi.lParam=reinterpret_cast(pTask); - lvi.iImage=GetImageFromStatus(td.m_uiStatus); - if (nPos < m_ctlStatusList.GetItemCount()) - m_ctlStatusList.SetItem(&lvi); - else - m_ctlStatusList.InsertItem(&lvi); - - // status subitem - lvi.mask=LVIF_TEXT; // zmie� mask� - lvi.iSubItem=1; - m_strTemp=td.m_fi.GetFileName(); - lvi.pszText=m_strTemp.GetBuffer(0); - m_strTemp.ReleaseBuffer(); - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlStatusList.SetItem(&lvi); - - // insert 'file' subitem - lvi.iSubItem=2; - m_strTemp=td.m_pdpDestPath->GetPath(); - lvi.pszText=m_strTemp.GetBuffer(0); - m_strTemp.ReleaseBuffer(); - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlStatusList.SetItem(&lvi); - - // insert dest subitem - lvi.iSubItem=3; - _itot( td.m_nPercent, m_szData, 10 ); - _tcscat(m_szData, _T(" %")); - lvi.pszText=m_szData; - lvi.cchTextMax=lstrlen(lvi.pszText); - m_ctlStatusList.SetItem(&lvi); - - // right side update - if (pTask == pSelectedItem && GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) - { - // data that can be changed by a thread - GetDlgItem(IDC_OPERATION_STATIC)->SetWindowText(td.m_szStatusText); // operation - GetDlgItem(IDC_SOURCE_STATIC)->SetWindowText(td.m_fi.GetFullFilePath()); // src object - - // error message - if ( (td.m_uiStatus & ST_WORKING_MASK) == ST_ERROR ) - { - m_ctlErrors.GetWindowText(m_strTemp); - if (m_strTemp != td.m_strErrorDesc) - m_ctlErrors.SetWindowText(td.m_strErrorDesc); - } - else - { - const TCHAR *pszText=GetResManager()->LoadString(IDS_EMPTYERRORTEXT_STRING); - - m_ctlErrors.GetWindowText(m_strTemp2); - if (m_strTemp2 != pszText) - m_ctlErrors.SetWindowText(pszText); - } - - // count of processed data/overall count of data - _stprintf(m_szData, _T("%d/%d ("), td.m_iIndex, td.m_iSize); - m_strTemp=CString(m_szData); - m_strTemp+=GetSizeString(td.m_iProcessedSize, m_szData)+CString(_T("/")); - m_strTemp+=GetSizeString(td.m_iSizeAll, m_szData)+CString(_T(")")); - _stprintf(m_szData, _T(" (%s%d/%d)"), GetResManager()->LoadString(IDS_CURRENTPASS_STRING), td.m_ucCurrentCopy, td.m_ucCopies); - m_strTemp+=m_szData; - GetDlgItem(IDC_PROGRESS_STATIC)->SetWindowText(m_strTemp); - - // transfer - if (m_i64LastProcessed == 0) // if first time - show average - m_strTemp=GetSizeString( td.m_lTimeElapsed ? td.m_iProcessedSize/td.m_lTimeElapsed : 0, m_szData ); // last avg - else - if ( (dwCurrentTime-m_dwLastUpdate) != 0) - m_strTemp=GetSizeString( (static_cast(td.m_iProcessedSize) - static_cast(m_i64LastProcessed))/(static_cast(dwCurrentTime-m_dwLastUpdate)/1000.0), m_szData ); - else - m_strTemp=GetSizeString( 0I64, m_szData ); - - // avg transfer - GetDlgItem(IDC_TRANSFER_STATIC)->SetWindowText(m_strTemp+_T("/s (")+CString(GetResManager()->LoadString(IDS_AVERAGEWORD_STRING)) - +CString(GetSizeString(td.m_lTimeElapsed ? td.m_iProcessedSize/td.m_lTimeElapsed : 0, m_szData))+_T("/s )") - ); - - // elapsed time/estimated time - FormatTime(td.m_lTimeElapsed, m_szTimeBuffer1); - FormatTime( (td.m_iProcessedSize == 0) ? 0 : static_cast((static_cast<__int64>(td.m_iSizeAll)*static_cast<__int64>(td.m_lTimeElapsed))/td.m_iProcessedSize), m_szTimeBuffer2); - - _stprintf(m_szData, _T("%s / %s"), m_szTimeBuffer1, m_szTimeBuffer2); - GetDlgItem(IDC_TIME_STATIC)->SetWindowText(m_szData); - - // remember current processed data (used for calculating transfer) - m_i64LastProcessed=td.m_iProcessedSize; - - // set progress - m_ctlCurrentProgress.SetPos(td.m_nPercent); - - SetBufferSizesString(td.m_pbsSizes->m_auiSizes[td.m_iCurrentBufferIndex], td.m_iCurrentBufferIndex); - - // data that can be changed only by user from outside the thread - // refresh only when there are new selected item -// if (pTask != m_pLastSelected) - { - GetDlgItem(IDC_DESTINATION_STATIC)->SetWindowText(td.m_pdpDestPath->GetPath()); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(td.m_nPriority))); - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, m_strTemp.GetBuffer(1024), 1024); - m_strTemp.ReleaseBuffer(); - GetDlgItem(IDC_ASSOCIATEDFILES__STATIC)->SetWindowText(m_strTemp+*td.m_pstrUniqueName+_T(".atd (.atp, .log)")); - } - - // refresh m_pLastSelected - m_pLastSelected=pTask; - } -} - -void CStatusDlg::OnSetBuffersizeButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - CBufferSizeDlg dlg; - dlg.m_bsSizes=*pTask->GetBufferSizes(); - dlg.m_iActiveIndex=pTask->GetCurrentBufferIndex(); - if (dlg.DoModal() == IDOK) - { - // if the task has been deleted - skip - if ( pTask != GetSelectedItemPointer() ) - { - TRACE("Task were finished and deleted when trying to change buffer sizes"); - return; - } - - TRACE("bOnlyDefault=%d\n", dlg.m_bsSizes.m_bOnlyDefault); - pTask->SetBufferSizes(&dlg.m_bsSizes); - } -} - -CTask* CStatusDlg::GetSelectedItemPointer() -{ -// TRACE("inside GetSelectedItemPointer()\n"); - // returns ptr to a CTask for a given element in listview - if (m_ctlStatusList.GetSelectedCount() == 1) - { - POSITION pos=m_ctlStatusList.GetFirstSelectedItemPosition(); - int nPos=m_ctlStatusList.GetNextSelectedItem(pos); - CTask* pSelectedItem=reinterpret_cast(m_ctlStatusList.GetItemData(nPos)); -// if (AfxIsValidAddress(pSelectedItem, sizeof(CTask))) - return pSelectedItem; - } -// TRACE("exiting GetSelectedItemPointer()\n"); - - return NULL; -} - -void CStatusDlg::OnRollUnrollButton() -{ - // change settings in config dialog - GetConfig()->SetBoolValue(PP_STATUSSHOWDETAILS, !GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)); - - ApplyDisplayDetails(); -} - -void CStatusDlg::ApplyDisplayDetails(bool bInitial) -{ - // get coord of screen and window - CRect rcScreen, rect; - SystemParametersInfo(SPI_GETWORKAREA, 0, &rcScreen, 0); - GetWindowRect(&rect); - - bool bDetails=GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS); - - // stick cause - if (rect.right == rcScreen.right && rect.bottom == rcScreen.bottom) - bInitial=true; - - GetDlgItem(IDC_ROLL_UNROLL_BUTTON)->SetWindowText(bDetails ? _T("<<") : _T(">>")); - - CRect list, progress; - m_ctlProgressAll.GetWindowRect(&progress); - ScreenToClient(&progress); - m_ctlStatusList.GetWindowRect(&list); - ScreenToClient(&list); - - // set dialog size - CRect destRect; - if (!bInitial) - { - destRect.left=0; - destRect.top=0; - destRect.right=bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER); - destRect.bottom=rect.Height(); - SetWindowPos(NULL, destRect.left, destRect.top, destRect.right, destRect.bottom, SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); - } - else - { - SetWindowPos(NULL, rcScreen.right-(bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER)), - rcScreen.bottom-rect.Height(), (bDetails ? progress.right+list.left+3*GetSystemMetrics(SM_CXBORDER) : list.right+list.left+3*GetSystemMetrics(SM_CXBORDER)), - rect.Height(), SWP_NOOWNERZORDER | SWP_NOZORDER); - } -} - -void CStatusDlg::ApplyButtonsState() -{ - // remember ptr to CTask - pSelectedItem=GetSelectedItemPointer(); - bool bShowLog=GetConfig()->GetBoolValue(PP_CMCREATELOG); - - // set status of buttons pause/resume/cancel - if (pSelectedItem != NULL) - { - GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(true); - GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(bShowLog); - GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(true); - - if (pSelectedItem->GetStatus(ST_STEP_MASK) == ST_FINISHED - || pSelectedItem->GetStatus(ST_STEP_MASK) == ST_CANCELLED) - { - GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); - } - else - { - // pause/resume - if (pSelectedItem->GetStatus(ST_WORKING_MASK) & ST_PAUSED) - { - GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); - } - else - { - GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(true); - if (pSelectedItem->GetStatus(ST_WAITING_MASK) & ST_WAITING) - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); - else - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); - } - - GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(true); - } - } - else - { - GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(false); - } -} - -void CStatusDlg::OnSetPriorityButton() -{ - CMenu menu; - HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_PRIORITY_MENU)); - if (!menu.Attach(hMenu)) - { - DestroyMenu(hMenu); - return; - } - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - // set point in which to set menu - CRect rect; - GetDlgItem(IDC_SET_PRIORITY_BUTTON)->GetWindowRect(&rect); - - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right+1, rect.top, this); -} - -BOOL CStatusDlg::OnCommand(WPARAM wParam, LPARAM lParam) -{ - if (HIWORD(wParam) == 0) - { - if (LOWORD(wParam) >= ID_POPUP_TIME_CRITICAL && LOWORD(wParam) <= ID_POPUP_IDLE) - { - // processing priority - if ( (pSelectedItem=GetSelectedItemPointer()) == NULL ) - return CHLanguageDialog::OnCommand(wParam, lParam); - - switch (LOWORD(wParam)) - { - case ID_POPUP_TIME_CRITICAL: - pSelectedItem->SetPriority(THREAD_PRIORITY_TIME_CRITICAL); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_TIME_CRITICAL))); - break; - case ID_POPUP_HIGHEST: - pSelectedItem->SetPriority(THREAD_PRIORITY_HIGHEST); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_HIGHEST))); - break; - case ID_POPUP_ABOVE_NORMAL: - pSelectedItem->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_ABOVE_NORMAL))); - break; - case ID_POPUP_NORMAL: - pSelectedItem->SetPriority(THREAD_PRIORITY_NORMAL); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_NORMAL))); - break; - case ID_POPUP_BELOW_NORMAL: - pSelectedItem->SetPriority(THREAD_PRIORITY_BELOW_NORMAL); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_BELOW_NORMAL))); - break; - case ID_POPUP_LOWEST: - pSelectedItem->SetPriority(THREAD_PRIORITY_LOWEST); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_LOWEST))); - break; - case ID_POPUP_IDLE: - pSelectedItem->SetPriority(THREAD_PRIORITY_IDLE); - GetDlgItem(IDC_PRIORITY_STATIC)->SetWindowText(GetResManager()->LoadString(IDS_PRIORITY0_STRING+PriorityToIndex(THREAD_PRIORITY_IDLE))); - break; - } - } - } - return CHLanguageDialog::OnCommand(wParam, lParam); -} - -void CStatusDlg::OnPauseButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - TRACE("PauseProcessing call...\n"); - pTask->PauseProcessing(); - - RefreshStatus(); -} - -void CStatusDlg::OnResumeButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - TRACE("ResumeProcessing call "); - if (pTask->GetStatus(ST_WAITING_MASK) & ST_WAITING) - { - TRACE("by setting force flag\n"); - pTask->SetForceFlag(); - } - else - { - TRACE("by function ResumeProcessing\n"); - pTask->ResumeProcessing(); - } - - RefreshStatus(); -} - -void CStatusDlg::OnCancelButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) != NULL ) - { - TRACE("CancelProcessing call...\n"); - pTask->CancelProcessing(); - } - RefreshStatus(); -} - -void CStatusDlg::OnRestartButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - TRACE("RestartProcessing call...\n"); - pTask->RestartProcessing(); - RefreshStatus(); -} - -void CStatusDlg::OnDeleteButton() -{ - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - UINT uiStatus=pTask->GetStatus(ST_STEP_MASK); - if ( (uiStatus & ST_STEP_MASK) != ST_FINISHED && (uiStatus & ST_STEP_MASK) != ST_CANCELLED ) - { - // ask if cancel - if (MsgBox(IDS_CONFIRMCANCEL_STRING, MB_OKCANCEL | MB_ICONQUESTION) == IDOK) - { - // cancel - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - pTask->CancelProcessing(); - } - else - return; - } - - m_pTasks->RemoveFinished(&pTask); - RefreshStatus(); -} - -void CStatusDlg::OnPauseAllButton() -{ - TRACE("Pause All...\n"); - m_pTasks->TasksPauseProcessing(); - RefreshStatus(); -} - -void CStatusDlg::OnStartAllButton() -{ - TRACE("Resume Processing...\n"); - m_pTasks->TasksResumeProcessing(); - RefreshStatus(); -} - -void CStatusDlg::OnRestartAllButton() -{ - TRACE("Restart Processing...\n"); - m_pTasks->TasksRestartProcessing(); - RefreshStatus(); -} - -void CStatusDlg::OnCancelAllButton() -{ - TRACE("Cancel Processing...\n"); - m_pTasks->TasksCancelProcessing(); - RefreshStatus(); -} - -void CStatusDlg::OnRemoveFinishedButton() -{ - m_pTasks->RemoveAllFinished(); - RefreshStatus(); -} - -void CStatusDlg::OnKeydownStatusList(NMHDR* pNMHDR, LRESULT* pResult) -{ - LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR; - switch (pLVKeyDow->wVKey) - { - case VK_DELETE: - OnDeleteButton(); - break; - case VK_SPACE: - { - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL ) - return; - - if (pTask->GetStatus(ST_WORKING_MASK) & ST_PAUSED) - OnResumeButton(); - else - OnPauseButton(); - break; - } - } - - *pResult = 0; -} - -int CStatusDlg::GetImageFromStatus(UINT nStatus) -{ - if ( (nStatus & ST_STEP_MASK) == ST_CANCELLED ) - return 4; - if ( (nStatus & ST_STEP_MASK) == ST_FINISHED ) - return 3; - if ( (nStatus & ST_WAITING_MASK) == ST_WAITING ) - return 5; - if ( (nStatus & ST_WORKING_MASK) == ST_PAUSED ) - return 2; - if ( (nStatus & ST_WORKING_MASK) == ST_ERROR ) - return 1; - return 0; -} - -LPTSTR CStatusDlg::FormatTime(long lSeconds, LPTSTR lpszBuffer) -{ - long lDays=lSeconds/86400; - lSeconds%=86400; - long lHours=lSeconds/3600; - lSeconds%=3600; - long lMinutes=lSeconds/60; - lSeconds%=60; - - if (lDays != 0) - _stprintf(lpszBuffer, _T("%02d:%02d:%02d:%02d"), lDays, lHours, lMinutes, lSeconds); - else - if (lHours != 0) - _stprintf(lpszBuffer, _T("%02d:%02d:%02d"), lHours, lMinutes, lSeconds); - else - _stprintf(lpszBuffer, _T("%02d:%02d"), lMinutes, lSeconds); - - return lpszBuffer; -} - -void CStatusDlg::RefreshStatus() -{ - // remember address of a current selection - pSelectedItem=GetSelectedItemPointer(); - - // current time - DWORD dwCurrentTime=GetTickCount(); - - // get rid of item after the current part - m_ctlStatusList.LimitItems(m_pTasks->GetSize()); - - // add task info - for (int i=0;iGetSize();i++) - AddTaskInfo(i, m_pTasks->GetAt(i), dwCurrentTime); - - // percent - int nPercent=m_pTasks->GetPercent(); - - // set title - if (m_pTasks->GetSize() != 0) - _stprintf(m_szData, _T("%s [%d %%]"), GetResManager()->LoadString(IDS_STATUSTITLE_STRING), m_pTasks->GetPercent()); - else - _tcscpy(m_szData, GetResManager()->LoadString(IDS_STATUSTITLE_STRING)); - - // if changed - GetWindowText(m_strTemp); - if (m_strTemp != CString(m_szData)) - SetWindowText(m_szData); - - // refresh overall progress - if (GetConfig()->GetBoolValue(PP_STATUSSHOWDETAILS)) - { - m_ctlProgressAll.SetPos(nPercent); - - // progress - count of processed data/count of data - m_strTemp=GetSizeString(m_pTasks->GetPosition(), m_szData)+CString(_T("/")); - m_strTemp+=GetSizeString(m_pTasks->GetRange(), m_szData); - GetDlgItem(IDC_OVERALL_PROGRESS_STATIC)->SetWindowText(m_strTemp); - - // transfer - if (m_i64LastAllTasksProcessed == 0) - m_i64LastAllTasksProcessed=m_pTasks->GetPosition(); - - if (dwCurrentTime-m_dwLastUpdate != 0) - m_strTemp=GetSizeString( (static_cast(m_pTasks->GetPosition()) - static_cast(m_i64LastAllTasksProcessed))/static_cast(static_cast(dwCurrentTime-m_dwLastUpdate)/1000.0), m_szData ); - else - m_strTemp=GetSizeString( 0I64, m_szData ); - - GetDlgItem(IDC_OVERALL_TRANSFER_STATIC)->SetWindowText(m_strTemp+_T("/s")); - m_i64LastAllTasksProcessed=m_pTasks->GetPosition(); - m_dwLastUpdate=dwCurrentTime; - } - - // if selection's missing - hide controls - if (m_ctlStatusList.GetSelectedCount() == 0) - { - EnableControls(false); - m_pLastSelected=NULL; - m_i64LastProcessed=0; - } - else - EnableControls(); // enable controls - - // apply state of the resume, cancel, ... buttons - ApplyButtonsState(); -} - -void CStatusDlg::OnSelectionChanged(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/) -{ - TRACE("Received LVN_CHANGEDSELECTION\n"); - RefreshStatus(); -} - -void CStatusDlg::OnCancel() -{ - PostCloseMessage(); - CHLanguageDialog::OnCancel(); -} - -void CStatusDlg::OnAdvancedButton() -{ - CMenu menu; - HMENU hMenu=GetResManager()->LoadMenu(MAKEINTRESOURCE(IDR_ADVANCED_MENU)); - if (!menu.Attach(hMenu)) - { - DestroyMenu(hMenu); - return; - } - - CMenu* pPopup = menu.GetSubMenu(0); - ASSERT(pPopup != NULL); - - // get the point to show menu at - CRect rect; - GetDlgItem(IDC_ADVANCED_BUTTON)->GetWindowRect(&rect); - - pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right+1, rect.top, this); -} - -void CStatusDlg::OnPopupReplacePaths() -{ - // check if there's a selection currently - if ( (pSelectedItem=GetSelectedItemPointer()) != NULL ) - { - if (pSelectedItem->GetStatus(ST_WORKING_MASK) & ST_PAUSED) - { - bool bContinue=false; - if (pSelectedItem->GetStatus(ST_WORKING_MASK) == ST_ERROR) - { - pSelectedItem->PauseProcessing(); - bContinue=true; - } - - // assuming here that there's selection and task is paused - CReplacePathsDlg dlg; - dlg.m_pTask=pSelectedItem; - if (dlg.DoModal() == IDOK) - { - // change 'no case' - int iClipboard=pSelectedItem->ReplaceClipboardStrings(dlg.m_strSource, dlg.m_strDest); - - CString strStats; - strStats.Format(IDS_REPLACEPATHSTEXT_STRING, iClipboard); - AfxMessageBox(strStats); - } - - // resume if earlier was an error - if (bContinue) - pSelectedItem->ResumeProcessing(); - } - else - MsgBox(IDS_TASKNOTPAUSED_STRING); - } - else - MsgBox(IDS_TASKNOTSELECTED_STRING); -} - -void CStatusDlg::OnShowLogButton() -{ - // show log - CTask* pTask; - if ( (pTask=GetSelectedItemPointer()) == NULL || !GetConfig()->GetBoolValue(PP_CMCREATELOG)) - return; - - // call what's needed - TCHAR szExec[1024]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szExec, 1024); - GetApp()->ExpandPath(szExec); - unsigned long lResult=(unsigned long)(ShellExecute(this->m_hWnd, _T("open"), _T("notepad.exe"), - CString(szExec)+pTask->GetUniqueName()+_T(".log"), szExec, SW_SHOWNORMAL)); - if (lResult < 32) - { - CString str=CString(szExec)+pTask->GetUniqueName()+_T(".log"); - _stprintf(szExec, GetResManager()->LoadString(IDS_SHELLEXECUTEERROR_STRING), lResult, str); - AfxMessageBox(szExec); - } -} - -LRESULT CStatusDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - if (message == WM_UPDATESTATUS) - { - TRACE("Received WM_UPDATESTATUS\n"); - RefreshStatus(); - } - return CHLanguageDialog::WindowProc(message, wParam, lParam); -} - -void CStatusDlg::OnStickButton() -{ - ApplyDisplayDetails(true); -} - -void CStatusDlg::SetBufferSizesString(UINT uiValue, int iIndex) -{ - TCHAR szData[1024]; - switch (iIndex) - { - case BI_DEFAULT: - GetResManager()->LoadStringCopy(IDS_BSDEFAULT_STRING, szData, 256); - break; - case BI_ONEDISK: - GetResManager()->LoadStringCopy(IDS_BSONEDISK_STRING, szData, 256); - break; - case BI_TWODISKS: - GetResManager()->LoadStringCopy(IDS_BSTWODISKS_STRING, szData, 256); - break; - case BI_CD: - GetResManager()->LoadStringCopy(IDS_BSCD_STRING, szData, 256); - break; - case BI_LAN: - GetResManager()->LoadStringCopy(IDS_BSLAN_STRING, szData, 256); - break; - } - - _tcscat(szData, GetSizeString((__int64)uiValue, m_szData)); - - GetDlgItem(IDC_BUFFERSIZE_STATIC)->SetWindowText(szData); -} - -void CStatusDlg::PostCloseMessage() -{ - GetParent()->PostMessage(WM_STATUSCLOSING); -} - -void CStatusDlg::OnLanguageChanged(WORD /*wOld*/, WORD /*wNew*/) -{ - // remove all columns - int iCnt=m_ctlStatusList.GetHeaderCtrl()->GetItemCount(); - - // Delete all of the columns. - for (int i=0;iLoadString(IDS_COLUMNSTATUS_STRING); /*_T("Status")*/; - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.27*iWidth); - lvc.iSubItem=-1; - m_ctlStatusList.InsertColumn(1, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNSOURCE_STRING);/*_T("File");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.3*iWidth); - lvc.iSubItem=0; - m_ctlStatusList.InsertColumn(2, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNDESTINATION_STRING);/*_T("To:");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.27*iWidth); - lvc.iSubItem=1; - m_ctlStatusList.InsertColumn(3, &lvc); - - lvc.pszText=(PTSTR)GetResManager()->LoadString(IDS_COLUMNPROGRESS_STRING);/*_T("Progress");*/ - lvc.cchTextMax = lstrlen(lvc.pszText); - lvc.cx = static_cast(0.15*iWidth); - lvc.iSubItem=2; - m_ctlStatusList.InsertColumn(4, &lvc); - - RefreshStatus(); -} Index: src/ch/StatusDlg.h =================================================================== diff -u -N --- src/ch/StatusDlg.h (revision 0) +++ src/ch/StatusDlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,126 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __STATUSDLG_H__ +#define __STATUSDLG_H__ + +#include "structs.h" +#include "FFListCtrl.h" + +#define WM_UPDATESTATUS WM_USER+6 +#define WM_STATUSCLOSING WM_USER+12 + +///////////////////////////////////////////////////////////////////////////// +// CStatusDlg dialog +class CStatusDlg : public CHLanguageDialog +{ +// Construction +public: + CStatusDlg(CTaskArray* pTasks, CWnd* pParent = NULL); // standard constructor + ~CStatusDlg(); + void PostCloseMessage(); + void SetBufferSizesString(UINT uiValue, int iIndex); + void RefreshStatus(); + LPTSTR FormatTime(long lSeconds, LPTSTR lpszBuffer); + int GetImageFromStatus(UINT nStatus); + + void ApplyButtonsState(); + void ApplyDisplayDetails(bool bInitial=false); + CTask* GetSelectedItemPointer(); + + void AddTaskInfo(int nPos, CTask *pTask, DWORD dwCurrentTime); + void EnableControls(bool bEnable=true); + + CTaskArray* m_pTasks; + CTask* pSelectedItem; + const CTask *m_pLastSelected; + const CTask* m_pInitialSelection; + + TCHAR m_szData[_MAX_PATH]; + TCHAR m_szTimeBuffer1[40]; + TCHAR m_szTimeBuffer2[40]; + + __int64 m_i64LastProcessed; + __int64 m_i64LastAllTasksProcessed; + DWORD m_dwLastUpdate; + + LVITEM lvi; + TASK_DISPLAY_DATA td; + CString m_strTemp, m_strTemp2; + + CImageList m_images; + + static bool m_bLock; // locker + +// Dialog Data + //{{AFX_DATA(CStatusDlg) + enum { IDD = IDD_STATUS_DIALOG }; + CEdit m_ctlErrors; + CProgressCtrl m_ctlCurrentProgress; + CFFListCtrl m_ctlStatusList; + CProgressCtrl m_ctlProgressAll; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CStatusDlg) + public: + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + virtual void OnLanguageChanged(WORD wOld, WORD wNew); + + // Generated message map functions + //{{AFX_MSG(CStatusDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT nIDEvent); + afx_msg void OnPauseButton(); + afx_msg void OnCancelButton(); + afx_msg void OnRollUnrollButton(); + afx_msg void OnSetPriorityButton(); + afx_msg void OnSetBuffersizeButton(); + afx_msg void OnStartAllButton(); + afx_msg void OnRestartButton(); + afx_msg void OnDeleteButton(); + afx_msg void OnPauseAllButton(); + afx_msg void OnRestartAllButton(); + afx_msg void OnCancelAllButton(); + afx_msg void OnRemoveFinishedButton(); + afx_msg void OnKeydownStatusList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSelectionChanged(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/); + virtual void OnCancel(); + afx_msg void OnAdvancedButton(); + afx_msg void OnPopupReplacePaths(); + afx_msg void OnShowLogButton(); + afx_msg void OnStickButton(); + afx_msg void OnResumeButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/StatusDlg.h =================================================================== diff -u -N --- ch/StatusDlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StatusDlg.h (revision 0) @@ -1,126 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __STATUSDLG_H__ -#define __STATUSDLG_H__ - -#include "structs.h" -#include "FFListCtrl.h" - -#define WM_UPDATESTATUS WM_USER+6 -#define WM_STATUSCLOSING WM_USER+12 - -///////////////////////////////////////////////////////////////////////////// -// CStatusDlg dialog -class CStatusDlg : public CHLanguageDialog -{ -// Construction -public: - CStatusDlg(CTaskArray* pTasks, CWnd* pParent = NULL); // standard constructor - ~CStatusDlg(); - void PostCloseMessage(); - void SetBufferSizesString(UINT uiValue, int iIndex); - void RefreshStatus(); - LPTSTR FormatTime(long lSeconds, LPTSTR lpszBuffer); - int GetImageFromStatus(UINT nStatus); - - void ApplyButtonsState(); - void ApplyDisplayDetails(bool bInitial=false); - CTask* GetSelectedItemPointer(); - - void AddTaskInfo(int nPos, CTask *pTask, DWORD dwCurrentTime); - void EnableControls(bool bEnable=true); - - CTaskArray* m_pTasks; - CTask* pSelectedItem; - const CTask *m_pLastSelected; - const CTask* m_pInitialSelection; - - TCHAR m_szData[_MAX_PATH]; - TCHAR m_szTimeBuffer1[40]; - TCHAR m_szTimeBuffer2[40]; - - __int64 m_i64LastProcessed; - __int64 m_i64LastAllTasksProcessed; - DWORD m_dwLastUpdate; - - LVITEM lvi; - TASK_DISPLAY_DATA td; - CString m_strTemp, m_strTemp2; - - CImageList m_images; - - static bool m_bLock; // locker - -// Dialog Data - //{{AFX_DATA(CStatusDlg) - enum { IDD = IDD_STATUS_DIALOG }; - CEdit m_ctlErrors; - CProgressCtrl m_ctlCurrentProgress; - CFFListCtrl m_ctlStatusList; - CProgressCtrl m_ctlProgressAll; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CStatusDlg) - public: - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - virtual void OnLanguageChanged(WORD wOld, WORD wNew); - - // Generated message map functions - //{{AFX_MSG(CStatusDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT nIDEvent); - afx_msg void OnPauseButton(); - afx_msg void OnCancelButton(); - afx_msg void OnRollUnrollButton(); - afx_msg void OnSetPriorityButton(); - afx_msg void OnSetBuffersizeButton(); - afx_msg void OnStartAllButton(); - afx_msg void OnRestartButton(); - afx_msg void OnDeleteButton(); - afx_msg void OnPauseAllButton(); - afx_msg void OnRestartAllButton(); - afx_msg void OnCancelAllButton(); - afx_msg void OnRemoveFinishedButton(); - afx_msg void OnKeydownStatusList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSelectionChanged(NMHDR* /*pNMHDR*/, LRESULT* /*pResult*/); - virtual void OnCancel(); - afx_msg void OnAdvancedButton(); - afx_msg void OnPopupReplacePaths(); - afx_msg void OnShowLogButton(); - afx_msg void OnStickButton(); - afx_msg void OnResumeButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/Stdafx.h =================================================================== diff -u -N --- src/ch/Stdafx.h (revision 0) +++ src/ch/Stdafx.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,44 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __STDAFX_H__ +#define __STDAFX_H__ + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT +#include "afxmt.h" + +#define DISABLE_CRYPT +#include "ConfigManager.h" + +#pragma warning (disable: 4711) +#include "HelpLngDialog.h" +#include "htmlhelp.h" +#include "debug.h" + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif Index: ch/Stdafx.h =================================================================== diff -u -N --- ch/Stdafx.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Stdafx.h (revision 0) @@ -1,44 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __STDAFX_H__ -#define __STDAFX_H__ - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT -#include "afxmt.h" - -#define DISABLE_CRYPT -#include "ConfigManager.h" - -#pragma warning (disable: 4711) -#include "HelpLngDialog.h" -#include "htmlhelp.h" -#include "debug.h" - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/StringHelpers.cpp =================================================================== diff -u -N --- src/ch/StringHelpers.cpp (revision 0) +++ src/ch/StringHelpers.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,77 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "Copy Handler.h" +#include "StringHelpers.h" +#include "stdio.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#ifdef _MFC_VER +void ExpandFormatString(CString* pstrFmt, DWORD dwError) +{ + // replace strings %errnum & %errdesc to something else + TCHAR xx[_MAX_PATH]; + pstrFmt->Replace(_T("%errnum"), _itot(dwError, xx, 10)); + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, xx, _MAX_PATH, NULL); + + while (xx[_tcslen(xx)-1] == _T('\n') || xx[_tcslen(xx)-1] == _T('\r')) + xx[_tcslen(xx)-1] = _T('\0'); + + pstrFmt->Replace(_T("%errdesc"), xx); +} +#endif + +LPTSTR GetSizeString(double dData, LPTSTR pszBuffer) +{ + if (dData < 0.0) + dData=0.0; + + if (dData < 1200.0) + _stprintf(pszBuffer, _T("%.2f %s"), dData, GetResManager()->LoadString(IDS_BYTE_STRING)); + else if (dData < 1228800.0) + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1024.0, GetResManager()->LoadString(IDS_KBYTE_STRING)); + else if (dData < 1258291200.0) + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1048576.0, GetResManager()->LoadString(IDS_MBYTE_STRING)); + else + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1073741824.0, GetResManager()->LoadString(IDS_GBYTE_STRING)); + + return pszBuffer; +} + +LPTSTR GetSizeString(__int64 llData, LPTSTR pszBuffer, bool bStrict) +{ + if (llData < 0) + llData=0; + + if (llData >= 1258291200 && (!bStrict || (llData % 1073741824) == 0)) + _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1073741824.0), GetResManager()->LoadString(IDS_GBYTE_STRING)); + else if (llData >= 1228800 && (!bStrict || (llData % 1048576) == 0)) + _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1048576.0), GetResManager()->LoadString(IDS_MBYTE_STRING)); + else if (llData >= 1200 && (!bStrict || (llData % 1024) == 0)) + _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1024.0), GetResManager()->LoadString(IDS_KBYTE_STRING)); + else + _stprintf(pszBuffer, _T("%I64u %s"), llData, GetResManager()->LoadString(IDS_BYTE_STRING)); + + return pszBuffer; +} Index: ch/StringHelpers.cpp =================================================================== diff -u -N --- ch/StringHelpers.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StringHelpers.cpp (revision 0) @@ -1,77 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "Copy Handler.h" -#include "StringHelpers.h" -#include "stdio.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#ifdef _MFC_VER -void ExpandFormatString(CString* pstrFmt, DWORD dwError) -{ - // replace strings %errnum & %errdesc to something else - TCHAR xx[_MAX_PATH]; - pstrFmt->Replace(_T("%errnum"), _itot(dwError, xx, 10)); - - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, 0, xx, _MAX_PATH, NULL); - - while (xx[_tcslen(xx)-1] == _T('\n') || xx[_tcslen(xx)-1] == _T('\r')) - xx[_tcslen(xx)-1] = _T('\0'); - - pstrFmt->Replace(_T("%errdesc"), xx); -} -#endif - -LPTSTR GetSizeString(double dData, LPTSTR pszBuffer) -{ - if (dData < 0.0) - dData=0.0; - - if (dData < 1200.0) - _stprintf(pszBuffer, _T("%.2f %s"), dData, GetResManager()->LoadString(IDS_BYTE_STRING)); - else if (dData < 1228800.0) - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1024.0, GetResManager()->LoadString(IDS_KBYTE_STRING)); - else if (dData < 1258291200.0) - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1048576.0, GetResManager()->LoadString(IDS_MBYTE_STRING)); - else - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1073741824.0, GetResManager()->LoadString(IDS_GBYTE_STRING)); - - return pszBuffer; -} - -LPTSTR GetSizeString(__int64 llData, LPTSTR pszBuffer, bool bStrict) -{ - if (llData < 0) - llData=0; - - if (llData >= 1258291200 && (!bStrict || (llData % 1073741824) == 0)) - _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1073741824.0), GetResManager()->LoadString(IDS_GBYTE_STRING)); - else if (llData >= 1228800 && (!bStrict || (llData % 1048576) == 0)) - _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1048576.0), GetResManager()->LoadString(IDS_MBYTE_STRING)); - else if (llData >= 1200 && (!bStrict || (llData % 1024) == 0)) - _stprintf(pszBuffer, _T("%.2f %s"), (double)(llData/1024.0), GetResManager()->LoadString(IDS_KBYTE_STRING)); - else - _stprintf(pszBuffer, _T("%I64u %s"), llData, GetResManager()->LoadString(IDS_BYTE_STRING)); - - return pszBuffer; -} Index: src/ch/StringHelpers.h =================================================================== diff -u -N --- src/ch/StringHelpers.h (revision 0) +++ src/ch/StringHelpers.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,31 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __STRINGHELPERS_H__ +#define __STRINGHELPERS_H__ + +// formatting routines +#ifdef _MFC_VER +void ExpandFormatString(CString* pstrFmt, DWORD dwError); +#endif + +LPTSTR GetSizeString(double dData, LPTSTR pszBuffer); +LPTSTR GetSizeString(__int64 llData, LPTSTR pszBuffer, bool bStrict=false); + +#endif Index: ch/StringHelpers.h =================================================================== diff -u -N --- ch/StringHelpers.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/StringHelpers.h (revision 0) @@ -1,31 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __STRINGHELPERS_H__ -#define __STRINGHELPERS_H__ - -// formatting routines -#ifdef _MFC_VER -void ExpandFormatString(CString* pstrFmt, DWORD dwError); -#endif - -LPTSTR GetSizeString(double dData, LPTSTR pszBuffer); -LPTSTR GetSizeString(__int64 llData, LPTSTR pszBuffer, bool bStrict=false); - -#endif Index: src/ch/Structs.cpp =================================================================== diff -u -N --- src/ch/Structs.cpp (revision 0) +++ src/ch/Structs.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1578 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "structs.h" +#include "resource.h" +#include "StringHelpers.h" +#include "..\common\FileSupport.h" +#include "Copy Handler.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +// global +int PriorityToIndex(int nPriority) +{ + switch(nPriority) + { + case THREAD_PRIORITY_TIME_CRITICAL: + return 0; + case THREAD_PRIORITY_HIGHEST: + return 1; + case THREAD_PRIORITY_ABOVE_NORMAL: + return 2; + case THREAD_PRIORITY_NORMAL: + return 3; + case THREAD_PRIORITY_BELOW_NORMAL: + return 4; + case THREAD_PRIORITY_LOWEST: + return 5; + case THREAD_PRIORITY_IDLE: + return 6; + default: + return 3; + } +} + +int IndexToPriority(int nIndex) +{ + switch(nIndex) + { + case 0: + return THREAD_PRIORITY_TIME_CRITICAL; + case 1: + return THREAD_PRIORITY_HIGHEST; + case 2: + return THREAD_PRIORITY_ABOVE_NORMAL; + case 3: + return THREAD_PRIORITY_NORMAL; + case 4: + return THREAD_PRIORITY_BELOW_NORMAL; + case 5: + return THREAD_PRIORITY_LOWEST; + case 6: + return THREAD_PRIORITY_IDLE; + default: + return THREAD_PRIORITY_NORMAL; + } +} + +int IndexToPriorityClass(int iIndex) +{ + switch(iIndex) + { + case 0: + return IDLE_PRIORITY_CLASS; + case 1: + return NORMAL_PRIORITY_CLASS; + case 2: + return HIGH_PRIORITY_CLASS; + case 3: + return REALTIME_PRIORITY_CLASS; + default: + return NORMAL_PRIORITY_CLASS; + } +} + +int PriorityClassToIndex(int iPriority) +{ + switch(iPriority) + { + case IDLE_PRIORITY_CLASS: + return 0; + case NORMAL_PRIORITY_CLASS: + return 1; + case HIGH_PRIORITY_CLASS: + return 2; + case REALTIME_PRIORITY_CLASS: + return 3; + default: + return 1; + } +} + +//////////////////////////////////////////////////////////////////////////// +// CTask members + +CTask::CTask(const TASK_CREATE_DATA *pCreateData) : + m_log(false) +{ + m_nCurrentIndex=0; + m_iLastProcessedIndex=-1; + m_nStatus=ST_NULL_STATUS; + m_bsSizes.m_uiDefaultSize=65536; + m_bsSizes.m_uiOneDiskSize=4194304; + m_bsSizes.m_uiTwoDisksSize=262144; + m_bsSizes.m_uiCDSize=262144; + m_bsSizes.m_uiLANSize=65536; + m_pThread=NULL; + m_nPriority=THREAD_PRIORITY_NORMAL; + m_nProcessed=0; + m_nAll=0; + m_pnTasksProcessed=pCreateData->pTasksProcessed; + m_pnTasksAll=pCreateData->pTasksAll; + m_bKill=false; + m_bKilled=true; + m_pcs=pCreateData->pcs; + m_pfnTaskProc=pCreateData->pfnTaskProc; + m_lTimeElapsed=0; + m_lLastTime=-1; + m_puiOperationsPending=pCreateData->puiOperationsPending; + m_bQueued=false; + m_ucCopies=1; + m_ucCurrentCopy=0; + m_files.Init(&m_clipboard); + m_uiResumeInterval=0; + m_plFinished=pCreateData->plFinished; + m_bForce=false; + m_bContinue=false; + m_bSaved=false; + + m_iIdentical=-1; + m_iDestinationLess=-1; + m_iDestinationGreater=-1; + m_iMissingInput=-1; + m_iOutputError=-1; + m_iMoveFile=-1; + + TCHAR xx[16]; + _itot(time(NULL), xx, 10); + m_strUniqueName=xx; +} + +CTask::~CTask() +{ + KillThread(); +} + +// m_clipboard +int CTask::AddClipboardData(CClipboardEntry* pEntry) +{ + m_cs.Lock(); + int retval=m_clipboard.Add(pEntry); + m_cs.Unlock(); + + return retval; +} + +CClipboardEntry* CTask::GetClipboardData(int nIndex) +{ + m_cs.Lock(); + CClipboardEntry* pEntry=m_clipboard.GetAt(nIndex); + m_cs.Unlock(); + + return pEntry; +} + +int CTask::GetClipboardDataSize() +{ + m_cs.Lock(); + int rv=m_clipboard.GetSize(); + m_cs.Unlock(); + + return rv; +} + +int CTask::ReplaceClipboardStrings(CString strOld, CString strNew) +{ + // small chars to make comparing case insensitive + strOld.MakeLower(); + + CString strText; + int iOffset; + int iCount=0; + m_cs.Lock(); + for (int i=0;iGetPath(); + strText.MakeLower(); + iOffset=strText.Find(strOld, 0); + if (iOffset != -1) + { + // found + strText=pEntry->GetPath(); + strText=strText.Left(iOffset)+strNew+strText.Mid(iOffset+strOld.GetLength()); + pEntry->SetPath(strText); + iCount++; + } + } + m_cs.Unlock(); + + return iCount; +} + +// m_files +int CTask::FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, + const bool bRecurse, const bool bIncludeDirs) +{ + // this uses much of memory, but resolves problem critical section hungs and m_bKill + CFileInfoArray fa; + fa.Init(&m_clipboard); + + fa.AddDir(strDirName, pFilters, iSrcIndex, bRecurse, bIncludeDirs, &m_bKill); + + m_cs.Lock(); + + m_files.Append(fa); + + m_cs.Unlock(); + + return 0; +} + +int CTask::FilesAdd(CFileInfo fi) +{ + int rv=-1; + m_cs.Lock(); + if (fi.IsDirectory() || m_afFilters.Match(fi)) + rv=m_files.Add(fi); + m_cs.Unlock(); + + return rv; +} + +CFileInfo CTask::FilesGetAt(int nIndex) +{ + m_cs.Lock(); + CFileInfo info=m_files.GetAt(nIndex); + m_cs.Unlock(); + + return info; +} + +CFileInfo CTask::FilesGetAtCurrentIndex() +{ + m_cs.Lock(); + CFileInfo info=m_files.GetAt(m_nCurrentIndex); + m_cs.Unlock(); + return info; +} + +void CTask::FilesRemoveAll() +{ + m_cs.Lock(); + m_files.RemoveAll(); + m_cs.Unlock(); +} + +int CTask::FilesGetSize() +{ + m_cs.Lock(); + int nSize=m_files.GetSize(); + m_cs.Unlock(); + + return nSize; +} + +// m_nCurrentIndex +void CTask::IncreaseCurrentIndex() +{ + m_cs.Lock(); + ++m_nCurrentIndex; + m_cs.Unlock(); +} + +int CTask::GetCurrentIndex() +{ + m_cs.Lock(); + int nIndex=m_nCurrentIndex; + m_cs.Unlock(); + + return nIndex; +} + +void CTask::SetCurrentIndex(int nIndex) +{ + m_cs.Lock(); + m_nCurrentIndex=nIndex; + m_cs.Unlock(); +} + +// m_strDestPath - adds '\\' +void CTask::SetDestPath(LPCTSTR lpszPath) +{ + m_dpDestPath.SetPath(lpszPath); +} + +// guaranteed '\\' +const CDestPath& CTask::GetDestPath() +{ + return m_dpDestPath; +} + +int CTask::GetDestDriveNumber() +{ + return m_dpDestPath.GetDriveNumber(); +} + +// m_nStatus +void CTask::SetStatus(UINT nStatus, UINT nMask) +{ + m_cs.Lock(); + m_nStatus &= ~nMask; + m_nStatus |= nStatus; + m_cs.Unlock(); +} + +UINT CTask::GetStatus(UINT nMask) +{ + m_cs.Lock(); + UINT nStatus=m_nStatus; + m_cs.Unlock(); + + return (nStatus & nMask); +} + +// m_nBufferSize +void CTask::SetBufferSizes(const BUFFERSIZES* bsSizes) +{ + m_cs.Lock(); + m_bsSizes=*bsSizes; + m_bSaved=false; + m_cs.Unlock(); +} + +const BUFFERSIZES* CTask::GetBufferSizes() +{ + m_cs.Lock(); + const BUFFERSIZES* pbsSizes=&m_bsSizes; + m_cs.Unlock(); + + return pbsSizes; +} + +int CTask::GetCurrentBufferIndex() +{ + int rv=0; + m_cs.Lock(); + int iSize=m_files.GetSize(); + if (iSize > 0 && m_nCurrentIndex != -1) + rv=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < iSize) ? m_nCurrentIndex : 0).GetBufferIndex(); + m_cs.Unlock(); + + return rv; +} + +// m_pThread +// m_nPriority +int CTask::GetPriority() +{ + m_cs.Lock(); + int nPriority=m_nPriority; + m_cs.Unlock(); + return nPriority; +} + +void CTask::SetPriority(int nPriority) +{ + m_cs.Lock(); + m_nPriority=nPriority; + m_bSaved=false; + if (m_pThread != NULL) + { + TRACE("Changing thread priority"); + m_pThread->SuspendThread(); + m_pThread->SetThreadPriority(nPriority); + m_pThread->ResumeThread(); + } + m_cs.Unlock(); +} + +// m_nProcessed +void CTask::IncreaseProcessedSize(__int64 nSize) +{ + m_cs.Lock(); + m_nProcessed+=nSize; + m_cs.Unlock(); +} + +void CTask::SetProcessedSize(__int64 nSize) +{ + m_cs.Lock(); + m_nProcessed=nSize; + m_cs.Unlock(); +} + +__int64 CTask::GetProcessedSize() +{ + m_cs.Lock(); + __int64 nSize=m_nProcessed; + m_cs.Unlock(); + + return nSize; +} + +// m_nAll +void CTask::SetAllSize(__int64 nSize) +{ + m_cs.Lock(); + m_nAll=nSize; + m_cs.Unlock(); +} + +__int64 CTask::GetAllSize() +{ + m_cs.Lock(); + __int64 nAll=m_nAll; + m_cs.Unlock(); + + return nAll; +} + +void CTask::CalcAllSize() +{ + m_cs.Lock(); + m_nAll=0; + + int nSize=m_files.GetSize(); + CFileInfo* pFiles=m_files.GetData(); + + for (int i=0;iLock(); + (*m_pnTasksProcessed)+=nSize; + m_pcs->Unlock(); +// m_cs.Unlock(); +} + +void CTask::DecreaseProcessedTasksSize(__int64 nSize) +{ +// m_cs.Lock(); + m_pcs->Lock(); + (*m_pnTasksProcessed)-=nSize; + m_pcs->Unlock(); +// m_cs.Unlock(); +} + +// m_pnTasksAll +void CTask::IncreaseAllTasksSize(__int64 nSize) +{ +// m_cs.Lock(); + m_pcs->Lock(); + (*m_pnTasksAll)+=nSize; + m_pcs->Unlock(); +// m_cs.Unlock(); +} + +void CTask::DecreaseAllTasksSize(__int64 nSize) +{ +// m_cs.Lock(); + m_pcs->Lock(); + (*m_pnTasksAll)-=nSize; + m_pcs->Unlock(); +// m_cs.Unlock(); +} + +// m_bKill +/*inline*/ void CTask::SetKillFlag(bool bKill) +{ + m_cs.Lock(); + m_bKill=bKill; + m_cs.Unlock(); +} + +bool CTask::GetKillFlag() +{ + m_cs.Lock(); + bool bKill=m_bKill; + m_cs.Unlock(); + + return bKill; +} + +// m_bKilled +/*inline*/ void CTask::SetKilledFlag(bool bKilled) +{ + m_cs.Lock(); + m_bKilled=bKilled; + m_cs.Unlock(); +} + +/*inline*/ bool CTask::GetKilledFlag() +{ + m_cs.Lock(); + bool bKilled=m_bKilled; + m_cs.Unlock(); + + return bKilled; +} + +// m_strUniqueName + +CString CTask::GetUniqueName() +{ + m_cs.Lock(); + CString name=m_strUniqueName; + m_cs.Unlock(); + + return name; +} + +void CTask::Load(CArchive& ar, bool bData) +{ + m_cs.Lock(); + try + { + if (bData) + { + m_clipboard.Serialize(ar, bData); + + m_files.Load(ar); + m_dpDestPath.Serialize(ar); + ar>>m_strUniqueName; + m_afFilters.Serialize(ar); + ar>>m_ucCopies; + } + else + { + int data; + unsigned long part; + + ar>>data; + m_nCurrentIndex=data; + ar>>data; + m_nStatus=data; + ar>>m_lOsError; + ar>>m_strErrorDesc; + m_bsSizes.Serialize(ar); + ar>>m_nPriority; + + ar>>part; + m_nAll=(static_cast(part) << 32); + ar>>part; + m_nAll|=part; + // czas + ar>>m_lTimeElapsed; + + ar>>part; + m_nProcessed=(static_cast(part) << 32); + ar>>part; + m_nProcessed|=part; + + ar>>m_ucCurrentCopy; + + m_clipboard.Serialize(ar, bData); + + unsigned char ucTmp; + ar>>ucTmp; + m_bSaved=ucTmp != 0; + } + } + catch(CException*) + { + m_cs.Unlock(); + throw; + } + m_cs.Unlock(); +} + +void CTask::Store(LPCTSTR lpszDirectory, bool bData) +{ + m_cs.Lock(); + if (!bData && m_bSaved) + { + m_cs.Unlock(); + TRACE("Saving locked - file not saved\n"); + return; + } + + if (!bData && !m_bSaved && ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED || (m_nStatus & ST_STEP_MASK) == ST_CANCELLED + || (m_nStatus & ST_WORKING_MASK) == ST_PAUSED )) + { + TRACE("Last save - saving blocked\n"); + m_bSaved=true; + } + + try + { + CFile file(lpszDirectory+GetUniqueName()+( (bData) ? _T(".atd") : _T(".atp") ), CFile::modeWrite | CFile::modeCreate); + CArchive ar(&file, CArchive::store); + + if (bData) + { + m_clipboard.Serialize(ar, bData); + + if (GetStatus(ST_STEP_MASK) > ST_SEARCHING) + m_files.Store(ar); + else + ar<(0); + + m_dpDestPath.Serialize(ar); + ar<((m_nAll & 0xffffffff00000000) >> 32); + ar<(m_nAll & 0x00000000ffffffff); + ar<((m_nProcessed & 0xffffffff00000000) >> 32); + ar<(m_nProcessed & 0x00000000ffffffff); + ar<Delete(); + m_cs.Unlock(); + return; + } + m_cs.Unlock(); +} + +/*inline*/ void CTask::KillThread() +{ + if (!GetKilledFlag()) // protection from recalling Cleanup + { + SetKillFlag(); + while (!GetKilledFlag()) + Sleep(10); + + // cleanup + CleanupAfterKill(); + } +} + +void CTask::BeginProcessing() +{ + m_cs.Lock(); + if (m_pThread != NULL) + { + m_cs.Unlock(); + return; + } + m_cs.Unlock(); + + // create new thread + m_uiResumeInterval=0; // just in case + m_bSaved=false; // save + SetKillFlag(false); + SetKilledFlag(false); + CWinThread* pThread=AfxBeginThread(m_pfnTaskProc, this, GetPriority()); + + m_cs.Lock(); + m_pThread=pThread; + m_cs.Unlock(); +} + +void CTask::ResumeProcessing() +{ + // the same as retry but less demanding + if ( (GetStatus(ST_WORKING_MASK) & ST_PAUSED) && GetStatus(ST_STEP_MASK) != ST_FINISHED + && GetStatus(ST_STEP_MASK) != ST_CANCELLED) + { + SetStatus(0, ST_ERROR); + BeginProcessing(); + } +} + +bool CTask::RetryProcessing(bool bOnlyErrors/*=false*/, UINT uiInterval) +{ + // retry used to auto-resume, after loading + if ( (GetStatus(ST_WORKING_MASK) == ST_ERROR || (!bOnlyErrors && GetStatus(ST_WORKING_MASK) != ST_PAUSED)) + && GetStatus(ST_STEP_MASK) != ST_FINISHED && GetStatus(ST_STEP_MASK) != ST_CANCELLED) + { + if (uiInterval != 0) + { + m_uiResumeInterval+=uiInterval; + if (m_uiResumeInterval < (UINT)GetConfig()->GetIntValue(PP_CMAUTORETRYINTERVAL)) + return false; + else + m_uiResumeInterval=0; + } + + SetStatus(0, ST_ERROR); + BeginProcessing(); + return true; + } + return false; +} + +void CTask::RestartProcessing() +{ + KillThread(); + SetStatus(0, ST_ERROR); + SetStatus(ST_NULL_STATUS, ST_STEP_MASK); + m_lTimeElapsed=0; + SetCurrentIndex(0); + SetCurrentCopy(0); + BeginProcessing(); +} + +void CTask::PauseProcessing() +{ + if (GetStatus(ST_STEP_MASK) != ST_FINISHED && GetStatus(ST_STEP_MASK) != ST_CANCELLED) + { + KillThread(); + SetStatus(ST_PAUSED, ST_WORKING_MASK); + SetLastProcessedIndex(GetCurrentIndex()); + m_bSaved=false; + } +} + +void CTask::CancelProcessing() +{ + // change to ST_CANCELLED + if (GetStatus(ST_STEP_MASK) != ST_FINISHED) + { + KillThread(); + SetStatus(ST_CANCELLED, ST_STEP_MASK); + SetStatus(0, ST_ERROR); + m_bSaved=false; + } +} + +void CTask::GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData) +{ + m_cs.Lock(); + if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) + pData->m_fi=m_files.GetAt(m_nCurrentIndex); + else + { + if (m_files.GetSize() > 0) + { + pData->m_fi=m_files.GetAt(0); + pData->m_fi.SetFilePath(pData->m_fi.GetFullFilePath()); + pData->m_fi.SetSrcIndex(-1); + } + else + { + if (m_clipboard.GetSize() > 0) + { + pData->m_fi.SetFilePath(m_clipboard.GetAt(0)->GetPath()); + pData->m_fi.SetSrcIndex(-1); + } + else + { + pData->m_fi.SetFilePath(GetResManager()->LoadString(IDS_NONEINPUTFILE_STRING)); + pData->m_fi.SetSrcIndex(-1); + } + } + } + + pData->m_uiStatus=m_nStatus; + + // percents + int iSize=m_files.GetSize()*m_ucCopies; + int iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); + if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) + pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); + else + if (iSize != 0) + pData->m_nPercent=static_cast( static_cast(iIndex)*100.0/static_cast(iSize) ); + else + pData->m_nPercent=0; + + m_cs.Unlock(); +} + +void CTask::GetSnapshot(TASK_DISPLAY_DATA *pData) +{ + m_cs.Lock(); + if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) + pData->m_fi=m_files.GetAt(m_nCurrentIndex); + else + { + if (m_files.GetSize() > 0) + { + pData->m_fi=m_files.GetAt(0); + pData->m_fi.SetFilePath(pData->m_fi.GetFullFilePath()); + pData->m_fi.SetSrcIndex(-1); + } + else + { + if (m_clipboard.GetSize() > 0) + { + pData->m_fi.SetFilePath(m_clipboard.GetAt(0)->GetPath()); + pData->m_fi.SetSrcIndex(-1); + } + else + { + pData->m_fi.SetFilePath(GetResManager()->LoadString(IDS_NONEINPUTFILE_STRING)); + pData->m_fi.SetSrcIndex(-1); + } + } + } + + pData->m_pbsSizes=&m_bsSizes; + pData->m_nPriority=m_nPriority; + pData->m_pdpDestPath=&m_dpDestPath; + pData->m_pafFilters=&m_afFilters; + pData->m_dwOsErrorCode=m_lOsError; + pData->m_strErrorDesc=m_strErrorDesc; + pData->m_uiStatus=m_nStatus; + pData->m_iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); + pData->m_iProcessedSize=m_nProcessed; + pData->m_iSize=m_files.GetSize()*m_ucCopies; + pData->m_iSizeAll=m_nAll; + pData->m_ucCurrentCopy=static_cast(m_ucCurrentCopy+1); // visual aspect + pData->m_ucCopies=m_ucCopies; + pData->m_pstrUniqueName=&m_strUniqueName; + + if (m_files.GetSize() > 0 && m_nCurrentIndex != -1) + pData->m_iCurrentBufferIndex=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < m_files.GetSize()) ? m_nCurrentIndex : 0).GetBufferIndex(); + else + pData->m_iCurrentBufferIndex=0; + + // percents + if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) + pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); + else + if (pData->m_iSize != 0) + pData->m_nPercent=static_cast( static_cast(pData->m_iIndex)*100.0/static_cast(pData->m_iSize) ); + else + pData->m_nPercent=0; + + // status string + // first + if ( (m_nStatus & ST_WORKING_MASK) == ST_ERROR ) + { + GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+4, pData->m_szStatusText, _MAX_PATH); + _tcscat(pData->m_szStatusText, _T("/")); + } + else if ( (m_nStatus & ST_WORKING_MASK) == ST_PAUSED ) + { + GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+5, pData->m_szStatusText, _MAX_PATH); + _tcscat(pData->m_szStatusText, _T("/")); + } + else if ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED ) + { + GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+3, pData->m_szStatusText, _MAX_PATH); + _tcscat(pData->m_szStatusText, _T("/")); + } + else if ( (m_nStatus & ST_WAITING_MASK) == ST_WAITING ) + { + GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+9, pData->m_szStatusText, _MAX_PATH); + _tcscat(pData->m_szStatusText, _T("/")); + } + else if ( (m_nStatus & ST_STEP_MASK) == ST_CANCELLED ) + { + GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+8, pData->m_szStatusText, _MAX_PATH); + _tcscat(pData->m_szStatusText, _T("/")); + } + else + _tcscpy(pData->m_szStatusText, _T("")); + + // second part + if ( (m_nStatus & ST_STEP_MASK) == ST_DELETING ) + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+6)); + else if ( (m_nStatus & ST_STEP_MASK) == ST_SEARCHING ) + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+0)); + else if ((m_nStatus & ST_OPERATION_MASK) == ST_COPY ) + { + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+1)); + if (m_afFilters.GetSize()) + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); + } + else if ( (m_nStatus & ST_OPERATION_MASK) == ST_MOVE ) + { + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+2)); + if (m_afFilters.GetSize()) + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); + } + else + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+7)); + + // third part + if ( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_DIRS ) + { + _tcscat(pData->m_szStatusText, _T("/")); + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+10)); + } + if ( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT ) + { + _tcscat(pData->m_szStatusText, _T("/")); + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+11)); + } + + // count of copies + if (m_ucCopies > 1) + { + _tcscat(pData->m_szStatusText, _T("/")); + TCHAR xx[4]; + _tcscat(pData->m_szStatusText, _itot(m_ucCopies, xx, 10)); + if (m_ucCopies < 5) + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_COPYWORDLESSFIVE_STRING)); + else + _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_COPYWORDMOREFOUR_STRING)); + } + + // time + UpdateTime(); + pData->m_lTimeElapsed=m_lTimeElapsed; + + m_cs.Unlock(); +} + +/*inline*/ void CTask::CleanupAfterKill() +{ + m_cs.Lock(); + m_pThread=NULL; + UpdateTime(); + m_lLastTime=-1; + m_cs.Unlock(); +} + +void CTask::DeleteProgress(LPCTSTR lpszDirectory) +{ + m_cs.Lock(); + DeleteFile(lpszDirectory+m_strUniqueName+_T(".atd")); + DeleteFile(lpszDirectory+m_strUniqueName+_T(".atp")); + DeleteFile(lpszDirectory+m_strUniqueName+_T(".log")); + m_cs.Unlock(); +} + +void CTask::SetOsErrorCode(DWORD dwError, LPCTSTR lpszErrDesc) +{ + m_cs.Lock(); + m_lOsError=dwError; + m_strErrorDesc=lpszErrDesc; + m_cs.Unlock(); +} + +void CTask::UpdateTime() +{ + m_cs.Lock(); + if (m_lLastTime != -1) + { + long lVal=time(NULL); + m_lTimeElapsed+=lVal-m_lLastTime; + m_lLastTime=lVal; + } + m_cs.Unlock(); +} + +void CTask::DecreaseOperationsPending(UINT uiBy) +{ + m_pcs->Lock(); + if (m_bQueued) + { + TRACE("Decreasing operations pending by %lu\n", uiBy); + (*m_puiOperationsPending)-=uiBy; + m_bQueued=false; + } + m_pcs->Unlock(); +} + +void CTask::IncreaseOperationsPending(UINT uiBy) +{ + TRACE("Trying to increase operations pending...\n"); + if (!m_bQueued) + { + TRACE("Increasing operations pending by %lu\n", uiBy); + m_pcs->Lock(); + (*m_puiOperationsPending)+=uiBy; + m_pcs->Unlock(); + m_bQueued=true; + } +} + +const CFiltersArray* CTask::GetFilters() +{ + return &m_afFilters; +} + +void CTask::SetFilters(const CFiltersArray* pFilters) +{ + m_cs.Lock(); + m_afFilters.Copy(*pFilters); + m_cs.Unlock(); +} + +bool CTask::CanBegin() +{ + bool bRet=true; + m_cs.Lock(); + if (GetContinueFlag() || GetForceFlag()) + { + TRACE("New operation Begins... continue: %d, force: %d\n", GetContinueFlag(), GetForceFlag()); + IncreaseOperationsPending(); + SetForceFlag(false); + SetContinueFlag(false); + } + else + bRet=false; + m_cs.Unlock(); + + return bRet; +} + +void CTask::SetCopies(unsigned char ucCopies) +{ + m_cs.Lock(); + m_ucCopies=ucCopies; + m_cs.Unlock(); +} + +unsigned char CTask::GetCopies() +{ + unsigned char ucCopies; + m_cs.Lock(); + ucCopies=m_ucCopies; + m_cs.Unlock(); + + return ucCopies; +} + +void CTask::SetCurrentCopy(unsigned char ucCopy) +{ + m_cs.Lock(); + m_ucCurrentCopy=ucCopy; + m_cs.Unlock(); +} + +unsigned char CTask::GetCurrentCopy() +{ + m_cs.Lock(); + unsigned char ucCopy=m_ucCurrentCopy; + m_cs.Unlock(); + + return ucCopy; +} + +void CTask::SetLastProcessedIndex(int iIndex) +{ + m_cs.Lock(); + m_iLastProcessedIndex=iIndex; + m_cs.Unlock(); +} + +int CTask::GetLastProcessedIndex() +{ + int iIndex; + m_cs.Lock(); + iIndex=m_iLastProcessedIndex; + m_cs.Unlock(); + + return iIndex; +} + +bool CTask::GetRequiredFreeSpace(__int64 *pi64Needed, __int64 *pi64Available) +{ + *pi64Needed=GetAllSize()-GetProcessedSize(); // it'd be nice to round up to take cluster size into consideration, + // but GetDiskFreeSpace returns flase values + + // get free space + if (!GetDynamicFreeSpace(GetDestPath().GetPath(), pi64Available, NULL)) + return true; + + return (*pi64Needed <= *pi64Available); +} + +void CTask::SetForceFlag(bool bFlag) +{ + m_cs.Lock(); + m_bForce=bFlag; + m_cs.Unlock(); +} + +bool CTask::GetForceFlag() +{ + return m_bForce; +} + +void CTask::SetContinueFlag(bool bFlag) +{ + m_cs.Lock(); + m_bContinue=bFlag; + m_cs.Unlock(); +} + +bool CTask::GetContinueFlag() +{ + return m_bContinue; +} + +CString CTask::GetLogName() +{ + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + return GetApp()->ExpandPath(szPath)+GetUniqueName()+_T(".log"); +} + +//////////////////////////////////////////////////////////////////////////////// +// CTaskArray members +void CTaskArray::Create(UINT (*pfnTaskProc)(LPVOID pParam)) +{ + m_tcd.pcs=&m_cs; + m_tcd.pfnTaskProc=pfnTaskProc; + m_tcd.pTasksAll=&m_uhRange; + m_tcd.pTasksProcessed=&m_uhPosition; + m_tcd.puiOperationsPending=&m_uiOperationsPending; + m_tcd.plFinished=&m_lFinished; +} + +CTaskArray::~CTaskArray() +{ +} + +int CTaskArray::GetSize( ) +{ + m_cs.Lock(); + int nSize=m_nSize; + m_cs.Unlock(); + + return nSize; +} + +int CTaskArray::GetUpperBound( ) +{ + m_cs.Lock(); + int upper=m_nSize; + m_cs.Unlock(); + + return upper-1; +} + +void CTaskArray::SetSize( int nNewSize, int nGrowBy ) +{ + m_cs.Lock(); + (static_cast*>(this))->SetSize(nNewSize, nGrowBy); + m_cs.Unlock(); +} + +CTask* CTaskArray::GetAt( int nIndex ) +{ + ASSERT(nIndex >= 0 && nIndex < m_nSize); + m_cs.Lock(); + CTask* pTask=m_pData[nIndex]; + m_cs.Unlock(); + + return pTask; +} + +void CTaskArray::SetAt( int nIndex, CTask* newElement ) +{ + m_cs.Lock(); + ASSERT(nIndex >= 0 && nIndex < m_nSize); + m_uhRange-=m_pData[nIndex]->GetAllSize(); // subtract old element + m_pData[nIndex]=newElement; + m_uhRange+=m_pData[nIndex]->GetAllSize(); // add new + m_cs.Unlock(); +} + +int CTaskArray::Add( CTask* newElement ) +{ + m_cs.Lock(); + m_uhRange+=newElement->GetAllSize(); + m_uhPosition+=newElement->GetProcessedSize(); + int pos=(static_cast*>(this))->Add(newElement); + m_cs.Unlock(); + + return pos; +} + +void CTaskArray::RemoveAt(int nIndex, int nCount) +{ + m_cs.Lock(); + for (int i=nIndex;iKillThread(); + + m_uhRange-=pTask->GetAllSize(); + m_uhPosition-=pTask->GetProcessedSize(); + + delete pTask; + } + + // remove elements from array + (static_cast*>(this))->RemoveAt(nIndex, nCount); + m_cs.Unlock(); +} + +void CTaskArray::RemoveAll() +{ + m_cs.Lock(); + CTask* pTask; + + for (int i=0;iSetKillFlag(); // send an info about finishing + + // wait for finishing and get rid of it + for (i=0;iGetKilledFlag()) + Sleep(10); + + pTask->CleanupAfterKill(); + + m_uhRange-=pTask->GetAllSize(); + m_uhPosition-=pTask->GetProcessedSize(); + + // delete data + delete pTask; + } + + (static_cast*>(this))->RemoveAll(); + m_cs.Unlock(); +} + +void CTaskArray::RemoveAllFinished() +{ + m_cs.Lock(); + int i=GetSize(); + + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + while (i) + { + CTask* pTask=GetAt(i-1); + + // delete only when the thread is finished + if ( (pTask->GetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED) + && pTask->GetKilledFlag()) + { + m_uhRange-=pTask->GetAllSize(); + m_uhPosition-=pTask->GetProcessedSize(); + + // delete associated files + pTask->DeleteProgress(szPath); + + delete pTask; + + static_cast*>(this)->RemoveAt(i-1); + } + + --i; + } + + m_cs.Unlock(); +} + +void CTaskArray::RemoveFinished(CTask** pSelTask) +{ + m_cs.Lock(); + TCHAR szPath[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + for (int i=0;iGetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED)) + { + // kill task if needed + pTask->KillThread(); + + m_uhRange-=pTask->GetAllSize(); + m_uhPosition-=pTask->GetProcessedSize(); + + // delete associated files + pTask->DeleteProgress(szPath); + + // delete data + delete pTask; + + static_cast*>(this)->RemoveAt(i); + + m_cs.Unlock(); + return; + } + } + m_cs.Unlock(); +} + +void CTaskArray::SaveData(LPCTSTR lpszDirectory) +{ + m_cs.Lock(); + for (int i=0;iStore(lpszDirectory, true); + m_cs.Unlock(); +} + +void CTaskArray::SaveProgress(LPCTSTR lpszDirectory) +{ + m_cs.Lock(); + for (int i=0;iStore(lpszDirectory, false); + m_cs.Unlock(); +} + +void CTaskArray::LoadDataProgress(LPCTSTR lpszDirectory) +{ + m_cs.Lock(); + CFileFind finder; + CTask* pTask; + + BOOL bWorking=finder.FindFile(CString(lpszDirectory)+_T("*.atd")); + while ( bWorking ) + { + bWorking=finder.FindNextFile(); + + // load data + pTask=new CTask(&m_tcd); + + try + { + CString strPath=finder.GetFilePath(); + + // load data file + CFile file(strPath, CFile::modeRead); + CArchive ar(&file, CArchive::load); + + pTask->Load(ar, true); + + ar.Close(); + file.Close(); + + // load progress file + strPath=strPath.Left(strPath.GetLength()-4); + strPath+=_T(".atp"); + CFile file2(strPath, CFile::modeRead); + CArchive ar2(&file2, CArchive::load); + + pTask->Load(ar2, false); + + ar2.Close(); + file2.Close(); + + // add read task to array + Add(pTask); + } + catch(CException* e) + { + e->Delete(); + delete pTask; + } + } + finder.Close(); + + m_cs.Unlock(); +} + +void CTaskArray::TasksBeginProcessing() +{ + for (int i=0;iBeginProcessing(); +} + +void CTaskArray::TasksPauseProcessing() +{ + for (int i=0;iPauseProcessing(); +} + +void CTaskArray::TasksResumeProcessing() +{ + for (int i=0;iResumeProcessing(); +} + +void CTaskArray::TasksRestartProcessing() +{ + for (int i=0;iRestartProcessing(); +} + +bool CTaskArray::TasksRetryProcessing(bool bOnlyErrors/*=false*/, UINT uiInterval) +{ + bool bChanged=false; + for (int i=0;iRetryProcessing(bOnlyErrors, uiInterval)) + bChanged=true; + } + + return bChanged; +} + +void CTaskArray::TasksCancelProcessing() +{ + for (int i=0;iCancelProcessing(); +} + +__int64 CTaskArray::GetPosition() +{ + m_cs.Lock(); + __int64 rv=m_uhPosition; + m_cs.Unlock(); + + return rv; +} + +__int64 CTaskArray::GetRange() +{ + m_cs.Lock(); + __int64 rv=m_uhRange; + m_cs.Unlock(); + + return rv; +} + +int CTaskArray::GetPercent() +{ + int pos; + m_cs.Lock(); + if (m_uhRange != 0) + pos=static_cast((static_cast(m_uhPosition)*100.0)/static_cast(m_uhRange)); + else + if (GetSize() != 0) // if anything is in an array, but size of it is 0 + pos=100; + else + pos=0; + m_cs.Unlock(); + + return pos; +} + +UINT CTaskArray::GetOperationsPending() +{ + m_cs.Lock(); + UINT uiOP=m_uiOperationsPending; + m_cs.Unlock(); + return uiOP; +} + +bool CTaskArray::IsFinished() +{ + bool bFlag=true; + UINT uiStatus; + + m_cs.Lock(); + if (m_uiOperationsPending != 0) + bFlag=false; + else + { + for (int i=0;iGetStatus(); + bFlag=((uiStatus & ST_STEP_MASK) == ST_FINISHED || (uiStatus & ST_STEP_MASK) == ST_CANCELLED + || (uiStatus & ST_WORKING_MASK) == ST_PAUSED + || ((uiStatus & ST_WORKING_MASK) == ST_ERROR && !GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR))); + } + } + + m_cs.Unlock(); + return bFlag; +} + +/////////////////////////////////////////////////////////////////////// +// CProcessingException + +CProcessingException::CProcessingException(int iType, CTask* pTask, UINT uiFmtID, DWORD dwError, ...) +{ + // std values + m_iType=iType; + m_pTask=pTask; + m_dwError=dwError; + + // format some text + CString strFormat=GetResManager()->LoadString(uiFmtID); + ExpandFormatString(&strFormat, dwError); + + // get param list + va_list marker; + va_start(marker, dwError); + m_strErrorDesc.FormatV(strFormat, marker); + va_end(marker); +} + +void CProcessingException::Cleanup() +{ + TCHAR szPath[_MAX_PATH]; + switch (m_pTask->GetStatus(ST_STEP_MASK)) + { + case ST_NULL_STATUS: + case ST_SEARCHING: + // get rif of m_files contents + m_pTask->FilesRemoveAll(); + + // save state of a task + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + m_pTask->Store(szPath, true); + m_pTask->Store(szPath, false); + + m_pTask->SetKilledFlag(); + m_pTask->CleanupAfterKill(); + + break; + case ST_COPYING: + case ST_DELETING: + switch (m_iType) + { + case E_ERROR: + m_pTask->SetStatus(ST_ERROR, ST_WORKING_MASK); + m_pTask->SetOsErrorCode(m_dwError, this->m_strErrorDesc); + break; + case E_CANCEL: + m_pTask->SetStatus(ST_CANCELLED, ST_STEP_MASK); + break; + } + + GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); + GetApp()->ExpandPath(szPath); + m_pTask->Store(szPath, false); + + m_pTask->SetKilledFlag(); + m_pTask->CleanupAfterKill(); + + break; + } +} Index: ch/Structs.cpp =================================================================== diff -u -N --- ch/Structs.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Structs.cpp (revision 0) @@ -1,1578 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "structs.h" -#include "resource.h" -#include "StringHelpers.h" -#include "..\common\FileSupport.h" -#include "Copy Handler.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -// global -int PriorityToIndex(int nPriority) -{ - switch(nPriority) - { - case THREAD_PRIORITY_TIME_CRITICAL: - return 0; - case THREAD_PRIORITY_HIGHEST: - return 1; - case THREAD_PRIORITY_ABOVE_NORMAL: - return 2; - case THREAD_PRIORITY_NORMAL: - return 3; - case THREAD_PRIORITY_BELOW_NORMAL: - return 4; - case THREAD_PRIORITY_LOWEST: - return 5; - case THREAD_PRIORITY_IDLE: - return 6; - default: - return 3; - } -} - -int IndexToPriority(int nIndex) -{ - switch(nIndex) - { - case 0: - return THREAD_PRIORITY_TIME_CRITICAL; - case 1: - return THREAD_PRIORITY_HIGHEST; - case 2: - return THREAD_PRIORITY_ABOVE_NORMAL; - case 3: - return THREAD_PRIORITY_NORMAL; - case 4: - return THREAD_PRIORITY_BELOW_NORMAL; - case 5: - return THREAD_PRIORITY_LOWEST; - case 6: - return THREAD_PRIORITY_IDLE; - default: - return THREAD_PRIORITY_NORMAL; - } -} - -int IndexToPriorityClass(int iIndex) -{ - switch(iIndex) - { - case 0: - return IDLE_PRIORITY_CLASS; - case 1: - return NORMAL_PRIORITY_CLASS; - case 2: - return HIGH_PRIORITY_CLASS; - case 3: - return REALTIME_PRIORITY_CLASS; - default: - return NORMAL_PRIORITY_CLASS; - } -} - -int PriorityClassToIndex(int iPriority) -{ - switch(iPriority) - { - case IDLE_PRIORITY_CLASS: - return 0; - case NORMAL_PRIORITY_CLASS: - return 1; - case HIGH_PRIORITY_CLASS: - return 2; - case REALTIME_PRIORITY_CLASS: - return 3; - default: - return 1; - } -} - -//////////////////////////////////////////////////////////////////////////// -// CTask members - -CTask::CTask(const TASK_CREATE_DATA *pCreateData) : - m_log(false) -{ - m_nCurrentIndex=0; - m_iLastProcessedIndex=-1; - m_nStatus=ST_NULL_STATUS; - m_bsSizes.m_uiDefaultSize=65536; - m_bsSizes.m_uiOneDiskSize=4194304; - m_bsSizes.m_uiTwoDisksSize=262144; - m_bsSizes.m_uiCDSize=262144; - m_bsSizes.m_uiLANSize=65536; - m_pThread=NULL; - m_nPriority=THREAD_PRIORITY_NORMAL; - m_nProcessed=0; - m_nAll=0; - m_pnTasksProcessed=pCreateData->pTasksProcessed; - m_pnTasksAll=pCreateData->pTasksAll; - m_bKill=false; - m_bKilled=true; - m_pcs=pCreateData->pcs; - m_pfnTaskProc=pCreateData->pfnTaskProc; - m_lTimeElapsed=0; - m_lLastTime=-1; - m_puiOperationsPending=pCreateData->puiOperationsPending; - m_bQueued=false; - m_ucCopies=1; - m_ucCurrentCopy=0; - m_files.Init(&m_clipboard); - m_uiResumeInterval=0; - m_plFinished=pCreateData->plFinished; - m_bForce=false; - m_bContinue=false; - m_bSaved=false; - - m_iIdentical=-1; - m_iDestinationLess=-1; - m_iDestinationGreater=-1; - m_iMissingInput=-1; - m_iOutputError=-1; - m_iMoveFile=-1; - - TCHAR xx[16]; - _itot(time(NULL), xx, 10); - m_strUniqueName=xx; -} - -CTask::~CTask() -{ - KillThread(); -} - -// m_clipboard -int CTask::AddClipboardData(CClipboardEntry* pEntry) -{ - m_cs.Lock(); - int retval=m_clipboard.Add(pEntry); - m_cs.Unlock(); - - return retval; -} - -CClipboardEntry* CTask::GetClipboardData(int nIndex) -{ - m_cs.Lock(); - CClipboardEntry* pEntry=m_clipboard.GetAt(nIndex); - m_cs.Unlock(); - - return pEntry; -} - -int CTask::GetClipboardDataSize() -{ - m_cs.Lock(); - int rv=m_clipboard.GetSize(); - m_cs.Unlock(); - - return rv; -} - -int CTask::ReplaceClipboardStrings(CString strOld, CString strNew) -{ - // small chars to make comparing case insensitive - strOld.MakeLower(); - - CString strText; - int iOffset; - int iCount=0; - m_cs.Lock(); - for (int i=0;iGetPath(); - strText.MakeLower(); - iOffset=strText.Find(strOld, 0); - if (iOffset != -1) - { - // found - strText=pEntry->GetPath(); - strText=strText.Left(iOffset)+strNew+strText.Mid(iOffset+strOld.GetLength()); - pEntry->SetPath(strText); - iCount++; - } - } - m_cs.Unlock(); - - return iCount; -} - -// m_files -int CTask::FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs) -{ - // this uses much of memory, but resolves problem critical section hungs and m_bKill - CFileInfoArray fa; - fa.Init(&m_clipboard); - - fa.AddDir(strDirName, pFilters, iSrcIndex, bRecurse, bIncludeDirs, &m_bKill); - - m_cs.Lock(); - - m_files.Append(fa); - - m_cs.Unlock(); - - return 0; -} - -int CTask::FilesAdd(CFileInfo fi) -{ - int rv=-1; - m_cs.Lock(); - if (fi.IsDirectory() || m_afFilters.Match(fi)) - rv=m_files.Add(fi); - m_cs.Unlock(); - - return rv; -} - -CFileInfo CTask::FilesGetAt(int nIndex) -{ - m_cs.Lock(); - CFileInfo info=m_files.GetAt(nIndex); - m_cs.Unlock(); - - return info; -} - -CFileInfo CTask::FilesGetAtCurrentIndex() -{ - m_cs.Lock(); - CFileInfo info=m_files.GetAt(m_nCurrentIndex); - m_cs.Unlock(); - return info; -} - -void CTask::FilesRemoveAll() -{ - m_cs.Lock(); - m_files.RemoveAll(); - m_cs.Unlock(); -} - -int CTask::FilesGetSize() -{ - m_cs.Lock(); - int nSize=m_files.GetSize(); - m_cs.Unlock(); - - return nSize; -} - -// m_nCurrentIndex -void CTask::IncreaseCurrentIndex() -{ - m_cs.Lock(); - ++m_nCurrentIndex; - m_cs.Unlock(); -} - -int CTask::GetCurrentIndex() -{ - m_cs.Lock(); - int nIndex=m_nCurrentIndex; - m_cs.Unlock(); - - return nIndex; -} - -void CTask::SetCurrentIndex(int nIndex) -{ - m_cs.Lock(); - m_nCurrentIndex=nIndex; - m_cs.Unlock(); -} - -// m_strDestPath - adds '\\' -void CTask::SetDestPath(LPCTSTR lpszPath) -{ - m_dpDestPath.SetPath(lpszPath); -} - -// guaranteed '\\' -const CDestPath& CTask::GetDestPath() -{ - return m_dpDestPath; -} - -int CTask::GetDestDriveNumber() -{ - return m_dpDestPath.GetDriveNumber(); -} - -// m_nStatus -void CTask::SetStatus(UINT nStatus, UINT nMask) -{ - m_cs.Lock(); - m_nStatus &= ~nMask; - m_nStatus |= nStatus; - m_cs.Unlock(); -} - -UINT CTask::GetStatus(UINT nMask) -{ - m_cs.Lock(); - UINT nStatus=m_nStatus; - m_cs.Unlock(); - - return (nStatus & nMask); -} - -// m_nBufferSize -void CTask::SetBufferSizes(const BUFFERSIZES* bsSizes) -{ - m_cs.Lock(); - m_bsSizes=*bsSizes; - m_bSaved=false; - m_cs.Unlock(); -} - -const BUFFERSIZES* CTask::GetBufferSizes() -{ - m_cs.Lock(); - const BUFFERSIZES* pbsSizes=&m_bsSizes; - m_cs.Unlock(); - - return pbsSizes; -} - -int CTask::GetCurrentBufferIndex() -{ - int rv=0; - m_cs.Lock(); - int iSize=m_files.GetSize(); - if (iSize > 0 && m_nCurrentIndex != -1) - rv=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < iSize) ? m_nCurrentIndex : 0).GetBufferIndex(); - m_cs.Unlock(); - - return rv; -} - -// m_pThread -// m_nPriority -int CTask::GetPriority() -{ - m_cs.Lock(); - int nPriority=m_nPriority; - m_cs.Unlock(); - return nPriority; -} - -void CTask::SetPriority(int nPriority) -{ - m_cs.Lock(); - m_nPriority=nPriority; - m_bSaved=false; - if (m_pThread != NULL) - { - TRACE("Changing thread priority"); - m_pThread->SuspendThread(); - m_pThread->SetThreadPriority(nPriority); - m_pThread->ResumeThread(); - } - m_cs.Unlock(); -} - -// m_nProcessed -void CTask::IncreaseProcessedSize(__int64 nSize) -{ - m_cs.Lock(); - m_nProcessed+=nSize; - m_cs.Unlock(); -} - -void CTask::SetProcessedSize(__int64 nSize) -{ - m_cs.Lock(); - m_nProcessed=nSize; - m_cs.Unlock(); -} - -__int64 CTask::GetProcessedSize() -{ - m_cs.Lock(); - __int64 nSize=m_nProcessed; - m_cs.Unlock(); - - return nSize; -} - -// m_nAll -void CTask::SetAllSize(__int64 nSize) -{ - m_cs.Lock(); - m_nAll=nSize; - m_cs.Unlock(); -} - -__int64 CTask::GetAllSize() -{ - m_cs.Lock(); - __int64 nAll=m_nAll; - m_cs.Unlock(); - - return nAll; -} - -void CTask::CalcAllSize() -{ - m_cs.Lock(); - m_nAll=0; - - int nSize=m_files.GetSize(); - CFileInfo* pFiles=m_files.GetData(); - - for (int i=0;iLock(); - (*m_pnTasksProcessed)+=nSize; - m_pcs->Unlock(); -// m_cs.Unlock(); -} - -void CTask::DecreaseProcessedTasksSize(__int64 nSize) -{ -// m_cs.Lock(); - m_pcs->Lock(); - (*m_pnTasksProcessed)-=nSize; - m_pcs->Unlock(); -// m_cs.Unlock(); -} - -// m_pnTasksAll -void CTask::IncreaseAllTasksSize(__int64 nSize) -{ -// m_cs.Lock(); - m_pcs->Lock(); - (*m_pnTasksAll)+=nSize; - m_pcs->Unlock(); -// m_cs.Unlock(); -} - -void CTask::DecreaseAllTasksSize(__int64 nSize) -{ -// m_cs.Lock(); - m_pcs->Lock(); - (*m_pnTasksAll)-=nSize; - m_pcs->Unlock(); -// m_cs.Unlock(); -} - -// m_bKill -/*inline*/ void CTask::SetKillFlag(bool bKill) -{ - m_cs.Lock(); - m_bKill=bKill; - m_cs.Unlock(); -} - -bool CTask::GetKillFlag() -{ - m_cs.Lock(); - bool bKill=m_bKill; - m_cs.Unlock(); - - return bKill; -} - -// m_bKilled -/*inline*/ void CTask::SetKilledFlag(bool bKilled) -{ - m_cs.Lock(); - m_bKilled=bKilled; - m_cs.Unlock(); -} - -/*inline*/ bool CTask::GetKilledFlag() -{ - m_cs.Lock(); - bool bKilled=m_bKilled; - m_cs.Unlock(); - - return bKilled; -} - -// m_strUniqueName - -CString CTask::GetUniqueName() -{ - m_cs.Lock(); - CString name=m_strUniqueName; - m_cs.Unlock(); - - return name; -} - -void CTask::Load(CArchive& ar, bool bData) -{ - m_cs.Lock(); - try - { - if (bData) - { - m_clipboard.Serialize(ar, bData); - - m_files.Load(ar); - m_dpDestPath.Serialize(ar); - ar>>m_strUniqueName; - m_afFilters.Serialize(ar); - ar>>m_ucCopies; - } - else - { - int data; - unsigned long part; - - ar>>data; - m_nCurrentIndex=data; - ar>>data; - m_nStatus=data; - ar>>m_lOsError; - ar>>m_strErrorDesc; - m_bsSizes.Serialize(ar); - ar>>m_nPriority; - - ar>>part; - m_nAll=(static_cast(part) << 32); - ar>>part; - m_nAll|=part; - // czas - ar>>m_lTimeElapsed; - - ar>>part; - m_nProcessed=(static_cast(part) << 32); - ar>>part; - m_nProcessed|=part; - - ar>>m_ucCurrentCopy; - - m_clipboard.Serialize(ar, bData); - - unsigned char ucTmp; - ar>>ucTmp; - m_bSaved=ucTmp != 0; - } - } - catch(CException*) - { - m_cs.Unlock(); - throw; - } - m_cs.Unlock(); -} - -void CTask::Store(LPCTSTR lpszDirectory, bool bData) -{ - m_cs.Lock(); - if (!bData && m_bSaved) - { - m_cs.Unlock(); - TRACE("Saving locked - file not saved\n"); - return; - } - - if (!bData && !m_bSaved && ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED || (m_nStatus & ST_STEP_MASK) == ST_CANCELLED - || (m_nStatus & ST_WORKING_MASK) == ST_PAUSED )) - { - TRACE("Last save - saving blocked\n"); - m_bSaved=true; - } - - try - { - CFile file(lpszDirectory+GetUniqueName()+( (bData) ? _T(".atd") : _T(".atp") ), CFile::modeWrite | CFile::modeCreate); - CArchive ar(&file, CArchive::store); - - if (bData) - { - m_clipboard.Serialize(ar, bData); - - if (GetStatus(ST_STEP_MASK) > ST_SEARCHING) - m_files.Store(ar); - else - ar<(0); - - m_dpDestPath.Serialize(ar); - ar<((m_nAll & 0xffffffff00000000) >> 32); - ar<(m_nAll & 0x00000000ffffffff); - ar<((m_nProcessed & 0xffffffff00000000) >> 32); - ar<(m_nProcessed & 0x00000000ffffffff); - ar<Delete(); - m_cs.Unlock(); - return; - } - m_cs.Unlock(); -} - -/*inline*/ void CTask::KillThread() -{ - if (!GetKilledFlag()) // protection from recalling Cleanup - { - SetKillFlag(); - while (!GetKilledFlag()) - Sleep(10); - - // cleanup - CleanupAfterKill(); - } -} - -void CTask::BeginProcessing() -{ - m_cs.Lock(); - if (m_pThread != NULL) - { - m_cs.Unlock(); - return; - } - m_cs.Unlock(); - - // create new thread - m_uiResumeInterval=0; // just in case - m_bSaved=false; // save - SetKillFlag(false); - SetKilledFlag(false); - CWinThread* pThread=AfxBeginThread(m_pfnTaskProc, this, GetPriority()); - - m_cs.Lock(); - m_pThread=pThread; - m_cs.Unlock(); -} - -void CTask::ResumeProcessing() -{ - // the same as retry but less demanding - if ( (GetStatus(ST_WORKING_MASK) & ST_PAUSED) && GetStatus(ST_STEP_MASK) != ST_FINISHED - && GetStatus(ST_STEP_MASK) != ST_CANCELLED) - { - SetStatus(0, ST_ERROR); - BeginProcessing(); - } -} - -bool CTask::RetryProcessing(bool bOnlyErrors/*=false*/, UINT uiInterval) -{ - // retry used to auto-resume, after loading - if ( (GetStatus(ST_WORKING_MASK) == ST_ERROR || (!bOnlyErrors && GetStatus(ST_WORKING_MASK) != ST_PAUSED)) - && GetStatus(ST_STEP_MASK) != ST_FINISHED && GetStatus(ST_STEP_MASK) != ST_CANCELLED) - { - if (uiInterval != 0) - { - m_uiResumeInterval+=uiInterval; - if (m_uiResumeInterval < (UINT)GetConfig()->GetIntValue(PP_CMAUTORETRYINTERVAL)) - return false; - else - m_uiResumeInterval=0; - } - - SetStatus(0, ST_ERROR); - BeginProcessing(); - return true; - } - return false; -} - -void CTask::RestartProcessing() -{ - KillThread(); - SetStatus(0, ST_ERROR); - SetStatus(ST_NULL_STATUS, ST_STEP_MASK); - m_lTimeElapsed=0; - SetCurrentIndex(0); - SetCurrentCopy(0); - BeginProcessing(); -} - -void CTask::PauseProcessing() -{ - if (GetStatus(ST_STEP_MASK) != ST_FINISHED && GetStatus(ST_STEP_MASK) != ST_CANCELLED) - { - KillThread(); - SetStatus(ST_PAUSED, ST_WORKING_MASK); - SetLastProcessedIndex(GetCurrentIndex()); - m_bSaved=false; - } -} - -void CTask::CancelProcessing() -{ - // change to ST_CANCELLED - if (GetStatus(ST_STEP_MASK) != ST_FINISHED) - { - KillThread(); - SetStatus(ST_CANCELLED, ST_STEP_MASK); - SetStatus(0, ST_ERROR); - m_bSaved=false; - } -} - -void CTask::GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData) -{ - m_cs.Lock(); - if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) - pData->m_fi=m_files.GetAt(m_nCurrentIndex); - else - { - if (m_files.GetSize() > 0) - { - pData->m_fi=m_files.GetAt(0); - pData->m_fi.SetFilePath(pData->m_fi.GetFullFilePath()); - pData->m_fi.SetSrcIndex(-1); - } - else - { - if (m_clipboard.GetSize() > 0) - { - pData->m_fi.SetFilePath(m_clipboard.GetAt(0)->GetPath()); - pData->m_fi.SetSrcIndex(-1); - } - else - { - pData->m_fi.SetFilePath(GetResManager()->LoadString(IDS_NONEINPUTFILE_STRING)); - pData->m_fi.SetSrcIndex(-1); - } - } - } - - pData->m_uiStatus=m_nStatus; - - // percents - int iSize=m_files.GetSize()*m_ucCopies; - int iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); - if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) - pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); - else - if (iSize != 0) - pData->m_nPercent=static_cast( static_cast(iIndex)*100.0/static_cast(iSize) ); - else - pData->m_nPercent=0; - - m_cs.Unlock(); -} - -void CTask::GetSnapshot(TASK_DISPLAY_DATA *pData) -{ - m_cs.Lock(); - if (m_nCurrentIndex >= 0 && m_nCurrentIndex < m_files.GetSize()) - pData->m_fi=m_files.GetAt(m_nCurrentIndex); - else - { - if (m_files.GetSize() > 0) - { - pData->m_fi=m_files.GetAt(0); - pData->m_fi.SetFilePath(pData->m_fi.GetFullFilePath()); - pData->m_fi.SetSrcIndex(-1); - } - else - { - if (m_clipboard.GetSize() > 0) - { - pData->m_fi.SetFilePath(m_clipboard.GetAt(0)->GetPath()); - pData->m_fi.SetSrcIndex(-1); - } - else - { - pData->m_fi.SetFilePath(GetResManager()->LoadString(IDS_NONEINPUTFILE_STRING)); - pData->m_fi.SetSrcIndex(-1); - } - } - } - - pData->m_pbsSizes=&m_bsSizes; - pData->m_nPriority=m_nPriority; - pData->m_pdpDestPath=&m_dpDestPath; - pData->m_pafFilters=&m_afFilters; - pData->m_dwOsErrorCode=m_lOsError; - pData->m_strErrorDesc=m_strErrorDesc; - pData->m_uiStatus=m_nStatus; - pData->m_iIndex=m_nCurrentIndex+m_ucCurrentCopy*m_files.GetSize(); - pData->m_iProcessedSize=m_nProcessed; - pData->m_iSize=m_files.GetSize()*m_ucCopies; - pData->m_iSizeAll=m_nAll; - pData->m_ucCurrentCopy=static_cast(m_ucCurrentCopy+1); // visual aspect - pData->m_ucCopies=m_ucCopies; - pData->m_pstrUniqueName=&m_strUniqueName; - - if (m_files.GetSize() > 0 && m_nCurrentIndex != -1) - pData->m_iCurrentBufferIndex=m_bsSizes.m_bOnlyDefault ? 0 : m_files.GetAt((m_nCurrentIndex < m_files.GetSize()) ? m_nCurrentIndex : 0).GetBufferIndex(); - else - pData->m_iCurrentBufferIndex=0; - - // percents - if (m_nAll != 0 && !((m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT)) - pData->m_nPercent=static_cast( (static_cast(m_nProcessed)*100.0)/static_cast(m_nAll) ); - else - if (pData->m_iSize != 0) - pData->m_nPercent=static_cast( static_cast(pData->m_iIndex)*100.0/static_cast(pData->m_iSize) ); - else - pData->m_nPercent=0; - - // status string - // first - if ( (m_nStatus & ST_WORKING_MASK) == ST_ERROR ) - { - GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+4, pData->m_szStatusText, _MAX_PATH); - _tcscat(pData->m_szStatusText, _T("/")); - } - else if ( (m_nStatus & ST_WORKING_MASK) == ST_PAUSED ) - { - GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+5, pData->m_szStatusText, _MAX_PATH); - _tcscat(pData->m_szStatusText, _T("/")); - } - else if ( (m_nStatus & ST_STEP_MASK) == ST_FINISHED ) - { - GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+3, pData->m_szStatusText, _MAX_PATH); - _tcscat(pData->m_szStatusText, _T("/")); - } - else if ( (m_nStatus & ST_WAITING_MASK) == ST_WAITING ) - { - GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+9, pData->m_szStatusText, _MAX_PATH); - _tcscat(pData->m_szStatusText, _T("/")); - } - else if ( (m_nStatus & ST_STEP_MASK) == ST_CANCELLED ) - { - GetResManager()->LoadStringCopy(IDS_STATUS0_STRING+8, pData->m_szStatusText, _MAX_PATH); - _tcscat(pData->m_szStatusText, _T("/")); - } - else - _tcscpy(pData->m_szStatusText, _T("")); - - // second part - if ( (m_nStatus & ST_STEP_MASK) == ST_DELETING ) - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+6)); - else if ( (m_nStatus & ST_STEP_MASK) == ST_SEARCHING ) - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+0)); - else if ((m_nStatus & ST_OPERATION_MASK) == ST_COPY ) - { - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+1)); - if (m_afFilters.GetSize()) - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); - } - else if ( (m_nStatus & ST_OPERATION_MASK) == ST_MOVE ) - { - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+2)); - if (m_afFilters.GetSize()) - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_FILTERING_STRING)); - } - else - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+7)); - - // third part - if ( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_DIRS ) - { - _tcscat(pData->m_szStatusText, _T("/")); - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+10)); - } - if ( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT ) - { - _tcscat(pData->m_szStatusText, _T("/")); - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_STATUS0_STRING+11)); - } - - // count of copies - if (m_ucCopies > 1) - { - _tcscat(pData->m_szStatusText, _T("/")); - TCHAR xx[4]; - _tcscat(pData->m_szStatusText, _itot(m_ucCopies, xx, 10)); - if (m_ucCopies < 5) - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_COPYWORDLESSFIVE_STRING)); - else - _tcscat(pData->m_szStatusText, GetResManager()->LoadString(IDS_COPYWORDMOREFOUR_STRING)); - } - - // time - UpdateTime(); - pData->m_lTimeElapsed=m_lTimeElapsed; - - m_cs.Unlock(); -} - -/*inline*/ void CTask::CleanupAfterKill() -{ - m_cs.Lock(); - m_pThread=NULL; - UpdateTime(); - m_lLastTime=-1; - m_cs.Unlock(); -} - -void CTask::DeleteProgress(LPCTSTR lpszDirectory) -{ - m_cs.Lock(); - DeleteFile(lpszDirectory+m_strUniqueName+_T(".atd")); - DeleteFile(lpszDirectory+m_strUniqueName+_T(".atp")); - DeleteFile(lpszDirectory+m_strUniqueName+_T(".log")); - m_cs.Unlock(); -} - -void CTask::SetOsErrorCode(DWORD dwError, LPCTSTR lpszErrDesc) -{ - m_cs.Lock(); - m_lOsError=dwError; - m_strErrorDesc=lpszErrDesc; - m_cs.Unlock(); -} - -void CTask::UpdateTime() -{ - m_cs.Lock(); - if (m_lLastTime != -1) - { - long lVal=time(NULL); - m_lTimeElapsed+=lVal-m_lLastTime; - m_lLastTime=lVal; - } - m_cs.Unlock(); -} - -void CTask::DecreaseOperationsPending(UINT uiBy) -{ - m_pcs->Lock(); - if (m_bQueued) - { - TRACE("Decreasing operations pending by %lu\n", uiBy); - (*m_puiOperationsPending)-=uiBy; - m_bQueued=false; - } - m_pcs->Unlock(); -} - -void CTask::IncreaseOperationsPending(UINT uiBy) -{ - TRACE("Trying to increase operations pending...\n"); - if (!m_bQueued) - { - TRACE("Increasing operations pending by %lu\n", uiBy); - m_pcs->Lock(); - (*m_puiOperationsPending)+=uiBy; - m_pcs->Unlock(); - m_bQueued=true; - } -} - -const CFiltersArray* CTask::GetFilters() -{ - return &m_afFilters; -} - -void CTask::SetFilters(const CFiltersArray* pFilters) -{ - m_cs.Lock(); - m_afFilters.Copy(*pFilters); - m_cs.Unlock(); -} - -bool CTask::CanBegin() -{ - bool bRet=true; - m_cs.Lock(); - if (GetContinueFlag() || GetForceFlag()) - { - TRACE("New operation Begins... continue: %d, force: %d\n", GetContinueFlag(), GetForceFlag()); - IncreaseOperationsPending(); - SetForceFlag(false); - SetContinueFlag(false); - } - else - bRet=false; - m_cs.Unlock(); - - return bRet; -} - -void CTask::SetCopies(unsigned char ucCopies) -{ - m_cs.Lock(); - m_ucCopies=ucCopies; - m_cs.Unlock(); -} - -unsigned char CTask::GetCopies() -{ - unsigned char ucCopies; - m_cs.Lock(); - ucCopies=m_ucCopies; - m_cs.Unlock(); - - return ucCopies; -} - -void CTask::SetCurrentCopy(unsigned char ucCopy) -{ - m_cs.Lock(); - m_ucCurrentCopy=ucCopy; - m_cs.Unlock(); -} - -unsigned char CTask::GetCurrentCopy() -{ - m_cs.Lock(); - unsigned char ucCopy=m_ucCurrentCopy; - m_cs.Unlock(); - - return ucCopy; -} - -void CTask::SetLastProcessedIndex(int iIndex) -{ - m_cs.Lock(); - m_iLastProcessedIndex=iIndex; - m_cs.Unlock(); -} - -int CTask::GetLastProcessedIndex() -{ - int iIndex; - m_cs.Lock(); - iIndex=m_iLastProcessedIndex; - m_cs.Unlock(); - - return iIndex; -} - -bool CTask::GetRequiredFreeSpace(__int64 *pi64Needed, __int64 *pi64Available) -{ - *pi64Needed=GetAllSize()-GetProcessedSize(); // it'd be nice to round up to take cluster size into consideration, - // but GetDiskFreeSpace returns flase values - - // get free space - if (!GetDynamicFreeSpace(GetDestPath().GetPath(), pi64Available, NULL)) - return true; - - return (*pi64Needed <= *pi64Available); -} - -void CTask::SetForceFlag(bool bFlag) -{ - m_cs.Lock(); - m_bForce=bFlag; - m_cs.Unlock(); -} - -bool CTask::GetForceFlag() -{ - return m_bForce; -} - -void CTask::SetContinueFlag(bool bFlag) -{ - m_cs.Lock(); - m_bContinue=bFlag; - m_cs.Unlock(); -} - -bool CTask::GetContinueFlag() -{ - return m_bContinue; -} - -CString CTask::GetLogName() -{ - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - return GetApp()->ExpandPath(szPath)+GetUniqueName()+_T(".log"); -} - -//////////////////////////////////////////////////////////////////////////////// -// CTaskArray members -void CTaskArray::Create(UINT (*pfnTaskProc)(LPVOID pParam)) -{ - m_tcd.pcs=&m_cs; - m_tcd.pfnTaskProc=pfnTaskProc; - m_tcd.pTasksAll=&m_uhRange; - m_tcd.pTasksProcessed=&m_uhPosition; - m_tcd.puiOperationsPending=&m_uiOperationsPending; - m_tcd.plFinished=&m_lFinished; -} - -CTaskArray::~CTaskArray() -{ -} - -int CTaskArray::GetSize( ) -{ - m_cs.Lock(); - int nSize=m_nSize; - m_cs.Unlock(); - - return nSize; -} - -int CTaskArray::GetUpperBound( ) -{ - m_cs.Lock(); - int upper=m_nSize; - m_cs.Unlock(); - - return upper-1; -} - -void CTaskArray::SetSize( int nNewSize, int nGrowBy ) -{ - m_cs.Lock(); - (static_cast*>(this))->SetSize(nNewSize, nGrowBy); - m_cs.Unlock(); -} - -CTask* CTaskArray::GetAt( int nIndex ) -{ - ASSERT(nIndex >= 0 && nIndex < m_nSize); - m_cs.Lock(); - CTask* pTask=m_pData[nIndex]; - m_cs.Unlock(); - - return pTask; -} - -void CTaskArray::SetAt( int nIndex, CTask* newElement ) -{ - m_cs.Lock(); - ASSERT(nIndex >= 0 && nIndex < m_nSize); - m_uhRange-=m_pData[nIndex]->GetAllSize(); // subtract old element - m_pData[nIndex]=newElement; - m_uhRange+=m_pData[nIndex]->GetAllSize(); // add new - m_cs.Unlock(); -} - -int CTaskArray::Add( CTask* newElement ) -{ - m_cs.Lock(); - m_uhRange+=newElement->GetAllSize(); - m_uhPosition+=newElement->GetProcessedSize(); - int pos=(static_cast*>(this))->Add(newElement); - m_cs.Unlock(); - - return pos; -} - -void CTaskArray::RemoveAt(int nIndex, int nCount) -{ - m_cs.Lock(); - for (int i=nIndex;iKillThread(); - - m_uhRange-=pTask->GetAllSize(); - m_uhPosition-=pTask->GetProcessedSize(); - - delete pTask; - } - - // remove elements from array - (static_cast*>(this))->RemoveAt(nIndex, nCount); - m_cs.Unlock(); -} - -void CTaskArray::RemoveAll() -{ - m_cs.Lock(); - CTask* pTask; - - for (int i=0;iSetKillFlag(); // send an info about finishing - - // wait for finishing and get rid of it - for (i=0;iGetKilledFlag()) - Sleep(10); - - pTask->CleanupAfterKill(); - - m_uhRange-=pTask->GetAllSize(); - m_uhPosition-=pTask->GetProcessedSize(); - - // delete data - delete pTask; - } - - (static_cast*>(this))->RemoveAll(); - m_cs.Unlock(); -} - -void CTaskArray::RemoveAllFinished() -{ - m_cs.Lock(); - int i=GetSize(); - - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - while (i) - { - CTask* pTask=GetAt(i-1); - - // delete only when the thread is finished - if ( (pTask->GetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED) - && pTask->GetKilledFlag()) - { - m_uhRange-=pTask->GetAllSize(); - m_uhPosition-=pTask->GetProcessedSize(); - - // delete associated files - pTask->DeleteProgress(szPath); - - delete pTask; - - static_cast*>(this)->RemoveAt(i-1); - } - - --i; - } - - m_cs.Unlock(); -} - -void CTaskArray::RemoveFinished(CTask** pSelTask) -{ - m_cs.Lock(); - TCHAR szPath[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - for (int i=0;iGetStatus(ST_STEP_MASK) == ST_FINISHED || pTask->GetStatus(ST_STEP_MASK) == ST_CANCELLED)) - { - // kill task if needed - pTask->KillThread(); - - m_uhRange-=pTask->GetAllSize(); - m_uhPosition-=pTask->GetProcessedSize(); - - // delete associated files - pTask->DeleteProgress(szPath); - - // delete data - delete pTask; - - static_cast*>(this)->RemoveAt(i); - - m_cs.Unlock(); - return; - } - } - m_cs.Unlock(); -} - -void CTaskArray::SaveData(LPCTSTR lpszDirectory) -{ - m_cs.Lock(); - for (int i=0;iStore(lpszDirectory, true); - m_cs.Unlock(); -} - -void CTaskArray::SaveProgress(LPCTSTR lpszDirectory) -{ - m_cs.Lock(); - for (int i=0;iStore(lpszDirectory, false); - m_cs.Unlock(); -} - -void CTaskArray::LoadDataProgress(LPCTSTR lpszDirectory) -{ - m_cs.Lock(); - CFileFind finder; - CTask* pTask; - - BOOL bWorking=finder.FindFile(CString(lpszDirectory)+_T("*.atd")); - while ( bWorking ) - { - bWorking=finder.FindNextFile(); - - // load data - pTask=new CTask(&m_tcd); - - try - { - CString strPath=finder.GetFilePath(); - - // load data file - CFile file(strPath, CFile::modeRead); - CArchive ar(&file, CArchive::load); - - pTask->Load(ar, true); - - ar.Close(); - file.Close(); - - // load progress file - strPath=strPath.Left(strPath.GetLength()-4); - strPath+=_T(".atp"); - CFile file2(strPath, CFile::modeRead); - CArchive ar2(&file2, CArchive::load); - - pTask->Load(ar2, false); - - ar2.Close(); - file2.Close(); - - // add read task to array - Add(pTask); - } - catch(CException* e) - { - e->Delete(); - delete pTask; - } - } - finder.Close(); - - m_cs.Unlock(); -} - -void CTaskArray::TasksBeginProcessing() -{ - for (int i=0;iBeginProcessing(); -} - -void CTaskArray::TasksPauseProcessing() -{ - for (int i=0;iPauseProcessing(); -} - -void CTaskArray::TasksResumeProcessing() -{ - for (int i=0;iResumeProcessing(); -} - -void CTaskArray::TasksRestartProcessing() -{ - for (int i=0;iRestartProcessing(); -} - -bool CTaskArray::TasksRetryProcessing(bool bOnlyErrors/*=false*/, UINT uiInterval) -{ - bool bChanged=false; - for (int i=0;iRetryProcessing(bOnlyErrors, uiInterval)) - bChanged=true; - } - - return bChanged; -} - -void CTaskArray::TasksCancelProcessing() -{ - for (int i=0;iCancelProcessing(); -} - -__int64 CTaskArray::GetPosition() -{ - m_cs.Lock(); - __int64 rv=m_uhPosition; - m_cs.Unlock(); - - return rv; -} - -__int64 CTaskArray::GetRange() -{ - m_cs.Lock(); - __int64 rv=m_uhRange; - m_cs.Unlock(); - - return rv; -} - -int CTaskArray::GetPercent() -{ - int pos; - m_cs.Lock(); - if (m_uhRange != 0) - pos=static_cast((static_cast(m_uhPosition)*100.0)/static_cast(m_uhRange)); - else - if (GetSize() != 0) // if anything is in an array, but size of it is 0 - pos=100; - else - pos=0; - m_cs.Unlock(); - - return pos; -} - -UINT CTaskArray::GetOperationsPending() -{ - m_cs.Lock(); - UINT uiOP=m_uiOperationsPending; - m_cs.Unlock(); - return uiOP; -} - -bool CTaskArray::IsFinished() -{ - bool bFlag=true; - UINT uiStatus; - - m_cs.Lock(); - if (m_uiOperationsPending != 0) - bFlag=false; - else - { - for (int i=0;iGetStatus(); - bFlag=((uiStatus & ST_STEP_MASK) == ST_FINISHED || (uiStatus & ST_STEP_MASK) == ST_CANCELLED - || (uiStatus & ST_WORKING_MASK) == ST_PAUSED - || ((uiStatus & ST_WORKING_MASK) == ST_ERROR && !GetConfig()->GetBoolValue(PP_CMAUTORETRYONERROR))); - } - } - - m_cs.Unlock(); - return bFlag; -} - -/////////////////////////////////////////////////////////////////////// -// CProcessingException - -CProcessingException::CProcessingException(int iType, CTask* pTask, UINT uiFmtID, DWORD dwError, ...) -{ - // std values - m_iType=iType; - m_pTask=pTask; - m_dwError=dwError; - - // format some text - CString strFormat=GetResManager()->LoadString(uiFmtID); - ExpandFormatString(&strFormat, dwError); - - // get param list - va_list marker; - va_start(marker, dwError); - m_strErrorDesc.FormatV(strFormat, marker); - va_end(marker); -} - -void CProcessingException::Cleanup() -{ - TCHAR szPath[_MAX_PATH]; - switch (m_pTask->GetStatus(ST_STEP_MASK)) - { - case ST_NULL_STATUS: - case ST_SEARCHING: - // get rif of m_files contents - m_pTask->FilesRemoveAll(); - - // save state of a task - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_pTask->Store(szPath, true); - m_pTask->Store(szPath, false); - - m_pTask->SetKilledFlag(); - m_pTask->CleanupAfterKill(); - - break; - case ST_COPYING: - case ST_DELETING: - switch (m_iType) - { - case E_ERROR: - m_pTask->SetStatus(ST_ERROR, ST_WORKING_MASK); - m_pTask->SetOsErrorCode(m_dwError, this->m_strErrorDesc); - break; - case E_CANCEL: - m_pTask->SetStatus(ST_CANCELLED, ST_STEP_MASK); - break; - } - - GetConfig()->GetStringValue(PP_PAUTOSAVEDIRECTORY, szPath, _MAX_PATH); - GetApp()->ExpandPath(szPath); - m_pTask->Store(szPath, false); - - m_pTask->SetKilledFlag(); - m_pTask->CleanupAfterKill(); - - break; - } -} Index: src/ch/Structs.h =================================================================== diff -u -N --- src/ch/Structs.h (revision 0) +++ src/ch/Structs.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,422 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __STRUCTS_H__ +#define __STRUCTS_H__ + +#include "fileinfo.h" +#include "DestPath.h" +#include "DataBuffer.h" +//#include "LogFile.h" +#include + +#define ST_NULL_STATUS 0x00000000 + +#define ST_WRITE_MASK 0x000fffff + +//------------------------------------ +#define ST_STEP_MASK 0x000000ff +#define ST_SEARCHING 0x00000001 +#define ST_COPYING 0x00000002 +#define ST_DELETING 0x00000003 +#define ST_FINISHED 0x00000004 +#define ST_CANCELLED 0x00000005 + +//------------------------------------ +#define ST_OPERATION_MASK 0x00000f00 +#define ST_COPY 0x00000100 +// moving - delete after copying all files +#define ST_MOVE 0x00000200 + +//------------------------------------ +#define ST_SPECIAL_MASK 0x0000f000 +// simultaneous flags +#define ST_IGNORE_DIRS 0x00001000 +#define ST_IGNORE_CONTENT 0x00002000 +#define ST_FORCE_DIRS 0x00004000 + +//------------------------------------ +#define ST_WORKING_MASK 0x000f0000 +#define ST_ERROR 0x000C0000 +#define ST_PAUSED 0x00080000 + +//------------------------------------ +#define ST_WAITING_MASK 0x00f00000 +#define ST_WAITING 0x00100000 + + +///////////////////////////////////////////////////////////////////////////// +// priority + +int PriorityToIndex(int nPriority); +int IndexToPriority(int nIndex); +int IndexToPriorityClass(int iIndex); +int PriorityClassToIndex(int iPriority); + +/////////////////////////////////////////////////////////////////////////// +// Exceptions + +#define E_KILL_REQUEST 0x00 +#define E_ERROR 0x01 +#define E_CANCEL 0x02 + +///////////////////////////////////////////////////////////////////// +// CTask + +struct TASK_CREATE_DATA +{ + __int64 *pTasksProcessed; + __int64 *pTasksAll; + + UINT *puiOperationsPending; + LONG *plFinished; + + CCriticalSection* pcs; + + UINT (*pfnTaskProc)(LPVOID pParam); +}; + +// structure for gettings status of a task +struct TASK_DISPLAY_DATA +{ + CFileInfo m_fi; // fi at CurrIndex + int m_iCurrentBufferIndex; + int m_iIndex; + int m_iSize; + + CDestPath* m_pdpDestPath; + CFiltersArray* m_pafFilters; + + UINT m_uiStatus; + DWORD m_dwOsErrorCode; + CString m_strErrorDesc; + + const BUFFERSIZES* m_pbsSizes; + int m_nPriority; + + __int64 m_iProcessedSize; + __int64 m_iSizeAll; + int m_nPercent; + + long m_lTimeElapsed; + + unsigned char m_ucCurrentCopy; + unsigned char m_ucCopies; + + const CString* m_pstrUniqueName; // doesn't change from first setting + + TCHAR m_szStatusText[_MAX_PATH]; +}; + +struct TASK_MINI_DISPLAY_DATA +{ + CFileInfo m_fi; // fi at CurrIndex + + UINT m_uiStatus; + int m_nPercent; +}; + +class CTask +{ +public: + CTask(const TASK_CREATE_DATA *pCreateData); + ~CTask(); +public: + +// Attributes +public: + // m_clipboard + int AddClipboardData(CClipboardEntry* pEntry); + CClipboardEntry* GetClipboardData(int nIndex); + int GetClipboardDataSize(); + int ReplaceClipboardStrings(CString strOld, CString strNew); + + // m_files + int FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, + const bool bRecurse, const bool bIncludeDirs); + int FilesAdd(CFileInfo fi); + CFileInfo FilesGetAt(int nIndex); + CFileInfo FilesGetAtCurrentIndex(); + void FilesRemoveAll(); + int FilesGetSize(); + + // m_nCurrentIndex + void IncreaseCurrentIndex(); + int GetCurrentIndex(); + void SetCurrentIndex(int nIndex); + + // m_strDestPath + void SetDestPath(LPCTSTR lpszPath); + const CDestPath& GetDestPath(); + int GetDestDriveNumber(); + + // m_nStatus + void SetStatus(UINT nStatus, UINT nMask); + UINT GetStatus(UINT nMask=0xffffffff); + + // m_nBufferSize + void SetBufferSizes(const BUFFERSIZES* bsSizes); + const BUFFERSIZES* GetBufferSizes(); + int GetCurrentBufferIndex(); + + // m_pThread + // m_nPriority + int GetPriority(); + void SetPriority(int nPriority); + + // m_nProcessed + void IncreaseProcessedSize(__int64 nSize); + void SetProcessedSize(__int64 nSize); + __int64 GetProcessedSize(); + + // m_nAll + void SetAllSize(__int64 nSize); + __int64 GetAllSize(); + void CalcAllSize(); + + // m_pnTasksProcessed + void IncreaseProcessedTasksSize(__int64 nSize); + void DecreaseProcessedTasksSize(__int64 nSize); + + // m_pnTasksAll + void IncreaseAllTasksSize(__int64 nSize); + void DecreaseAllTasksSize(__int64 nSize); + + // m_bKill + void SetKillFlag(bool bKill=true); + bool GetKillFlag(); + + // m_bKilled + void SetKilledFlag(bool bKilled=true); + bool GetKilledFlag(); + + void KillThread(); + void CleanupAfterKill(); + + // m_strUniqueName + CString GetUniqueName(); + + void Load(CArchive& ar, bool bData); + void Store(LPCTSTR lpszDirectory, bool bData); + + void BeginProcessing(); + + void PauseProcessing(); // pause + void ResumeProcessing(); // resume + bool RetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); // retry + void RestartProcessing(); // from beginning + void CancelProcessing(); // cancel + + void GetSnapshot(TASK_DISPLAY_DATA *pData); + void GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData); + + void DeleteProgress(LPCTSTR lpszDirectory); + + void SetOsErrorCode(DWORD dwError, LPCTSTR lpszErrDesc); + void CalcProcessedSize(); + + void DecreaseOperationsPending(UINT uiBy=1); + void IncreaseOperationsPending(UINT uiBy=1); + + bool CanBegin(); + + void UpdateTime(); + + void SetFilters(const CFiltersArray* pFilters); + const CFiltersArray* GetFilters(); + + void SetCopies(unsigned char ucCopies); + unsigned char GetCopies(); + void SetCurrentCopy(unsigned char ucCopy); + unsigned char GetCurrentCopy(); + + CClipboardArray* GetClipboard() { return &m_clipboard; }; + + void SetLastProcessedIndex(int iIndex); + int GetLastProcessedIndex(); + + CString GetLogName(); + + bool GetRequiredFreeSpace(__int64 *pi64Needed, __int64 *pi64Available); + +// Implementation +protected: + CClipboardArray m_clipboard; + CFileInfoArray m_files; + volatile int m_nCurrentIndex; + int m_iLastProcessedIndex; + + CDestPath m_dpDestPath; + + volatile UINT m_nStatus; + + // info about last error + DWORD m_lOsError; + CString m_strErrorDesc; + + // buffers + BUFFERSIZES m_bsSizes; + + CWinThread *m_pThread; + int m_nPriority; + + __int64 m_nProcessed; + __int64 m_nAll; + + __int64 *m_pnTasksProcessed; + __int64 *m_pnTasksAll; + + bool m_bQueued; // has operations pending for this task been increased ? + UINT *m_puiOperationsPending; + + volatile bool m_bKill; + volatile bool m_bKilled; + + // other stuff + CString m_strUniqueName; + + // mask (filter) + CFiltersArray m_afFilters; + + // copiees count + unsigned char m_ucCopies; + unsigned char m_ucCurrentCopy; + + bool m_bSaved; // has the state been saved ('til next modification) + +public: + UINT m_uiResumeInterval; // works only if the thread is off + // time + long m_lTimeElapsed; // store + long m_lLastTime; // not store + + // feedback + int m_iIdentical; + int m_iDestinationLess; + int m_iDestinationGreater; + int m_iMissingInput; + int m_iOutputError; + int m_iMoveFile; + + // ptr to count of currently started tasks + LONG* m_plFinished; + bool m_bForce; // if the continuation of tasks should be independent of limitation + bool m_bContinue; // used by ClipboardMonitorProc + +protected: + CCriticalSection* m_pcs; // protects *m_pnTasksProcessed & *m_pnTasksAll from external array + + UINT (*m_pfnTaskProc)(LPVOID pParam); // external function that processes this task +public: + void SetForceFlag(bool bFlag=true); + bool GetForceFlag(); + void SetContinueFlag(bool bFlag=true); + bool GetContinueFlag(); + +// CLogFile m_log; + icpf::log_file m_log; + CCriticalSection m_cs; // protection for this class +}; + +/////////////////////////////////////////////////////////////////////////// +// CTaskArray + +class CTaskArray : public CArray +{ +public: + CTaskArray() : CArray() { m_uhRange=0; m_uhPosition=0; m_uiOperationsPending=0; m_lFinished=0; }; + ~CTaskArray(); + + void Create(UINT (*pfnTaskProc)(LPVOID pParam)); + + int GetSize( ); + int GetUpperBound( ); + void SetSize( int nNewSize, int nGrowBy = -1 ); + + CTask* GetAt( int nIndex ); + void SetAt( int nIndex, CTask* newElement ); + int Add( CTask* newElement ); + + void RemoveAt( int nIndex, int nCount = 1 ); + void RemoveAll(); + void RemoveAllFinished(); + void RemoveFinished(CTask** pSelTask); + + void SaveData(LPCTSTR lpszDirectory); + void SaveProgress(LPCTSTR lpszDirectory); + void LoadDataProgress(LPCTSTR lpszDirectory); + + void TasksBeginProcessing(); + void TasksPauseProcessing(); + void TasksResumeProcessing(); + void TasksRestartProcessing(); + bool TasksRetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); + void TasksCancelProcessing(); + + __int64 GetPosition(); + __int64 GetRange(); + int GetPercent(); + + UINT GetOperationsPending(); + void SetLimitOperations(UINT uiLimit); + UINT GetLimitOperations(); + + bool IsFinished(); + +public: + __int64 m_uhRange, m_uhPosition; + + UINT m_uiOperationsPending; // count of current operations + LONG m_lFinished; // count of finished tasks + + CCriticalSection m_cs; + TASK_CREATE_DATA m_tcd; +}; + +/////////////////////////////////////////////////////////////////////////// +// CLIPBOARDMONITORDATA + +struct CLIPBOARDMONITORDATA +{ + HWND m_hwnd; // hwnd to window + CTaskArray *m_pTasks; + + volatile bool bKill, bKilled; +}; + +/////////////////////////////////////////////////////////////////////////// +// CProcessingException + +class CProcessingException +{ +public: + CProcessingException(int iType, CTask* pTask) { m_iType=iType; m_pTask=pTask; m_dwError=0; }; + CProcessingException(int iType, CTask* pTask, UINT uiFmtID, DWORD dwError, ...); + void Cleanup(); + +// Implementation +public: + int m_iType; // kill request, error, ... + CTask* m_pTask; + + CString m_strErrorDesc; + DWORD m_dwError; +}; + +#endif \ No newline at end of file Index: ch/Structs.h =================================================================== diff -u -N --- ch/Structs.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Structs.h (revision 0) @@ -1,422 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __STRUCTS_H__ -#define __STRUCTS_H__ - -#include "fileinfo.h" -#include "DestPath.h" -#include "DataBuffer.h" -//#include "LogFile.h" -#include - -#define ST_NULL_STATUS 0x00000000 - -#define ST_WRITE_MASK 0x000fffff - -//------------------------------------ -#define ST_STEP_MASK 0x000000ff -#define ST_SEARCHING 0x00000001 -#define ST_COPYING 0x00000002 -#define ST_DELETING 0x00000003 -#define ST_FINISHED 0x00000004 -#define ST_CANCELLED 0x00000005 - -//------------------------------------ -#define ST_OPERATION_MASK 0x00000f00 -#define ST_COPY 0x00000100 -// moving - delete after copying all files -#define ST_MOVE 0x00000200 - -//------------------------------------ -#define ST_SPECIAL_MASK 0x0000f000 -// simultaneous flags -#define ST_IGNORE_DIRS 0x00001000 -#define ST_IGNORE_CONTENT 0x00002000 -#define ST_FORCE_DIRS 0x00004000 - -//------------------------------------ -#define ST_WORKING_MASK 0x000f0000 -#define ST_ERROR 0x000C0000 -#define ST_PAUSED 0x00080000 - -//------------------------------------ -#define ST_WAITING_MASK 0x00f00000 -#define ST_WAITING 0x00100000 - - -///////////////////////////////////////////////////////////////////////////// -// priority - -int PriorityToIndex(int nPriority); -int IndexToPriority(int nIndex); -int IndexToPriorityClass(int iIndex); -int PriorityClassToIndex(int iPriority); - -/////////////////////////////////////////////////////////////////////////// -// Exceptions - -#define E_KILL_REQUEST 0x00 -#define E_ERROR 0x01 -#define E_CANCEL 0x02 - -///////////////////////////////////////////////////////////////////// -// CTask - -struct TASK_CREATE_DATA -{ - __int64 *pTasksProcessed; - __int64 *pTasksAll; - - UINT *puiOperationsPending; - LONG *plFinished; - - CCriticalSection* pcs; - - UINT (*pfnTaskProc)(LPVOID pParam); -}; - -// structure for gettings status of a task -struct TASK_DISPLAY_DATA -{ - CFileInfo m_fi; // fi at CurrIndex - int m_iCurrentBufferIndex; - int m_iIndex; - int m_iSize; - - CDestPath* m_pdpDestPath; - CFiltersArray* m_pafFilters; - - UINT m_uiStatus; - DWORD m_dwOsErrorCode; - CString m_strErrorDesc; - - const BUFFERSIZES* m_pbsSizes; - int m_nPriority; - - __int64 m_iProcessedSize; - __int64 m_iSizeAll; - int m_nPercent; - - long m_lTimeElapsed; - - unsigned char m_ucCurrentCopy; - unsigned char m_ucCopies; - - const CString* m_pstrUniqueName; // doesn't change from first setting - - TCHAR m_szStatusText[_MAX_PATH]; -}; - -struct TASK_MINI_DISPLAY_DATA -{ - CFileInfo m_fi; // fi at CurrIndex - - UINT m_uiStatus; - int m_nPercent; -}; - -class CTask -{ -public: - CTask(const TASK_CREATE_DATA *pCreateData); - ~CTask(); -public: - -// Attributes -public: - // m_clipboard - int AddClipboardData(CClipboardEntry* pEntry); - CClipboardEntry* GetClipboardData(int nIndex); - int GetClipboardDataSize(); - int ReplaceClipboardStrings(CString strOld, CString strNew); - - // m_files - int FilesAddDir(const CString strDirName, const CFiltersArray* pFilters, int iSrcIndex, - const bool bRecurse, const bool bIncludeDirs); - int FilesAdd(CFileInfo fi); - CFileInfo FilesGetAt(int nIndex); - CFileInfo FilesGetAtCurrentIndex(); - void FilesRemoveAll(); - int FilesGetSize(); - - // m_nCurrentIndex - void IncreaseCurrentIndex(); - int GetCurrentIndex(); - void SetCurrentIndex(int nIndex); - - // m_strDestPath - void SetDestPath(LPCTSTR lpszPath); - const CDestPath& GetDestPath(); - int GetDestDriveNumber(); - - // m_nStatus - void SetStatus(UINT nStatus, UINT nMask); - UINT GetStatus(UINT nMask=0xffffffff); - - // m_nBufferSize - void SetBufferSizes(const BUFFERSIZES* bsSizes); - const BUFFERSIZES* GetBufferSizes(); - int GetCurrentBufferIndex(); - - // m_pThread - // m_nPriority - int GetPriority(); - void SetPriority(int nPriority); - - // m_nProcessed - void IncreaseProcessedSize(__int64 nSize); - void SetProcessedSize(__int64 nSize); - __int64 GetProcessedSize(); - - // m_nAll - void SetAllSize(__int64 nSize); - __int64 GetAllSize(); - void CalcAllSize(); - - // m_pnTasksProcessed - void IncreaseProcessedTasksSize(__int64 nSize); - void DecreaseProcessedTasksSize(__int64 nSize); - - // m_pnTasksAll - void IncreaseAllTasksSize(__int64 nSize); - void DecreaseAllTasksSize(__int64 nSize); - - // m_bKill - void SetKillFlag(bool bKill=true); - bool GetKillFlag(); - - // m_bKilled - void SetKilledFlag(bool bKilled=true); - bool GetKilledFlag(); - - void KillThread(); - void CleanupAfterKill(); - - // m_strUniqueName - CString GetUniqueName(); - - void Load(CArchive& ar, bool bData); - void Store(LPCTSTR lpszDirectory, bool bData); - - void BeginProcessing(); - - void PauseProcessing(); // pause - void ResumeProcessing(); // resume - bool RetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); // retry - void RestartProcessing(); // from beginning - void CancelProcessing(); // cancel - - void GetSnapshot(TASK_DISPLAY_DATA *pData); - void GetMiniSnapshot(TASK_MINI_DISPLAY_DATA *pData); - - void DeleteProgress(LPCTSTR lpszDirectory); - - void SetOsErrorCode(DWORD dwError, LPCTSTR lpszErrDesc); - void CalcProcessedSize(); - - void DecreaseOperationsPending(UINT uiBy=1); - void IncreaseOperationsPending(UINT uiBy=1); - - bool CanBegin(); - - void UpdateTime(); - - void SetFilters(const CFiltersArray* pFilters); - const CFiltersArray* GetFilters(); - - void SetCopies(unsigned char ucCopies); - unsigned char GetCopies(); - void SetCurrentCopy(unsigned char ucCopy); - unsigned char GetCurrentCopy(); - - CClipboardArray* GetClipboard() { return &m_clipboard; }; - - void SetLastProcessedIndex(int iIndex); - int GetLastProcessedIndex(); - - CString GetLogName(); - - bool GetRequiredFreeSpace(__int64 *pi64Needed, __int64 *pi64Available); - -// Implementation -protected: - CClipboardArray m_clipboard; - CFileInfoArray m_files; - volatile int m_nCurrentIndex; - int m_iLastProcessedIndex; - - CDestPath m_dpDestPath; - - volatile UINT m_nStatus; - - // info about last error - DWORD m_lOsError; - CString m_strErrorDesc; - - // buffers - BUFFERSIZES m_bsSizes; - - CWinThread *m_pThread; - int m_nPriority; - - __int64 m_nProcessed; - __int64 m_nAll; - - __int64 *m_pnTasksProcessed; - __int64 *m_pnTasksAll; - - bool m_bQueued; // has operations pending for this task been increased ? - UINT *m_puiOperationsPending; - - volatile bool m_bKill; - volatile bool m_bKilled; - - // other stuff - CString m_strUniqueName; - - // mask (filter) - CFiltersArray m_afFilters; - - // copiees count - unsigned char m_ucCopies; - unsigned char m_ucCurrentCopy; - - bool m_bSaved; // has the state been saved ('til next modification) - -public: - UINT m_uiResumeInterval; // works only if the thread is off - // time - long m_lTimeElapsed; // store - long m_lLastTime; // not store - - // feedback - int m_iIdentical; - int m_iDestinationLess; - int m_iDestinationGreater; - int m_iMissingInput; - int m_iOutputError; - int m_iMoveFile; - - // ptr to count of currently started tasks - LONG* m_plFinished; - bool m_bForce; // if the continuation of tasks should be independent of limitation - bool m_bContinue; // used by ClipboardMonitorProc - -protected: - CCriticalSection* m_pcs; // protects *m_pnTasksProcessed & *m_pnTasksAll from external array - - UINT (*m_pfnTaskProc)(LPVOID pParam); // external function that processes this task -public: - void SetForceFlag(bool bFlag=true); - bool GetForceFlag(); - void SetContinueFlag(bool bFlag=true); - bool GetContinueFlag(); - -// CLogFile m_log; - icpf::log_file m_log; - CCriticalSection m_cs; // protection for this class -}; - -/////////////////////////////////////////////////////////////////////////// -// CTaskArray - -class CTaskArray : public CArray -{ -public: - CTaskArray() : CArray() { m_uhRange=0; m_uhPosition=0; m_uiOperationsPending=0; m_lFinished=0; }; - ~CTaskArray(); - - void Create(UINT (*pfnTaskProc)(LPVOID pParam)); - - int GetSize( ); - int GetUpperBound( ); - void SetSize( int nNewSize, int nGrowBy = -1 ); - - CTask* GetAt( int nIndex ); - void SetAt( int nIndex, CTask* newElement ); - int Add( CTask* newElement ); - - void RemoveAt( int nIndex, int nCount = 1 ); - void RemoveAll(); - void RemoveAllFinished(); - void RemoveFinished(CTask** pSelTask); - - void SaveData(LPCTSTR lpszDirectory); - void SaveProgress(LPCTSTR lpszDirectory); - void LoadDataProgress(LPCTSTR lpszDirectory); - - void TasksBeginProcessing(); - void TasksPauseProcessing(); - void TasksResumeProcessing(); - void TasksRestartProcessing(); - bool TasksRetryProcessing(bool bOnlyErrors=false, UINT uiInterval=0); - void TasksCancelProcessing(); - - __int64 GetPosition(); - __int64 GetRange(); - int GetPercent(); - - UINT GetOperationsPending(); - void SetLimitOperations(UINT uiLimit); - UINT GetLimitOperations(); - - bool IsFinished(); - -public: - __int64 m_uhRange, m_uhPosition; - - UINT m_uiOperationsPending; // count of current operations - LONG m_lFinished; // count of finished tasks - - CCriticalSection m_cs; - TASK_CREATE_DATA m_tcd; -}; - -/////////////////////////////////////////////////////////////////////////// -// CLIPBOARDMONITORDATA - -struct CLIPBOARDMONITORDATA -{ - HWND m_hwnd; // hwnd to window - CTaskArray *m_pTasks; - - volatile bool bKill, bKilled; -}; - -/////////////////////////////////////////////////////////////////////////// -// CProcessingException - -class CProcessingException -{ -public: - CProcessingException(int iType, CTask* pTask) { m_iType=iType; m_pTask=pTask; m_dwError=0; }; - CProcessingException(int iType, CTask* pTask, UINT uiFmtID, DWORD dwError, ...); - void Cleanup(); - -// Implementation -public: - int m_iType; // kill request, error, ... - CTask* m_pTask; - - CString m_strErrorDesc; - DWORD m_dwError; -}; - -#endif \ No newline at end of file Index: src/ch/Theme Helpers.cpp =================================================================== diff -u -N --- src/ch/Theme Helpers.cpp (revision 0) +++ src/ch/Theme Helpers.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,108 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "Theme Helpers.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +CUxThemeSupport::CUxThemeSupport() +{ + m_hThemesDll=LoadLibrary(_T("UxTheme.dll")); +} + +CUxThemeSupport::~CUxThemeSupport() +{ + if (m_hThemesDll) + FreeLibrary(m_hThemesDll); +} + +HTHEME CUxThemeSupport::OpenThemeData(HWND hwnd, LPCWSTR pszClassList) +{ + ASSERT(m_hThemesDll); + + PFNOPENTHEMEDATA pfnProc=(PFNOPENTHEMEDATA)GetProcAddress(m_hThemesDll, _T("OpenThemeData")); + + if (pfnProc) + return (*pfnProc)(hwnd, pszClassList); + else + return NULL; +} + +HRESULT CUxThemeSupport::CloseThemeData(HTHEME hTheme) +{ + ASSERT(m_hThemesDll); + + PFNCLOSETHEMEDATA pfnProc=(PFNCLOSETHEMEDATA)GetProcAddress(m_hThemesDll, _T("CloseThemeData")); + + if (pfnProc) + return (*pfnProc)(hTheme); + else + return E_UNEXPECTED; +} + +HRESULT CUxThemeSupport::DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect) +{ + ASSERT(m_hThemesDll); + + PFNDRAWTHEMEEDGE pfnProc=(PFNDRAWTHEMEEDGE)GetProcAddress(m_hThemesDll, _T("DrawThemeEdge")); + + if (pfnProc) + return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect); + else + return E_UNEXPECTED; +} + +HRESULT CUxThemeSupport::DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect) +{ + ASSERT(m_hThemesDll); + + PFNDRAWTHEMEBACKGROUND pfnProc=(PFNDRAWTHEMEBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeBackground")); + + if (pfnProc) + return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect); + else + return E_UNEXPECTED; +} + +HRESULT CUxThemeSupport::DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc) +{ + ASSERT(m_hThemesDll); + + PFNDRAWTHEMEPARENTBACKGROUND pfnProc=(PFNDRAWTHEMEPARENTBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeParentBackground")); + + if (pfnProc) + return (*pfnProc)(hwnd, hdc, prc); + else + return E_UNEXPECTED; +} + +BOOL CUxThemeSupport::IsAppThemed() +{ + ASSERT(m_hThemesDll); + + PFNISAPPTHEMED pfnProc=(PFNISAPPTHEMED)GetProcAddress(m_hThemesDll, _T("IsAppThemed")); + + if (pfnProc) + return (*pfnProc)(); + else + return FALSE; +} Index: ch/Theme Helpers.cpp =================================================================== diff -u -N --- ch/Theme Helpers.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Theme Helpers.cpp (revision 0) @@ -1,108 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "Theme Helpers.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -CUxThemeSupport::CUxThemeSupport() -{ - m_hThemesDll=LoadLibrary(_T("UxTheme.dll")); -} - -CUxThemeSupport::~CUxThemeSupport() -{ - if (m_hThemesDll) - FreeLibrary(m_hThemesDll); -} - -HTHEME CUxThemeSupport::OpenThemeData(HWND hwnd, LPCWSTR pszClassList) -{ - ASSERT(m_hThemesDll); - - PFNOPENTHEMEDATA pfnProc=(PFNOPENTHEMEDATA)GetProcAddress(m_hThemesDll, _T("OpenThemeData")); - - if (pfnProc) - return (*pfnProc)(hwnd, pszClassList); - else - return NULL; -} - -HRESULT CUxThemeSupport::CloseThemeData(HTHEME hTheme) -{ - ASSERT(m_hThemesDll); - - PFNCLOSETHEMEDATA pfnProc=(PFNCLOSETHEMEDATA)GetProcAddress(m_hThemesDll, _T("CloseThemeData")); - - if (pfnProc) - return (*pfnProc)(hTheme); - else - return E_UNEXPECTED; -} - -HRESULT CUxThemeSupport::DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect) -{ - ASSERT(m_hThemesDll); - - PFNDRAWTHEMEEDGE pfnProc=(PFNDRAWTHEMEEDGE)GetProcAddress(m_hThemesDll, _T("DrawThemeEdge")); - - if (pfnProc) - return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pDestRect, uEdge, uFlags, pContentRect); - else - return E_UNEXPECTED; -} - -HRESULT CUxThemeSupport::DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect) -{ - ASSERT(m_hThemesDll); - - PFNDRAWTHEMEBACKGROUND pfnProc=(PFNDRAWTHEMEBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeBackground")); - - if (pfnProc) - return (*pfnProc)(hTheme, hdc, iPartId, iStateId, pRect, pClipRect); - else - return E_UNEXPECTED; -} - -HRESULT CUxThemeSupport::DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc) -{ - ASSERT(m_hThemesDll); - - PFNDRAWTHEMEPARENTBACKGROUND pfnProc=(PFNDRAWTHEMEPARENTBACKGROUND)GetProcAddress(m_hThemesDll, _T("DrawThemeParentBackground")); - - if (pfnProc) - return (*pfnProc)(hwnd, hdc, prc); - else - return E_UNEXPECTED; -} - -BOOL CUxThemeSupport::IsAppThemed() -{ - ASSERT(m_hThemesDll); - - PFNISAPPTHEMED pfnProc=(PFNISAPPTHEMED)GetProcAddress(m_hThemesDll, _T("IsAppThemed")); - - if (pfnProc) - return (*pfnProc)(); - else - return FALSE; -} Index: src/ch/Theme Helpers.h =================================================================== diff -u -N --- src/ch/Theme Helpers.h (revision 0) +++ src/ch/Theme Helpers.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,173 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __THEME_SUPPORT__ +#define __THEME_SUPPORT__ + +// definicja HTHEME - podobna do tej z UxTheme...h +#ifndef HTHEME +#define HTHEME HANDLE +#endif + +typedef HTHEME(_stdcall *PFNOPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList); +typedef HRESULT(_stdcall *PFNCLOSETHEMEDATA)(HTHEME hTheme); +typedef HRESULT(_stdcall *PFNDRAWTHEMEEDGE)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect); +typedef HRESULT(_stdcall *PFNDRAWTHEMEBACKGROUND)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect); +typedef HRESULT(_stdcall *PFNDRAWTHEMEPARENTBACKGROUND)(HWND hwnd, HDC hdc, RECT* prc); +typedef BOOL(_stdcall *PFNISAPPTHEMED)(); + +class CUxThemeSupport +{ +public: + CUxThemeSupport(); + ~CUxThemeSupport(); + + HTHEME OpenThemeData(HWND hwnd, LPCWSTR pszClassList); + HRESULT CloseThemeData(HTHEME hTheme); + + bool IsThemeSupported() { return m_hThemesDll != NULL; }; + BOOL IsAppThemed(); + + HRESULT DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect); + + HRESULT DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); + HRESULT DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc); + +/* HRESULT DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect); + +THEMEAPI GetThemeBackgroundContentRect(HTHEME hTheme, OPTIONAL HDC hdc, + int iPartId, int iStateId, const RECT *pBoundingRect, + OUT RECT *pContentRect); + +THEMEAPI GetThemeBackgroundExtent(HTHEME hTheme, OPTIONAL HDC hdc, + int iPartId, int iStateId, const RECT *pContentRect, + OUT RECT *pExtentRect); + +THEMEAPI GetThemeTextMetrics(HTHEME hTheme, OPTIONAL HDC hdc, + int iPartId, int iStateId, OUT TEXTMETRIC* ptm); + +THEMEAPI GetThemeBackgroundRegion(HTHEME hTheme, OPTIONAL HDC hdc, + int iPartId, int iStateId, const RECT *pRect, OUT HRGN *pRegion); + +THEMEAPI HitTestThemeBackground(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, + int iStateId, DWORD dwOptions, const RECT *pRect, OPTIONAL HRGN hrgn, + POINT ptTest, OUT WORD *pwHitTestCode); + +THEMEAPI DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, + const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect); + +THEMEAPI DrawThemeIcon(HTHEME hTheme, HDC hdc, int iPartId, + int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex); + +THEMEAPI_(BOOL) IsThemePartDefined(HTHEME hTheme, int iPartId, + int iStateId); + +THEMEAPI_(BOOL) IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, + int iPartId, int iStateId); + +THEMEAPI GetThemeColor(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT COLORREF *pColor); + +THEMEAPI GetThemeMetric(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, + int iStateId, int iPropId, OUT int *piVal); + +THEMEAPI GetThemeString(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars); + +THEMEAPI GetThemeBool(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT BOOL *pfVal); + +THEMEAPI GetThemeInt(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT int *piVal); + +THEMEAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT int *piVal); + +THEMEAPI GetThemePosition(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT POINT *pPoint); + +THEMEAPI GetThemeFont(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, + int iStateId, int iPropId, OUT LOGFONT *pFont); + +THEMEAPI GetThemeRect(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT RECT *pRect); + +THEMEAPI GetThemeMargins(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, + int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins); + +THEMEAPI GetThemeIntList(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT INTLIST *pIntList); + +THEMEAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin); + +THEMEAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, + LPCWSTR pszSubIdList); + +THEMEAPI GetThemeFilename(HTHEME hTheme, int iPartId, + int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars); + +THEMEAPI_(COLORREF) GetThemeSysColor(HTHEME hTheme, int iColorId); + +THEMEAPI_(HBRUSH) GetThemeSysColorBrush(HTHEME hTheme, int iColorId); + +THEMEAPI_(BOOL) GetThemeSysBool(HTHEME hTheme, int iBoolId); + +THEMEAPI_(int) GetThemeSysSize(HTHEME hTheme, int iSizeId); + +THEMEAPI GetThemeSysFont(HTHEME hTheme, int iFontId, OUT LOGFONT *plf); + +THEMEAPI GetThemeSysString(HTHEME hTheme, int iStringId, + OUT LPWSTR pszStringBuff, int cchMaxStringChars); + +THEMEAPI GetThemeSysInt(HTHEME hTheme, int iIntId, int *piValue); + +THEMEAPI_(BOOL) IsThemeActive(); + + +THEMEAPI_(HTHEME) GetWindowTheme(HWND hwnd); + + +THEMEAPI EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags); + + +THEMEAPI_(BOOL) IsThemeDialogTextureEnabled(HWND hwnd); + +THEMEAPI_(DWORD) GetThemeAppProperties(); + +THEMEAPI_(void) SetThemeAppProperties(DWORD dwFlags); + +THEMEAPI GetCurrentThemeName( + OUT LPWSTR pszThemeFileName, int cchMaxNameChars, + OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, + OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars); + +THEMEAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName, + LPCWSTR pszPropertyName, OUT LPWSTR pszValueBuff, int cchMaxValChars); + +THEMEAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, OPTIONAL RECT* prc); + +THEMEAPI EnableTheming(BOOL fEnable); +*/ +protected: + + HMODULE m_hThemesDll; +}; + +#endif Index: ch/Theme Helpers.h =================================================================== diff -u -N --- ch/Theme Helpers.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/Theme Helpers.h (revision 0) @@ -1,173 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __THEME_SUPPORT__ -#define __THEME_SUPPORT__ - -// definicja HTHEME - podobna do tej z UxTheme...h -#ifndef HTHEME -#define HTHEME HANDLE -#endif - -typedef HTHEME(_stdcall *PFNOPENTHEMEDATA)(HWND hwnd, LPCWSTR pszClassList); -typedef HRESULT(_stdcall *PFNCLOSETHEMEDATA)(HTHEME hTheme); -typedef HRESULT(_stdcall *PFNDRAWTHEMEEDGE)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect); -typedef HRESULT(_stdcall *PFNDRAWTHEMEBACKGROUND)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect); -typedef HRESULT(_stdcall *PFNDRAWTHEMEPARENTBACKGROUND)(HWND hwnd, HDC hdc, RECT* prc); -typedef BOOL(_stdcall *PFNISAPPTHEMED)(); - -class CUxThemeSupport -{ -public: - CUxThemeSupport(); - ~CUxThemeSupport(); - - HTHEME OpenThemeData(HWND hwnd, LPCWSTR pszClassList); - HRESULT CloseThemeData(HTHEME hTheme); - - bool IsThemeSupported() { return m_hThemesDll != NULL; }; - BOOL IsAppThemed(); - - HRESULT DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pDestRect, UINT uEdge, UINT uFlags, RECT* pContentRect); - - HRESULT DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect); - HRESULT DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT* prc); - -/* HRESULT DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect); - -THEMEAPI GetThemeBackgroundContentRect(HTHEME hTheme, OPTIONAL HDC hdc, - int iPartId, int iStateId, const RECT *pBoundingRect, - OUT RECT *pContentRect); - -THEMEAPI GetThemeBackgroundExtent(HTHEME hTheme, OPTIONAL HDC hdc, - int iPartId, int iStateId, const RECT *pContentRect, - OUT RECT *pExtentRect); - -THEMEAPI GetThemeTextMetrics(HTHEME hTheme, OPTIONAL HDC hdc, - int iPartId, int iStateId, OUT TEXTMETRIC* ptm); - -THEMEAPI GetThemeBackgroundRegion(HTHEME hTheme, OPTIONAL HDC hdc, - int iPartId, int iStateId, const RECT *pRect, OUT HRGN *pRegion); - -THEMEAPI HitTestThemeBackground(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, - int iStateId, DWORD dwOptions, const RECT *pRect, OPTIONAL HRGN hrgn, - POINT ptTest, OUT WORD *pwHitTestCode); - -THEMEAPI DrawThemeEdge(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, - const RECT *pDestRect, UINT uEdge, UINT uFlags, OPTIONAL OUT RECT *pContentRect); - -THEMEAPI DrawThemeIcon(HTHEME hTheme, HDC hdc, int iPartId, - int iStateId, const RECT *pRect, HIMAGELIST himl, int iImageIndex); - -THEMEAPI_(BOOL) IsThemePartDefined(HTHEME hTheme, int iPartId, - int iStateId); - -THEMEAPI_(BOOL) IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, - int iPartId, int iStateId); - -THEMEAPI GetThemeColor(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT COLORREF *pColor); - -THEMEAPI GetThemeMetric(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, - int iStateId, int iPropId, OUT int *piVal); - -THEMEAPI GetThemeString(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars); - -THEMEAPI GetThemeBool(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT BOOL *pfVal); - -THEMEAPI GetThemeInt(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT int *piVal); - -THEMEAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT int *piVal); - -THEMEAPI GetThemePosition(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT POINT *pPoint); - -THEMEAPI GetThemeFont(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, - int iStateId, int iPropId, OUT LOGFONT *pFont); - -THEMEAPI GetThemeRect(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT RECT *pRect); - -THEMEAPI GetThemeMargins(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, - int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins); - -THEMEAPI GetThemeIntList(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT INTLIST *pIntList); - -THEMEAPI GetThemePropertyOrigin(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin); - -THEMEAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName, - LPCWSTR pszSubIdList); - -THEMEAPI GetThemeFilename(HTHEME hTheme, int iPartId, - int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars); - -THEMEAPI_(COLORREF) GetThemeSysColor(HTHEME hTheme, int iColorId); - -THEMEAPI_(HBRUSH) GetThemeSysColorBrush(HTHEME hTheme, int iColorId); - -THEMEAPI_(BOOL) GetThemeSysBool(HTHEME hTheme, int iBoolId); - -THEMEAPI_(int) GetThemeSysSize(HTHEME hTheme, int iSizeId); - -THEMEAPI GetThemeSysFont(HTHEME hTheme, int iFontId, OUT LOGFONT *plf); - -THEMEAPI GetThemeSysString(HTHEME hTheme, int iStringId, - OUT LPWSTR pszStringBuff, int cchMaxStringChars); - -THEMEAPI GetThemeSysInt(HTHEME hTheme, int iIntId, int *piValue); - -THEMEAPI_(BOOL) IsThemeActive(); - - -THEMEAPI_(HTHEME) GetWindowTheme(HWND hwnd); - - -THEMEAPI EnableThemeDialogTexture(HWND hwnd, DWORD dwFlags); - - -THEMEAPI_(BOOL) IsThemeDialogTextureEnabled(HWND hwnd); - -THEMEAPI_(DWORD) GetThemeAppProperties(); - -THEMEAPI_(void) SetThemeAppProperties(DWORD dwFlags); - -THEMEAPI GetCurrentThemeName( - OUT LPWSTR pszThemeFileName, int cchMaxNameChars, - OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, - OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars); - -THEMEAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName, - LPCWSTR pszPropertyName, OUT LPWSTR pszValueBuff, int cchMaxValChars); - -THEMEAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, OPTIONAL RECT* prc); - -THEMEAPI EnableTheming(BOOL fEnable); -*/ -protected: - - HMODULE m_hThemesDll; -}; - -#endif Index: src/ch/ThemedButton.cpp =================================================================== diff -u -N --- src/ch/ThemedButton.cpp (revision 0) +++ src/ch/ThemedButton.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,142 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "ThemedButton.h" +#include "MemDC.h" +#include "Theme helpers.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CThemedButton + +// undefine this if use some internal windows files +#define TP_BUTTON 1 +#define TS_NORMAL 1 +#define TS_HOT 2 +#define TS_PRESSED 3 +#define TS_DISABLED 4 +#define TS_CHECKED 5 +#define TS_HOTCHECKED 6 + +CThemedButton::CThemedButton() +{ + m_bHovering=false; + m_iIndex=-1; + m_pilList=NULL; +} + +CThemedButton::~CThemedButton() +{ +} + + +BEGIN_MESSAGE_MAP(CThemedButton, CButton) + //{{AFX_MSG_MAP(CThemedButton) + ON_WM_MOUSEMOVE() + ON_WM_ERASEBKGND() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CThemedButton message handlers + +void CThemedButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) +{ + CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); + CMemDC memdc(pDC, &lpDrawItemStruct->rcItem); + + bool bPushed=(lpDrawItemStruct->itemState & ODS_SELECTED); + CRect rcItem=lpDrawItemStruct->rcItem; + + // draw button's frame + CUxThemeSupport uxTheme; + if (uxTheme.IsThemeSupported() && uxTheme.IsAppThemed()) + { + HTHEME ht=uxTheme.OpenThemeData(lpDrawItemStruct->hwndItem, L"TOOLBAR"); + + uxTheme.DrawThemeParentBackground(lpDrawItemStruct->hwndItem, memdc.GetSafeHdc(), &rcItem); + uxTheme.DrawThemeBackground(ht, memdc.GetSafeHdc(), TP_BUTTON, bPushed ? TS_PRESSED : (m_bHovering ? TS_HOT : TS_NORMAL), &rcItem, NULL); + + uxTheme.CloseThemeData(ht); + } + else + DrawFrameControl(memdc.GetSafeHdc(), &rcItem, DFC_BUTTON, DFCS_ADJUSTRECT | DFCS_BUTTONPUSH | (bPushed ? DFCS_PUSHED : 0)); + + ASSERT(m_pilList); // make sure the image list exist + + int cx=16, cy=16; + ImageList_GetIconSize(m_pilList->m_hImageList, &cx, &cy); + + CRect rcBtn; + GetClientRect(&rcBtn); + m_pilList->Draw(&memdc, m_iIndex, CPoint( ((rcBtn.Width()-cx)/2)+(bPushed ? 1 : 0), (rcBtn.Height()-cy)/2+(bPushed ? 1 : 0)), ILD_TRANSPARENT); +} + +void CThemedButton::OnMouseMove(UINT nFlags, CPoint point) +{ + if (!m_bHovering) + { + TRACKMOUSEEVENT tme; + tme.cbSize=sizeof(TRACKMOUSEEVENT); + tme.dwFlags=TME_LEAVE; + tme.dwHoverTime=0; + tme.hwndTrack=this->GetSafeHwnd(); + + ::_TrackMouseEvent(&tme); + + m_bHovering=true; + Invalidate(); + } + + CButton::OnMouseMove(nFlags, point); +} + +LRESULT CThemedButton::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_LBUTTONDBLCLK: + message=WM_LBUTTONDOWN; + break; + case WM_MOUSELEAVE: + m_bHovering=false; + Invalidate(); + break; + } + + return CButton::WindowProc(message, wParam, lParam); +} + +BOOL CThemedButton::OnEraseBkgnd(CDC* /*pDC*/) +{ + return FALSE;/*CButton::OnEraseBkgnd(pDC);*/ +} + +void CThemedButton::SetImage(CImageList *pImgList, int iIndex) +{ + m_pilList=pImgList; + m_iIndex=iIndex; +} Index: ch/ThemedButton.cpp =================================================================== diff -u -N --- ch/ThemedButton.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ThemedButton.cpp (revision 0) @@ -1,142 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "ThemedButton.h" -#include "MemDC.h" -#include "Theme helpers.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CThemedButton - -// undefine this if use some internal windows files -#define TP_BUTTON 1 -#define TS_NORMAL 1 -#define TS_HOT 2 -#define TS_PRESSED 3 -#define TS_DISABLED 4 -#define TS_CHECKED 5 -#define TS_HOTCHECKED 6 - -CThemedButton::CThemedButton() -{ - m_bHovering=false; - m_iIndex=-1; - m_pilList=NULL; -} - -CThemedButton::~CThemedButton() -{ -} - - -BEGIN_MESSAGE_MAP(CThemedButton, CButton) - //{{AFX_MSG_MAP(CThemedButton) - ON_WM_MOUSEMOVE() - ON_WM_ERASEBKGND() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CThemedButton message handlers - -void CThemedButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) -{ - CDC* pDC=CDC::FromHandle(lpDrawItemStruct->hDC); - CMemDC memdc(pDC, &lpDrawItemStruct->rcItem); - - bool bPushed=(lpDrawItemStruct->itemState & ODS_SELECTED); - CRect rcItem=lpDrawItemStruct->rcItem; - - // draw button's frame - CUxThemeSupport uxTheme; - if (uxTheme.IsThemeSupported() && uxTheme.IsAppThemed()) - { - HTHEME ht=uxTheme.OpenThemeData(lpDrawItemStruct->hwndItem, L"TOOLBAR"); - - uxTheme.DrawThemeParentBackground(lpDrawItemStruct->hwndItem, memdc.GetSafeHdc(), &rcItem); - uxTheme.DrawThemeBackground(ht, memdc.GetSafeHdc(), TP_BUTTON, bPushed ? TS_PRESSED : (m_bHovering ? TS_HOT : TS_NORMAL), &rcItem, NULL); - - uxTheme.CloseThemeData(ht); - } - else - DrawFrameControl(memdc.GetSafeHdc(), &rcItem, DFC_BUTTON, DFCS_ADJUSTRECT | DFCS_BUTTONPUSH | (bPushed ? DFCS_PUSHED : 0)); - - ASSERT(m_pilList); // make sure the image list exist - - int cx=16, cy=16; - ImageList_GetIconSize(m_pilList->m_hImageList, &cx, &cy); - - CRect rcBtn; - GetClientRect(&rcBtn); - m_pilList->Draw(&memdc, m_iIndex, CPoint( ((rcBtn.Width()-cx)/2)+(bPushed ? 1 : 0), (rcBtn.Height()-cy)/2+(bPushed ? 1 : 0)), ILD_TRANSPARENT); -} - -void CThemedButton::OnMouseMove(UINT nFlags, CPoint point) -{ - if (!m_bHovering) - { - TRACKMOUSEEVENT tme; - tme.cbSize=sizeof(TRACKMOUSEEVENT); - tme.dwFlags=TME_LEAVE; - tme.dwHoverTime=0; - tme.hwndTrack=this->GetSafeHwnd(); - - ::_TrackMouseEvent(&tme); - - m_bHovering=true; - Invalidate(); - } - - CButton::OnMouseMove(nFlags, point); -} - -LRESULT CThemedButton::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch(message) - { - case WM_LBUTTONDBLCLK: - message=WM_LBUTTONDOWN; - break; - case WM_MOUSELEAVE: - m_bHovering=false; - Invalidate(); - break; - } - - return CButton::WindowProc(message, wParam, lParam); -} - -BOOL CThemedButton::OnEraseBkgnd(CDC* /*pDC*/) -{ - return FALSE;/*CButton::OnEraseBkgnd(pDC);*/ -} - -void CThemedButton::SetImage(CImageList *pImgList, int iIndex) -{ - m_pilList=pImgList; - m_iIndex=iIndex; -} Index: src/ch/ThemedButton.h =================================================================== diff -u -N --- src/ch/ThemedButton.h (revision 0) +++ src/ch/ThemedButton.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,72 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __THEMEDBUTTON_H__ +#define __THEMEDBUTTON_H__ + +///////////////////////////////////////////////////////////////////////////// +// CThemedButton window + +class CThemedButton : public CButton +{ +// Construction +public: + CThemedButton(); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CThemedButton) + public: + virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + protected: + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + void SetImage(CImageList *pImgList, int iIndex); + virtual ~CThemedButton(); + + // Generated message map functions +protected: + bool m_bHovering; + + CImageList* m_pilList; + int m_iIndex; + + //{{AFX_MSG(CThemedButton) + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/ThemedButton.h =================================================================== diff -u -N --- ch/ThemedButton.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/ThemedButton.h (revision 0) @@ -1,72 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __THEMEDBUTTON_H__ -#define __THEMEDBUTTON_H__ - -///////////////////////////////////////////////////////////////////////////// -// CThemedButton window - -class CThemedButton : public CButton -{ -// Construction -public: - CThemedButton(); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CThemedButton) - public: - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - protected: - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -public: - void SetImage(CImageList *pImgList, int iIndex); - virtual ~CThemedButton(); - - // Generated message map functions -protected: - bool m_bHovering; - - CImageList* m_pilList; - int m_iIndex; - - //{{AFX_MSG(CThemedButton) - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/TrayIcon.cpp =================================================================== diff -u -N --- src/ch/TrayIcon.cpp (revision 0) +++ src/ch/TrayIcon.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,162 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "TrayIcon.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +///////////////////////////////////////////////////////////////////////////// +// CTrayIcon construction/creation/destruction + +CTrayIcon::CTrayIcon() +{ + memset(&m_tnd, 0, sizeof(m_tnd)); + m_bHidden=false; +} + +CTrayIcon::CTrayIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID) +{ + CreateIcon(hWnd, uClbMsg, szText, hIcon, uiID); + m_bHidden=false; +} + +bool CTrayIcon::CreateIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID) +{ + _ASSERT(hWnd); + + // load up the NOTIFYICONDATA structure + m_tnd.cbSize=sizeof(NOTIFYICONDATA); + m_tnd.hWnd=hWnd; + m_tnd.uID=uiID; + m_tnd.hIcon=hIcon; + m_tnd.uFlags=NIF_MESSAGE | NIF_ICON | NIF_TIP; + m_tnd.uCallbackMessage=uClbMsg; + _tcsncpy(m_tnd.szTip, szText, 64); + size_t tLen=_tcslen(szText); + if (tLen < 64) + m_tnd.szTip[tLen]=_T('\0'); + else + m_tnd.szTip[63]=_T('\0'); + + // Set the tray icon + return Shell_NotifyIcon(NIM_ADD, &m_tnd) != FALSE; +} + +CTrayIcon::~CTrayIcon() +{ + RemoveIcon(); +} + + +///////////////////////////////////////////////////////////////////////////// +// CTrayIcon icon manipulation + +void CTrayIcon::MoveToRight() +{ + HideIcon(); + ShowIcon(); +} + +void CTrayIcon::RemoveIcon() +{ + m_tnd.uFlags=0; + Shell_NotifyIcon(NIM_DELETE, &m_tnd); +} + +void CTrayIcon::HideIcon() +{ + if (!m_bHidden) + { + m_tnd.uFlags=NIF_ICON; + Shell_NotifyIcon (NIM_DELETE, &m_tnd); + m_bHidden=true; + } +} + +bool CTrayIcon::ShowIcon() +{ + if (m_bHidden) + { + m_tnd.uFlags=NIF_MESSAGE | NIF_ICON | NIF_TIP; + m_bHidden=false; + return Shell_NotifyIcon(NIM_ADD, &m_tnd) != FALSE; + } + return true; +} + +bool CTrayIcon::SetIcon(HICON hIcon) +{ + m_tnd.uFlags=NIF_ICON; + m_tnd.hIcon=hIcon; + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != 0; +} + +bool CTrayIcon::SetStandardIcon(LPCTSTR lpIconName) +{ + HICON hIcon=::LoadIcon(NULL, lpIconName); + return SetIcon(hIcon); +} + +HICON CTrayIcon::GetIcon() const +{ + return m_tnd.hIcon; +} + +///////////////////////////////////////////////////////////////////////////// +// CTrayIcon tooltip text manipulation + +bool CTrayIcon::SetTooltipText(LPCTSTR pszTip) +{ + m_tnd.uFlags = NIF_TIP; + _tcsncpy(m_tnd.szTip, pszTip, 64); + size_t tLen=_tcslen(pszTip); + if (tLen < 64) + m_tnd.szTip[tLen]=_T('\0'); + else + m_tnd.szTip[63]=_T('\0'); + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != FALSE; +} + +void CTrayIcon::GetTooltipText(LPTSTR pszText) const +{ + _tcscpy(pszText, m_tnd.szTip); +} + +///////////////////////////////////////////////////////////////////////////// +// CTrayIcon notification window stuff + +bool CTrayIcon::SetNotificationWnd(HWND hWnd) +{ + _ASSERT(hWnd); + + m_tnd.hWnd=hWnd; + m_tnd.uFlags=0; + + return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != FALSE; +} + +HWND CTrayIcon::GetNotificationWnd() const +{ + return m_tnd.hWnd; +} \ No newline at end of file Index: ch/TrayIcon.cpp =================================================================== diff -u -N --- ch/TrayIcon.cpp (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/TrayIcon.cpp (revision 0) @@ -1,162 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "TrayIcon.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -///////////////////////////////////////////////////////////////////////////// -// CTrayIcon construction/creation/destruction - -CTrayIcon::CTrayIcon() -{ - memset(&m_tnd, 0, sizeof(m_tnd)); - m_bHidden=false; -} - -CTrayIcon::CTrayIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID) -{ - CreateIcon(hWnd, uClbMsg, szText, hIcon, uiID); - m_bHidden=false; -} - -bool CTrayIcon::CreateIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID) -{ - _ASSERT(hWnd); - - // load up the NOTIFYICONDATA structure - m_tnd.cbSize=sizeof(NOTIFYICONDATA); - m_tnd.hWnd=hWnd; - m_tnd.uID=uiID; - m_tnd.hIcon=hIcon; - m_tnd.uFlags=NIF_MESSAGE | NIF_ICON | NIF_TIP; - m_tnd.uCallbackMessage=uClbMsg; - _tcsncpy(m_tnd.szTip, szText, 64); - size_t tLen=_tcslen(szText); - if (tLen < 64) - m_tnd.szTip[tLen]=_T('\0'); - else - m_tnd.szTip[63]=_T('\0'); - - // Set the tray icon - return Shell_NotifyIcon(NIM_ADD, &m_tnd) != FALSE; -} - -CTrayIcon::~CTrayIcon() -{ - RemoveIcon(); -} - - -///////////////////////////////////////////////////////////////////////////// -// CTrayIcon icon manipulation - -void CTrayIcon::MoveToRight() -{ - HideIcon(); - ShowIcon(); -} - -void CTrayIcon::RemoveIcon() -{ - m_tnd.uFlags=0; - Shell_NotifyIcon(NIM_DELETE, &m_tnd); -} - -void CTrayIcon::HideIcon() -{ - if (!m_bHidden) - { - m_tnd.uFlags=NIF_ICON; - Shell_NotifyIcon (NIM_DELETE, &m_tnd); - m_bHidden=true; - } -} - -bool CTrayIcon::ShowIcon() -{ - if (m_bHidden) - { - m_tnd.uFlags=NIF_MESSAGE | NIF_ICON | NIF_TIP; - m_bHidden=false; - return Shell_NotifyIcon(NIM_ADD, &m_tnd) != FALSE; - } - return true; -} - -bool CTrayIcon::SetIcon(HICON hIcon) -{ - m_tnd.uFlags=NIF_ICON; - m_tnd.hIcon=hIcon; - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != 0; -} - -bool CTrayIcon::SetStandardIcon(LPCTSTR lpIconName) -{ - HICON hIcon=::LoadIcon(NULL, lpIconName); - return SetIcon(hIcon); -} - -HICON CTrayIcon::GetIcon() const -{ - return m_tnd.hIcon; -} - -///////////////////////////////////////////////////////////////////////////// -// CTrayIcon tooltip text manipulation - -bool CTrayIcon::SetTooltipText(LPCTSTR pszTip) -{ - m_tnd.uFlags = NIF_TIP; - _tcsncpy(m_tnd.szTip, pszTip, 64); - size_t tLen=_tcslen(pszTip); - if (tLen < 64) - m_tnd.szTip[tLen]=_T('\0'); - else - m_tnd.szTip[63]=_T('\0'); - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != FALSE; -} - -void CTrayIcon::GetTooltipText(LPTSTR pszText) const -{ - _tcscpy(pszText, m_tnd.szTip); -} - -///////////////////////////////////////////////////////////////////////////// -// CTrayIcon notification window stuff - -bool CTrayIcon::SetNotificationWnd(HWND hWnd) -{ - _ASSERT(hWnd); - - m_tnd.hWnd=hWnd; - m_tnd.uFlags=0; - - return Shell_NotifyIcon(NIM_MODIFY, &m_tnd) != FALSE; -} - -HWND CTrayIcon::GetNotificationWnd() const -{ - return m_tnd.hWnd; -} \ No newline at end of file Index: src/ch/TrayIcon.h =================================================================== diff -u -N --- src/ch/TrayIcon.h (revision 0) +++ src/ch/TrayIcon.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,61 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +/* Code based on code written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au) */ + +#ifndef __TRAYICON_H__ +#define __TRAYICON_H__ + +#include "shellapi.h" + +class CTrayIcon +{ +public: +// construction/destruction + CTrayIcon(); + CTrayIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID); + ~CTrayIcon(); + +//creation + bool CreateIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID); + +// ToolTip text handleing + bool SetTooltipText(LPCTSTR pszTip); + void GetTooltipText(LPTSTR pszText) const; + +// Icon handling + bool SetIcon(HICON hIcon); + bool SetStandardIcon(LPCTSTR lpIconName); + HICON GetIcon() const; + void HideIcon(); + bool ShowIcon(); + void RemoveIcon(); + void MoveToRight(); + +// Notifications + bool SetNotificationWnd(HWND hWnd); + HWND GetNotificationWnd() const; + +// Attribs +public: + bool m_bHidden; // Has the icon been hidden? + NOTIFYICONDATA m_tnd; +}; + +#endif \ No newline at end of file Index: ch/TrayIcon.h =================================================================== diff -u -N --- ch/TrayIcon.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/TrayIcon.h (revision 0) @@ -1,61 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -/* Code based on code written by Chris Maunder (Chris.Maunder@cbr.clw.csiro.au) */ - -#ifndef __TRAYICON_H__ -#define __TRAYICON_H__ - -#include "shellapi.h" - -class CTrayIcon -{ -public: -// construction/destruction - CTrayIcon(); - CTrayIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID); - ~CTrayIcon(); - -//creation - bool CreateIcon(HWND hWnd, UINT uClbMsg, LPCTSTR szText, HICON hIcon, UINT uiID); - -// ToolTip text handleing - bool SetTooltipText(LPCTSTR pszTip); - void GetTooltipText(LPTSTR pszText) const; - -// Icon handling - bool SetIcon(HICON hIcon); - bool SetStandardIcon(LPCTSTR lpIconName); - HICON GetIcon() const; - void HideIcon(); - bool ShowIcon(); - void RemoveIcon(); - void MoveToRight(); - -// Notifications - bool SetNotificationWnd(HWND hWnd); - HWND GetNotificationWnd() const; - -// Attribs -public: - bool m_bHidden; // Has the icon been hidden? - NOTIFYICONDATA m_tnd; -}; - -#endif \ No newline at end of file Index: src/ch/af_defs.h =================================================================== diff -u -N --- src/ch/af_defs.h (revision 0) +++ src/ch/af_defs.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,28 @@ +#ifndef __AFMESSAGES_H__ +#define __AFMESSAGES_H__ + +// messages used by the app framework's modules +#define WM_TRAYNOTIFY (WM_USER+0) +#define WM_CFGNOTIFY (WM_USER+1) +#define WM_RMNOTIFY (WM_USER+2) + +// message routing +// types of routing +// sends a message everywhere it could be sent (hwnds, registered modules, ...) +#define ROT_EVERYWHERE 0x0000000000000000 +// sends a message to all hwnds in an app +#define ROT_HWNDS 0x0100000000000000 +// sends a message to all registered modules +#define ROT_REGISTERED 0x0200000000000000 +// sends a message to one excact module +#define ROT_EXACT 0x0300000000000000 + +// internal modules +#define IMID_CONFIGMANAGER 0x0001000000000000 +#define IMID_RESOURCEMANAGER 0x0001000000000001 +#define IMID_LOGFILE 0x0001000000000002 + +// callbacks +typedef (*PFNNOTIFYCALLBACK)(ULONGLONG, UINT, WPARAM, LPARAM); + +#endif \ No newline at end of file Index: ch/af_defs.h =================================================================== diff -u -N --- ch/af_defs.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/af_defs.h (revision 0) @@ -1,28 +0,0 @@ -#ifndef __AFMESSAGES_H__ -#define __AFMESSAGES_H__ - -// messages used by the app framework's modules -#define WM_TRAYNOTIFY (WM_USER+0) -#define WM_CFGNOTIFY (WM_USER+1) -#define WM_RMNOTIFY (WM_USER+2) - -// message routing -// types of routing -// sends a message everywhere it could be sent (hwnds, registered modules, ...) -#define ROT_EVERYWHERE 0x0000000000000000 -// sends a message to all hwnds in an app -#define ROT_HWNDS 0x0100000000000000 -// sends a message to all registered modules -#define ROT_REGISTERED 0x0200000000000000 -// sends a message to one excact module -#define ROT_EXACT 0x0300000000000000 - -// internal modules -#define IMID_CONFIGMANAGER 0x0001000000000000 -#define IMID_RESOURCEMANAGER 0x0001000000000001 -#define IMID_LOGFILE 0x0001000000000002 - -// callbacks -typedef (*PFNNOTIFYCALLBACK)(ULONGLONG, UINT, WPARAM, LPARAM); - -#endif \ No newline at end of file Index: src/ch/btnIDs.h =================================================================== diff -u -N --- src/ch/btnIDs.h (revision 0) +++ src/ch/btnIDs.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,36 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __BUTTON_IDENTIFIERS_H__ +#define __BUTTON_IDENTIFIERS_H__ + +#define ID_IGNORE 0x10 +#define ID_IGNOREALL 0x11 +#define ID_COPYREST 0x12 +#define ID_COPYRESTALL 0x13 +#define ID_RECOPY 0x14 +#define ID_RECOPYALL 0x15 +#define ID_REFRESHENTRY 0x16 +#define ID_REFRESHENTRYALL 0x17 +#define ID_WAIT 0x18 +#define ID_RETRY 0x19 +#define ID_YESALL 0x1a +#define ID_NOALL 0x1b + +#endif \ No newline at end of file Index: ch/btnIDs.h =================================================================== diff -u -N --- ch/btnIDs.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/btnIDs.h (revision 0) @@ -1,36 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __BUTTON_IDENTIFIERS_H__ -#define __BUTTON_IDENTIFIERS_H__ - -#define ID_IGNORE 0x10 -#define ID_IGNOREALL 0x11 -#define ID_COPYREST 0x12 -#define ID_COPYRESTALL 0x13 -#define ID_RECOPY 0x14 -#define ID_RECOPYALL 0x15 -#define ID_REFRESHENTRY 0x16 -#define ID_REFRESHENTRYALL 0x17 -#define ID_WAIT 0x18 -#define ID_RETRY 0x19 -#define ID_YESALL 0x1a -#define ID_NOALL 0x1b - -#endif \ No newline at end of file Index: src/ch/ch.cpp =================================================================== diff -u -N --- src/ch/ch.cpp (revision 0) +++ src/ch/ch.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,364 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" +#include "COPY HANDLER.h" + +#include "CfgProperties.h" +#include "MainWnd.h" +#include "..\common\ipcstructs.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CCopyHandlerApp + +BEGIN_MESSAGE_MAP(CCopyHandlerApp, CWinApp) + //{{AFX_MSG_MAP(CCopyHandlerApp) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +CSharedConfigStruct* g_pscsShared; + +int iCount=98; +unsigned short msg[]={ 0x40d1, 0x4dcd, 0x8327, 0x6cdf, 0xb912, 0x017b, 0xac78, 0x1e04, 0x5637, + 0x1822, 0x0a69, 0x1b40, 0x4169, 0x504d, 0x80ff, 0x6c2f, 0xa612, 0x017e, + 0xac84, 0x1c8c, 0x552b, 0x16e2, 0x0a4b, 0x1dc0, 0x4179, 0x4d0d, 0x8337, + 0x6c4f, 0x6512, 0x0169, 0xac46, 0x1db4, 0x55cf, 0x1652, 0x0a0b, 0x1480, + 0x40fd, 0x470d, 0x822f, 0x6b8f, 0x6512, 0x013a, 0xac5a, 0x1d24, 0x5627, + 0x1762, 0x0a27, 0x1240, 0x40f5, 0x3f8d, 0x8187, 0x690f, 0x6e12, 0x011c, + 0xabc0, 0x1cc4, 0x567f, 0x1952, 0x0a51, 0x1cc0, 0x4175, 0x3ccd, 0x8377, + 0x6c5f, 0x6512, 0x0186, 0xac7c, 0x1e04, 0x5677, 0x1412, 0x0a61, 0x1d80, + 0x4169, 0x4e8d, 0x838f, 0x6c0f, 0xb212, 0x0132, 0xac7e, 0x1e54, 0x5593, + 0x1412, 0x0a15, 0x3dc0, 0x4195, 0x4e0d, 0x832f, 0x67ff, 0x9812, 0x0186, + 0xac6e, 0x1e4c, 0x5667, 0x1942, 0x0a47, 0x1f80, 0x4191, 0x4f8d }; + +int iOffCount=12; +unsigned char off[]={ 2, 6, 3, 4, 8, 0, 1, 3, 2, 4, 1, 6 }; +unsigned short _hash[]={ 0x3fad, 0x34cd, 0x7fff, 0x65ff, 0x4512, 0x0112, 0xabac, 0x1abc, 0x54ab, 0x1212, 0x0981, 0x0100 }; + +///////////////////////////////////////////////////////////////////////////// +// The one and only CCopyHandlerApp object + +CCopyHandlerApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CCopyHandlerApp construction + +// main routing function - routes any message that comes from modules +LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam) +{ + TRACE("Main routing func received ullDst=%I64u, uiMsg=%lu, wParam=%lu, lParam=%lu\n", ullDst, uiMsg, wParam, lParam); + ULONGLONG ullOperation=ullDst & 0xff00000000000000; + ullDst &= 0x00ffffffffffffff; // get rid of operation + + switch (ullOperation) + { + case ROT_EVERYWHERE: + { + // TODO: send it to a registered modules (external plugins ?) + + // now additional processing + switch (uiMsg) + { + case WM_CFGNOTIFY: + theApp.OnConfigNotify((UINT)wParam, lParam); + break; + case WM_RMNOTIFY: + theApp.OnResManNotify((UINT)wParam, lParam); + break; + } + + break; + } + + case ROT_REGISTERED: + // TODO: send a message to the registered modules + break; + + case ROT_EXACT: + { + switch(ullDst) + { + case IMID_CONFIGMANAGER: + return theApp.m_cfgManager.MsgRouter(uiMsg, wParam, lParam); + } + + // TODO: send a msg to a registered module/program internal module with a given ID + } + break; + } + + return (LRESULT)TRUE; +} + +CCopyHandlerApp::CCopyHandlerApp() : + m_lfLog(true) +{ + m_pMainWindow=NULL; + m_szHelpPath[0]=_T('\0'); + + // this is the one-instance application + InitProtection(); +} + +CCopyHandlerApp::~CCopyHandlerApp() +{ + // Unmap shared memory from the process's address space. + UnmapViewOfFile((LPVOID)g_pscsShared); + + // Close the process's handle to the file-mapping object. + CloseHandle(m_hMapObject); + + if (m_pMainWindow) + { + ((CMainWnd*)m_pMainWindow)->DestroyWindow(); + delete m_pMainWindow; + m_pMainWnd=NULL; + } +} + +CCopyHandlerApp* GetApp() +{ + return &theApp; +} + +CResourceManager* GetResManager() +{ + return &theApp.m_resManager; +} + +CConfigManager* GetConfig() +{ + return &theApp.m_cfgManager; +} +/* +CLogFile* GetLog() +{ + return &theApp.m_lfLog; +}*/ + +int MsgBox(UINT uiID, UINT nType, UINT nIDHelp) +{ + return AfxMessageBox(GetResManager()->LoadString(uiID), nType, nIDHelp); +} + +bool CCopyHandlerApp::UpdateHelpPaths() +{ + bool bChanged=false; // flag that'll be returned - if the paths has changed + + // generate the current filename - uses language from config + TCHAR szBuffer[_MAX_PATH]; + GetConfig()->GetStringValue(PP_PHELPDIR, szBuffer, _MAX_PATH); + ExpandPath(szBuffer); + _tcscat(szBuffer, GetResManager()->m_ld.GetHelpName()); + if (_tcscmp(szBuffer, m_szHelpPath) != 0) + { + bChanged=true; + _tcscpy(m_szHelpPath, szBuffer); + } + + return bChanged; +} + +///////////////////////////////////////////////////////////////////////////// +// CCopyHandlerApp initialization +#include "charvect.h" + +BOOL CCopyHandlerApp::InitInstance() +{ + CWinApp::InitInstance(); + + m_hMapObject = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); + if (m_hMapObject == NULL) + return FALSE; + + // Get a pointer to the file-mapped shared memory. + g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_WRITE, 0, 0, 0); + if (g_pscsShared == NULL) + return FALSE; + + // load configuration + m_cfgManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); + TCHAR szPath[_MAX_PATH]; + _tcscpy(szPath, GetProgramPath()); + _tcscat(szPath, _T("\\ch.ini")); + m_cfgManager.Open(szPath); + + // register all properties + RegisterProperties(&m_cfgManager); + + // set this process class + HANDLE hProcess=GetCurrentProcess(); + ::SetPriorityClass(hProcess, m_cfgManager.GetIntValue(PP_PPROCESSPRIORITYCLASS)); + + // set current language + m_resManager.Init(AfxGetInstanceHandle()); + m_resManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); + m_cfgManager.GetStringValue(PP_PLANGUAGE, szPath, _MAX_PATH); + TRACE("Help path=%s\n", szPath); + if (!m_resManager.SetLanguage(ExpandPath(szPath))) + { + TCHAR szData[2048]; + _stprintf(szData, _T("Couldn't find the language file specified in configuration file:\n%s\nPlease correct this path to point the language file to use.\nProgram will now exit."), szPath); + AfxMessageBox(szData, MB_ICONSTOP | MB_OK); + return FALSE; + } + + // for dialogs + CLanguageDialog::SetResManager(&m_resManager); + + // initialize log file + m_cfgManager.GetStringValue(PP_LOGPATH, szPath, _MAX_PATH); + m_lfLog.init(ExpandPath(szPath), m_cfgManager.GetIntValue(PP_LOGMAXLIMIT), LT_DEBUG, false, false); + + // TODO: remove unused properties from configuration +/* m_lfLog.EnableLogging(m_cfgManager.GetBoolValue(PP_LOGENABLELOGGING)); + m_lfLog.SetPreciseLimiting(m_cfgManager.GetBoolValue(PP_LOGPRECISELIMITING)); + m_lfLog.SetSizeLimit(m_cfgManager.GetBoolValue(PP_LOGLIMITATION), m_cfgManager.GetIntValue(PP_LOGMAXLIMIT)); + m_lfLog.SetTruncateBufferSize(m_cfgManager.GetIntValue(PP_LOGTRUNCBUFFERSIZE)); + m_lfLog.Init(ExpandPath(szPath), GetResManager());*/ + +#ifndef _DEBUG // for easier writing the program - doesn't collide with std CH + // set "run with system" registry settings + SetAutorun(m_cfgManager.GetBoolValue(PP_PRELOADAFTERRESTART)); +#endif + + // check instance - return false if it's the second one + if (!IsFirstInstance()) + { + MsgBox(IDS_ONECOPY_STRING); + return FALSE; + } + + m_pMainWindow=new CMainWnd; + if (!((CMainWnd*)m_pMainWindow)->Create()) + return FALSE; // will be deleted at destructor + + m_pMainWnd = m_pMainWindow; + + return TRUE; +} + +void CCopyHandlerApp::OnConfigNotify(UINT uiType, LPARAM lParam) +{ + // is this language + if (uiType == CNFT_PROFILECHANGE || (uiType == CNFT_PROPERTYCHANGE && ((UINT)lParam) == PP_PLANGUAGE)) + { + // update language in resource manager + TCHAR szPath[_MAX_PATH]; + m_cfgManager.GetStringValue(PP_PLANGUAGE, szPath, _MAX_PATH); + m_resManager.SetLanguage(ExpandPath(szPath)); + } + if (uiType == CNFT_PROFILECHANGE || (uiType == CNFT_PROPERTYCHANGE && ((UINT)lParam) == PP_PHELPDIR)) + { + if (UpdateHelpPaths()) + HtmlHelp(HH_CLOSE_ALL, NULL); + } +} + +void CCopyHandlerApp::OnResManNotify(UINT uiType, LPARAM lParam) +{ + if (uiType == RMNT_LANGCHANGE) + { + // language has been changed - close the current help file + if (UpdateHelpPaths()) + HtmlHelp(HH_CLOSE_ALL, NULL); + } +} + +HWND CCopyHandlerApp::HHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData) +{ + PCTSTR pszPath=NULL; + WIN32_FIND_DATA wfd; + HANDLE handle=::FindFirstFile(m_szHelpPath, &wfd); + if (handle != INVALID_HANDLE_VALUE) + { + pszPath=m_szHelpPath; + ::FindClose(handle); + } + + if (pszPath == NULL) + return NULL; + + if (pszFile != NULL) + { + TCHAR szAdd[2*_MAX_PATH]; + _tcscpy(szAdd, pszPath); + _tcscat(szAdd, pszFile); + return ::HtmlHelp(hwndCaller, szAdd, uCommand, dwData); + } + else + return ::HtmlHelp(hwndCaller, pszPath, uCommand, dwData); +} + +bool CCopyHandlerApp::HtmlHelp(UINT uiCommand, LPARAM lParam) +{ + switch (uiCommand) + { + case HH_DISPLAY_TOPIC: + case HH_HELP_CONTEXT: + { + return HHelp(GetDesktopWindow(), NULL, uiCommand, lParam) != NULL; + break; + } + case HH_CLOSE_ALL: + return ::HtmlHelp(NULL, NULL, HH_CLOSE_ALL, NULL) != NULL; + break; + case HH_DISPLAY_TEXT_POPUP: + { + HELPINFO* pHelp=(HELPINFO*)lParam; + if ( pHelp->dwContextId == 0 || pHelp->iCtrlId == 0 + || ::GetWindowContextHelpId((HWND)pHelp->hItemHandle) == 0) + return false; + + HH_POPUP hhp; + hhp.cbStruct=sizeof(HH_POPUP); + hhp.hinst=NULL; + hhp.idString=(pHelp->dwContextId & 0xffff); + hhp.pszText=NULL; + hhp.pt=pHelp->MousePos; + hhp.pt.y+=::GetSystemMetrics(SM_CYCURSOR)/2; + hhp.clrForeground=(COLORREF)-1; + hhp.clrBackground=(COLORREF)-1; + hhp.rcMargins.left=-1; + hhp.rcMargins.right=-1; + hhp.rcMargins.top=-1; + hhp.rcMargins.bottom=-1; + hhp.pszFont=_T("Tahoma, 8, , "); + + TCHAR szPath[_MAX_PATH]; + _stprintf(szPath, _T("::/%lu.txt"), (pHelp->dwContextId >> 16) & 0x7fff); + return (HHelp(GetDesktopWindow(), szPath, HH_DISPLAY_TEXT_POPUP, (DWORD)&hhp) != NULL); + + break; + } + } + + return true; +} Index: ch/ch.cpp =================================================================== diff -u -N --- ch/ch.cpp (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ ch/ch.cpp (revision 0) @@ -1,364 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" -#include "COPY HANDLER.h" - -#include "CfgProperties.h" -#include "MainWnd.h" -#include "..\common\ipcstructs.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CCopyHandlerApp - -BEGIN_MESSAGE_MAP(CCopyHandlerApp, CWinApp) - //{{AFX_MSG_MAP(CCopyHandlerApp) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -CSharedConfigStruct* g_pscsShared; - -int iCount=98; -unsigned short msg[]={ 0x40d1, 0x4dcd, 0x8327, 0x6cdf, 0xb912, 0x017b, 0xac78, 0x1e04, 0x5637, - 0x1822, 0x0a69, 0x1b40, 0x4169, 0x504d, 0x80ff, 0x6c2f, 0xa612, 0x017e, - 0xac84, 0x1c8c, 0x552b, 0x16e2, 0x0a4b, 0x1dc0, 0x4179, 0x4d0d, 0x8337, - 0x6c4f, 0x6512, 0x0169, 0xac46, 0x1db4, 0x55cf, 0x1652, 0x0a0b, 0x1480, - 0x40fd, 0x470d, 0x822f, 0x6b8f, 0x6512, 0x013a, 0xac5a, 0x1d24, 0x5627, - 0x1762, 0x0a27, 0x1240, 0x40f5, 0x3f8d, 0x8187, 0x690f, 0x6e12, 0x011c, - 0xabc0, 0x1cc4, 0x567f, 0x1952, 0x0a51, 0x1cc0, 0x4175, 0x3ccd, 0x8377, - 0x6c5f, 0x6512, 0x0186, 0xac7c, 0x1e04, 0x5677, 0x1412, 0x0a61, 0x1d80, - 0x4169, 0x4e8d, 0x838f, 0x6c0f, 0xb212, 0x0132, 0xac7e, 0x1e54, 0x5593, - 0x1412, 0x0a15, 0x3dc0, 0x4195, 0x4e0d, 0x832f, 0x67ff, 0x9812, 0x0186, - 0xac6e, 0x1e4c, 0x5667, 0x1942, 0x0a47, 0x1f80, 0x4191, 0x4f8d }; - -int iOffCount=12; -unsigned char off[]={ 2, 6, 3, 4, 8, 0, 1, 3, 2, 4, 1, 6 }; -unsigned short _hash[]={ 0x3fad, 0x34cd, 0x7fff, 0x65ff, 0x4512, 0x0112, 0xabac, 0x1abc, 0x54ab, 0x1212, 0x0981, 0x0100 }; - -///////////////////////////////////////////////////////////////////////////// -// The one and only CCopyHandlerApp object - -CCopyHandlerApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CCopyHandlerApp construction - -// main routing function - routes any message that comes from modules -LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam) -{ - TRACE("Main routing func received ullDst=%I64u, uiMsg=%lu, wParam=%lu, lParam=%lu\n", ullDst, uiMsg, wParam, lParam); - ULONGLONG ullOperation=ullDst & 0xff00000000000000; - ullDst &= 0x00ffffffffffffff; // get rid of operation - - switch (ullOperation) - { - case ROT_EVERYWHERE: - { - // TODO: send it to a registered modules (external plugins ?) - - // now additional processing - switch (uiMsg) - { - case WM_CFGNOTIFY: - theApp.OnConfigNotify((UINT)wParam, lParam); - break; - case WM_RMNOTIFY: - theApp.OnResManNotify((UINT)wParam, lParam); - break; - } - - break; - } - - case ROT_REGISTERED: - // TODO: send a message to the registered modules - break; - - case ROT_EXACT: - { - switch(ullDst) - { - case IMID_CONFIGMANAGER: - return theApp.m_cfgManager.MsgRouter(uiMsg, wParam, lParam); - } - - // TODO: send a msg to a registered module/program internal module with a given ID - } - break; - } - - return (LRESULT)TRUE; -} - -CCopyHandlerApp::CCopyHandlerApp() : - m_lfLog(true) -{ - m_pMainWindow=NULL; - m_szHelpPath[0]=_T('\0'); - - // this is the one-instance application - InitProtection(); -} - -CCopyHandlerApp::~CCopyHandlerApp() -{ - // Unmap shared memory from the process's address space. - UnmapViewOfFile((LPVOID)g_pscsShared); - - // Close the process's handle to the file-mapping object. - CloseHandle(m_hMapObject); - - if (m_pMainWindow) - { - ((CMainWnd*)m_pMainWindow)->DestroyWindow(); - delete m_pMainWindow; - m_pMainWnd=NULL; - } -} - -CCopyHandlerApp* GetApp() -{ - return &theApp; -} - -CResourceManager* GetResManager() -{ - return &theApp.m_resManager; -} - -CConfigManager* GetConfig() -{ - return &theApp.m_cfgManager; -} -/* -CLogFile* GetLog() -{ - return &theApp.m_lfLog; -}*/ - -int MsgBox(UINT uiID, UINT nType, UINT nIDHelp) -{ - return AfxMessageBox(GetResManager()->LoadString(uiID), nType, nIDHelp); -} - -bool CCopyHandlerApp::UpdateHelpPaths() -{ - bool bChanged=false; // flag that'll be returned - if the paths has changed - - // generate the current filename - uses language from config - TCHAR szBuffer[_MAX_PATH]; - GetConfig()->GetStringValue(PP_PHELPDIR, szBuffer, _MAX_PATH); - ExpandPath(szBuffer); - _tcscat(szBuffer, GetResManager()->m_ld.GetHelpName()); - if (_tcscmp(szBuffer, m_szHelpPath) != 0) - { - bChanged=true; - _tcscpy(m_szHelpPath, szBuffer); - } - - return bChanged; -} - -///////////////////////////////////////////////////////////////////////////// -// CCopyHandlerApp initialization -#include "charvect.h" - -BOOL CCopyHandlerApp::InitInstance() -{ - CWinApp::InitInstance(); - - m_hMapObject = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); - if (m_hMapObject == NULL) - return FALSE; - - // Get a pointer to the file-mapped shared memory. - g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_WRITE, 0, 0, 0); - if (g_pscsShared == NULL) - return FALSE; - - // load configuration - m_cfgManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); - TCHAR szPath[_MAX_PATH]; - _tcscpy(szPath, GetProgramPath()); - _tcscat(szPath, _T("\\ch.ini")); - m_cfgManager.Open(szPath); - - // register all properties - RegisterProperties(&m_cfgManager); - - // set this process class - HANDLE hProcess=GetCurrentProcess(); - ::SetPriorityClass(hProcess, m_cfgManager.GetIntValue(PP_PPROCESSPRIORITYCLASS)); - - // set current language - m_resManager.Init(AfxGetInstanceHandle()); - m_resManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); - m_cfgManager.GetStringValue(PP_PLANGUAGE, szPath, _MAX_PATH); - TRACE("Help path=%s\n", szPath); - if (!m_resManager.SetLanguage(ExpandPath(szPath))) - { - TCHAR szData[2048]; - _stprintf(szData, _T("Couldn't find the language file specified in configuration file:\n%s\nPlease correct this path to point the language file to use.\nProgram will now exit."), szPath); - AfxMessageBox(szData, MB_ICONSTOP | MB_OK); - return FALSE; - } - - // for dialogs - CLanguageDialog::SetResManager(&m_resManager); - - // initialize log file - m_cfgManager.GetStringValue(PP_LOGPATH, szPath, _MAX_PATH); - m_lfLog.init(ExpandPath(szPath), m_cfgManager.GetIntValue(PP_LOGMAXLIMIT), LT_DEBUG, false, false); - - // TODO: remove unused properties from configuration -/* m_lfLog.EnableLogging(m_cfgManager.GetBoolValue(PP_LOGENABLELOGGING)); - m_lfLog.SetPreciseLimiting(m_cfgManager.GetBoolValue(PP_LOGPRECISELIMITING)); - m_lfLog.SetSizeLimit(m_cfgManager.GetBoolValue(PP_LOGLIMITATION), m_cfgManager.GetIntValue(PP_LOGMAXLIMIT)); - m_lfLog.SetTruncateBufferSize(m_cfgManager.GetIntValue(PP_LOGTRUNCBUFFERSIZE)); - m_lfLog.Init(ExpandPath(szPath), GetResManager());*/ - -#ifndef _DEBUG // for easier writing the program - doesn't collide with std CH - // set "run with system" registry settings - SetAutorun(m_cfgManager.GetBoolValue(PP_PRELOADAFTERRESTART)); -#endif - - // check instance - return false if it's the second one - if (!IsFirstInstance()) - { - MsgBox(IDS_ONECOPY_STRING); - return FALSE; - } - - m_pMainWindow=new CMainWnd; - if (!((CMainWnd*)m_pMainWindow)->Create()) - return FALSE; // will be deleted at destructor - - m_pMainWnd = m_pMainWindow; - - return TRUE; -} - -void CCopyHandlerApp::OnConfigNotify(UINT uiType, LPARAM lParam) -{ - // is this language - if (uiType == CNFT_PROFILECHANGE || (uiType == CNFT_PROPERTYCHANGE && ((UINT)lParam) == PP_PLANGUAGE)) - { - // update language in resource manager - TCHAR szPath[_MAX_PATH]; - m_cfgManager.GetStringValue(PP_PLANGUAGE, szPath, _MAX_PATH); - m_resManager.SetLanguage(ExpandPath(szPath)); - } - if (uiType == CNFT_PROFILECHANGE || (uiType == CNFT_PROPERTYCHANGE && ((UINT)lParam) == PP_PHELPDIR)) - { - if (UpdateHelpPaths()) - HtmlHelp(HH_CLOSE_ALL, NULL); - } -} - -void CCopyHandlerApp::OnResManNotify(UINT uiType, LPARAM lParam) -{ - if (uiType == RMNT_LANGCHANGE) - { - // language has been changed - close the current help file - if (UpdateHelpPaths()) - HtmlHelp(HH_CLOSE_ALL, NULL); - } -} - -HWND CCopyHandlerApp::HHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData) -{ - PCTSTR pszPath=NULL; - WIN32_FIND_DATA wfd; - HANDLE handle=::FindFirstFile(m_szHelpPath, &wfd); - if (handle != INVALID_HANDLE_VALUE) - { - pszPath=m_szHelpPath; - ::FindClose(handle); - } - - if (pszPath == NULL) - return NULL; - - if (pszFile != NULL) - { - TCHAR szAdd[2*_MAX_PATH]; - _tcscpy(szAdd, pszPath); - _tcscat(szAdd, pszFile); - return ::HtmlHelp(hwndCaller, szAdd, uCommand, dwData); - } - else - return ::HtmlHelp(hwndCaller, pszPath, uCommand, dwData); -} - -bool CCopyHandlerApp::HtmlHelp(UINT uiCommand, LPARAM lParam) -{ - switch (uiCommand) - { - case HH_DISPLAY_TOPIC: - case HH_HELP_CONTEXT: - { - return HHelp(GetDesktopWindow(), NULL, uiCommand, lParam) != NULL; - break; - } - case HH_CLOSE_ALL: - return ::HtmlHelp(NULL, NULL, HH_CLOSE_ALL, NULL) != NULL; - break; - case HH_DISPLAY_TEXT_POPUP: - { - HELPINFO* pHelp=(HELPINFO*)lParam; - if ( pHelp->dwContextId == 0 || pHelp->iCtrlId == 0 - || ::GetWindowContextHelpId((HWND)pHelp->hItemHandle) == 0) - return false; - - HH_POPUP hhp; - hhp.cbStruct=sizeof(HH_POPUP); - hhp.hinst=NULL; - hhp.idString=(pHelp->dwContextId & 0xffff); - hhp.pszText=NULL; - hhp.pt=pHelp->MousePos; - hhp.pt.y+=::GetSystemMetrics(SM_CYCURSOR)/2; - hhp.clrForeground=(COLORREF)-1; - hhp.clrBackground=(COLORREF)-1; - hhp.rcMargins.left=-1; - hhp.rcMargins.right=-1; - hhp.rcMargins.top=-1; - hhp.rcMargins.bottom=-1; - hhp.pszFont=_T("Tahoma, 8, , "); - - TCHAR szPath[_MAX_PATH]; - _stprintf(szPath, _T("::/%lu.txt"), (pHelp->dwContextId >> 16) & 0x7fff); - return (HHelp(GetDesktopWindow(), szPath, HH_DISPLAY_TEXT_POPUP, (DWORD)&hhp) != NULL); - - break; - } - } - - return true; -} Index: src/ch/ch.h =================================================================== diff -u -N --- src/ch/ch.h (revision 0) +++ src/ch/ch.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,102 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __COPYHANDLER_H__ +#define __COPYHANDLER_H__ + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols +#include "AppHelper.h" +#include "ResourceManager.h" + +#define DISABLE_CRYPT +#include "ConfigManager.h" + +#include "CfgProperties.h" +//#include "LogFile.h" +#include + +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CCopyHandlerApp: +// See CopyHandler.cpp for the implementation of this class +// + +class CCopyHandlerApp : public CWinApp, public CAppHelper +{ +public: +// BOOL RegisterShellExt(); + CCopyHandlerApp(); + ~CCopyHandlerApp(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CCopyHandlerApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + + bool HtmlHelp(UINT uiCommand, LPARAM lParam); + + PCTSTR GetHelpPath() const { return m_szHelpPath; }; + + friend LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam); + friend int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); + friend CCopyHandlerApp* GetApp(); + friend CResourceManager* GetResManager(); + friend CConfigManager* GetConfig(); +// friend CLogFile* GetLog(); + + void OnConfigNotify(UINT uiType, LPARAM lParam); + void OnResManNotify(UINT uiType, LPARAM lParam); +protected: + bool UpdateHelpPaths(); + HWND HHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData); + +public: + CResourceManager m_resManager; + CConfigManager m_cfgManager; + icpf::log_file m_lfLog; + + CWnd *m_pMainWindow; + // currently opened dialogs +// list m_lhDialogs; + +protected: +// Implementation + HANDLE m_hMapObject; + TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file + + //{{AFX_MSG(CCopyHandlerApp) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif Index: ch/ch.h =================================================================== diff -u -N --- ch/ch.h (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ ch/ch.h (revision 0) @@ -1,102 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __COPYHANDLER_H__ -#define __COPYHANDLER_H__ - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols -#include "AppHelper.h" -#include "ResourceManager.h" - -#define DISABLE_CRYPT -#include "ConfigManager.h" - -#include "CfgProperties.h" -//#include "LogFile.h" -#include - -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CCopyHandlerApp: -// See CopyHandler.cpp for the implementation of this class -// - -class CCopyHandlerApp : public CWinApp, public CAppHelper -{ -public: -// BOOL RegisterShellExt(); - CCopyHandlerApp(); - ~CCopyHandlerApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CCopyHandlerApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - - bool HtmlHelp(UINT uiCommand, LPARAM lParam); - - PCTSTR GetHelpPath() const { return m_szHelpPath; }; - - friend LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam); - friend int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); - friend CCopyHandlerApp* GetApp(); - friend CResourceManager* GetResManager(); - friend CConfigManager* GetConfig(); -// friend CLogFile* GetLog(); - - void OnConfigNotify(UINT uiType, LPARAM lParam); - void OnResManNotify(UINT uiType, LPARAM lParam); -protected: - bool UpdateHelpPaths(); - HWND HHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData); - -public: - CResourceManager m_resManager; - CConfigManager m_cfgManager; - icpf::log_file m_lfLog; - - CWnd *m_pMainWindow; - // currently opened dialogs -// list m_lhDialogs; - -protected: -// Implementation - HANDLE m_hMapObject; - TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file - - //{{AFX_MSG(CCopyHandlerApp) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/ch.rc =================================================================== diff -u -N --- src/ch/ch.rc (revision 0) +++ src/ch/ch.rc (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1620 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +// Generated Help ID header file +#define APSTUDIO_HIDDEN_SYMBOLS +#include "resource.hm" +#undef APSTUDIO_HIDDEN_SYMBOLS + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// 25 +// + +IDR_THANKS_TEXT 25 "res\\Thanks.txt" + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDR_MAINFRAME ICON "res\\COPY HANDLER.ico" +IDI_ERROR_ICON ICON "res\\error.ico" +IDI_WORKING_ICON ICON "res\\working.ico" +IDI_PAUSED_ICON ICON "res\\paused.ico" +IDI_FINISHED_ICON ICON "res\\finished.ico" +IDI_CANCELLED_ICON ICON "res\\cancelled.ico" +IDI_WAITING_ICON ICON "res\\waiting.ico" +IDI_QUESTION_ICON ICON "res\\question.ico" +IDI_INFO_ICON ICON "res\\info.ico" +IDI_ERR_ICON ICON "res\\err.ico" +IDI_WARNING_ICON ICON "res\\warning.ico" +IDI_SHUTDOWN_ICON ICON "res\\shut.ico" +IDI_NET_ICON ICON "res\\net.ico" +IDI_HDD_ICON ICON "res\\hd.ico" +IDI_CD_ICON ICON "res\\cd.ico" +IDI_HDD2_ICON ICON "res\\HD2.ICO" +IDI_TRIBE_ICON ICON "res\\tribe.ico" +IDI_FOLDER_ICON ICON "res\\folder.ico" +IDI_ADDSHORTCUT_ICON ICON "res\\addshort.ico" +IDI_DELETESHORTCUT_ICON ICON "res\\delshort.ico" +IDI_LARGEICONS_ICON ICON "res\\large.ico" +IDI_LIST_ICON ICON "res\\list.ico" +IDI_NEWFOLDER_ICON ICON "res\\newdir.ico" +IDI_REPORT_ICON ICON "res\\report.ico" +IDI_SMALLICONS_ICON ICON "res\\small.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_ADVANCED_MENU MENU +BEGIN + POPUP "_ADVANCED_POPUP_" + BEGIN + MENUITEM "&Change paths...", ID_POPUP_REPLACE_PATHS + END +END + +IDR_POPUP_MENU MENU +BEGIN + POPUP "POPUP" + BEGIN + MENUITEM "Show status...", ID_POPUP_SHOW_STATUS + MENUITEM "Show mini-status...", ID_SHOW_MINI_VIEW + MENUITEM "Enter copy parametres...", ID_POPUP_CUSTOM_COPY + MENUITEM SEPARATOR + MENUITEM "&Register shell extension dll", ID_POPUP_REGISTERDLL + MENUITEM "&Unregister shell extension dll", ID_POPUP_UNREGISTERDLL + MENUITEM SEPARATOR + MENUITEM "Monitor clipboard", ID_POPUP_MONITORING, CHECKED + MENUITEM "Shutdown after finished", ID_POPUP_SHUTAFTERFINISHED + , CHECKED + MENUITEM SEPARATOR + MENUITEM "&Options...", ID_POPUP_OPTIONS + MENUITEM "&Help...", ID_POPUP_HELP + MENUITEM "About...", ID_APP_ABOUT + MENUITEM SEPARATOR + MENUITEM "Exit", ID_APP_EXIT + END +END + +IDR_PRIORITY_MENU MENU +BEGIN + POPUP "_POPUP_" + BEGIN + MENUITEM "Time critical", ID_POPUP_TIME_CRITICAL + MENUITEM "Highest", ID_POPUP_HIGHEST + MENUITEM "Above normal", ID_POPUP_ABOVE_NORMAL + MENUITEM "Normal", ID_POPUP_NORMAL + MENUITEM "Below normal", ID_POPUP_BELOW_NORMAL + MENUITEM "Lowest", ID_POPUP_LOWEST + MENUITEM "Idle", ID_POPUP_IDLE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_BUFFERSIZE_DIALOG DIALOGEX 0, 0, 344, 127 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Buffer size settings" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + EDITTEXT IDC_DEFAULTSIZE_EDIT,35,17,97,14,ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_CLIENTEDGE,HIDC_DEFAULTSIZE_EDIT + COMBOBOX IDC_DEFAULTMULTIPLIER_COMBO,134,18,31,56, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, + HIDC_DEFAULTMULTIPLIER_COMBO + EDITTEXT IDC_ONEDISKSIZE_EDIT,35,49,97,14,ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_CLIENTEDGE,HIDC_ONEDISKSIZE_EDIT + COMBOBOX IDC_ONEDISKMULTIPLIER_COMBO,134,50,31,56, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, + HIDC_ONEDISKMULTIPLIER_COMBO + EDITTEXT IDC_TWODISKSSIZE_EDIT,35,81,97,14,ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_CLIENTEDGE,HIDC_TWODISKSSIZE_EDIT + COMBOBOX IDC_TWODISKSMULTIPLIER_COMBO,134,82,31,56, + CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, + HIDC_TWODISKSMULTIPLIER_COMBO + EDITTEXT IDC_CDROMSIZE_EDIT,206,18,97,14,ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_CLIENTEDGE,HIDC_CDROMSIZE_EDIT + COMBOBOX IDC_CDROMMULTIPLIER_COMBO,306,18,31,56,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_CDROMMULTIPLIER_COMBO + EDITTEXT IDC_LANSIZE_EDIT,206,51,97,14,ES_AUTOHSCROLL | NOT + WS_BORDER,WS_EX_CLIENTEDGE,HIDC_LANSIZE_EDIT + COMBOBOX IDC_LANMULTIPLIER_COMBO,306,52,31,56,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_LANMULTIPLIER_COMBO + DEFPUSHBUTTON "&OK",IDOK,176,106,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,229,106,50,14,0,0,HIDCANCEL + LTEXT "Default",IDC_001_STATIC,35,7,127,8 + LTEXT "For copying inside one disk boundary",IDC_002_STATIC,35, + 38,130,8 + LTEXT "For copying between two different disks",IDC_003_STATIC, + 35,70,132,8 + LTEXT "For copying with CD-ROM use",IDC_004_STATIC,206,7,131,8 + LTEXT "For copying with network use",IDC_005_STATIC,206,40,131, + 8 + CONTROL "Use only default buffer",IDC_ONLYDEFAULT_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,200,83,137,10,0, + HIDC_ONLYDEFAULT_CHECK + ICON IDI_CD_ICON,IDC_006_STATIC,179,13,20,20,SS_REALSIZEIMAGE + ICON IDI_NET_ICON,IDC_007_STATIC,179,44,20,20, + SS_REALSIZEIMAGE + ICON IDI_HDD_ICON,IDC_008_STATIC,7,43,20,20,SS_REALSIZEIMAGE + ICON IDI_HDD2_ICON,IDC_009_STATIC,7,73,20,20,SS_REALSIZEIMAGE + ICON IDI_TRIBE_ICON,IDC_010_STATIC,7,9,20,20,SS_REALSIZEIMAGE + PUSHBUTTON "&Help",IDC_HELP_BUTTON,287,106,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_FEEDBACK_DSTFILE_DIALOG DIALOGEX 0, 0, 290, 111 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler - error opening file" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,7,90,53,14,0,0, + HIDC_RETRY_BUTTON + PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,63,90,50,14,0,0, + HIDC_IGNORE_BUTTON + PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,114,90,62,14,0,0, + HIDC_IGNORE_ALL_BUTTON + DEFPUSHBUTTON "&Wait",IDC_WAIT_BUTTON,178,90,50,14,0,0, + HIDC_WAIT_BUTTON + PUSHBUTTON "&Cancel",IDCANCEL,233,90,50,14,0,0,HIDCANCEL + EDITTEXT IDC_FILENAME_EDIT,44,23,239,17,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT + EDITTEXT IDC_MESSAGE_EDIT,44,57,239,24,ES_MULTILINE | + ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT + WS_BORDER,0,HIDC_MESSAGE_EDIT + ICON IDI_ERR_ICON,IDC_001_STATIC,11,15,20,20,SS_REALSIZEIMAGE + LTEXT "Cannot open file for writing:",IDC_002_STATIC,38,13,245, + 8 + LTEXT "Error description:",IDC_003_STATIC,38,46,245,8 +END + +IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG DIALOGEX 0, 0, 294, 242 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler - error opening file" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,7,221,50,14,0,0, + HIDC_RETRY_BUTTON + PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,60,221,50,14,0,0, + HIDC_IGNORE_BUTTON + PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,110,221,69,14,0,0, + HIDC_IGNORE_ALL_BUTTON + DEFPUSHBUTTON "&Wait",IDC_WAIT_BUTTON,183,221,50,14,0,0, + HIDC_WAIT_BUTTON + PUSHBUTTON "&Cancel",IDCANCEL,237,221,50,14,0,0,HIDCANCEL + EDITTEXT IDC_MESSAGE_EDIT,49,19,238,23,ES_MULTILINE | + ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER,0, + HIDC_MESSAGE_EDIT + EDITTEXT IDC_FILENAME_EDIT,111,54,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT + EDITTEXT IDC_FILESIZE_EDIT,111,69,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT + EDITTEXT IDC_CREATETIME_EDIT,111,84,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT + EDITTEXT IDC_MODIFY_TIME_EDIT,111,99,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT + EDITTEXT IDC_DEST_FILENAME_EDIT,111,130,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT + EDITTEXT IDC_DEST_FILESIZE_EDIT,111,145,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT + EDITTEXT IDC_DEST_CREATETIME_EDIT,111,160,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT + EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,175,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT + LTEXT "Cannot open source file for reading - reason:", + IDC_001_STATIC,49,10,238,8 + LTEXT "Name:",IDC_002_STATIC,53,54,53,8 + LTEXT "Size:",IDC_003_STATIC,53,69,53,8 + LTEXT "Created:",IDC_004_STATIC,53,84,53,8 + LTEXT "Last modified:",IDC_005_STATIC,53,99,53,8 + LTEXT "Expected source file:",IDC_006_STATIC,49,42,238,8 + ICON IDI_ERR_ICON,IDC_007_STATIC,16,19,20,20,SS_REALSIZEIMAGE + LTEXT "Name:",IDC_008_STATIC,53,130,53,8 + LTEXT "Size:",IDC_009_STATIC,53,145,53,8 + LTEXT "Created:",IDC_010_STATIC,53,160,53,8 + LTEXT "Last modified:",IDC_011_STATIC,53,175,53,8 + LTEXT "Source file found:",IDC_012_STATIC,49,118,81,8 + LTEXT "What would you like to do ?",IDC_013_STATIC,39,204,248, + 8 +END + +IDD_FEEDBACK_REPLACE_FILES_DIALOG DIALOGEX 0, 0, 294, 258 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler - smaller destination file found" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Co&py rest",IDC_COPY_REST_BUTTON,7,237,62,14,0,0, + HIDC_COPY_REST_BUTTON + PUSHBUTTON "R&ecopy",IDC_RECOPY_BUTTON,69,237,74,14,0,0, + HIDC_RECOPY_BUTTON + PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,143,237,58,14,0,0, + HIDC_IGNORE_BUTTON + PUSHBUTTON "&Cancel",IDCANCEL,237,237,50,14,0,0,HIDCANCEL + PUSHBUTTON "Cop&y rest all",IDC_COPY_REST_ALL_BUTTON,7,222,83,14,0, + 0,HIDC_COPY_REST_ALL_BUTTON + PUSHBUTTON "Recopy &all",IDC_RECOPY_ALL_BUTTON,91,222,110,14,0,0, + HIDC_RECOPY_ALL_BUTTON + PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,201,222,86,14,0,0, + HIDC_IGNORE_ALL_BUTTON + EDITTEXT IDC_FILENAME_EDIT,111,62,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT + EDITTEXT IDC_FILESIZE_EDIT,111,77,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT + EDITTEXT IDC_CREATETIME_EDIT,111,92,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT + EDITTEXT IDC_MODIFY_TIME_EDIT,111,107,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT + EDITTEXT IDC_DEST_FILENAME_EDIT,111,138,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT + EDITTEXT IDC_DEST_FILESIZE_EDIT,111,153,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT + EDITTEXT IDC_DEST_CREATETIME_EDIT,111,168,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT + EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,183,176,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT + ICON IDI_QUESTION_ICON,IDC_001_STATIC,10,15,20,20, + SS_REALSIZEIMAGE + LTEXT "Destination file exists and is smaller than source file.\nPossible reasons:\n- copying/moving source file wasn't finished (copy rest)\n- file being copied is in another version than destination file (recopy)", + IDC_002_STATIC,41,7,246,41 + LTEXT "Name:",IDC_003_STATIC,48,62,61,8 + LTEXT "Size:",IDC_004_STATIC,48,77,61,8 + LTEXT "Created:",IDC_005_STATIC,48,92,61,8 + LTEXT "Last modified:",IDC_006_STATIC,48,107,61,8 + LTEXT "Source file:",IDC_007_STATIC,41,50,246,8 + LTEXT "Name:",IDC_008_STATIC,48,138,61,8 + LTEXT "Size:",IDC_009_STATIC,48,153,61,8 + LTEXT "Created:",IDC_010_STATIC,48,168,61,8 + LTEXT "Last modified:",IDC_011_STATIC,48,183,61,8 + LTEXT "Destination file:",IDC_012_STATIC,41,125,246,8 + LTEXT "What would you like to do ?",IDC_013_STATIC,41,203,246, + 8 +END + +IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG DIALOGEX 0, 0, 294, 258 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler - destination file found" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + PUSHBUTTON "R&ecopy",IDC_RECOPY_BUTTON,7,237,143,14,0,0, + HIDC_RECOPY_BUTTON + DEFPUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,151,237,86,14,0,0, + HIDC_IGNORE_BUTTON + PUSHBUTTON "&Cancel",IDCANCEL,237,237,50,14,0,0,HIDCANCEL + PUSHBUTTON "Recopy &all",IDC_RECOPY_ALL_BUTTON,7,222,143,14,0,0, + HIDC_RECOPY_ALL_BUTTON + PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,151,222,136,14,0,0, + HIDC_IGNORE_ALL_BUTTON + EDITTEXT IDC_FILENAME_EDIT,111,64,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT + EDITTEXT IDC_FILESIZE_EDIT,111,79,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT + EDITTEXT IDC_CREATETIME_EDIT,111,94,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT + EDITTEXT IDC_MODIFY_TIME_EDIT,111,109,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT + EDITTEXT IDC_DEST_FILENAME_EDIT,111,138,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT + EDITTEXT IDC_DEST_FILESIZE_EDIT,111,153,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT + EDITTEXT IDC_DEST_CREATETIME_EDIT,111,168,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT + EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,183,173,14,ES_AUTOHSCROLL | + ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT + ICON IDI_QUESTION_ICON,IDC_001_STATIC,10,15,20,20, + SS_REALSIZEIMAGE + LTEXT "Destination file exists and has equal or greater size than source file.\nPossible reasons:\n- file being copied is in another version than destination one (recopy/ignore)\n- source and destination files are identical (ignore)", + IDC_002_STATIC,41,7,246,44 + LTEXT "Name:",IDC_003_STATIC,48,64,61,8 + LTEXT "Size:",IDC_004_STATIC,48,79,61,8 + LTEXT "Created:",IDC_005_STATIC,48,94,61,8 + LTEXT "Last modified:",IDC_006_STATIC,48,109,61,8 + LTEXT "Source file:",IDC_007_STATIC,41,52,246,8 + LTEXT "Name:",IDC_008_STATIC,48,138,61,8 + LTEXT "Size:",IDC_009_STATIC,48,153,61,8 + LTEXT "Created:",IDC_010_STATIC,48,168,61,8 + LTEXT "Last modified:",IDC_011_STATIC,48,183,61,8 + LTEXT "Destination file:",IDC_012_STATIC,41,125,246,8 + LTEXT "What would you like to do ?",IDC_013_STATIC,41,203,246, + 8 +END + +IDD_MINIVIEW_DIALOG DIALOGEX 0, 0, 90, 23 +STYLE DS_ABSALIGN | DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | + DS_SETFOREGROUND | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION +EXSTYLE WS_EX_TOOLWINDOW +CAPTION "Status" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + LISTBOX IDC_PROGRESS_LIST,7,7,76,9,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | LBS_NOSEL | NOT WS_BORDER | + WS_TABSTOP,0,HIDC_PROGRESS_LIST +END + +IDD_OPTIONS_DIALOG DIALOGEX 0, 0, 396, 214 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Options" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&OK",IDOK,173,193,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,227,193,50,14,0,0,HIDCANCEL + LISTBOX IDC_PROPERTIES_LIST,7,7,382,179,LBS_OWNERDRAWFIXED | + LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP,0,HIDC_PROPERTIES_LIST + PUSHBUTTON "&Apply",IDC_APPLY_BUTTON,283,193,50,14,0,0, + HIDC_APPLY_BUTTON + PUSHBUTTON "&Help",IDC_HELP_BUTTON,339,193,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_REPLACE_PATHS_DIALOG DIALOGEX 0, 0, 342, 148 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Partial replace of source paths" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + LISTBOX IDC_PATHS_LIST,7,17,328,52,LBS_SORT | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP,0, + HIDC_PATHS_LIST + EDITTEXT IDC_SOURCE_EDIT,7,70,328,14,ES_AUTOHSCROLL,0, + HIDC_SOURCE_EDIT + EDITTEXT IDC_DESTINATION_EDIT,7,98,309,14,ES_AUTOHSCROLL,0, + HIDC_DESTINATION_EDIT + PUSHBUTTON "...",IDC_BROWSE_BUTTON,319,98,16,14,0,0, + HIDC_BROWSE_BUTTON + DEFPUSHBUTTON "OK",IDOK,173,127,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,229,127,50,14,0,0,HIDCANCEL + LTEXT "Source paths:",IDC_001_STATIC,7,7,328,8 + LTEXT "Change to:",IDC_002_STATIC,7,89,328,8 + PUSHBUTTON "&Help",IDC_HELP_BUTTON,285,127,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_STATUS_DIALOG DIALOGEX 0, 0, 478, 250 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_MINIMIZEBOX | + WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Status" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_STATUS_LIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | + WS_BORDER | WS_TABSTOP,7,19,224,171,0,HIDC_STATUS_LIST + PUSHBUTTON "&Pause",IDC_PAUSE_BUTTON,7,196,44,14,0,0, + HIDC_PAUSE_BUTTON + PUSHBUTTON "&Restart",IDC_RESTART_BUTTON,97,196,44,14,0,0, + HIDC_RESTART_BUTTON + PUSHBUTTON "&Cancel",IDC_CANCEL_BUTTON,142,196,44,14,0,0, + HIDC_CANCEL_BUTTON + PUSHBUTTON "&Remove",IDC_DELETE_BUTTON,187,196,44,14,0,0, + HIDC_DELETE_BUTTON + PUSHBUTTON "Pause/all",IDC_PAUSE_ALL_BUTTON,7,213,71,14,0,0, + HIDC_PAUSE_ALL_BUTTON + PUSHBUTTON "Resume/all",IDC_START_ALL_BUTTON,79,213,71,14,0,0, + HIDC_START_ALL_BUTTON + PUSHBUTTON "Cancel/all",IDC_CANCEL_ALL_BUTTON,7,229,71,14,0,0, + HIDC_CANCEL_ALL_BUTTON + PUSHBUTTON "Remove/all",IDC_REMOVE_FINISHED_BUTTON,79,229,71,14,0,0, + HIDC_REMOVE_FINISHED_BUTTON + PUSHBUTTON "Restart/all",IDC_RESTART_ALL_BUTTON,151,229,71,14,0,0, + HIDC_RESTART_ALL_BUTTON + PUSHBUTTON "&Advanced >",IDC_ADVANCED_BUTTON,160,212,71,14,0,0, + HIDC_ADVANCED_BUTTON + PUSHBUTTON "",IDC_STICK_BUTTON,471,243,7,7,BS_CENTER | BS_VCENTER | + BS_FLAT,0,HIDC_STICK_BUTTON + PUSHBUTTON "&<<",IDC_ROLL_UNROLL_BUTTON,212,7,19,12,0,0, + HIDC_ROLL_UNROLL_BUTTON + PUSHBUTTON "...",IDC_SET_BUFFERSIZE_BUTTON,458,72,13,14,0,0, + HIDC_SET_BUFFERSIZE_BUTTON + PUSHBUTTON ">",IDC_SET_PRIORITY_BUTTON,458,88,13,14,0,0, + HIDC_SET_PRIORITY_BUTTON + PUSHBUTTON "View log",IDC_SHOW_LOG_BUTTON,249,116,60,14,0,0, + HIDC_SHOW_LOG_BUTTON + LTEXT "Operations list:",IDC_001_STATIC,7,7,197,8 + CONTROL "Progress1",IDC_ALL_PROGRESS,"msctls_progress32",0x1,312, + 234,159,9 + LTEXT "Progress:",IDC_002_STATIC,249,235,62,8 + CONTROL "Progress2",IDC_TASK_PROGRESS,"msctls_progress32",0x0, + 312,181,159,6 + LTEXT "Progress:",IDC_003_STATIC,249,179,62,8 + LTEXT "Destination object:",IDC_004_STATIC,249,59,62,8 + LTEXT "Source object:",IDC_005_STATIC,249,47,62,8 + LTEXT "Buffer size:",IDC_006_STATIC,249,75,62,8 + LTEXT "Thread priority:",IDC_007_STATIC,249,90,62,8 + LTEXT "Comments:",IDC_008_STATIC,249,106,62,8 + LTEXT "Operation:",IDC_009_STATIC,249,34,62,8 + LTEXT "Transfer:",IDC_010_STATIC,249,167,62,8 + LTEXT "Processed:",IDC_011_STATIC,249,137,62,8 + LTEXT "Transfer:",IDC_012_STATIC,249,220,62,8 + LTEXT "Processed:",IDC_013_STATIC,249,205,62,8 + CTEXT "Global statistics",IDC_014_STATIC,293,191,84,8 + CTEXT "Current selection statistics",IDC_015_STATIC,293,7,113, + 8 + CONTROL "",IDC_016_STATIC,"Static",SS_ETCHEDHORZ,384,194,87,1 + CONTROL "",IDC_017_STATIC,"Static",SS_ETCHEDHORZ,411,10,61,1 + CONTROL "",IDC_018_STATIC,"Static",SS_ETCHEDHORZ,249,194,37,1 + CONTROL "",IDC_019_STATIC,"Static",SS_ETCHEDHORZ,249,10,38,1 + LTEXT "Time:",IDC_020_STATIC,249,152,62,8 + PUSHBUTTON "&Resume",IDC_RESUME_BUTTON,52,196,44,14,0,0, + HIDC_RESUME_BUTTON + EDITTEXT IDC_ERRORS_EDIT,312,104,159,26,ES_MULTILINE | + ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | + WS_VSCROLL,WS_EX_STATICEDGE,HIDC_ERRORS_EDIT + LTEXT "Associated file:",IDC_021_STATIC,249,19,62,8 + CONTROL "",IDC_ASSOCIATEDFILES__STATIC,"STATICEX",0x4,312,17,159, + 12,WS_EX_STATICEDGE,HIDC_ASSOCIATEDFILES__STATIC + CONTROL "",IDC_OPERATION_STATIC,"STATICEX",0x4,312,32,159,12, + WS_EX_STATICEDGE,HIDC_OPERATION_STATIC + CONTROL "",IDC_SOURCE_STATIC,"STATICEX",0x4,312,45,159,12, + WS_EX_STATICEDGE,HIDC_SOURCE_STATIC + CONTROL "",IDC_DESTINATION_STATIC,"STATICEX",0x4,312,58,159,12, + WS_EX_STATICEDGE,HIDC_DESTINATION_STATIC + CONTROL "",IDC_PROGRESS_STATIC,"STATICEX",0x4,312,135,159,12, + WS_EX_STATICEDGE,HIDC_PROGRESS_STATIC + CONTROL "",IDC_TIME_STATIC,"STATICEX",0x4,312,150,159,12, + WS_EX_STATICEDGE,HIDC_TIME_STATIC + CONTROL "",IDC_TRANSFER_STATIC,"STATICEX",0x4,312,165,159,12, + WS_EX_STATICEDGE,HIDC_TRANSFER_STATIC + CONTROL "",IDC_OVERALL_PROGRESS_STATIC,"STATICEX",0x4,312,203, + 159,12,WS_EX_STATICEDGE,HIDC_OVERALL_PROGRESS_STATIC + CONTROL "",IDC_OVERALL_TRANSFER_STATIC,"STATICEX",0x4,312,218, + 159,12,WS_EX_STATICEDGE,HIDC_OVERALL_TRANSFER_STATIC + CONTROL "",IDC_BUFFERSIZE_STATIC,"STATICEX",0x4,312,74,143,12, + WS_EX_STATICEDGE,HIDC_BUFFERSIZE_STATIC + CONTROL "",IDC_PRIORITY_STATIC,"STATICEX",0x4,312,88,143,12, + WS_EX_STATICEDGE,HIDC_PRIORITY_STATIC +END + +IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG DIALOGEX 0, 0, 254, 138 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler - not enough free space" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,78,117,57,14,0,0, + HIDC_RETRY_BUTTON + PUSHBUTTON "C&ontinue",IDC_IGNORE_BUTTON,136,117,57,14,0,0, + HIDC_IGNORE_BUTTON + PUSHBUTTON "&Cancel",IDCANCEL,197,117,50,14,0,0,HIDCANCEL + LISTBOX IDC_FILES_LIST,41,35,206,44,LBS_NOINTEGRALHEIGHT | + WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,0,HIDC_FILES_LIST + LTEXT "",IDC_REQUIRED_STATIC,108,85,139,8,0,0, + HIDC_REQUIRED_STATIC + LTEXT "",IDC_AVAILABLE_STATIC,108,97,139,8,0,0, + HIDC_AVAILABLE_STATIC + ICON IDI_WARNING_ICON,IDC_001_STATIC,9,11,20,20, + SS_REALSIZEIMAGE + LTEXT "Required space:",IDC_003_STATIC,41,85,59,8 + LTEXT "Space available:",IDC_004_STATIC,41,97,59,8 + LTEXT "",IDC_HEADER_STATIC,41,7,206,24 +END + +IDD_SHUTDOWN_DIALOG DIALOGEX 0, 0, 186, 86 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | + WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Copy handler" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Cancel",IDCANCEL,67,65,50,14,0,0,HIDCANCEL + ICON IDI_SHUTDOWN_ICON,IDC_001_STATIC,7,10,20,20, + SS_REALSIZEIMAGE + LTEXT "All copy/move operations were finished. Attempt to shut down the system will be performed in:", + IDC_002_STATIC,37,7,142,24 + CTEXT "",IDC_TIME_STATIC,7,35,172,8 + CONTROL "Progress1",IDC_TIME_PROGRESS,"msctls_progress32",0x1,7, + 48,172,9 +END + +IDD_CUSTOM_COPY_DIALOG DIALOGEX 0, 0, 349, 319 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_APPWINDOW +CAPTION "Copying/moving parameters" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_FILES_LIST,"SysListView32",LVS_REPORT | + LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | + LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,16,279,57, + 0,HIDC_FILES_LIST + PUSHBUTTON "Add &file(s)...",IDC_ADDFILE_BUTTON,289,15,53,14,0,0, + HIDC_ADDFILE_BUTTON + PUSHBUTTON "Add f&older...",IDC_ADDDIR_BUTTON,289,30,53,14,0,0, + HIDC_ADDDIR_BUTTON + PUSHBUTTON "&Delete",IDC_REMOVEFILEFOLDER_BUTTON,289,45,53,14,0,0, + HIDC_REMOVEFILEFOLDER_BUTTON + PUSHBUTTON "&Import...",IDC_IMPORT_BUTTON,289,60,53,14,0,0, + HIDC_IMPORT_BUTTON + CONTROL "",IDC_DESTPATH_COMBOBOXEX,"ComboBoxEx32",CBS_DROPDOWN | + CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP,7, + 86,314,136,0,HIDC_DESTPATH_COMBOBOXEX + PUSHBUTTON "...",IDC_DESTBROWSE_BUTTON,324,85,18,14,0,0, + HIDC_DESTBROWSE_BUTTON + COMBOBOX IDC_OPERATION_COMBO,13,124,117,143,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_OPERATION_COMBO + COMBOBOX IDC_PRIORITY_COMBO,137,124,122,75,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_PRIORITY_COMBO + EDITTEXT IDC_COUNT_EDIT,262,124,80,14,ES_AUTOHSCROLL,0, + HIDC_COUNT_EDIT + CONTROL "Spin1",IDC_COUNT_SPIN,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,331,124, + 11,14 + LISTBOX IDC_BUFFERSIZES_LIST,13,152,275,20,LBS_NOINTEGRALHEIGHT | + LBS_MULTICOLUMN | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP,0, + HIDC_BUFFERSIZES_LIST + PUSHBUTTON "&Change...",IDC_BUFFERSIZES_BUTTON,292,152,50,14,0,0, + HIDC_BUFFERSIZES_BUTTON + CONTROL "Filtering",IDC_FILTERS_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,7,177,61,10,0,HIDC_FILTERS_CHECK + CONTROL "List2",IDC_FILTERS_LIST,"SysListView32",LVS_REPORT | + WS_BORDER | WS_TABSTOP,13,190,303,46,0,HIDC_FILTERS_LIST + PUSHBUTTON "+",IDC_ADDFILTER_BUTTON,320,190,22,14,0,0, + HIDC_ADDFILTER_BUTTON + PUSHBUTTON "-",IDC_REMOVEFILTER_BUTTON,320,206,22,14,0,0, + HIDC_REMOVEFILTER_BUTTON + CONTROL "Advanced options",IDC_ADVANCED_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,242,84,10,0, + HIDC_ADVANCED_CHECK + CONTROL "Do not create destination directories - copy files loosely to destination folder", + IDC_IGNOREFOLDERS_CHECK,"Button",BS_AUTOCHECKBOX | + BS_NOTIFY | WS_TABSTOP,13,255,329,10,0, + HIDC_IGNOREFOLDERS_CHECK + CONTROL "Do not copy/move contents of files - only create it (empty)", + IDC_ONLYSTRUCTURE_CHECK,"Button",BS_AUTOCHECKBOX | + BS_NOTIFY | WS_TABSTOP,13,277,329,10,0, + HIDC_ONLYSTRUCTURE_CHECK + PUSHBUTTON "&OK",IDOK,186,298,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,239,298,50,14,0,0,HIDCANCEL + LTEXT "Source files/folders:",IDC_001_STATIC,7,7,335,8 + LTEXT "Destination folder:",IDC_002_STATIC,7,76,335,8 + LTEXT "Operation type:",IDC_003_STATIC,13,115,117,8 + LTEXT "Priority:",IDC_004_STATIC,137,115,120,8 + LTEXT "Count of copies:",IDC_005_STATIC,262,115,80,8 + LTEXT "Buffer sizes:",IDC_006_STATIC,13,142,244,8 + CONTROL "",IDC_BAR3_STATIC,"Static",SS_ETCHEDHORZ,74,181,268,1 + CONTROL "",IDC_BAR4_STATIC,"Static",SS_ETCHEDHORZ,96,247,246,1 + CONTROL "",IDC_BAR5_STATIC,"Static",SS_ETCHEDHORZ,7,291,335,1 + CONTROL "",IDC_BAR2_STATIC,"Static",SS_ETCHEDHORZ,105,107,237,1 + CTEXT "Standard options",IDC_007_STATIC,20,104,80,8 + CONTROL "",IDC_BAR1_STATIC,"Static",SS_ETCHEDHORZ,7,107,8,1 + CONTROL "Create directory structure in destination folder (relatively to root directory)", + IDC_FORCEDIRECTORIES_CHECK,"Button",BS_AUTOCHECKBOX | + BS_NOTIFY | WS_TABSTOP,13,266,329,10,0, + HIDC_FORCEDIRECTORIES_CHECK + PUSHBUTTON "&Help",IDC_HELP_BUTTON,292,298,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_FILTER_DIALOG DIALOGEX 0, 0, 291, 266 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Filtering settings" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + CONTROL "Include mask (separate by vertical lines ie. *.jpg|*.gif)", + IDC_FILTER_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + 7,277,10,0,HIDC_FILTER_CHECK + COMBOBOX IDC_FILTER_COMBO,15,19,269,98,CBS_DROPDOWN | WS_VSCROLL | + WS_TABSTOP,0,HIDC_FILTER_COMBO + CONTROL "Exclude mask",IDC_EXCLUDEMASK_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,35,277,10,0, + HIDC_EXCLUDEMASK_CHECK + COMBOBOX IDC_FILTEREXCLUDE_COMBO,15,48,269,170,CBS_DROPDOWN | + WS_VSCROLL | WS_TABSTOP,0,HIDC_FILTEREXCLUDE_COMBO + CONTROL "Filtering by size",IDC_SIZE_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,66,277,10,0, + HIDC_SIZE_CHECK + COMBOBOX IDC_SIZETYPE1_COMBO,63,81,34,140,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZETYPE1_COMBO + EDITTEXT IDC_SIZE1_EDIT,100,80,77,14,ES_AUTOHSCROLL,0, + HIDC_SIZE1_EDIT + CONTROL "Spin1",IDC_SIZE1_SPIN,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,166,80,11, + 14,0,HIDC_SIZE1_SPIN + COMBOBOX IDC_SIZE1MULTI_COMBO,180,81,34,135,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZE1MULTI_COMBO + CONTROL "and",IDC_SIZE2_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,30,101,32,10,0,HIDC_SIZE2_CHECK + COMBOBOX IDC_SIZETYPE2_COMBO,63,99,34,137,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZETYPE2_COMBO + EDITTEXT IDC_SIZE2_EDIT,100,98,77,14,ES_AUTOHSCROLL,0, + HIDC_SIZE2_EDIT + CONTROL "Spin1",IDC_SIZE2_SPIN,"msctls_updown32",UDS_SETBUDDYINT | + UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,166,98,11, + 14,0,HIDC_SIZE2_SPIN + COMBOBOX IDC_SIZE2MULTI_COMBO,180,99,34,143,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZE2MULTI_COMBO + CONTROL "Filtering by date",IDC_DATE_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,124,277,10,0, + HIDC_DATE_CHECK + COMBOBOX IDC_DATETYPE_COMBO,32,138,151,133,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_DATETYPE_COMBO + COMBOBOX IDC_DATE1TYPE_COMBO,58,158,48,104,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_DATE1TYPE_COMBO + CONTROL "DateTimePicker1",IDC_DATE1_DATETIMEPICKER, + "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | + DTS_SHOWNONE | WS_TABSTOP,108,157,109,15,0, + HIDC_DATE1_DATETIMEPICKER + CONTROL "DateTimePicker2",IDC_TIME1_DATETIMEPICKER, + "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | + DTS_SHOWNONE | WS_TABSTOP,220,157,64,15,0, + HIDC_TIME1_DATETIMEPICKER + CONTROL "and",IDC_DATE2_CHECK,"Button",BS_AUTOCHECKBOX | + WS_TABSTOP,25,176,30,10,0,HIDC_DATE2_CHECK + COMBOBOX IDC_DATE2TYPE_COMBO,58,174,48,107,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP,0,HIDC_DATE2TYPE_COMBO + CONTROL "DateTimePicker1",IDC_DATE2_DATETIMEPICKER, + "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | + DTS_SHOWNONE | WS_TABSTOP,108,173,109,15,0, + HIDC_DATE2_DATETIMEPICKER + CONTROL "DateTimePicker2",IDC_TIME2_DATETIMEPICKER, + "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | + DTS_SHOWNONE | WS_TABSTOP,220,173,64,15,0, + HIDC_TIME2_DATETIMEPICKER + CONTROL "By attributes",IDC_ATTRIBUTES_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,199,277,10,0, + HIDC_ATTRIBUTES_CHECK + CONTROL "Archive",IDC_ARCHIVE_CHECK,"Button",BS_AUTO3STATE | + WS_TABSTOP,29,212,81,10,0,HIDC_ARCHIVE_CHECK + CONTROL "Read only",IDC_READONLY_CHECK,"Button",BS_AUTO3STATE | + WS_TABSTOP,29,224,81,10,0,HIDC_READONLY_CHECK + CONTROL "Hidden",IDC_HIDDEN_CHECK,"Button",BS_AUTO3STATE | + WS_TABSTOP,117,212,68,10,0,HIDC_HIDDEN_CHECK + CONTROL "System",IDC_SYSTEM_CHECK,"Button",BS_AUTO3STATE | + WS_TABSTOP,117,224,68,10,0,HIDC_SYSTEM_CHECK + CONTROL "Directory",IDC_DIRECTORY_CHECK,"Button",BS_AUTO3STATE | + NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,191,212,93,10, + 0,HIDC_DIRECTORY_CHECK + DEFPUSHBUTTON "&OK",IDOK,127,245,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,179,245,50,14,0,0,HIDCANCEL + CONTROL "",IDC_001_STATIC,"Static",SS_ETCHEDHORZ,7,238,276,1 + PUSHBUTTON "&Help",IDC_HELP_BUTTON,234,245,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_SHORTCUTEDIT_DIALOG DIALOGEX 0, 0, 324, 206 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Shortcuts editing" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_SHORTCUT_LIST,"SysListView32",LVS_REPORT | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | + LVS_AUTOARRANGE | LVS_EDITLABELS | WS_BORDER | + WS_TABSTOP,7,16,261,88,0,HIDC_SHORTCUT_LIST + EDITTEXT IDC_NAME_EDIT,77,123,228,14,ES_AUTOHSCROLL,0, + HIDC_NAME_EDIT + CONTROL "",IDC_PATH_COMBOBOXEX,"ComboBoxEx32",CBS_DROPDOWN | + CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP,77, + 142,205,89,0,HIDC_PATH_COMBOBOXEX + PUSHBUTTON "...",IDC_BROWSE_BUTTON,286,142,18,13,0,0, + HIDC_BROWSE_BUTTON + PUSHBUTTON "&Add",IDC_ADD_BUTTON,17,160,50,14,0,0,HIDC_ADD_BUTTON + PUSHBUTTON "&Update",IDC_CHANGE_BUTTON,69,160,50,14,0,0, + HIDC_CHANGE_BUTTON + PUSHBUTTON "&Delete",IDC_DELETE_BUTTON,121,160,50,14,0,0, + HIDC_DELETE_BUTTON + DEFPUSHBUTTON "&OK",IDOK,156,185,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,211,185,50,14,0,0,HIDCANCEL + LTEXT "Shortcuts:",IDC_001_STATIC,7,7,310,8 + LTEXT "Name:",IDC_002_STATIC,18,126,53,8 + LTEXT "Path:",IDC_003_STATIC,18,145,56,8 + GROUPBOX "Shortcut properties",IDC_004_STATIC,7,111,310,70 + PUSHBUTTON "Move up",IDC_UP_BUTTON,272,47,45,14,0,0,HIDC_UP_BUTTON + PUSHBUTTON "Move down",IDC_DOWN_BUTTON,272,63,45,14,0,0, + HIDC_DOWN_BUTTON + PUSHBUTTON "&Help",IDC_HELP_BUTTON,267,185,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_RECENTEDIT_DIALOG DIALOGEX 0, 0, 324, 190 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "Recent paths" +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + CONTROL "List1",IDC_RECENT_LIST,"SysListView32",LVS_LIST | + LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | + LVS_AUTOARRANGE | LVS_EDITLABELS | WS_BORDER | + WS_TABSTOP,7,16,310,88,0,HIDC_RECENT_LIST + EDITTEXT IDC_PATH_EDIT,20,123,266,14,ES_AUTOHSCROLL,0, + HIDC_PATH_EDIT + PUSHBUTTON "...",IDC_BROWSE_BUTTON,290,123,18,14,0,0, + HIDC_BROWSE_BUTTON + PUSHBUTTON "&Add",IDC_ADD_BUTTON,20,141,50,14,0,0,HIDC_ADD_BUTTON + PUSHBUTTON "&Update",IDC_CHANGE_BUTTON,72,141,50,14,0,0, + HIDC_CHANGE_BUTTON + PUSHBUTTON "&Delete",IDC_DELETE_BUTTON,124,141,50,14,0,0, + HIDC_DELETE_BUTTON + DEFPUSHBUTTON "&OK",IDOK,156,169,50,14,0,0,HIDOK + PUSHBUTTON "&Cancel",IDCANCEL,211,169,50,14,0,0,HIDCANCEL + LTEXT "Recently used paths:",IDC_001_STATIC,7,7,310,8 + GROUPBOX "Path",IDC_002_STATIC,7,110,310,51 + PUSHBUTTON "&Help",IDC_HELP_BUTTON,267,169,50,14,0,0, + HIDC_HELP_BUTTON +END + +IDD_ABOUTBOX DIALOGEX 0, 0, 369, 249 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | + WS_CAPTION | WS_SYSMENU +CAPTION "About ..." +FONT 8, "Tahoma", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&OK",IDOK,306,228,56,14,WS_GROUP,0,HIDOK + ICON IDR_MAINFRAME,IDC_STATIC,11,14,20,20 + CTEXT "Copyright (C) 2001-2004 J�zef Starosczyk", + IDC_COPYRIGHT_STATIC,40,80,322,8 + LTEXT "General discussion forum:",IDC_GENFORUM_STATIC,46,124, + 98,8 + LTEXT "Developers' discussion forum: ",IDC_DEVFORUM_STATIC,46, + 137,98,8 + LTEXT "Special thanks list:",IDC_THANX_STATIC,46,154,316,8 + EDITTEXT IDC_THANX_EDIT,46,164,316,54,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | WS_VSCROLL,WS_EX_STATICEDGE, + HIDC_THANX_EDIT + CONTROL "http://www.copyhandler.com|http://www.copyhandler.com", + IDC_HOMEPAGELINK_STATIC,"STATICEX",0x1,257,7,105,8 + CONTROL "ixen@copyhandler.com|mailto:ixen@copyhandler.com", + IDC_CONTACT1LINK_STATIC,"STATICEX",0x1,257,41,105,8 + CONTROL "Page|http://groups.yahoo.com/group/copyhandler", + IDC_GENFORUMPAGELINK_STATIC,"STATICEX",0x1,155,124,33,8 + CONTROL "Page|http://groups.yahoo.com/group/chdev", + IDC_DEVFORUMPAGELINK_STATIC,"STATICEX",0x1,155,137,33,8 + CONTROL "Subscribe|mailto:copyhandler-subscribe@yahoogroups.com", + IDC_GENFORUMSUBSCRIBELINK_STATIC,"STATICEX",0x1,198,124, + 44,8 + CONTROL "Subscribe|mailto:chdev-subscribe@yahoogroups.com", + IDC_DEVFORUMSUBSCRIBELINK_STATIC,"STATICEX",0x1,198,137, + 44,8 + CONTROL "Unsubscribe|mailto:copyhandler-unsubscribe@yahoogroups.com", + IDC_GENFORUMUNSUBSCRIBELINK_STATIC,"STATICEX",0x1,251, + 124,48,8 + CONTROL "Unsubscribe|mailto:chdev-unsubscribe@yahoogroups.com", + IDC_DEVFORUMUNSUBSCRIBELINK_STATIC,"STATICEX",0x1,251, + 137,48,8 + CONTROL "Send message|mailto:copyhandler@yahoogroups.com", + IDC_GENFORUMSENDLINK_STATIC,"STATICEX",0x1,307,124,55,8 + CONTROL "Send message|mailto:chdev@yahoogroups.com", + IDC_DEVFORUMSENDLINK_STATIC,"STATICEX",0x1,307,137,55,8 + CONTROL "",IDC_PROGRAM_STATICEX,"STATICEX",0x30,39,7,122,10 + CONTROL "",IDC_FULLVERSION_STATICEX,"STATICEX",0x10,39,20,109,8 + CONTROL "Home page:",IDC_HOMEPAGE_STATICEX,"STATICEX",0x10,185,7, + 68,8 + CONTROL "Contact:",IDC_CONTACT_STATICEX,"STATICEX",0x10,185,29, + 68,8 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,39,92,323,1 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,39,120,323,1 + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,41,148,321,1 + CONTROL "This program is free software and may be distributed according to the terms of the GNU General Public License.", + IDC_LICENSE_STATICEX,"STATICEX",0x90,46,98,310,16 + CONTROL "http://www.copyhandler.prv.pl|http://www.copyhandler.prv.pl", + IDC_HOMEPAGELINK2_STATIC,"STATICEX",0x1,257,17,105,8 + CONTROL "Author:",IDC_CONTACTAUTHOR_STATICEX,"STATICEX",0x50,185, + 41,68,8 + CONTROL "support@copyhandler.com|mailto:support@copyhandler.com", + IDC_CONTACT2LINK_STATIC,"STATICEX",0x1,257,55,105,8 + CONTROL "Support:",IDC_CONTACTSUPPORT_STATICEX,"STATICEX",0x50, + 185,55,68,8 + CONTROL "copyhandler@o2.pl|mailto:copyhandler@o2.pl", + IDC_CONTACT3LINK_STATIC,"STATICEX",0x1,257,66,105,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,28,43,1507 + PRODUCTVERSION 1,28,43,1507 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x29L +#else + FILEFLAGS 0x28L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Program for copying files/folders" + VALUE "CompanyName", " " + VALUE "FileDescription", "Copy Handler v. 1.28 development snapshot" + VALUE "FileVersion", "1.28.43.1507" + VALUE "InternalName", "Copy Handler" + VALUE "LegalCopyright", "Copyright (C) 2001-2006 J�zef Starosczyk" + VALUE "LegalTrademarks", " " + VALUE "OriginalFilename", "COPY HANDLER.EXE" + VALUE "PrivateBuild", " " + VALUE "ProductName", "Copy Handler v. 1.28 development version" + VALUE "ProductVersion", "1.28.43.1507" + VALUE "SpecialBuild", " " + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_BUFFERSIZE_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 337 + TOPMARGIN, 7 + BOTTOMMARGIN, 120 + END + + IDD_FEEDBACK_DSTFILE_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 283 + TOPMARGIN, 7 + BOTTOMMARGIN, 104 + END + + IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 287 + TOPMARGIN, 7 + BOTTOMMARGIN, 235 + END + + IDD_FEEDBACK_REPLACE_FILES_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 287 + TOPMARGIN, 7 + BOTTOMMARGIN, 251 + END + + IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 287 + TOPMARGIN, 7 + BOTTOMMARGIN, 251 + END + + IDD_MINIVIEW_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 83 + TOPMARGIN, 7 + BOTTOMMARGIN, 16 + END + + IDD_OPTIONS_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 389 + TOPMARGIN, 7 + BOTTOMMARGIN, 207 + END + + IDD_REPLACE_PATHS_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 335 + TOPMARGIN, 7 + BOTTOMMARGIN, 141 + END + + IDD_STATUS_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 471 + TOPMARGIN, 7 + BOTTOMMARGIN, 243 + END + + IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 247 + TOPMARGIN, 7 + BOTTOMMARGIN, 131 + END + + IDD_SHUTDOWN_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 179 + TOPMARGIN, 7 + BOTTOMMARGIN, 79 + END + + IDD_CUSTOM_COPY_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 342 + TOPMARGIN, 7 + BOTTOMMARGIN, 312 + END + + IDD_FILTER_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 284 + TOPMARGIN, 7 + BOTTOMMARGIN, 259 + END + + IDD_SHORTCUTEDIT_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 317 + TOPMARGIN, 7 + BOTTOMMARGIN, 199 + END + + IDD_RECENTEDIT_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 317 + TOPMARGIN, 7 + BOTTOMMARGIN, 183 + END + + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 362 + TOPMARGIN, 7 + BOTTOMMARGIN, 242 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_POPUP_TOOLBAR TOOLBAR 16, 15 +BEGIN + BUTTON ID_POPUP_OPTIONS +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_POPUP_TOOLBAR BITMAP "res\\main_toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// RT_MANIFEST +// + +IDR_MANIFEST RT_MANIFEST "res\\manifest.txt" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "#ifdef _WIN32\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#endif\r\n" + "#include ""res\\COPY HANDLER.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#endif\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_ONECOPY_STRING "Cannot run the second instance of this program" + IDS_REGISTEROK_STRING "Library chext.dll was registered successfully" + IDS_REGISTERERR_STRING "Encountered error while trying to register library chext.dll\nError #%lu (%s)." + IDS_UNREGISTEROK_STRING "Library chext.dll was unregistered successfully" + IDS_UNREGISTERERR_STRING + "Encountered error while trying to unregister library chext.dll\nError #%lu (%s)." + IDS_HELPERR_STRING "Cannot open html help file:\n%s\n" +END + +STRINGTABLE +BEGIN + IDS_BROWSE_STRING "Choose path" + IDS_BDREMOTENAME_STRING "Remote name: " + IDS_BDLOCALNAME_STRING "Local name: " + IDS_BDTYPE_STRING "Type: " + IDS_BDNETTYPE_STRING "Network type: " + IDS_BDDESCRIPTION_STRING "Description: " + IDS_BDFREESPACE_STRING "Free space: " + IDS_BDCAPACITY_STRING "Capacity: " +END + +STRINGTABLE +BEGIN + IDS_FILEDLGALLFILTER_STRING "All files (*)|*||" + IDS_DSTFOLDERBROWSE_STRING "Choose destination folder" + IDS_MISSINGDATA_STRING "You didn't fill destination path or source file.\nProgram cannot continue" + IDS_CCDCOPY_STRING "Copy" + IDS_CCDMOVE_STRING "Move" + IDS_BSEDEFAULT_STRING "Default: %s" + IDS_BSEONEDISK_STRING "One Disk: %s" + IDS_BSETWODISKS_STRING "Two disks: %s" +END + +STRINGTABLE +BEGIN + IDS_APPNAME_STRING "Copy Handler" + IDS_PRIORITY0_STRING "Time critical" + IDS_PRIORITY1_STRING "Highest" + IDS_PRIORITY2_STRING "Above normal" + IDS_PRIORITY3_STRING "Normal" + IDS_PRIORITY4_STRING "Below normal" + IDS_PRIORITY5_STRING "Lowest" + IDS_PRIORITY6_STRING "Idle" +END + +STRINGTABLE +BEGIN + IDS_MINIVIEWALL_STRING "All:" +END + +STRINGTABLE +BEGIN + IDS_PROGRAM_STRING "Program" + IDS_CLIPBOARDMONITORING_STRING "Clipboard monitoring" + IDS_CLIPBOARDINTERVAL_STRING "Scan clipboard every ... [ms]" + IDS_AUTORUNPROGRAM_STRING "Run program with system" + IDS_AUTOSHUTDOWN_STRING "Shutdown system after copying finishes" + IDS_AUTOSAVEINTERVAL_STRING "Autosave every ... [ms]" + IDS_TEMPFOLDER_STRING "Folder for temporary data" + IDS_STATUSWINDOW_STRING "Status window" + IDS_REFRESHSTATUSINTERVAL_STRING "Refresh status every ... [ms]" + IDS_STATUSSHOWDETAILS_STRING "Show details in status window" + IDS_STATUSAUTOREMOVE_STRING "Automatically remove finished tasks" + IDS_MINIVIEW_STRING "Miniview" + IDS_SHOWFILENAMES_STRING "Show file names" + IDS_SHOWSINGLETASKS_STRING "Show single tasks" + IDS_MINIVIEWREFRESHINTERVAL_STRING "Refresh status every ... [ms]" + IDS_MINIVIEWSHOWAFTERSTART_STRING "Show at program startup" +END + +STRINGTABLE +BEGIN + IDS_CFGSHSHOWICONS_STRING "Show icons with shortcuts (experimental)" + IDS_CFGSHOVERRIDEDRAG_STRING + "Intercept drag&drop operation by left mouse button (experimental)" + IDS_CFGSHORTCUTS_STRING "Shortcuts" + IDS_CFGRECENT_STRING "Recently used paths" + IDS_CFGSHELL_STRING "Shell" + IDS_CFGSCCOUNT_STRING "Defined shortcuts' count" + IDS_CFGRPCOUNT_STRING "Count of recent paths" + IDS_CFGOVERRIDEDEFACTION_STRING + "Default action for dragging by left mouse button" + IDS_CFGPRIORITYCLASS_STRING "Application's priority class" + IDS_CFGDISABLEPRIORITYBOOST_STRING "Disable priority boosting" + IDS_BOOLTEXT_STRING "No!Yes" + IDS_TEMPFOLDERCHOOSE_STRING "!Choose temporary folder" + IDS_FEEDBACKTYPE_STRING "Disabled!Normal!Heavy" + IDS_SOUNDSWAVFILTER_STRING "!Sound files (.wav)|*.wav||" + IDS_FORCESHUTDOWNVALUES_STRING "Normal!Force" +END + +STRINGTABLE +BEGIN + IDS_MINIVIEWAUTOHIDE_STRING "Hide when empty" + IDS_PROCESSINGTHREAD_STRING "Copying/moving thread" + IDS_AUTOCOPYREST_STRING "Auto ""copy-rest"" of files" + IDS_SETDESTATTRIB_STRING "Set attributes of destination files" + IDS_SETDESTTIME_STRING "Set date/time of destination files" + IDS_PROTECTROFILES_STRING "Protect read-only files" + IDS_LIMITOPERATIONS_STRING + "Limit maximum operations running simultaneously ..." + IDS_SHOWVISUALFEEDBACK_STRING "Show visual confirmation dialogs" + IDS_USETIMEDDIALOGS_STRING "Use timed confirmation dialogs" + IDS_TIMEDDIALOGINTERVAL_STRING "Time of showing confirmation dialogs" + IDS_AUTORETRYONERROR_STRING "Auto resume on error" + IDS_AUTORETRYINTERVAL_STRING "Auto resume every ... [ms]" + IDS_DEFAULTPRIORITY_STRING "Default thread priority" + IDS_AUTODETECTBUFFERSIZE_STRING "Use only default buffer" + IDS_DEFAULTBUFFERSIZE_STRING "Default buffer size" + IDS_DELETEAFTERFINISHED_STRING + "Don't delete files before copying finishes (moving)" +END + +STRINGTABLE +BEGIN + IDS_CREATELOGFILES_STRING "Create .log files" + IDS_SOUNDS_STRING "Sounds" + IDS_PLAYSOUNDS_STRING "Playing sounds" + IDS_SOUNDONERROR_STRING "Sound on error" + IDS_SOUNDONFINISH_STRING "Sound on copying finished" + IDS_LANGUAGE_STRING "Language" + IDS_READSIZEBEFOREBLOCK_STRING "Read tasks size before blocking" + IDS_USENOBUFFERING_STRING "Disable buffering for large files" + IDS_LARGEFILESMINSIZE_STRING + "Minimum file size for which buffering should be turned off" + IDS_OPTIONSBUFFER_STRING "Buffer" + IDS_ONEDISKBUFFERSIZE_STRING + "Buffer size for copying inside one physical disk boundary" + IDS_TWODISKSBUFFERSIZE_STRING + "Buffer size for copying between two different disks" + IDS_CDBUFFERSIZE_STRING "Buffer size for copying from CD-ROM" + IDS_LANBUFFERSIZE_STRING "Buffer size for copying over a network" + IDS_SHUTDOWNTIME_STRING "Wait ... [ms] before shutdown" + IDS_FORCESHUTDOWN_STRING "Type of shutdown" +END + +STRINGTABLE +BEGIN + IDS_SOURCESTRINGMISSING_STRING "You didn't enter source text" +END + +STRINGTABLE +BEGIN + IDS_COLUMNSTATUS_STRING "Status" + IDS_COLUMNSOURCE_STRING "File" + IDS_COLUMNDESTINATION_STRING "To:" + IDS_COLUMNPROGRESS_STRING "Progress" +END + +STRINGTABLE +BEGIN + IDS_EMPTYOPERATIONTEXT_STRING "None of tasks selected" + IDS_EMPTYSOURCETEXT_STRING "empty" + IDS_EMPTYDESTINATIONTEXT_STRING "empty" + IDS_EMPTYBUFFERSIZETEXT_STRING "unknown" + IDS_EMPTYPRIORITYTEXT_STRING "unknown" + IDS_EMPTYERRORTEXT_STRING "empty" + IDS_EMPTYPROCESSEDTEXT_STRING "empty" + IDS_EMPTYTRANSFERTEXT_STRING "unknown" + IDS_EMPTYTIMETEXT_STRING "00:00 / 00:00" + IDS_CURRENTPASS_STRING "pass: " + IDS_AVERAGEWORD_STRING "avg: " + IDS_STATUSTITLE_STRING "Status" + IDS_REPLACEPATHSTEXT_STRING + "Changed:\n%d paths primarily got from clipboard" + IDS_TASKNOTPAUSED_STRING "Selected task isn't paused" + IDS_TASKNOTSELECTED_STRING "Task not selected" + IDS_NONEINPUTFILE_STRING "(waiting...)" +END + +STRINGTABLE +BEGIN + IDS_BUFFERSIZEZERO_STRING "Cannot operate with buffer of 0 size" +END + +STRINGTABLE +BEGIN + IDS_OTFSEARCHINGFORFILES_STRING "Searching for files..." + IDS_OTFMISSINGCLIPBOARDINPUT_STRING + "Source file/folder not found (clipboard) : %s" + IDS_OTFADDINGCLIPBOARDFILE_STRING + "Adding file/folder (clipboard) : %s ..." + IDS_OTFADDEDFOLDER_STRING "Added folder %s" + IDS_OTFRECURSINGFOLDER_STRING "Recursing folder %s" + IDS_OTFADDINGKILLREQEST_STRING + "Kill request while adding data to files array (RecurseDirectories)" + IDS_OTFADDEDFILE_STRING "Added file %s" + IDS_OTFSEARCHINGFINISHED_STRING "Searching for files finished" +END + +STRINGTABLE +BEGIN + IDS_OTFDELETINGFILES_STRING "Deleting files (DeleteFiles)..." + IDS_OTFDELETINGKILLREQUEST_STRING + "Kill request while deleting files (Delete Files)" + IDS_OTFDELETINGERROR_STRING + "Error #%lu (%s) while deleting file/folder %s" + IDS_OTFDELETINGFINISHED_STRING "Deleting files finished" + IDS_OTFPRECHECKCANCELREQUEST_STRING + "Cancel request while checking result of dialog before opening source file %s (CustomCopyFile)" + IDS_OTFOPENINGERROR_STRING + "Error %err while opening source file %s (CustomCopyFile)" + IDS_OTFOPENINGCANCELREQUEST_STRING + "Cancel request [error %err] while opening source file %s (CustomCopyFile)" + IDS_OTFOPENINGWAITREQUEST_STRING + "Wait request [error %err] while opening source file %s (CustomCopyFile)" + IDS_OTFOPENINGRETRY_STRING + "Retrying [error %err] to open source file %s (CustomCopyFile)" + IDS_OTFDESTOPENINGERROR_STRING + "Error %err while opening destination file %s (CustomCopyFile)" + IDS_OTFDESTOPENINGRETRY_STRING + "Retrying [error %err] to open destination file %s (CustomCopyFile)" + IDS_OTFDESTOPENINGCANCELREQUEST_STRING + "Cancel request [error %err] while opening destination file %s (CustomCopyFile)" + IDS_OTFDESTOPENINGWAITREQUEST_STRING + "Wait request [error %err] while opening destination file %s (CustomCopyFile)" + IDS_OTFMOVINGPOINTERSERROR_STRING + "Error %err while moving file pointers of %s and %s to %I64u" + IDS_OTFRESTORINGPOINTERSERROR_STRING + "Error %err while restoring (moving to beginning) file pointers of %s and %s" + IDS_OTFSETTINGZEROSIZEERROR_STRING + "Error %err while setting size of file %s to 0" +END + +STRINGTABLE +BEGIN + IDS_OTFCOPYINGKILLREQUEST_STRING + "Kill request while main copying file %s -> %s" + IDS_OTFCHANGINGBUFFERSIZE_STRING + "Changing buffer size from [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu] to [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu] wile copying %s -> %s (CustomCopyFile)" + IDS_OTFREADINGERROR_STRING + "Error %err while trying to read %d bytes from source file %s (CustomCopyFile)" + IDS_OTFWRITINGERROR_STRING + "Error %err while trying to write %d bytes to destination file %s (CustomCopyFile)" + IDS_OTFCAUGHTEXCEPTIONCCF_STRING + "Caught exception in CustomCopyFile [last error: %err] (at time %lu)" + IDS_OTFPROCESSINGFILES_STRING "Processing files/folders (ProcessFiles)" + IDS_OTFPROCESSINGFILESDATA_STRING + "Processing files/folders (ProcessFiles):\r\n\tOnlyCreate: %d\r\n\tBufferSize: [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu]\r\n\tFiles/folders count: %lu\r\n\tCopies count: %d\r\n\tIgnore Folders: %d\r\n\tDest path: %s\r\n\tCurrent pass (0-based): %d\r\n\tCurrent index (0-based): %d" + IDS_OTFPROCESSINGKILLREQUEST_STRING + "Kill request while processing file in ProcessFiles" + IDS_OTFMOVEFILEERROR_STRING + "Error %err while calling MoveFile %s -> %s (ProcessFiles)" + IDS_OTFCREATEDIRECTORYERROR_STRING + "Error %err while calling CreateDirectory %s (ProcessFiles)" + IDS_OTFPROCESSINGFINISHED_STRING "Finished processing in ProcessFiles" + IDS_OTFTHREADSTART_STRING + "\r\n# COPYING THREAD STARTED #\r\nBegan processing data (dd:mm:yyyy) %02d.%02d.%4d at %02d:%02d.%02d" + IDS_OTFWAITINGFINISHED_STRING "Finished waiting for begin permission" + IDS_OTFWAITINGKILLREQUEST_STRING + "Kill request while waiting for begin permission (wait state)" + IDS_OTFTHREADFINISHED_STRING + "Finished processing data (dd:mm:yyyy) %02d.%02d.%4d at %02d:%02d.%02d" + IDS_OTFCAUGHTEXCEPTIONMAIN_STRING + "Caught exception in ThrdProc [last error: %err, type: %d]" +END + +STRINGTABLE +BEGIN + IDS_TITLECOPY_STRING "Copying..." + IDS_TITLEMOVE_STRING "Moving..." + IDS_TITLEUNKNOWNOPERATION_STRING + "Unknown operation type - this shouldn't happen" + IDS_MAINBROWSETEXT_STRING "Enter destination path for:\n" +END + +STRINGTABLE +BEGIN + IDS_COPYWORDLESSFIVE_STRING " copies" + IDS_COPYWORDMOREFOUR_STRING " copies" + IDS_STATUS0_STRING "Searching" + IDS_STATUS1_STRING "Copying" + IDS_STATUS2_STRING "Moving" + IDS_STATUS3_STRING "Finished" + IDS_STATUS4_STRING "Error" + IDS_STATUS5_STRING "Paused" + IDS_STATUS6_STRING "Deleting" + IDS_STATUS7_STRING "Unknown" + IDS_STATUS8_STRING "Cancelled" + IDS_STATUS9_STRING "Waiting" + IDS_STATUS10_STRING "Only files" + IDS_STATUS11_STRING "Without contents" + IDS_SHELLEXECUTEERROR_STRING "Error #%lu calling ShellExecute for file %s" + IDS_BSDEFAULT_STRING "Default: " +END + +STRINGTABLE +BEGIN + IDS_FIRSTCOPY_STRING "Copy of %s" + IDS_NEXTCOPY_STRING "Copy (%d) of %s" + IDS_NOTFOUND_STRING "File not found (doesn't exist)" + IDS_BYTE_STRING "B" + IDS_KBYTE_STRING "kB" + IDS_MBYTE_STRING "MB" + IDS_GBYTE_STRING "GB" + IDS_TBYTE_STRING "TB" + IDS_PBYTE_STRING "PB" + IDS_LT_STRING "<" + IDS_LE_STRING "<=" + IDS_EQ_STRING "=" + IDS_GE_STRING ">=" + IDS_GT_STRING ">" +END + +STRINGTABLE +BEGIN + IDS_OTFCHECKINGSPACE_STRING + "Checking for free space on destination disk..." + IDS_OTFNOTENOUGHFREESPACE_STRING + "Not enough free space on disk - needed %I64d bytes for data, available: %I64d bytes." + IDS_OTFFREESPACECANCELREQUEST_STRING + "Cancel request while checking for free space on disk." + IDS_OTFFREESPACERETRYING_STRING "Retrying to read drive's free space..." + IDS_OTFFREESPACEIGNORE_STRING + "Ignored warning about not enough place on disk to copy data." + IDS_OTFMOVEFILECANCELREQUEST_STRING + "Cancel request while calling MoveFileEx %s -> %s (ProcessFiles)" +END + +STRINGTABLE +BEGIN + IDS_BSONEDISK_STRING "One disk: " + IDS_BSTWODISKS_STRING "Two disks: " + IDS_BSCD_STRING "CD: " + IDS_BSLAN_STRING "LAN: " + IDS_CPEDELETINGERROR_STRING + "Error #%errnum (%errdesc) while deleting file %s" + IDS_CPEOPENINGERROR_STRING + "Error #%errnum (%errdesc) while trying to open source file %s" + IDS_CPEDESTOPENINGERROR_STRING + "Error #%errnum (%errdesc) while trying to open destination file %s. Probably file has read-only attribute set, and 'Protect read-only files' flag in configuration is set (so the file cannot be open to write)." + IDS_CPERESTORINGPOINTERSERROR_STRING + "Error #%errnum (%errdesc) while restoring (moving to beginning) file pointers of %s and %s" + IDS_CPESETTINGZEROSIZEERROR_STRING + "Error #%errnum (%errdesc) while setting size of file %s to 0" + IDS_CPEREADINGERROR_STRING + "Error #%errnum (%errdesc) while trying to read %d bytes from source file %s" + IDS_CPEWRITINGERROR_STRING + "Error #%errnum (%errdesc) while trying to write %d bytes to destination file %s" + IDS_CPEMOVEFILEERROR_STRING + "Error #%errnum (%errdesc) while calling MoveFile %s -> %s" + IDS_CPECREATEDIRECTORYERROR_STRING + "Error #%errnum (%errdesc) while calling CreateDirectory %s" + IDS_EMPTYASSOCFILE_STRING "not associated" + IDS_FILTERING_STRING " [with filter]" + IDS_CONFIRMCANCEL_STRING + "Selected task wasn't finished yet.\nDo you want to finish it now ?" +END + +STRINGTABLE +BEGIN + IDS_SHUTDOWNERROR_STRING + "Cannot shutdown this operating system.\nEncountered error #%lu." +END + +STRINGTABLE +BEGIN + IDS_MINIVIEWSMOOTHPROGRESS_STRING "Use smooth progress bars" + IDS_CFGFOLDERDIALOG_STRING "Choose folder dialog" + IDS_CFGFDEXTVIEW_STRING "Show extended view" + IDS_CFGFDWIDTH_STRING "Dialog width [pixels]" + IDS_CFGFDHEIGHT_STRING "Dialog height [pixels]" + IDS_CFGFDSHORTCUTS_STRING "Shortcuts' list style" + IDS_CFGFDIGNOREDIALOGS_STRING "Ignore additional shell dialogs" + IDS_CFGSHCOPY_STRING "Show 'Copy' command in drag&drop menu" + IDS_CFGSHMOVE_STRING "Show 'Move' command in drag&drop menu" + IDS_CFGSHCMSPECIAL_STRING + "Show 'Copy/move special' command in drag&drop menu" + IDS_CFGSHPASTE_STRING "Show 'Paste' command in context menu" + IDS_CFGSHPASTESPECIAL_STRING + "Show 'Paste special' command in context menu" + IDS_CFGSHCOPYTO_STRING "Show 'Copy to' command in context menu" + IDS_CFGSHMOVETO_STRING "Show 'Move to' command in context menu" + IDS_CFGSHCMTOSPECIAL_STRING + "Show 'Copy/move special to' command in context menu" + IDS_CFGSHSHOWFREESPACE_STRING "Show free space with shortcuts' names" +END + +STRINGTABLE +BEGIN + IDS_BSECD_STRING "CD: %s" + IDS_BSELAN_STRING "LAN: %s" + IDS_HDRMASK_STRING "Include mask" + IDS_HDRSIZE_STRING "Size" + IDS_HDRDATE_STRING "Date" + IDS_HDRATTRIB_STRING "Attributes included" + IDS_AND_STRING " and " + IDS_FILTERMASKEMPTY_STRING "none" + IDS_FILTERSIZE_STRING "any" + IDS_FILTERDATE_STRING "any" + IDS_HDREXCLUDEMASK_STRING "Exclude mask" + IDS_HDREXCLUDEATTRIB_STRING "Attributes excluded" + IDS_FILTERATTRIB_STRING "none" + IDS_EMPTYFILTER_STRING "None of filtering options were selected" + IDS_FLTALLFILTER_STRING "All files (*.*)|*.*||" + IDS_IMPORTREPORT_STRING "Imported %lu path(s)" +END + +STRINGTABLE +BEGIN + IDS_DATECREATED_STRING "Date of creation" + IDS_DATELASTWRITE_STRING "Date of last write" + IDS_DATEACCESSED_STRING "Date of last access" +END + +STRINGTABLE +BEGIN + IDS_MENUCOPY_STRING "(CH) Copy here" + IDS_MENUMOVE_STRING "(CH) Move here" + IDS_MENUCOPYMOVESPECIAL_STRING "(CH) Copy/move special..." + IDS_MENUPASTE_STRING "(CH) Paste" + IDS_MENUPASTESPECIAL_STRING "(CH) Paste special..." + IDS_MENUCOPYTO_STRING "(CH) Copy to" + IDS_MENUMOVETO_STRING "(CH) Move to" + IDS_MENUCOPYMOVETOSPECIAL_STRING "(CH) Copy/move special to..." +END + +STRINGTABLE +BEGIN + IDS_MENUTIPCOPY_STRING "Copies data here with Copy Handler" + IDS_MENUTIPMOVE_STRING "Moves data here with Copy Handler" + IDS_MENUTIPCOPYMOVESPECIAL_STRING + "Copies/moves data with additional settings" + IDS_MENUTIPPASTE_STRING "Pastes files/folders from clipboard here" + IDS_MENUTIPPASTESPECIAL_STRING + "Pastes files/folders from clipboard here with additional settings" + IDS_MENUTIPCOPYTO_STRING "Copies selected data into specified folder" + IDS_MENUTIPMOVETO_STRING "Moves selected data into specified folder" + IDS_MENUTIPCOPYMOVETOSPECIAL_STRING + "Copies/moves selected data into specified folder with additional settings" +END + +STRINGTABLE +BEGIN + IDS_CFGFDSHORTCUTSSTYLES_STRING "Large icons!Small icons!List!Report" + IDS_CFGPRIORITYCLASSITEMS_STRING "Idle!Normal!High!Real-time" + IDS_CFGACTIONS_STRING "Copy!Move!Special operation!Autodetect" + IDS_PLUGSFOLDER_STRING "Folder with plugins" + IDS_PLUGSFOLDERCHOOSE_STRING "!Choose folder with plugins" + IDS_CFGLOGFILE_STRING "Main log file" + IDS_CFGENABLELOGGING_STRING "Enable logging" + IDS_CFGLIMITATION_STRING "Use log file size limit" + IDS_CFGMAXLIMIT_STRING "Maximum size of the limited log file" + IDS_CFGLOGPRECISELIMITING_STRING "Use precise limiting of a log file" + IDS_CFGTRUNCBUFFERSIZE_STRING "Truncate buffer size" + IDS_CFGHELPDIR_STRING "Directory with help files" + IDS_CFGHELPDIRCHOOSE_STRING "!Choose folder with program's help files" + IDS_LANGUAGESFOLDER_STRING "Directory with language files" + IDS_LANGSFOLDERCHOOSE_STRING "!Choose folder with language files" +END + +STRINGTABLE +BEGIN + IDS_SHORTCUTNAME_STRING "Shortcut's name" + IDS_SHORTCUTPATH_STRING "Path" +END + +STRINGTABLE +BEGIN + IDS_BDOK_STRING "&OK" + IDS_BDCANCEL_STRING "&Cancel" + IDS_BDCANNOTCREATEFOLDER_STRING "Cannot create the folder" + IDS_BDPATHDOESNTEXIST_STRING "Entered path doesn't exist" + IDS_BDNAME_STRING "Name" + IDS_BDPATH_STRING "Path" + IDS_BDPATH2_STRING "Path: " + IDS_BDRIGHT_STRING ">>" + IDS_BDLEFT_STRING "<<" + IDS_BDNOSHORTCUTPATH_STRING + "You haven't entered the path for this shortcut" + IDS_BDNEWFOLDER_STRING "Create new folder" + IDS_BDLARGEICONS_STRING "Large icons" + IDS_BDSMALLICONS_STRING "Small icons" + IDS_BDLIST_STRING "List" + IDS_BDREPORT_STRING "Report" + IDS_BDDETAILS_STRING "Details" +END + +STRINGTABLE +BEGIN + IDS_BDADDSHORTCUT_STRING "Add to shortcut's list" + IDS_BDREMOVESHORTCUT_STRING "Remove from shortcut's list" + IDS_BDDOMAIN_STRING "Domain/Workgroup" + IDS_BDSERVER_STRING "Server" + IDS_BDSHARE_STRING "Share" + IDS_BDFILE_STRING "File" + IDS_BDGROUP_STRING "Group" + IDS_BDNETWORK_STRING "Network" + IDS_BDROOT_STRING "Root" + IDS_BDADMINSHARE_STRING "Administration share" + IDS_BDDIR_STRING "Directory" + IDS_BDTREE_STRING "Tree" + IDS_BDNDSCONTAINER_STRING "NDS Container" +END + +STRINGTABLE +BEGIN + IDS_ABOUTVERSION_STRING "Compilation: %s" + IDS_LANGCODE_STRING "Code=" + IDS_LANGVER_STRING "Version=" +END + +STRINGTABLE +BEGIN + IDS_NERPATH_STRING "There is not enough room in %s to copy or move:" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE 9, 1 +#pragma code_page(1252) +#endif +#include "res\COPY HANDLER.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#endif +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + Index: ch/ch.rc =================================================================== diff -u -N --- ch/ch.rc (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ ch/ch.rc (revision 0) @@ -1,1620 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -// Generated Help ID header file -#define APSTUDIO_HIDDEN_SYMBOLS -#include "resource.hm" -#undef APSTUDIO_HIDDEN_SYMBOLS - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// 25 -// - -IDR_THANKS_TEXT 25 "res\\Thanks.txt" - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\COPY HANDLER.ico" -IDI_ERROR_ICON ICON "res\\error.ico" -IDI_WORKING_ICON ICON "res\\working.ico" -IDI_PAUSED_ICON ICON "res\\paused.ico" -IDI_FINISHED_ICON ICON "res\\finished.ico" -IDI_CANCELLED_ICON ICON "res\\cancelled.ico" -IDI_WAITING_ICON ICON "res\\waiting.ico" -IDI_QUESTION_ICON ICON "res\\question.ico" -IDI_INFO_ICON ICON "res\\info.ico" -IDI_ERR_ICON ICON "res\\err.ico" -IDI_WARNING_ICON ICON "res\\warning.ico" -IDI_SHUTDOWN_ICON ICON "res\\shut.ico" -IDI_NET_ICON ICON "res\\net.ico" -IDI_HDD_ICON ICON "res\\hd.ico" -IDI_CD_ICON ICON "res\\cd.ico" -IDI_HDD2_ICON ICON "res\\HD2.ICO" -IDI_TRIBE_ICON ICON "res\\tribe.ico" -IDI_FOLDER_ICON ICON "res\\folder.ico" -IDI_ADDSHORTCUT_ICON ICON "res\\addshort.ico" -IDI_DELETESHORTCUT_ICON ICON "res\\delshort.ico" -IDI_LARGEICONS_ICON ICON "res\\large.ico" -IDI_LIST_ICON ICON "res\\list.ico" -IDI_NEWFOLDER_ICON ICON "res\\newdir.ico" -IDI_REPORT_ICON ICON "res\\report.ico" -IDI_SMALLICONS_ICON ICON "res\\small.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_ADVANCED_MENU MENU -BEGIN - POPUP "_ADVANCED_POPUP_" - BEGIN - MENUITEM "&Change paths...", ID_POPUP_REPLACE_PATHS - END -END - -IDR_POPUP_MENU MENU -BEGIN - POPUP "POPUP" - BEGIN - MENUITEM "Show status...", ID_POPUP_SHOW_STATUS - MENUITEM "Show mini-status...", ID_SHOW_MINI_VIEW - MENUITEM "Enter copy parametres...", ID_POPUP_CUSTOM_COPY - MENUITEM SEPARATOR - MENUITEM "&Register shell extension dll", ID_POPUP_REGISTERDLL - MENUITEM "&Unregister shell extension dll", ID_POPUP_UNREGISTERDLL - MENUITEM SEPARATOR - MENUITEM "Monitor clipboard", ID_POPUP_MONITORING, CHECKED - MENUITEM "Shutdown after finished", ID_POPUP_SHUTAFTERFINISHED - , CHECKED - MENUITEM SEPARATOR - MENUITEM "&Options...", ID_POPUP_OPTIONS - MENUITEM "&Help...", ID_POPUP_HELP - MENUITEM "About...", ID_APP_ABOUT - MENUITEM SEPARATOR - MENUITEM "Exit", ID_APP_EXIT - END -END - -IDR_PRIORITY_MENU MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "Time critical", ID_POPUP_TIME_CRITICAL - MENUITEM "Highest", ID_POPUP_HIGHEST - MENUITEM "Above normal", ID_POPUP_ABOVE_NORMAL - MENUITEM "Normal", ID_POPUP_NORMAL - MENUITEM "Below normal", ID_POPUP_BELOW_NORMAL - MENUITEM "Lowest", ID_POPUP_LOWEST - MENUITEM "Idle", ID_POPUP_IDLE - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_BUFFERSIZE_DIALOG DIALOGEX 0, 0, 344, 127 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Buffer size settings" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_DEFAULTSIZE_EDIT,35,17,97,14,ES_AUTOHSCROLL | NOT - WS_BORDER,WS_EX_CLIENTEDGE,HIDC_DEFAULTSIZE_EDIT - COMBOBOX IDC_DEFAULTMULTIPLIER_COMBO,134,18,31,56, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, - HIDC_DEFAULTMULTIPLIER_COMBO - EDITTEXT IDC_ONEDISKSIZE_EDIT,35,49,97,14,ES_AUTOHSCROLL | NOT - WS_BORDER,WS_EX_CLIENTEDGE,HIDC_ONEDISKSIZE_EDIT - COMBOBOX IDC_ONEDISKMULTIPLIER_COMBO,134,50,31,56, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, - HIDC_ONEDISKMULTIPLIER_COMBO - EDITTEXT IDC_TWODISKSSIZE_EDIT,35,81,97,14,ES_AUTOHSCROLL | NOT - WS_BORDER,WS_EX_CLIENTEDGE,HIDC_TWODISKSSIZE_EDIT - COMBOBOX IDC_TWODISKSMULTIPLIER_COMBO,134,82,31,56, - CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP,0, - HIDC_TWODISKSMULTIPLIER_COMBO - EDITTEXT IDC_CDROMSIZE_EDIT,206,18,97,14,ES_AUTOHSCROLL | NOT - WS_BORDER,WS_EX_CLIENTEDGE,HIDC_CDROMSIZE_EDIT - COMBOBOX IDC_CDROMMULTIPLIER_COMBO,306,18,31,56,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_CDROMMULTIPLIER_COMBO - EDITTEXT IDC_LANSIZE_EDIT,206,51,97,14,ES_AUTOHSCROLL | NOT - WS_BORDER,WS_EX_CLIENTEDGE,HIDC_LANSIZE_EDIT - COMBOBOX IDC_LANMULTIPLIER_COMBO,306,52,31,56,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_LANMULTIPLIER_COMBO - DEFPUSHBUTTON "&OK",IDOK,176,106,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,229,106,50,14,0,0,HIDCANCEL - LTEXT "Default",IDC_001_STATIC,35,7,127,8 - LTEXT "For copying inside one disk boundary",IDC_002_STATIC,35, - 38,130,8 - LTEXT "For copying between two different disks",IDC_003_STATIC, - 35,70,132,8 - LTEXT "For copying with CD-ROM use",IDC_004_STATIC,206,7,131,8 - LTEXT "For copying with network use",IDC_005_STATIC,206,40,131, - 8 - CONTROL "Use only default buffer",IDC_ONLYDEFAULT_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,200,83,137,10,0, - HIDC_ONLYDEFAULT_CHECK - ICON IDI_CD_ICON,IDC_006_STATIC,179,13,20,20,SS_REALSIZEIMAGE - ICON IDI_NET_ICON,IDC_007_STATIC,179,44,20,20, - SS_REALSIZEIMAGE - ICON IDI_HDD_ICON,IDC_008_STATIC,7,43,20,20,SS_REALSIZEIMAGE - ICON IDI_HDD2_ICON,IDC_009_STATIC,7,73,20,20,SS_REALSIZEIMAGE - ICON IDI_TRIBE_ICON,IDC_010_STATIC,7,9,20,20,SS_REALSIZEIMAGE - PUSHBUTTON "&Help",IDC_HELP_BUTTON,287,106,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_FEEDBACK_DSTFILE_DIALOG DIALOGEX 0, 0, 290, 111 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler - error opening file" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,7,90,53,14,0,0, - HIDC_RETRY_BUTTON - PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,63,90,50,14,0,0, - HIDC_IGNORE_BUTTON - PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,114,90,62,14,0,0, - HIDC_IGNORE_ALL_BUTTON - DEFPUSHBUTTON "&Wait",IDC_WAIT_BUTTON,178,90,50,14,0,0, - HIDC_WAIT_BUTTON - PUSHBUTTON "&Cancel",IDCANCEL,233,90,50,14,0,0,HIDCANCEL - EDITTEXT IDC_FILENAME_EDIT,44,23,239,17,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT - EDITTEXT IDC_MESSAGE_EDIT,44,57,239,24,ES_MULTILINE | - ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT - WS_BORDER,0,HIDC_MESSAGE_EDIT - ICON IDI_ERR_ICON,IDC_001_STATIC,11,15,20,20,SS_REALSIZEIMAGE - LTEXT "Cannot open file for writing:",IDC_002_STATIC,38,13,245, - 8 - LTEXT "Error description:",IDC_003_STATIC,38,46,245,8 -END - -IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG DIALOGEX 0, 0, 294, 242 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler - error opening file" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,7,221,50,14,0,0, - HIDC_RETRY_BUTTON - PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,60,221,50,14,0,0, - HIDC_IGNORE_BUTTON - PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,110,221,69,14,0,0, - HIDC_IGNORE_ALL_BUTTON - DEFPUSHBUTTON "&Wait",IDC_WAIT_BUTTON,183,221,50,14,0,0, - HIDC_WAIT_BUTTON - PUSHBUTTON "&Cancel",IDCANCEL,237,221,50,14,0,0,HIDCANCEL - EDITTEXT IDC_MESSAGE_EDIT,49,19,238,23,ES_MULTILINE | - ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER,0, - HIDC_MESSAGE_EDIT - EDITTEXT IDC_FILENAME_EDIT,111,54,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT - EDITTEXT IDC_FILESIZE_EDIT,111,69,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT - EDITTEXT IDC_CREATETIME_EDIT,111,84,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT - EDITTEXT IDC_MODIFY_TIME_EDIT,111,99,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT - EDITTEXT IDC_DEST_FILENAME_EDIT,111,130,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT - EDITTEXT IDC_DEST_FILESIZE_EDIT,111,145,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT - EDITTEXT IDC_DEST_CREATETIME_EDIT,111,160,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT - EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,175,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT - LTEXT "Cannot open source file for reading - reason:", - IDC_001_STATIC,49,10,238,8 - LTEXT "Name:",IDC_002_STATIC,53,54,53,8 - LTEXT "Size:",IDC_003_STATIC,53,69,53,8 - LTEXT "Created:",IDC_004_STATIC,53,84,53,8 - LTEXT "Last modified:",IDC_005_STATIC,53,99,53,8 - LTEXT "Expected source file:",IDC_006_STATIC,49,42,238,8 - ICON IDI_ERR_ICON,IDC_007_STATIC,16,19,20,20,SS_REALSIZEIMAGE - LTEXT "Name:",IDC_008_STATIC,53,130,53,8 - LTEXT "Size:",IDC_009_STATIC,53,145,53,8 - LTEXT "Created:",IDC_010_STATIC,53,160,53,8 - LTEXT "Last modified:",IDC_011_STATIC,53,175,53,8 - LTEXT "Source file found:",IDC_012_STATIC,49,118,81,8 - LTEXT "What would you like to do ?",IDC_013_STATIC,39,204,248, - 8 -END - -IDD_FEEDBACK_REPLACE_FILES_DIALOG DIALOGEX 0, 0, 294, 258 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler - smaller destination file found" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Co&py rest",IDC_COPY_REST_BUTTON,7,237,62,14,0,0, - HIDC_COPY_REST_BUTTON - PUSHBUTTON "R&ecopy",IDC_RECOPY_BUTTON,69,237,74,14,0,0, - HIDC_RECOPY_BUTTON - PUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,143,237,58,14,0,0, - HIDC_IGNORE_BUTTON - PUSHBUTTON "&Cancel",IDCANCEL,237,237,50,14,0,0,HIDCANCEL - PUSHBUTTON "Cop&y rest all",IDC_COPY_REST_ALL_BUTTON,7,222,83,14,0, - 0,HIDC_COPY_REST_ALL_BUTTON - PUSHBUTTON "Recopy &all",IDC_RECOPY_ALL_BUTTON,91,222,110,14,0,0, - HIDC_RECOPY_ALL_BUTTON - PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,201,222,86,14,0,0, - HIDC_IGNORE_ALL_BUTTON - EDITTEXT IDC_FILENAME_EDIT,111,62,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT - EDITTEXT IDC_FILESIZE_EDIT,111,77,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT - EDITTEXT IDC_CREATETIME_EDIT,111,92,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT - EDITTEXT IDC_MODIFY_TIME_EDIT,111,107,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT - EDITTEXT IDC_DEST_FILENAME_EDIT,111,138,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT - EDITTEXT IDC_DEST_FILESIZE_EDIT,111,153,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT - EDITTEXT IDC_DEST_CREATETIME_EDIT,111,168,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT - EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,183,176,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT - ICON IDI_QUESTION_ICON,IDC_001_STATIC,10,15,20,20, - SS_REALSIZEIMAGE - LTEXT "Destination file exists and is smaller than source file.\nPossible reasons:\n- copying/moving source file wasn't finished (copy rest)\n- file being copied is in another version than destination file (recopy)", - IDC_002_STATIC,41,7,246,41 - LTEXT "Name:",IDC_003_STATIC,48,62,61,8 - LTEXT "Size:",IDC_004_STATIC,48,77,61,8 - LTEXT "Created:",IDC_005_STATIC,48,92,61,8 - LTEXT "Last modified:",IDC_006_STATIC,48,107,61,8 - LTEXT "Source file:",IDC_007_STATIC,41,50,246,8 - LTEXT "Name:",IDC_008_STATIC,48,138,61,8 - LTEXT "Size:",IDC_009_STATIC,48,153,61,8 - LTEXT "Created:",IDC_010_STATIC,48,168,61,8 - LTEXT "Last modified:",IDC_011_STATIC,48,183,61,8 - LTEXT "Destination file:",IDC_012_STATIC,41,125,246,8 - LTEXT "What would you like to do ?",IDC_013_STATIC,41,203,246, - 8 -END - -IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG DIALOGEX 0, 0, 294, 258 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler - destination file found" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - PUSHBUTTON "R&ecopy",IDC_RECOPY_BUTTON,7,237,143,14,0,0, - HIDC_RECOPY_BUTTON - DEFPUSHBUTTON "&Ignore",IDC_IGNORE_BUTTON,151,237,86,14,0,0, - HIDC_IGNORE_BUTTON - PUSHBUTTON "&Cancel",IDCANCEL,237,237,50,14,0,0,HIDCANCEL - PUSHBUTTON "Recopy &all",IDC_RECOPY_ALL_BUTTON,7,222,143,14,0,0, - HIDC_RECOPY_ALL_BUTTON - PUSHBUTTON "I&gnore all",IDC_IGNORE_ALL_BUTTON,151,222,136,14,0,0, - HIDC_IGNORE_ALL_BUTTON - EDITTEXT IDC_FILENAME_EDIT,111,64,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILENAME_EDIT - EDITTEXT IDC_FILESIZE_EDIT,111,79,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_FILESIZE_EDIT - EDITTEXT IDC_CREATETIME_EDIT,111,94,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_CREATETIME_EDIT - EDITTEXT IDC_MODIFY_TIME_EDIT,111,109,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_MODIFY_TIME_EDIT - EDITTEXT IDC_DEST_FILENAME_EDIT,111,138,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILENAME_EDIT - EDITTEXT IDC_DEST_FILESIZE_EDIT,111,153,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_FILESIZE_EDIT - EDITTEXT IDC_DEST_CREATETIME_EDIT,111,168,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_CREATETIME_EDIT - EDITTEXT IDC_DEST_MODIFYTIME_EDIT,111,183,173,14,ES_AUTOHSCROLL | - ES_READONLY | NOT WS_BORDER,0,HIDC_DEST_MODIFYTIME_EDIT - ICON IDI_QUESTION_ICON,IDC_001_STATIC,10,15,20,20, - SS_REALSIZEIMAGE - LTEXT "Destination file exists and has equal or greater size than source file.\nPossible reasons:\n- file being copied is in another version than destination one (recopy/ignore)\n- source and destination files are identical (ignore)", - IDC_002_STATIC,41,7,246,44 - LTEXT "Name:",IDC_003_STATIC,48,64,61,8 - LTEXT "Size:",IDC_004_STATIC,48,79,61,8 - LTEXT "Created:",IDC_005_STATIC,48,94,61,8 - LTEXT "Last modified:",IDC_006_STATIC,48,109,61,8 - LTEXT "Source file:",IDC_007_STATIC,41,52,246,8 - LTEXT "Name:",IDC_008_STATIC,48,138,61,8 - LTEXT "Size:",IDC_009_STATIC,48,153,61,8 - LTEXT "Created:",IDC_010_STATIC,48,168,61,8 - LTEXT "Last modified:",IDC_011_STATIC,48,183,61,8 - LTEXT "Destination file:",IDC_012_STATIC,41,125,246,8 - LTEXT "What would you like to do ?",IDC_013_STATIC,41,203,246, - 8 -END - -IDD_MINIVIEW_DIALOG DIALOGEX 0, 0, 90, 23 -STYLE DS_ABSALIGN | DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | - DS_SETFOREGROUND | DS_CONTEXTHELP | WS_POPUP | WS_CAPTION -EXSTYLE WS_EX_TOOLWINDOW -CAPTION "Status" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - LISTBOX IDC_PROGRESS_LIST,7,7,76,9,LBS_OWNERDRAWFIXED | - LBS_NOINTEGRALHEIGHT | LBS_NOSEL | NOT WS_BORDER | - WS_TABSTOP,0,HIDC_PROGRESS_LIST -END - -IDD_OPTIONS_DIALOG DIALOGEX 0, 0, 396, 214 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Options" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&OK",IDOK,173,193,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,227,193,50,14,0,0,HIDCANCEL - LISTBOX IDC_PROPERTIES_LIST,7,7,382,179,LBS_OWNERDRAWFIXED | - LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | - WS_TABSTOP,0,HIDC_PROPERTIES_LIST - PUSHBUTTON "&Apply",IDC_APPLY_BUTTON,283,193,50,14,0,0, - HIDC_APPLY_BUTTON - PUSHBUTTON "&Help",IDC_HELP_BUTTON,339,193,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_REPLACE_PATHS_DIALOG DIALOGEX 0, 0, 342, 148 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Partial replace of source paths" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - LISTBOX IDC_PATHS_LIST,7,17,328,52,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP,0, - HIDC_PATHS_LIST - EDITTEXT IDC_SOURCE_EDIT,7,70,328,14,ES_AUTOHSCROLL,0, - HIDC_SOURCE_EDIT - EDITTEXT IDC_DESTINATION_EDIT,7,98,309,14,ES_AUTOHSCROLL,0, - HIDC_DESTINATION_EDIT - PUSHBUTTON "...",IDC_BROWSE_BUTTON,319,98,16,14,0,0, - HIDC_BROWSE_BUTTON - DEFPUSHBUTTON "OK",IDOK,173,127,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,229,127,50,14,0,0,HIDCANCEL - LTEXT "Source paths:",IDC_001_STATIC,7,7,328,8 - LTEXT "Change to:",IDC_002_STATIC,7,89,328,8 - PUSHBUTTON "&Help",IDC_HELP_BUTTON,285,127,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_STATUS_DIALOG DIALOGEX 0, 0, 478, 250 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_MINIMIZEBOX | - WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Status" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_STATUS_LIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | - WS_BORDER | WS_TABSTOP,7,19,224,171,0,HIDC_STATUS_LIST - PUSHBUTTON "&Pause",IDC_PAUSE_BUTTON,7,196,44,14,0,0, - HIDC_PAUSE_BUTTON - PUSHBUTTON "&Restart",IDC_RESTART_BUTTON,97,196,44,14,0,0, - HIDC_RESTART_BUTTON - PUSHBUTTON "&Cancel",IDC_CANCEL_BUTTON,142,196,44,14,0,0, - HIDC_CANCEL_BUTTON - PUSHBUTTON "&Remove",IDC_DELETE_BUTTON,187,196,44,14,0,0, - HIDC_DELETE_BUTTON - PUSHBUTTON "Pause/all",IDC_PAUSE_ALL_BUTTON,7,213,71,14,0,0, - HIDC_PAUSE_ALL_BUTTON - PUSHBUTTON "Resume/all",IDC_START_ALL_BUTTON,79,213,71,14,0,0, - HIDC_START_ALL_BUTTON - PUSHBUTTON "Cancel/all",IDC_CANCEL_ALL_BUTTON,7,229,71,14,0,0, - HIDC_CANCEL_ALL_BUTTON - PUSHBUTTON "Remove/all",IDC_REMOVE_FINISHED_BUTTON,79,229,71,14,0,0, - HIDC_REMOVE_FINISHED_BUTTON - PUSHBUTTON "Restart/all",IDC_RESTART_ALL_BUTTON,151,229,71,14,0,0, - HIDC_RESTART_ALL_BUTTON - PUSHBUTTON "&Advanced >",IDC_ADVANCED_BUTTON,160,212,71,14,0,0, - HIDC_ADVANCED_BUTTON - PUSHBUTTON "",IDC_STICK_BUTTON,471,243,7,7,BS_CENTER | BS_VCENTER | - BS_FLAT,0,HIDC_STICK_BUTTON - PUSHBUTTON "&<<",IDC_ROLL_UNROLL_BUTTON,212,7,19,12,0,0, - HIDC_ROLL_UNROLL_BUTTON - PUSHBUTTON "...",IDC_SET_BUFFERSIZE_BUTTON,458,72,13,14,0,0, - HIDC_SET_BUFFERSIZE_BUTTON - PUSHBUTTON ">",IDC_SET_PRIORITY_BUTTON,458,88,13,14,0,0, - HIDC_SET_PRIORITY_BUTTON - PUSHBUTTON "View log",IDC_SHOW_LOG_BUTTON,249,116,60,14,0,0, - HIDC_SHOW_LOG_BUTTON - LTEXT "Operations list:",IDC_001_STATIC,7,7,197,8 - CONTROL "Progress1",IDC_ALL_PROGRESS,"msctls_progress32",0x1,312, - 234,159,9 - LTEXT "Progress:",IDC_002_STATIC,249,235,62,8 - CONTROL "Progress2",IDC_TASK_PROGRESS,"msctls_progress32",0x0, - 312,181,159,6 - LTEXT "Progress:",IDC_003_STATIC,249,179,62,8 - LTEXT "Destination object:",IDC_004_STATIC,249,59,62,8 - LTEXT "Source object:",IDC_005_STATIC,249,47,62,8 - LTEXT "Buffer size:",IDC_006_STATIC,249,75,62,8 - LTEXT "Thread priority:",IDC_007_STATIC,249,90,62,8 - LTEXT "Comments:",IDC_008_STATIC,249,106,62,8 - LTEXT "Operation:",IDC_009_STATIC,249,34,62,8 - LTEXT "Transfer:",IDC_010_STATIC,249,167,62,8 - LTEXT "Processed:",IDC_011_STATIC,249,137,62,8 - LTEXT "Transfer:",IDC_012_STATIC,249,220,62,8 - LTEXT "Processed:",IDC_013_STATIC,249,205,62,8 - CTEXT "Global statistics",IDC_014_STATIC,293,191,84,8 - CTEXT "Current selection statistics",IDC_015_STATIC,293,7,113, - 8 - CONTROL "",IDC_016_STATIC,"Static",SS_ETCHEDHORZ,384,194,87,1 - CONTROL "",IDC_017_STATIC,"Static",SS_ETCHEDHORZ,411,10,61,1 - CONTROL "",IDC_018_STATIC,"Static",SS_ETCHEDHORZ,249,194,37,1 - CONTROL "",IDC_019_STATIC,"Static",SS_ETCHEDHORZ,249,10,38,1 - LTEXT "Time:",IDC_020_STATIC,249,152,62,8 - PUSHBUTTON "&Resume",IDC_RESUME_BUTTON,52,196,44,14,0,0, - HIDC_RESUME_BUTTON - EDITTEXT IDC_ERRORS_EDIT,312,104,159,26,ES_MULTILINE | - ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | - WS_VSCROLL,WS_EX_STATICEDGE,HIDC_ERRORS_EDIT - LTEXT "Associated file:",IDC_021_STATIC,249,19,62,8 - CONTROL "",IDC_ASSOCIATEDFILES__STATIC,"STATICEX",0x4,312,17,159, - 12,WS_EX_STATICEDGE,HIDC_ASSOCIATEDFILES__STATIC - CONTROL "",IDC_OPERATION_STATIC,"STATICEX",0x4,312,32,159,12, - WS_EX_STATICEDGE,HIDC_OPERATION_STATIC - CONTROL "",IDC_SOURCE_STATIC,"STATICEX",0x4,312,45,159,12, - WS_EX_STATICEDGE,HIDC_SOURCE_STATIC - CONTROL "",IDC_DESTINATION_STATIC,"STATICEX",0x4,312,58,159,12, - WS_EX_STATICEDGE,HIDC_DESTINATION_STATIC - CONTROL "",IDC_PROGRESS_STATIC,"STATICEX",0x4,312,135,159,12, - WS_EX_STATICEDGE,HIDC_PROGRESS_STATIC - CONTROL "",IDC_TIME_STATIC,"STATICEX",0x4,312,150,159,12, - WS_EX_STATICEDGE,HIDC_TIME_STATIC - CONTROL "",IDC_TRANSFER_STATIC,"STATICEX",0x4,312,165,159,12, - WS_EX_STATICEDGE,HIDC_TRANSFER_STATIC - CONTROL "",IDC_OVERALL_PROGRESS_STATIC,"STATICEX",0x4,312,203, - 159,12,WS_EX_STATICEDGE,HIDC_OVERALL_PROGRESS_STATIC - CONTROL "",IDC_OVERALL_TRANSFER_STATIC,"STATICEX",0x4,312,218, - 159,12,WS_EX_STATICEDGE,HIDC_OVERALL_TRANSFER_STATIC - CONTROL "",IDC_BUFFERSIZE_STATIC,"STATICEX",0x4,312,74,143,12, - WS_EX_STATICEDGE,HIDC_BUFFERSIZE_STATIC - CONTROL "",IDC_PRIORITY_STATIC,"STATICEX",0x4,312,88,143,12, - WS_EX_STATICEDGE,HIDC_PRIORITY_STATIC -END - -IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG DIALOGEX 0, 0, 254, 138 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler - not enough free space" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - PUSHBUTTON "&Retry",IDC_RETRY_BUTTON,78,117,57,14,0,0, - HIDC_RETRY_BUTTON - PUSHBUTTON "C&ontinue",IDC_IGNORE_BUTTON,136,117,57,14,0,0, - HIDC_IGNORE_BUTTON - PUSHBUTTON "&Cancel",IDCANCEL,197,117,50,14,0,0,HIDCANCEL - LISTBOX IDC_FILES_LIST,41,35,206,44,LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,0,HIDC_FILES_LIST - LTEXT "",IDC_REQUIRED_STATIC,108,85,139,8,0,0, - HIDC_REQUIRED_STATIC - LTEXT "",IDC_AVAILABLE_STATIC,108,97,139,8,0,0, - HIDC_AVAILABLE_STATIC - ICON IDI_WARNING_ICON,IDC_001_STATIC,9,11,20,20, - SS_REALSIZEIMAGE - LTEXT "Required space:",IDC_003_STATIC,41,85,59,8 - LTEXT "Space available:",IDC_004_STATIC,41,97,59,8 - LTEXT "",IDC_HEADER_STATIC,41,7,206,24 -END - -IDD_SHUTDOWN_DIALOG DIALOGEX 0, 0, 186, 86 -STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Copy handler" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&Cancel",IDCANCEL,67,65,50,14,0,0,HIDCANCEL - ICON IDI_SHUTDOWN_ICON,IDC_001_STATIC,7,10,20,20, - SS_REALSIZEIMAGE - LTEXT "All copy/move operations were finished. Attempt to shut down the system will be performed in:", - IDC_002_STATIC,37,7,142,24 - CTEXT "",IDC_TIME_STATIC,7,35,172,8 - CONTROL "Progress1",IDC_TIME_PROGRESS,"msctls_progress32",0x1,7, - 48,172,9 -END - -IDD_CUSTOM_COPY_DIALOG DIALOGEX 0, 0, 349, 319 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Copying/moving parameters" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_FILES_LIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | - LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,16,279,57, - 0,HIDC_FILES_LIST - PUSHBUTTON "Add &file(s)...",IDC_ADDFILE_BUTTON,289,15,53,14,0,0, - HIDC_ADDFILE_BUTTON - PUSHBUTTON "Add f&older...",IDC_ADDDIR_BUTTON,289,30,53,14,0,0, - HIDC_ADDDIR_BUTTON - PUSHBUTTON "&Delete",IDC_REMOVEFILEFOLDER_BUTTON,289,45,53,14,0,0, - HIDC_REMOVEFILEFOLDER_BUTTON - PUSHBUTTON "&Import...",IDC_IMPORT_BUTTON,289,60,53,14,0,0, - HIDC_IMPORT_BUTTON - CONTROL "",IDC_DESTPATH_COMBOBOXEX,"ComboBoxEx32",CBS_DROPDOWN | - CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP,7, - 86,314,136,0,HIDC_DESTPATH_COMBOBOXEX - PUSHBUTTON "...",IDC_DESTBROWSE_BUTTON,324,85,18,14,0,0, - HIDC_DESTBROWSE_BUTTON - COMBOBOX IDC_OPERATION_COMBO,13,124,117,143,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_OPERATION_COMBO - COMBOBOX IDC_PRIORITY_COMBO,137,124,122,75,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_PRIORITY_COMBO - EDITTEXT IDC_COUNT_EDIT,262,124,80,14,ES_AUTOHSCROLL,0, - HIDC_COUNT_EDIT - CONTROL "Spin1",IDC_COUNT_SPIN,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,331,124, - 11,14 - LISTBOX IDC_BUFFERSIZES_LIST,13,152,275,20,LBS_NOINTEGRALHEIGHT | - LBS_MULTICOLUMN | LBS_NOSEL | WS_VSCROLL | WS_TABSTOP,0, - HIDC_BUFFERSIZES_LIST - PUSHBUTTON "&Change...",IDC_BUFFERSIZES_BUTTON,292,152,50,14,0,0, - HIDC_BUFFERSIZES_BUTTON - CONTROL "Filtering",IDC_FILTERS_CHECK,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,7,177,61,10,0,HIDC_FILTERS_CHECK - CONTROL "List2",IDC_FILTERS_LIST,"SysListView32",LVS_REPORT | - WS_BORDER | WS_TABSTOP,13,190,303,46,0,HIDC_FILTERS_LIST - PUSHBUTTON "+",IDC_ADDFILTER_BUTTON,320,190,22,14,0,0, - HIDC_ADDFILTER_BUTTON - PUSHBUTTON "-",IDC_REMOVEFILTER_BUTTON,320,206,22,14,0,0, - HIDC_REMOVEFILTER_BUTTON - CONTROL "Advanced options",IDC_ADVANCED_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,242,84,10,0, - HIDC_ADVANCED_CHECK - CONTROL "Do not create destination directories - copy files loosely to destination folder", - IDC_IGNOREFOLDERS_CHECK,"Button",BS_AUTOCHECKBOX | - BS_NOTIFY | WS_TABSTOP,13,255,329,10,0, - HIDC_IGNOREFOLDERS_CHECK - CONTROL "Do not copy/move contents of files - only create it (empty)", - IDC_ONLYSTRUCTURE_CHECK,"Button",BS_AUTOCHECKBOX | - BS_NOTIFY | WS_TABSTOP,13,277,329,10,0, - HIDC_ONLYSTRUCTURE_CHECK - PUSHBUTTON "&OK",IDOK,186,298,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,239,298,50,14,0,0,HIDCANCEL - LTEXT "Source files/folders:",IDC_001_STATIC,7,7,335,8 - LTEXT "Destination folder:",IDC_002_STATIC,7,76,335,8 - LTEXT "Operation type:",IDC_003_STATIC,13,115,117,8 - LTEXT "Priority:",IDC_004_STATIC,137,115,120,8 - LTEXT "Count of copies:",IDC_005_STATIC,262,115,80,8 - LTEXT "Buffer sizes:",IDC_006_STATIC,13,142,244,8 - CONTROL "",IDC_BAR3_STATIC,"Static",SS_ETCHEDHORZ,74,181,268,1 - CONTROL "",IDC_BAR4_STATIC,"Static",SS_ETCHEDHORZ,96,247,246,1 - CONTROL "",IDC_BAR5_STATIC,"Static",SS_ETCHEDHORZ,7,291,335,1 - CONTROL "",IDC_BAR2_STATIC,"Static",SS_ETCHEDHORZ,105,107,237,1 - CTEXT "Standard options",IDC_007_STATIC,20,104,80,8 - CONTROL "",IDC_BAR1_STATIC,"Static",SS_ETCHEDHORZ,7,107,8,1 - CONTROL "Create directory structure in destination folder (relatively to root directory)", - IDC_FORCEDIRECTORIES_CHECK,"Button",BS_AUTOCHECKBOX | - BS_NOTIFY | WS_TABSTOP,13,266,329,10,0, - HIDC_FORCEDIRECTORIES_CHECK - PUSHBUTTON "&Help",IDC_HELP_BUTTON,292,298,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_FILTER_DIALOG DIALOGEX 0, 0, 291, 266 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Filtering settings" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - CONTROL "Include mask (separate by vertical lines ie. *.jpg|*.gif)", - IDC_FILTER_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, - 7,277,10,0,HIDC_FILTER_CHECK - COMBOBOX IDC_FILTER_COMBO,15,19,269,98,CBS_DROPDOWN | WS_VSCROLL | - WS_TABSTOP,0,HIDC_FILTER_COMBO - CONTROL "Exclude mask",IDC_EXCLUDEMASK_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,35,277,10,0, - HIDC_EXCLUDEMASK_CHECK - COMBOBOX IDC_FILTEREXCLUDE_COMBO,15,48,269,170,CBS_DROPDOWN | - WS_VSCROLL | WS_TABSTOP,0,HIDC_FILTEREXCLUDE_COMBO - CONTROL "Filtering by size",IDC_SIZE_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,66,277,10,0, - HIDC_SIZE_CHECK - COMBOBOX IDC_SIZETYPE1_COMBO,63,81,34,140,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZETYPE1_COMBO - EDITTEXT IDC_SIZE1_EDIT,100,80,77,14,ES_AUTOHSCROLL,0, - HIDC_SIZE1_EDIT - CONTROL "Spin1",IDC_SIZE1_SPIN,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,166,80,11, - 14,0,HIDC_SIZE1_SPIN - COMBOBOX IDC_SIZE1MULTI_COMBO,180,81,34,135,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZE1MULTI_COMBO - CONTROL "and",IDC_SIZE2_CHECK,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,30,101,32,10,0,HIDC_SIZE2_CHECK - COMBOBOX IDC_SIZETYPE2_COMBO,63,99,34,137,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZETYPE2_COMBO - EDITTEXT IDC_SIZE2_EDIT,100,98,77,14,ES_AUTOHSCROLL,0, - HIDC_SIZE2_EDIT - CONTROL "Spin1",IDC_SIZE2_SPIN,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,166,98,11, - 14,0,HIDC_SIZE2_SPIN - COMBOBOX IDC_SIZE2MULTI_COMBO,180,99,34,143,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_SIZE2MULTI_COMBO - CONTROL "Filtering by date",IDC_DATE_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,124,277,10,0, - HIDC_DATE_CHECK - COMBOBOX IDC_DATETYPE_COMBO,32,138,151,133,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_DATETYPE_COMBO - COMBOBOX IDC_DATE1TYPE_COMBO,58,158,48,104,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_DATE1TYPE_COMBO - CONTROL "DateTimePicker1",IDC_DATE1_DATETIMEPICKER, - "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | - DTS_SHOWNONE | WS_TABSTOP,108,157,109,15,0, - HIDC_DATE1_DATETIMEPICKER - CONTROL "DateTimePicker2",IDC_TIME1_DATETIMEPICKER, - "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | - DTS_SHOWNONE | WS_TABSTOP,220,157,64,15,0, - HIDC_TIME1_DATETIMEPICKER - CONTROL "and",IDC_DATE2_CHECK,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,25,176,30,10,0,HIDC_DATE2_CHECK - COMBOBOX IDC_DATE2TYPE_COMBO,58,174,48,107,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP,0,HIDC_DATE2TYPE_COMBO - CONTROL "DateTimePicker1",IDC_DATE2_DATETIMEPICKER, - "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | - DTS_SHOWNONE | WS_TABSTOP,108,173,109,15,0, - HIDC_DATE2_DATETIMEPICKER - CONTROL "DateTimePicker2",IDC_TIME2_DATETIMEPICKER, - "SysDateTimePick32",DTS_RIGHTALIGN | DTS_UPDOWN | - DTS_SHOWNONE | WS_TABSTOP,220,173,64,15,0, - HIDC_TIME2_DATETIMEPICKER - CONTROL "By attributes",IDC_ATTRIBUTES_CHECK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,199,277,10,0, - HIDC_ATTRIBUTES_CHECK - CONTROL "Archive",IDC_ARCHIVE_CHECK,"Button",BS_AUTO3STATE | - WS_TABSTOP,29,212,81,10,0,HIDC_ARCHIVE_CHECK - CONTROL "Read only",IDC_READONLY_CHECK,"Button",BS_AUTO3STATE | - WS_TABSTOP,29,224,81,10,0,HIDC_READONLY_CHECK - CONTROL "Hidden",IDC_HIDDEN_CHECK,"Button",BS_AUTO3STATE | - WS_TABSTOP,117,212,68,10,0,HIDC_HIDDEN_CHECK - CONTROL "System",IDC_SYSTEM_CHECK,"Button",BS_AUTO3STATE | - WS_TABSTOP,117,224,68,10,0,HIDC_SYSTEM_CHECK - CONTROL "Directory",IDC_DIRECTORY_CHECK,"Button",BS_AUTO3STATE | - NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,191,212,93,10, - 0,HIDC_DIRECTORY_CHECK - DEFPUSHBUTTON "&OK",IDOK,127,245,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,179,245,50,14,0,0,HIDCANCEL - CONTROL "",IDC_001_STATIC,"Static",SS_ETCHEDHORZ,7,238,276,1 - PUSHBUTTON "&Help",IDC_HELP_BUTTON,234,245,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_SHORTCUTEDIT_DIALOG DIALOGEX 0, 0, 324, 206 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Shortcuts editing" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_SHORTCUT_LIST,"SysListView32",LVS_REPORT | - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | - LVS_AUTOARRANGE | LVS_EDITLABELS | WS_BORDER | - WS_TABSTOP,7,16,261,88,0,HIDC_SHORTCUT_LIST - EDITTEXT IDC_NAME_EDIT,77,123,228,14,ES_AUTOHSCROLL,0, - HIDC_NAME_EDIT - CONTROL "",IDC_PATH_COMBOBOXEX,"ComboBoxEx32",CBS_DROPDOWN | - CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP,77, - 142,205,89,0,HIDC_PATH_COMBOBOXEX - PUSHBUTTON "...",IDC_BROWSE_BUTTON,286,142,18,13,0,0, - HIDC_BROWSE_BUTTON - PUSHBUTTON "&Add",IDC_ADD_BUTTON,17,160,50,14,0,0,HIDC_ADD_BUTTON - PUSHBUTTON "&Update",IDC_CHANGE_BUTTON,69,160,50,14,0,0, - HIDC_CHANGE_BUTTON - PUSHBUTTON "&Delete",IDC_DELETE_BUTTON,121,160,50,14,0,0, - HIDC_DELETE_BUTTON - DEFPUSHBUTTON "&OK",IDOK,156,185,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,211,185,50,14,0,0,HIDCANCEL - LTEXT "Shortcuts:",IDC_001_STATIC,7,7,310,8 - LTEXT "Name:",IDC_002_STATIC,18,126,53,8 - LTEXT "Path:",IDC_003_STATIC,18,145,56,8 - GROUPBOX "Shortcut properties",IDC_004_STATIC,7,111,310,70 - PUSHBUTTON "Move up",IDC_UP_BUTTON,272,47,45,14,0,0,HIDC_UP_BUTTON - PUSHBUTTON "Move down",IDC_DOWN_BUTTON,272,63,45,14,0,0, - HIDC_DOWN_BUTTON - PUSHBUTTON "&Help",IDC_HELP_BUTTON,267,185,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_RECENTEDIT_DIALOG DIALOGEX 0, 0, 324, 190 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "Recent paths" -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - CONTROL "List1",IDC_RECENT_LIST,"SysListView32",LVS_LIST | - LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | - LVS_AUTOARRANGE | LVS_EDITLABELS | WS_BORDER | - WS_TABSTOP,7,16,310,88,0,HIDC_RECENT_LIST - EDITTEXT IDC_PATH_EDIT,20,123,266,14,ES_AUTOHSCROLL,0, - HIDC_PATH_EDIT - PUSHBUTTON "...",IDC_BROWSE_BUTTON,290,123,18,14,0,0, - HIDC_BROWSE_BUTTON - PUSHBUTTON "&Add",IDC_ADD_BUTTON,20,141,50,14,0,0,HIDC_ADD_BUTTON - PUSHBUTTON "&Update",IDC_CHANGE_BUTTON,72,141,50,14,0,0, - HIDC_CHANGE_BUTTON - PUSHBUTTON "&Delete",IDC_DELETE_BUTTON,124,141,50,14,0,0, - HIDC_DELETE_BUTTON - DEFPUSHBUTTON "&OK",IDOK,156,169,50,14,0,0,HIDOK - PUSHBUTTON "&Cancel",IDCANCEL,211,169,50,14,0,0,HIDCANCEL - LTEXT "Recently used paths:",IDC_001_STATIC,7,7,310,8 - GROUPBOX "Path",IDC_002_STATIC,7,110,310,51 - PUSHBUTTON "&Help",IDC_HELP_BUTTON,267,169,50,14,0,0, - HIDC_HELP_BUTTON -END - -IDD_ABOUTBOX DIALOGEX 0, 0, 369, 249 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CONTEXTHELP | WS_POPUP | WS_VISIBLE | - WS_CAPTION | WS_SYSMENU -CAPTION "About ..." -FONT 8, "Tahoma", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&OK",IDOK,306,228,56,14,WS_GROUP,0,HIDOK - ICON IDR_MAINFRAME,IDC_STATIC,11,14,20,20 - CTEXT "Copyright (C) 2001-2004 J�zef Starosczyk", - IDC_COPYRIGHT_STATIC,40,80,322,8 - LTEXT "General discussion forum:",IDC_GENFORUM_STATIC,46,124, - 98,8 - LTEXT "Developers' discussion forum: ",IDC_DEVFORUM_STATIC,46, - 137,98,8 - LTEXT "Special thanks list:",IDC_THANX_STATIC,46,154,316,8 - EDITTEXT IDC_THANX_EDIT,46,164,316,54,ES_MULTILINE | ES_READONLY | - NOT WS_BORDER | WS_VSCROLL,WS_EX_STATICEDGE, - HIDC_THANX_EDIT - CONTROL "http://www.copyhandler.com|http://www.copyhandler.com", - IDC_HOMEPAGELINK_STATIC,"STATICEX",0x1,257,7,105,8 - CONTROL "ixen@copyhandler.com|mailto:ixen@copyhandler.com", - IDC_CONTACT1LINK_STATIC,"STATICEX",0x1,257,41,105,8 - CONTROL "Page|http://groups.yahoo.com/group/copyhandler", - IDC_GENFORUMPAGELINK_STATIC,"STATICEX",0x1,155,124,33,8 - CONTROL "Page|http://groups.yahoo.com/group/chdev", - IDC_DEVFORUMPAGELINK_STATIC,"STATICEX",0x1,155,137,33,8 - CONTROL "Subscribe|mailto:copyhandler-subscribe@yahoogroups.com", - IDC_GENFORUMSUBSCRIBELINK_STATIC,"STATICEX",0x1,198,124, - 44,8 - CONTROL "Subscribe|mailto:chdev-subscribe@yahoogroups.com", - IDC_DEVFORUMSUBSCRIBELINK_STATIC,"STATICEX",0x1,198,137, - 44,8 - CONTROL "Unsubscribe|mailto:copyhandler-unsubscribe@yahoogroups.com", - IDC_GENFORUMUNSUBSCRIBELINK_STATIC,"STATICEX",0x1,251, - 124,48,8 - CONTROL "Unsubscribe|mailto:chdev-unsubscribe@yahoogroups.com", - IDC_DEVFORUMUNSUBSCRIBELINK_STATIC,"STATICEX",0x1,251, - 137,48,8 - CONTROL "Send message|mailto:copyhandler@yahoogroups.com", - IDC_GENFORUMSENDLINK_STATIC,"STATICEX",0x1,307,124,55,8 - CONTROL "Send message|mailto:chdev@yahoogroups.com", - IDC_DEVFORUMSENDLINK_STATIC,"STATICEX",0x1,307,137,55,8 - CONTROL "",IDC_PROGRAM_STATICEX,"STATICEX",0x30,39,7,122,10 - CONTROL "",IDC_FULLVERSION_STATICEX,"STATICEX",0x10,39,20,109,8 - CONTROL "Home page:",IDC_HOMEPAGE_STATICEX,"STATICEX",0x10,185,7, - 68,8 - CONTROL "Contact:",IDC_CONTACT_STATICEX,"STATICEX",0x10,185,29, - 68,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,39,92,323,1 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,39,120,323,1 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,41,148,321,1 - CONTROL "This program is free software and may be distributed according to the terms of the GNU General Public License.", - IDC_LICENSE_STATICEX,"STATICEX",0x90,46,98,310,16 - CONTROL "http://www.copyhandler.prv.pl|http://www.copyhandler.prv.pl", - IDC_HOMEPAGELINK2_STATIC,"STATICEX",0x1,257,17,105,8 - CONTROL "Author:",IDC_CONTACTAUTHOR_STATICEX,"STATICEX",0x50,185, - 41,68,8 - CONTROL "support@copyhandler.com|mailto:support@copyhandler.com", - IDC_CONTACT2LINK_STATIC,"STATICEX",0x1,257,55,105,8 - CONTROL "Support:",IDC_CONTACTSUPPORT_STATICEX,"STATICEX",0x50, - 185,55,68,8 - CONTROL "copyhandler@o2.pl|mailto:copyhandler@o2.pl", - IDC_CONTACT3LINK_STATIC,"STATICEX",0x1,257,66,105,8 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,28,43,1507 - PRODUCTVERSION 1,28,43,1507 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x29L -#else - FILEFLAGS 0x28L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Program for copying files/folders" - VALUE "CompanyName", " " - VALUE "FileDescription", "Copy Handler v. 1.28 development snapshot" - VALUE "FileVersion", "1.28.43.1507" - VALUE "InternalName", "Copy Handler" - VALUE "LegalCopyright", "Copyright (C) 2001-2006 J�zef Starosczyk" - VALUE "LegalTrademarks", " " - VALUE "OriginalFilename", "COPY HANDLER.EXE" - VALUE "PrivateBuild", " " - VALUE "ProductName", "Copy Handler v. 1.28 development version" - VALUE "ProductVersion", "1.28.43.1507" - VALUE "SpecialBuild", " " - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_BUFFERSIZE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 337 - TOPMARGIN, 7 - BOTTOMMARGIN, 120 - END - - IDD_FEEDBACK_DSTFILE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 283 - TOPMARGIN, 7 - BOTTOMMARGIN, 104 - END - - IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 287 - TOPMARGIN, 7 - BOTTOMMARGIN, 235 - END - - IDD_FEEDBACK_REPLACE_FILES_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 287 - TOPMARGIN, 7 - BOTTOMMARGIN, 251 - END - - IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 287 - TOPMARGIN, 7 - BOTTOMMARGIN, 251 - END - - IDD_MINIVIEW_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 83 - TOPMARGIN, 7 - BOTTOMMARGIN, 16 - END - - IDD_OPTIONS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 389 - TOPMARGIN, 7 - BOTTOMMARGIN, 207 - END - - IDD_REPLACE_PATHS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 335 - TOPMARGIN, 7 - BOTTOMMARGIN, 141 - END - - IDD_STATUS_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 471 - TOPMARGIN, 7 - BOTTOMMARGIN, 243 - END - - IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 247 - TOPMARGIN, 7 - BOTTOMMARGIN, 131 - END - - IDD_SHUTDOWN_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 179 - TOPMARGIN, 7 - BOTTOMMARGIN, 79 - END - - IDD_CUSTOM_COPY_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 342 - TOPMARGIN, 7 - BOTTOMMARGIN, 312 - END - - IDD_FILTER_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 284 - TOPMARGIN, 7 - BOTTOMMARGIN, 259 - END - - IDD_SHORTCUTEDIT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 317 - TOPMARGIN, 7 - BOTTOMMARGIN, 199 - END - - IDD_RECENTEDIT_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 317 - TOPMARGIN, 7 - BOTTOMMARGIN, 183 - END - - IDD_ABOUTBOX, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 362 - TOPMARGIN, 7 - BOTTOMMARGIN, 242 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Toolbar -// - -IDR_POPUP_TOOLBAR TOOLBAR 16, 15 -BEGIN - BUTTON ID_POPUP_OPTIONS -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Bitmap -// - -IDR_POPUP_TOOLBAR BITMAP "res\\main_toolbar.bmp" - -///////////////////////////////////////////////////////////////////////////// -// -// RT_MANIFEST -// - -IDR_MANIFEST RT_MANIFEST "res\\manifest.txt" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif\r\n" - "#include ""res\\COPY HANDLER.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_ONECOPY_STRING "Cannot run the second instance of this program" - IDS_REGISTEROK_STRING "Library chext.dll was registered successfully" - IDS_REGISTERERR_STRING "Encountered error while trying to register library chext.dll\nError #%lu (%s)." - IDS_UNREGISTEROK_STRING "Library chext.dll was unregistered successfully" - IDS_UNREGISTERERR_STRING - "Encountered error while trying to unregister library chext.dll\nError #%lu (%s)." - IDS_HELPERR_STRING "Cannot open html help file:\n%s\n" -END - -STRINGTABLE -BEGIN - IDS_BROWSE_STRING "Choose path" - IDS_BDREMOTENAME_STRING "Remote name: " - IDS_BDLOCALNAME_STRING "Local name: " - IDS_BDTYPE_STRING "Type: " - IDS_BDNETTYPE_STRING "Network type: " - IDS_BDDESCRIPTION_STRING "Description: " - IDS_BDFREESPACE_STRING "Free space: " - IDS_BDCAPACITY_STRING "Capacity: " -END - -STRINGTABLE -BEGIN - IDS_FILEDLGALLFILTER_STRING "All files (*)|*||" - IDS_DSTFOLDERBROWSE_STRING "Choose destination folder" - IDS_MISSINGDATA_STRING "You didn't fill destination path or source file.\nProgram cannot continue" - IDS_CCDCOPY_STRING "Copy" - IDS_CCDMOVE_STRING "Move" - IDS_BSEDEFAULT_STRING "Default: %s" - IDS_BSEONEDISK_STRING "One Disk: %s" - IDS_BSETWODISKS_STRING "Two disks: %s" -END - -STRINGTABLE -BEGIN - IDS_APPNAME_STRING "Copy Handler" - IDS_PRIORITY0_STRING "Time critical" - IDS_PRIORITY1_STRING "Highest" - IDS_PRIORITY2_STRING "Above normal" - IDS_PRIORITY3_STRING "Normal" - IDS_PRIORITY4_STRING "Below normal" - IDS_PRIORITY5_STRING "Lowest" - IDS_PRIORITY6_STRING "Idle" -END - -STRINGTABLE -BEGIN - IDS_MINIVIEWALL_STRING "All:" -END - -STRINGTABLE -BEGIN - IDS_PROGRAM_STRING "Program" - IDS_CLIPBOARDMONITORING_STRING "Clipboard monitoring" - IDS_CLIPBOARDINTERVAL_STRING "Scan clipboard every ... [ms]" - IDS_AUTORUNPROGRAM_STRING "Run program with system" - IDS_AUTOSHUTDOWN_STRING "Shutdown system after copying finishes" - IDS_AUTOSAVEINTERVAL_STRING "Autosave every ... [ms]" - IDS_TEMPFOLDER_STRING "Folder for temporary data" - IDS_STATUSWINDOW_STRING "Status window" - IDS_REFRESHSTATUSINTERVAL_STRING "Refresh status every ... [ms]" - IDS_STATUSSHOWDETAILS_STRING "Show details in status window" - IDS_STATUSAUTOREMOVE_STRING "Automatically remove finished tasks" - IDS_MINIVIEW_STRING "Miniview" - IDS_SHOWFILENAMES_STRING "Show file names" - IDS_SHOWSINGLETASKS_STRING "Show single tasks" - IDS_MINIVIEWREFRESHINTERVAL_STRING "Refresh status every ... [ms]" - IDS_MINIVIEWSHOWAFTERSTART_STRING "Show at program startup" -END - -STRINGTABLE -BEGIN - IDS_CFGSHSHOWICONS_STRING "Show icons with shortcuts (experimental)" - IDS_CFGSHOVERRIDEDRAG_STRING - "Intercept drag&drop operation by left mouse button (experimental)" - IDS_CFGSHORTCUTS_STRING "Shortcuts" - IDS_CFGRECENT_STRING "Recently used paths" - IDS_CFGSHELL_STRING "Shell" - IDS_CFGSCCOUNT_STRING "Defined shortcuts' count" - IDS_CFGRPCOUNT_STRING "Count of recent paths" - IDS_CFGOVERRIDEDEFACTION_STRING - "Default action for dragging by left mouse button" - IDS_CFGPRIORITYCLASS_STRING "Application's priority class" - IDS_CFGDISABLEPRIORITYBOOST_STRING "Disable priority boosting" - IDS_BOOLTEXT_STRING "No!Yes" - IDS_TEMPFOLDERCHOOSE_STRING "!Choose temporary folder" - IDS_FEEDBACKTYPE_STRING "Disabled!Normal!Heavy" - IDS_SOUNDSWAVFILTER_STRING "!Sound files (.wav)|*.wav||" - IDS_FORCESHUTDOWNVALUES_STRING "Normal!Force" -END - -STRINGTABLE -BEGIN - IDS_MINIVIEWAUTOHIDE_STRING "Hide when empty" - IDS_PROCESSINGTHREAD_STRING "Copying/moving thread" - IDS_AUTOCOPYREST_STRING "Auto ""copy-rest"" of files" - IDS_SETDESTATTRIB_STRING "Set attributes of destination files" - IDS_SETDESTTIME_STRING "Set date/time of destination files" - IDS_PROTECTROFILES_STRING "Protect read-only files" - IDS_LIMITOPERATIONS_STRING - "Limit maximum operations running simultaneously ..." - IDS_SHOWVISUALFEEDBACK_STRING "Show visual confirmation dialogs" - IDS_USETIMEDDIALOGS_STRING "Use timed confirmation dialogs" - IDS_TIMEDDIALOGINTERVAL_STRING "Time of showing confirmation dialogs" - IDS_AUTORETRYONERROR_STRING "Auto resume on error" - IDS_AUTORETRYINTERVAL_STRING "Auto resume every ... [ms]" - IDS_DEFAULTPRIORITY_STRING "Default thread priority" - IDS_AUTODETECTBUFFERSIZE_STRING "Use only default buffer" - IDS_DEFAULTBUFFERSIZE_STRING "Default buffer size" - IDS_DELETEAFTERFINISHED_STRING - "Don't delete files before copying finishes (moving)" -END - -STRINGTABLE -BEGIN - IDS_CREATELOGFILES_STRING "Create .log files" - IDS_SOUNDS_STRING "Sounds" - IDS_PLAYSOUNDS_STRING "Playing sounds" - IDS_SOUNDONERROR_STRING "Sound on error" - IDS_SOUNDONFINISH_STRING "Sound on copying finished" - IDS_LANGUAGE_STRING "Language" - IDS_READSIZEBEFOREBLOCK_STRING "Read tasks size before blocking" - IDS_USENOBUFFERING_STRING "Disable buffering for large files" - IDS_LARGEFILESMINSIZE_STRING - "Minimum file size for which buffering should be turned off" - IDS_OPTIONSBUFFER_STRING "Buffer" - IDS_ONEDISKBUFFERSIZE_STRING - "Buffer size for copying inside one physical disk boundary" - IDS_TWODISKSBUFFERSIZE_STRING - "Buffer size for copying between two different disks" - IDS_CDBUFFERSIZE_STRING "Buffer size for copying from CD-ROM" - IDS_LANBUFFERSIZE_STRING "Buffer size for copying over a network" - IDS_SHUTDOWNTIME_STRING "Wait ... [ms] before shutdown" - IDS_FORCESHUTDOWN_STRING "Type of shutdown" -END - -STRINGTABLE -BEGIN - IDS_SOURCESTRINGMISSING_STRING "You didn't enter source text" -END - -STRINGTABLE -BEGIN - IDS_COLUMNSTATUS_STRING "Status" - IDS_COLUMNSOURCE_STRING "File" - IDS_COLUMNDESTINATION_STRING "To:" - IDS_COLUMNPROGRESS_STRING "Progress" -END - -STRINGTABLE -BEGIN - IDS_EMPTYOPERATIONTEXT_STRING "None of tasks selected" - IDS_EMPTYSOURCETEXT_STRING "empty" - IDS_EMPTYDESTINATIONTEXT_STRING "empty" - IDS_EMPTYBUFFERSIZETEXT_STRING "unknown" - IDS_EMPTYPRIORITYTEXT_STRING "unknown" - IDS_EMPTYERRORTEXT_STRING "empty" - IDS_EMPTYPROCESSEDTEXT_STRING "empty" - IDS_EMPTYTRANSFERTEXT_STRING "unknown" - IDS_EMPTYTIMETEXT_STRING "00:00 / 00:00" - IDS_CURRENTPASS_STRING "pass: " - IDS_AVERAGEWORD_STRING "avg: " - IDS_STATUSTITLE_STRING "Status" - IDS_REPLACEPATHSTEXT_STRING - "Changed:\n%d paths primarily got from clipboard" - IDS_TASKNOTPAUSED_STRING "Selected task isn't paused" - IDS_TASKNOTSELECTED_STRING "Task not selected" - IDS_NONEINPUTFILE_STRING "(waiting...)" -END - -STRINGTABLE -BEGIN - IDS_BUFFERSIZEZERO_STRING "Cannot operate with buffer of 0 size" -END - -STRINGTABLE -BEGIN - IDS_OTFSEARCHINGFORFILES_STRING "Searching for files..." - IDS_OTFMISSINGCLIPBOARDINPUT_STRING - "Source file/folder not found (clipboard) : %s" - IDS_OTFADDINGCLIPBOARDFILE_STRING - "Adding file/folder (clipboard) : %s ..." - IDS_OTFADDEDFOLDER_STRING "Added folder %s" - IDS_OTFRECURSINGFOLDER_STRING "Recursing folder %s" - IDS_OTFADDINGKILLREQEST_STRING - "Kill request while adding data to files array (RecurseDirectories)" - IDS_OTFADDEDFILE_STRING "Added file %s" - IDS_OTFSEARCHINGFINISHED_STRING "Searching for files finished" -END - -STRINGTABLE -BEGIN - IDS_OTFDELETINGFILES_STRING "Deleting files (DeleteFiles)..." - IDS_OTFDELETINGKILLREQUEST_STRING - "Kill request while deleting files (Delete Files)" - IDS_OTFDELETINGERROR_STRING - "Error #%lu (%s) while deleting file/folder %s" - IDS_OTFDELETINGFINISHED_STRING "Deleting files finished" - IDS_OTFPRECHECKCANCELREQUEST_STRING - "Cancel request while checking result of dialog before opening source file %s (CustomCopyFile)" - IDS_OTFOPENINGERROR_STRING - "Error %err while opening source file %s (CustomCopyFile)" - IDS_OTFOPENINGCANCELREQUEST_STRING - "Cancel request [error %err] while opening source file %s (CustomCopyFile)" - IDS_OTFOPENINGWAITREQUEST_STRING - "Wait request [error %err] while opening source file %s (CustomCopyFile)" - IDS_OTFOPENINGRETRY_STRING - "Retrying [error %err] to open source file %s (CustomCopyFile)" - IDS_OTFDESTOPENINGERROR_STRING - "Error %err while opening destination file %s (CustomCopyFile)" - IDS_OTFDESTOPENINGRETRY_STRING - "Retrying [error %err] to open destination file %s (CustomCopyFile)" - IDS_OTFDESTOPENINGCANCELREQUEST_STRING - "Cancel request [error %err] while opening destination file %s (CustomCopyFile)" - IDS_OTFDESTOPENINGWAITREQUEST_STRING - "Wait request [error %err] while opening destination file %s (CustomCopyFile)" - IDS_OTFMOVINGPOINTERSERROR_STRING - "Error %err while moving file pointers of %s and %s to %I64u" - IDS_OTFRESTORINGPOINTERSERROR_STRING - "Error %err while restoring (moving to beginning) file pointers of %s and %s" - IDS_OTFSETTINGZEROSIZEERROR_STRING - "Error %err while setting size of file %s to 0" -END - -STRINGTABLE -BEGIN - IDS_OTFCOPYINGKILLREQUEST_STRING - "Kill request while main copying file %s -> %s" - IDS_OTFCHANGINGBUFFERSIZE_STRING - "Changing buffer size from [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu] to [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu] wile copying %s -> %s (CustomCopyFile)" - IDS_OTFREADINGERROR_STRING - "Error %err while trying to read %d bytes from source file %s (CustomCopyFile)" - IDS_OTFWRITINGERROR_STRING - "Error %err while trying to write %d bytes to destination file %s (CustomCopyFile)" - IDS_OTFCAUGHTEXCEPTIONCCF_STRING - "Caught exception in CustomCopyFile [last error: %err] (at time %lu)" - IDS_OTFPROCESSINGFILES_STRING "Processing files/folders (ProcessFiles)" - IDS_OTFPROCESSINGFILESDATA_STRING - "Processing files/folders (ProcessFiles):\r\n\tOnlyCreate: %d\r\n\tBufferSize: [Def:%lu, One:%lu, Two:%lu, CD:%lu, LAN:%lu]\r\n\tFiles/folders count: %lu\r\n\tCopies count: %d\r\n\tIgnore Folders: %d\r\n\tDest path: %s\r\n\tCurrent pass (0-based): %d\r\n\tCurrent index (0-based): %d" - IDS_OTFPROCESSINGKILLREQUEST_STRING - "Kill request while processing file in ProcessFiles" - IDS_OTFMOVEFILEERROR_STRING - "Error %err while calling MoveFile %s -> %s (ProcessFiles)" - IDS_OTFCREATEDIRECTORYERROR_STRING - "Error %err while calling CreateDirectory %s (ProcessFiles)" - IDS_OTFPROCESSINGFINISHED_STRING "Finished processing in ProcessFiles" - IDS_OTFTHREADSTART_STRING - "\r\n# COPYING THREAD STARTED #\r\nBegan processing data (dd:mm:yyyy) %02d.%02d.%4d at %02d:%02d.%02d" - IDS_OTFWAITINGFINISHED_STRING "Finished waiting for begin permission" - IDS_OTFWAITINGKILLREQUEST_STRING - "Kill request while waiting for begin permission (wait state)" - IDS_OTFTHREADFINISHED_STRING - "Finished processing data (dd:mm:yyyy) %02d.%02d.%4d at %02d:%02d.%02d" - IDS_OTFCAUGHTEXCEPTIONMAIN_STRING - "Caught exception in ThrdProc [last error: %err, type: %d]" -END - -STRINGTABLE -BEGIN - IDS_TITLECOPY_STRING "Copying..." - IDS_TITLEMOVE_STRING "Moving..." - IDS_TITLEUNKNOWNOPERATION_STRING - "Unknown operation type - this shouldn't happen" - IDS_MAINBROWSETEXT_STRING "Enter destination path for:\n" -END - -STRINGTABLE -BEGIN - IDS_COPYWORDLESSFIVE_STRING " copies" - IDS_COPYWORDMOREFOUR_STRING " copies" - IDS_STATUS0_STRING "Searching" - IDS_STATUS1_STRING "Copying" - IDS_STATUS2_STRING "Moving" - IDS_STATUS3_STRING "Finished" - IDS_STATUS4_STRING "Error" - IDS_STATUS5_STRING "Paused" - IDS_STATUS6_STRING "Deleting" - IDS_STATUS7_STRING "Unknown" - IDS_STATUS8_STRING "Cancelled" - IDS_STATUS9_STRING "Waiting" - IDS_STATUS10_STRING "Only files" - IDS_STATUS11_STRING "Without contents" - IDS_SHELLEXECUTEERROR_STRING "Error #%lu calling ShellExecute for file %s" - IDS_BSDEFAULT_STRING "Default: " -END - -STRINGTABLE -BEGIN - IDS_FIRSTCOPY_STRING "Copy of %s" - IDS_NEXTCOPY_STRING "Copy (%d) of %s" - IDS_NOTFOUND_STRING "File not found (doesn't exist)" - IDS_BYTE_STRING "B" - IDS_KBYTE_STRING "kB" - IDS_MBYTE_STRING "MB" - IDS_GBYTE_STRING "GB" - IDS_TBYTE_STRING "TB" - IDS_PBYTE_STRING "PB" - IDS_LT_STRING "<" - IDS_LE_STRING "<=" - IDS_EQ_STRING "=" - IDS_GE_STRING ">=" - IDS_GT_STRING ">" -END - -STRINGTABLE -BEGIN - IDS_OTFCHECKINGSPACE_STRING - "Checking for free space on destination disk..." - IDS_OTFNOTENOUGHFREESPACE_STRING - "Not enough free space on disk - needed %I64d bytes for data, available: %I64d bytes." - IDS_OTFFREESPACECANCELREQUEST_STRING - "Cancel request while checking for free space on disk." - IDS_OTFFREESPACERETRYING_STRING "Retrying to read drive's free space..." - IDS_OTFFREESPACEIGNORE_STRING - "Ignored warning about not enough place on disk to copy data." - IDS_OTFMOVEFILECANCELREQUEST_STRING - "Cancel request while calling MoveFileEx %s -> %s (ProcessFiles)" -END - -STRINGTABLE -BEGIN - IDS_BSONEDISK_STRING "One disk: " - IDS_BSTWODISKS_STRING "Two disks: " - IDS_BSCD_STRING "CD: " - IDS_BSLAN_STRING "LAN: " - IDS_CPEDELETINGERROR_STRING - "Error #%errnum (%errdesc) while deleting file %s" - IDS_CPEOPENINGERROR_STRING - "Error #%errnum (%errdesc) while trying to open source file %s" - IDS_CPEDESTOPENINGERROR_STRING - "Error #%errnum (%errdesc) while trying to open destination file %s. Probably file has read-only attribute set, and 'Protect read-only files' flag in configuration is set (so the file cannot be open to write)." - IDS_CPERESTORINGPOINTERSERROR_STRING - "Error #%errnum (%errdesc) while restoring (moving to beginning) file pointers of %s and %s" - IDS_CPESETTINGZEROSIZEERROR_STRING - "Error #%errnum (%errdesc) while setting size of file %s to 0" - IDS_CPEREADINGERROR_STRING - "Error #%errnum (%errdesc) while trying to read %d bytes from source file %s" - IDS_CPEWRITINGERROR_STRING - "Error #%errnum (%errdesc) while trying to write %d bytes to destination file %s" - IDS_CPEMOVEFILEERROR_STRING - "Error #%errnum (%errdesc) while calling MoveFile %s -> %s" - IDS_CPECREATEDIRECTORYERROR_STRING - "Error #%errnum (%errdesc) while calling CreateDirectory %s" - IDS_EMPTYASSOCFILE_STRING "not associated" - IDS_FILTERING_STRING " [with filter]" - IDS_CONFIRMCANCEL_STRING - "Selected task wasn't finished yet.\nDo you want to finish it now ?" -END - -STRINGTABLE -BEGIN - IDS_SHUTDOWNERROR_STRING - "Cannot shutdown this operating system.\nEncountered error #%lu." -END - -STRINGTABLE -BEGIN - IDS_MINIVIEWSMOOTHPROGRESS_STRING "Use smooth progress bars" - IDS_CFGFOLDERDIALOG_STRING "Choose folder dialog" - IDS_CFGFDEXTVIEW_STRING "Show extended view" - IDS_CFGFDWIDTH_STRING "Dialog width [pixels]" - IDS_CFGFDHEIGHT_STRING "Dialog height [pixels]" - IDS_CFGFDSHORTCUTS_STRING "Shortcuts' list style" - IDS_CFGFDIGNOREDIALOGS_STRING "Ignore additional shell dialogs" - IDS_CFGSHCOPY_STRING "Show 'Copy' command in drag&drop menu" - IDS_CFGSHMOVE_STRING "Show 'Move' command in drag&drop menu" - IDS_CFGSHCMSPECIAL_STRING - "Show 'Copy/move special' command in drag&drop menu" - IDS_CFGSHPASTE_STRING "Show 'Paste' command in context menu" - IDS_CFGSHPASTESPECIAL_STRING - "Show 'Paste special' command in context menu" - IDS_CFGSHCOPYTO_STRING "Show 'Copy to' command in context menu" - IDS_CFGSHMOVETO_STRING "Show 'Move to' command in context menu" - IDS_CFGSHCMTOSPECIAL_STRING - "Show 'Copy/move special to' command in context menu" - IDS_CFGSHSHOWFREESPACE_STRING "Show free space with shortcuts' names" -END - -STRINGTABLE -BEGIN - IDS_BSECD_STRING "CD: %s" - IDS_BSELAN_STRING "LAN: %s" - IDS_HDRMASK_STRING "Include mask" - IDS_HDRSIZE_STRING "Size" - IDS_HDRDATE_STRING "Date" - IDS_HDRATTRIB_STRING "Attributes included" - IDS_AND_STRING " and " - IDS_FILTERMASKEMPTY_STRING "none" - IDS_FILTERSIZE_STRING "any" - IDS_FILTERDATE_STRING "any" - IDS_HDREXCLUDEMASK_STRING "Exclude mask" - IDS_HDREXCLUDEATTRIB_STRING "Attributes excluded" - IDS_FILTERATTRIB_STRING "none" - IDS_EMPTYFILTER_STRING "None of filtering options were selected" - IDS_FLTALLFILTER_STRING "All files (*.*)|*.*||" - IDS_IMPORTREPORT_STRING "Imported %lu path(s)" -END - -STRINGTABLE -BEGIN - IDS_DATECREATED_STRING "Date of creation" - IDS_DATELASTWRITE_STRING "Date of last write" - IDS_DATEACCESSED_STRING "Date of last access" -END - -STRINGTABLE -BEGIN - IDS_MENUCOPY_STRING "(CH) Copy here" - IDS_MENUMOVE_STRING "(CH) Move here" - IDS_MENUCOPYMOVESPECIAL_STRING "(CH) Copy/move special..." - IDS_MENUPASTE_STRING "(CH) Paste" - IDS_MENUPASTESPECIAL_STRING "(CH) Paste special..." - IDS_MENUCOPYTO_STRING "(CH) Copy to" - IDS_MENUMOVETO_STRING "(CH) Move to" - IDS_MENUCOPYMOVETOSPECIAL_STRING "(CH) Copy/move special to..." -END - -STRINGTABLE -BEGIN - IDS_MENUTIPCOPY_STRING "Copies data here with Copy Handler" - IDS_MENUTIPMOVE_STRING "Moves data here with Copy Handler" - IDS_MENUTIPCOPYMOVESPECIAL_STRING - "Copies/moves data with additional settings" - IDS_MENUTIPPASTE_STRING "Pastes files/folders from clipboard here" - IDS_MENUTIPPASTESPECIAL_STRING - "Pastes files/folders from clipboard here with additional settings" - IDS_MENUTIPCOPYTO_STRING "Copies selected data into specified folder" - IDS_MENUTIPMOVETO_STRING "Moves selected data into specified folder" - IDS_MENUTIPCOPYMOVETOSPECIAL_STRING - "Copies/moves selected data into specified folder with additional settings" -END - -STRINGTABLE -BEGIN - IDS_CFGFDSHORTCUTSSTYLES_STRING "Large icons!Small icons!List!Report" - IDS_CFGPRIORITYCLASSITEMS_STRING "Idle!Normal!High!Real-time" - IDS_CFGACTIONS_STRING "Copy!Move!Special operation!Autodetect" - IDS_PLUGSFOLDER_STRING "Folder with plugins" - IDS_PLUGSFOLDERCHOOSE_STRING "!Choose folder with plugins" - IDS_CFGLOGFILE_STRING "Main log file" - IDS_CFGENABLELOGGING_STRING "Enable logging" - IDS_CFGLIMITATION_STRING "Use log file size limit" - IDS_CFGMAXLIMIT_STRING "Maximum size of the limited log file" - IDS_CFGLOGPRECISELIMITING_STRING "Use precise limiting of a log file" - IDS_CFGTRUNCBUFFERSIZE_STRING "Truncate buffer size" - IDS_CFGHELPDIR_STRING "Directory with help files" - IDS_CFGHELPDIRCHOOSE_STRING "!Choose folder with program's help files" - IDS_LANGUAGESFOLDER_STRING "Directory with language files" - IDS_LANGSFOLDERCHOOSE_STRING "!Choose folder with language files" -END - -STRINGTABLE -BEGIN - IDS_SHORTCUTNAME_STRING "Shortcut's name" - IDS_SHORTCUTPATH_STRING "Path" -END - -STRINGTABLE -BEGIN - IDS_BDOK_STRING "&OK" - IDS_BDCANCEL_STRING "&Cancel" - IDS_BDCANNOTCREATEFOLDER_STRING "Cannot create the folder" - IDS_BDPATHDOESNTEXIST_STRING "Entered path doesn't exist" - IDS_BDNAME_STRING "Name" - IDS_BDPATH_STRING "Path" - IDS_BDPATH2_STRING "Path: " - IDS_BDRIGHT_STRING ">>" - IDS_BDLEFT_STRING "<<" - IDS_BDNOSHORTCUTPATH_STRING - "You haven't entered the path for this shortcut" - IDS_BDNEWFOLDER_STRING "Create new folder" - IDS_BDLARGEICONS_STRING "Large icons" - IDS_BDSMALLICONS_STRING "Small icons" - IDS_BDLIST_STRING "List" - IDS_BDREPORT_STRING "Report" - IDS_BDDETAILS_STRING "Details" -END - -STRINGTABLE -BEGIN - IDS_BDADDSHORTCUT_STRING "Add to shortcut's list" - IDS_BDREMOVESHORTCUT_STRING "Remove from shortcut's list" - IDS_BDDOMAIN_STRING "Domain/Workgroup" - IDS_BDSERVER_STRING "Server" - IDS_BDSHARE_STRING "Share" - IDS_BDFILE_STRING "File" - IDS_BDGROUP_STRING "Group" - IDS_BDNETWORK_STRING "Network" - IDS_BDROOT_STRING "Root" - IDS_BDADMINSHARE_STRING "Administration share" - IDS_BDDIR_STRING "Directory" - IDS_BDTREE_STRING "Tree" - IDS_BDNDSCONTAINER_STRING "NDS Container" -END - -STRINGTABLE -BEGIN - IDS_ABOUTVERSION_STRING "Compilation: %s" - IDS_LANGCODE_STRING "Code=" - IDS_LANGVER_STRING "Version=" -END - -STRINGTABLE -BEGIN - IDS_NERPATH_STRING "There is not enough room in %s to copy or move:" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif -#include "res\COPY HANDLER.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - Index: src/ch/ch.vcproj =================================================================== diff -u -N --- src/ch/ch.vcproj (revision 0) +++ src/ch/ch.vcproj (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,1679 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ch/ch.vcproj =================================================================== diff -u -N --- ch/ch.vcproj (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/ch.vcproj (revision 0) @@ -1,1679 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: src/ch/charvect.h =================================================================== diff -u -N --- src/ch/charvect.h (revision 0) +++ src/ch/charvect.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,105 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __CHARVECT_H__ +#define __CHARVECT_H__ + +#include + +using namespace std; + +class char_vector : public vector +{ +public: + char_vector() : vector() { }; + char_vector(const char_vector& cv, bool bCopy) { insert(begin(), cv.begin(), cv.end(), bCopy); }; + ~char_vector() { erase(begin(), end(), true); }; + + void assign(size_type _Count, const PTSTR& _Type, bool bDelete, bool bCopy) { erase(begin(), end(), bDelete); insert(begin(), _Count, _Type, bCopy); }; + template void assign(_It _First, _It _Last, bool bDelete, bool bCopy) { erase(begin(), end(), bDelete); insert(begin(), _First, _Last, bCopy); }; + + void clear(bool bDelete) { erase(begin(), end(), bDelete); }; + + iterator erase(iterator _Where, bool bDelete) { if (bDelete) delete [] (*_Where); return ((vector*)this)->erase(_Where); }; + iterator erase(iterator _First, iterator _Last, bool bDelete) { if (bDelete) for (iterator _Run=_First;_Run != _Last;_Run++) delete [] (*_Run); return ((vector*)this)->erase(_First, _Last); }; + + void replace(iterator _Where, const PTSTR& _Val, bool bDelete, bool bCopy) + { + if (bDelete) + delete [] (*_Where); + if (bCopy) + { + (*_Where)=new TCHAR[_tcslen(_Val)+1]; + _tcscpy(*_Where, _Val); + } + else + (*_Where)=_Val; + }; + iterator insert(iterator _Where, const PTSTR& _Val, bool bCopy) + { + size_type _O = _Where - begin(); + insert(_Where, 1, _Val, bCopy); + return (begin() + _O); + }; + void insert(iterator _Where, size_type _Count, const PTSTR& _Val, bool bCopy) + { + if (bCopy) + { + size_type _Size=_tcslen(_Val)+1; + PTSTR *ppsz=new PTSTR[_Count]; + for (size_type i=0;i<_Count;i++) + { + ppsz[i]=new TCHAR[_Size]; + _tcscpy(ppsz[i], _Val); + } + + ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); + delete [] ppsz; + } + else + ((vector*)this)->insert(_Where, _Count, _Val); + }; + template void insert(iterator _Where, _It _First, _It _Last, bool bCopy) + { + if (bCopy) + { + size_type _Cnt=_Last-_First; + PTSTR *ppsz=new PTSTR[_Cnt]; + for (size_type i=0;i<_Cnt;i++) + { + ppsz[i]=new TCHAR[_tcslen(*_First)+1]; + _tcscpy(ppsz[i], *_First); + + _First++; + } + + ((vector*)this)->insert(_Where, ppsz, ppsz+_Cnt); + delete [] ppsz; + } + else + ((vector*)this)->insert(_Where, _First, _Last); + }; + + void swap_items(iterator _Item1, iterator _Item2) { PTSTR psz=(*_Item1); (*_Item1)=(*_Item2); (*_Item2)=psz; }; + + void pop_back(bool bDelete) { if (bDelete) delete [] (*(end()-1)); ((vector*)this)->pop_back(); }; + void push_back(const PTSTR& _Val, bool bCopy) { insert(end(), 1, _Val, bCopy); }; +}; + +#endif \ No newline at end of file Index: ch/charvect.h =================================================================== diff -u -N --- ch/charvect.h (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/charvect.h (revision 0) @@ -1,105 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __CHARVECT_H__ -#define __CHARVECT_H__ - -#include - -using namespace std; - -class char_vector : public vector -{ -public: - char_vector() : vector() { }; - char_vector(const char_vector& cv, bool bCopy) { insert(begin(), cv.begin(), cv.end(), bCopy); }; - ~char_vector() { erase(begin(), end(), true); }; - - void assign(size_type _Count, const PTSTR& _Type, bool bDelete, bool bCopy) { erase(begin(), end(), bDelete); insert(begin(), _Count, _Type, bCopy); }; - template void assign(_It _First, _It _Last, bool bDelete, bool bCopy) { erase(begin(), end(), bDelete); insert(begin(), _First, _Last, bCopy); }; - - void clear(bool bDelete) { erase(begin(), end(), bDelete); }; - - iterator erase(iterator _Where, bool bDelete) { if (bDelete) delete [] (*_Where); return ((vector*)this)->erase(_Where); }; - iterator erase(iterator _First, iterator _Last, bool bDelete) { if (bDelete) for (iterator _Run=_First;_Run != _Last;_Run++) delete [] (*_Run); return ((vector*)this)->erase(_First, _Last); }; - - void replace(iterator _Where, const PTSTR& _Val, bool bDelete, bool bCopy) - { - if (bDelete) - delete [] (*_Where); - if (bCopy) - { - (*_Where)=new TCHAR[_tcslen(_Val)+1]; - _tcscpy(*_Where, _Val); - } - else - (*_Where)=_Val; - }; - iterator insert(iterator _Where, const PTSTR& _Val, bool bCopy) - { - size_type _O = _Where - begin(); - insert(_Where, 1, _Val, bCopy); - return (begin() + _O); - }; - void insert(iterator _Where, size_type _Count, const PTSTR& _Val, bool bCopy) - { - if (bCopy) - { - size_type _Size=_tcslen(_Val)+1; - PTSTR *ppsz=new PTSTR[_Count]; - for (size_type i=0;i<_Count;i++) - { - ppsz[i]=new TCHAR[_Size]; - _tcscpy(ppsz[i], _Val); - } - - ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); - delete [] ppsz; - } - else - ((vector*)this)->insert(_Where, _Count, _Val); - }; - template void insert(iterator _Where, _It _First, _It _Last, bool bCopy) - { - if (bCopy) - { - size_type _Cnt=_Last-_First; - PTSTR *ppsz=new PTSTR[_Cnt]; - for (size_type i=0;i<_Cnt;i++) - { - ppsz[i]=new TCHAR[_tcslen(*_First)+1]; - _tcscpy(ppsz[i], *_First); - - _First++; - } - - ((vector*)this)->insert(_Where, ppsz, ppsz+_Cnt); - delete [] ppsz; - } - else - ((vector*)this)->insert(_Where, _First, _Last); - }; - - void swap_items(iterator _Item1, iterator _Item2) { PTSTR psz=(*_Item1); (*_Item1)=(*_Item2); (*_Item2)=psz; }; - - void pop_back(bool bDelete) { if (bDelete) delete [] (*(end()-1)); ((vector*)this)->pop_back(); }; - void push_back(const PTSTR& _Val, bool bCopy) { insert(end(), 1, _Val, bCopy); }; -}; - -#endif \ No newline at end of file Index: src/ch/debug.h =================================================================== diff -u -N --- src/ch/debug.h (revision 0) +++ src/ch/debug.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,280 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +// time measuring macros +#ifdef _DEBUG + static long __dwst, __dwen; + #define MEASURE_TIME(lines, text) __dwst=GetTickCount(); lines __dwen=GetTickCount(); TRACE(text, __dwen-__dwst); +#else + #define MEASURE_TIME(lines, text) lines +#endif + +#ifdef _DEBUG + #define TRACELOGFONT(str, lf)\ + {\ + TRACE( str "\tlfHeight: %ld\n\tlfWidth: %ld\n\tlfEscapement: %ld\n\tlfOrientation: %ld\n\tlfWeight: %ld\n", (lf).lfHeight, (lf).lfWidth, (lf).lfEscapement, (lf).lfOrientation, (lf).lfWeight);\ + TRACE("\tlfItalic: %d\n\tlfUnderline: %d\n\tlfStrikeOut: %d\n\tlfCharSet: %d\n\tlfOutPrecision: %d\n\tlfClipPrecision: %d\n\tlfQuality: %d\n\tlfPitchAndFamily: %d\n\tlfFaceName: %s\n", (lf).lfItalic, (lf).lfUnderline, (lf).lfStrikeOut, (lf).lfCharSet, (lf).lfOutPrecision, (lf).lfClipPrecision, (lf).lfQuality, (lf).lfPitchAndFamily, (lf).lfFaceName);\ + } +#else + #define TRACELOGFONT(lf) +#endif + +// window messages +#ifdef _DEBUG +struct __dbg_msg__ +{ + UINT uiMsg; + TCHAR *pszText; +}; + +////////////////////////////////////// + +#define GEN_PAIR(str) { str, #str } + +static __dbg_msg__ __msgs__[] = { + GEN_PAIR(WM_NULL), + GEN_PAIR(WM_CREATE), + GEN_PAIR(WM_DESTROY), + GEN_PAIR(WM_MOVE), + GEN_PAIR(WM_SIZE), + GEN_PAIR(WM_ACTIVATE), + GEN_PAIR(WM_SETFOCUS), + GEN_PAIR(WM_KILLFOCUS), + GEN_PAIR(WM_ENABLE), + GEN_PAIR(WM_SETREDRAW), + GEN_PAIR(WM_SETTEXT), + GEN_PAIR(WM_GETTEXT), + GEN_PAIR(WM_GETTEXTLENGTH), + GEN_PAIR(WM_PAINT), + GEN_PAIR(WM_CLOSE), + GEN_PAIR(WM_QUERYENDSESSION), + GEN_PAIR(WM_QUERYOPEN), + GEN_PAIR(WM_ENDSESSION), + GEN_PAIR(WM_QUIT), + GEN_PAIR(WM_ERASEBKGND), + GEN_PAIR(WM_SYSCOLORCHANGE), + GEN_PAIR(WM_SHOWWINDOW), + GEN_PAIR(WM_WININICHANGE), + GEN_PAIR(WM_DEVMODECHANGE), + GEN_PAIR(WM_ACTIVATEAPP), + GEN_PAIR(WM_FONTCHANGE), + GEN_PAIR(WM_TIMECHANGE), + GEN_PAIR(WM_CANCELMODE), + GEN_PAIR(WM_SETCURSOR), + GEN_PAIR(WM_MOUSEACTIVATE), + GEN_PAIR(WM_CHILDACTIVATE), + GEN_PAIR(WM_QUEUESYNC), + GEN_PAIR(WM_GETMINMAXINFO), + GEN_PAIR(WM_PAINTICON), + GEN_PAIR(WM_ICONERASEBKGND), + GEN_PAIR(WM_NEXTDLGCTL), + GEN_PAIR(WM_SPOOLERSTATUS), + GEN_PAIR(WM_DRAWITEM), + GEN_PAIR(WM_MEASUREITEM), + GEN_PAIR(WM_DELETEITEM), + GEN_PAIR(WM_VKEYTOITEM), + GEN_PAIR(WM_CHARTOITEM), + GEN_PAIR(WM_SETFONT), + GEN_PAIR(WM_GETFONT), + GEN_PAIR(WM_SETHOTKEY), + GEN_PAIR(WM_GETHOTKEY), + GEN_PAIR(WM_QUERYDRAGICON), + GEN_PAIR(WM_COMPAREITEM), + { 0x003d, "WM_GETOBJECT" }, + GEN_PAIR(WM_COMPACTING), + GEN_PAIR(WM_COMMNOTIFY), + GEN_PAIR(WM_WINDOWPOSCHANGING), + GEN_PAIR(WM_WINDOWPOSCHANGED), + GEN_PAIR(WM_POWER), + GEN_PAIR(WM_COPYDATA), + GEN_PAIR(WM_CANCELJOURNAL), + GEN_PAIR(WM_NOTIFY), + GEN_PAIR(WM_INPUTLANGCHANGEREQUEST), + GEN_PAIR(WM_INPUTLANGCHANGE), + GEN_PAIR(WM_TCARD), + GEN_PAIR(WM_HELP), + GEN_PAIR(WM_USERCHANGED), + GEN_PAIR(WM_NOTIFYFORMAT), + GEN_PAIR(WM_CONTEXTMENU), + GEN_PAIR(WM_STYLECHANGING), + GEN_PAIR(WM_STYLECHANGED), + GEN_PAIR(WM_DISPLAYCHANGE), + GEN_PAIR(WM_GETICON), + GEN_PAIR(WM_SETICON), + GEN_PAIR(WM_NCCREATE), + GEN_PAIR(WM_NCDESTROY), + GEN_PAIR(WM_NCCALCSIZE), + GEN_PAIR(WM_NCHITTEST), + GEN_PAIR(WM_NCPAINT), + GEN_PAIR(WM_NCACTIVATE), + GEN_PAIR(WM_GETDLGCODE), + GEN_PAIR(WM_SYNCPAINT), + GEN_PAIR(WM_NCMOUSEMOVE), + GEN_PAIR(WM_NCLBUTTONDOWN), + GEN_PAIR(WM_NCLBUTTONUP), + GEN_PAIR(WM_NCLBUTTONDBLCLK), + GEN_PAIR(WM_NCRBUTTONDOWN), + GEN_PAIR(WM_NCRBUTTONUP), + GEN_PAIR(WM_NCRBUTTONDBLCLK), + GEN_PAIR(WM_NCMBUTTONDOWN), + GEN_PAIR(WM_NCMBUTTONUP), + GEN_PAIR(WM_NCMBUTTONDBLCLK), + { 0x00AB, "WM_NCXBUTTONDOWN" }, + { 0x00AC, "WM_NCXBUTTONUP" }, + { 0x00AD, "WM_NCXBUTTONDBLCLK" }, + { 0x00FF, "WM_INPUT" }, + GEN_PAIR(WM_KEYFIRST), + GEN_PAIR(WM_KEYDOWN), + GEN_PAIR(WM_KEYUP), + GEN_PAIR(WM_CHAR), + GEN_PAIR(WM_DEADCHAR), + GEN_PAIR(WM_SYSKEYDOWN), + GEN_PAIR(WM_SYSKEYUP), + GEN_PAIR(WM_SYSCHAR), + GEN_PAIR(WM_SYSDEADCHAR), + GEN_PAIR(WM_UNICHAR), + GEN_PAIR(WM_KEYLAST), + GEN_PAIR(WM_IME_STARTCOMPOSITION), + GEN_PAIR(WM_IME_ENDCOMPOSITION), + GEN_PAIR(WM_IME_COMPOSITION), + GEN_PAIR(WM_IME_KEYLAST), + GEN_PAIR(WM_INITDIALOG), + GEN_PAIR(WM_COMMAND), + GEN_PAIR(WM_SYSCOMMAND), + GEN_PAIR(WM_TIMER), + GEN_PAIR(WM_HSCROLL), + GEN_PAIR(WM_VSCROLL), + GEN_PAIR(WM_INITMENU), + GEN_PAIR(WM_INITMENUPOPUP), + GEN_PAIR(WM_MENUSELECT), + GEN_PAIR(WM_MENUCHAR), + GEN_PAIR(WM_ENTERIDLE), + { 0x0122, "WM_MENURBUTTONUP" }, + { 0x0123, "WM_MENUDRAG" }, + { 0x0124, "WM_MENUGETOBJECT" }, + { 0x0125, "WM_UNINITMENUPOPUP" }, + { 0x0126, "WM_MENUCOMMAND" }, + { 0x0127, "WM_CHANGEUISTATE" }, + { 0x0128, "WM_UPDATEUISTATE" }, + { 0x0129, "WM_QUERYUISTATE" }, + GEN_PAIR(WM_CTLCOLORMSGBOX), + GEN_PAIR(WM_CTLCOLOREDIT), + GEN_PAIR(WM_CTLCOLORLISTBOX), + GEN_PAIR(WM_CTLCOLORBTN), + GEN_PAIR(WM_CTLCOLORDLG), + GEN_PAIR(WM_CTLCOLORSCROLLBAR), + GEN_PAIR(WM_CTLCOLORSTATIC), + GEN_PAIR(WM_MOUSEFIRST), + GEN_PAIR(WM_MOUSEMOVE), + GEN_PAIR(WM_LBUTTONDOWN), + GEN_PAIR(WM_LBUTTONUP), + GEN_PAIR(WM_LBUTTONDBLCLK), + GEN_PAIR(WM_RBUTTONDOWN), + GEN_PAIR(WM_RBUTTONUP), + GEN_PAIR(WM_RBUTTONDBLCLK), + GEN_PAIR(WM_MBUTTONDOWN), + GEN_PAIR(WM_MBUTTONUP), + GEN_PAIR(WM_MBUTTONDBLCLK), + GEN_PAIR(WM_MOUSEWHEEL), + { 0x020B, "WM_XBUTTONDOWN" }, + { 0x020C, "WM_XBUTTONUP" }, + { 0x020D, "WM_XBUTTONDBLCLK" }, + GEN_PAIR(WM_MOUSELAST), + GEN_PAIR(WM_MOUSELAST), + GEN_PAIR(WM_MOUSELAST), + GEN_PAIR(WM_PARENTNOTIFY), + GEN_PAIR(WM_ENTERMENULOOP), + GEN_PAIR(WM_EXITMENULOOP), + GEN_PAIR(WM_NEXTMENU), + GEN_PAIR(WM_SIZING), + GEN_PAIR(WM_CAPTURECHANGED), + GEN_PAIR(WM_MOVING), + GEN_PAIR(WM_POWERBROADCAST), + GEN_PAIR(WM_DEVICECHANGE), + GEN_PAIR(WM_MDICREATE), + GEN_PAIR(WM_MDIDESTROY), + GEN_PAIR(WM_MDIACTIVATE), + GEN_PAIR(WM_MDIRESTORE), + GEN_PAIR(WM_MDINEXT), + GEN_PAIR(WM_MDIMAXIMIZE), + GEN_PAIR(WM_MDITILE), + GEN_PAIR(WM_MDICASCADE), + GEN_PAIR(WM_MDIICONARRANGE), + GEN_PAIR(WM_MDIGETACTIVE), + GEN_PAIR(WM_MDISETMENU), + GEN_PAIR(WM_ENTERSIZEMOVE), + GEN_PAIR(WM_EXITSIZEMOVE), + GEN_PAIR(WM_DROPFILES), + GEN_PAIR(WM_MDIREFRESHMENU), + GEN_PAIR(WM_IME_SETCONTEXT), + GEN_PAIR(WM_IME_NOTIFY), + GEN_PAIR(WM_IME_CONTROL), + GEN_PAIR(WM_IME_COMPOSITIONFULL), + GEN_PAIR(WM_IME_SELECT), + GEN_PAIR(WM_IME_CHAR), + { 0x0288, "WM_IME_REQUEST" }, + GEN_PAIR(WM_IME_KEYDOWN), + GEN_PAIR(WM_IME_KEYUP), + GEN_PAIR(WM_MOUSEHOVER), + GEN_PAIR(WM_MOUSELEAVE), + { 0x02A0, "WM_NCMOUSEHOVER" }, + { 0x02A2, "WM_NCMOUSELEAVE" }, + { 0x02B1, "WM_WTSSESSION_CHANGE" }, + { 0x02C0, "WM_TABLET_FIRST" }, + { 0x02DF, "WM_TABLET_LAST" }, + GEN_PAIR(WM_CUT), + GEN_PAIR(WM_COPY), + GEN_PAIR(WM_PASTE), + GEN_PAIR(WM_CLEAR), + GEN_PAIR(WM_UNDO), + GEN_PAIR(WM_RENDERFORMAT), + GEN_PAIR(WM_RENDERALLFORMATS), + GEN_PAIR(WM_DESTROYCLIPBOARD), + GEN_PAIR(WM_DRAWCLIPBOARD), + GEN_PAIR(WM_PAINTCLIPBOARD), + GEN_PAIR(WM_VSCROLLCLIPBOARD), + GEN_PAIR(WM_SIZECLIPBOARD), + GEN_PAIR(WM_ASKCBFORMATNAME), + GEN_PAIR(WM_CHANGECBCHAIN), + GEN_PAIR(WM_HSCROLLCLIPBOARD), + GEN_PAIR(WM_QUERYNEWPALETTE), + GEN_PAIR(WM_PALETTEISCHANGING), + GEN_PAIR(WM_PALETTECHANGED), + GEN_PAIR(WM_HOTKEY), + GEN_PAIR(WM_PRINT), + GEN_PAIR(WM_PRINTCLIENT), + { 0x0319, "WM_APPCOMMAND" }, + { 0x031A, "WM_THEMECHANGED" }, + GEN_PAIR(WM_HANDHELDFIRST), + GEN_PAIR(WM_HANDHELDLAST), + GEN_PAIR(WM_AFXFIRST), + GEN_PAIR(WM_AFXLAST), + GEN_PAIR(WM_PENWINFIRST), + GEN_PAIR(WM_PENWINLAST), + GEN_PAIR(WM_APP), + GEN_PAIR(WM_USER) + }; +///////////////////////////////// + +static char* UINTToMsg(UINT uiMsg, char* szBuffer) +{ + int iCount=sizeof(__msgs__)/(sizeof(UINT)+sizeof(char*)); + for (int i=0;i + + +Program for copying files/folders in all 32-bit Windows systems + + + + + + Index: ch/res/Manifest.txt =================================================================== diff -u -N --- ch/res/Manifest.txt (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/res/Manifest.txt (revision 0) @@ -1,22 +0,0 @@ - - - -Program for copying files/folders in all 32-bit Windows systems - - - - - - Index: src/ch/res/Thanks.txt =================================================================== diff -u -N --- src/ch/res/Thanks.txt (revision 0) +++ src/ch/res/Thanks.txt (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,18 @@ +[Program] +El Magico great ideas, beta-tests, ... + +[Home page] +Tomas S. Refsland page hosting, other help +Barnaba webmaster + +[Language packs] +%s + +[Additional software] +Markus Oberhumer & Laszlo Molnar UPX software +Antonio Tejada Lacaci CFileInfoArray +Keith Rule CMemDC +Brett R. Mitchell CPropertyListCtrl + +[Other] +Thanks for anybody that helped in any way... \ No newline at end of file Index: ch/res/Thanks.txt =================================================================== diff -u -N --- ch/res/Thanks.txt (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/res/Thanks.txt (revision 0) @@ -1,18 +0,0 @@ -[Program] -El Magico great ideas, beta-tests, ... - -[Home page] -Tomas S. Refsland page hosting, other help -Barnaba webmaster - -[Language packs] -%s - -[Additional software] -Markus Oberhumer & Laszlo Molnar UPX software -Antonio Tejada Lacaci CFileInfoArray -Keith Rule CMemDC -Brett R. Mitchell CPropertyListCtrl - -[Other] -Thanks for anybody that helped in any way... \ No newline at end of file Index: src/ch/res/addshort.ico =================================================================== diff -u -N Binary files differ Index: ch/res/addshort.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/cancelled.ico =================================================================== diff -u -N Binary files differ Index: ch/res/cancelled.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/cd.ico =================================================================== diff -u -N Binary files differ Index: ch/res/cd.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/delshort.ico =================================================================== diff -u -N Binary files differ Index: ch/res/delshort.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/err.ico =================================================================== diff -u -N Binary files differ Index: ch/res/err.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/error.ico =================================================================== diff -u -N Binary files differ Index: ch/res/error.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/finished.ico =================================================================== diff -u -N Binary files differ Index: ch/res/finished.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/folder.ico =================================================================== diff -u -N Binary files differ Index: ch/res/folder.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/hd.ico =================================================================== diff -u -N Binary files differ Index: ch/res/hd.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/hd2.ico =================================================================== diff -u -N Binary files differ Index: ch/res/hd2.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/info.ico =================================================================== diff -u -N Binary files differ Index: ch/res/info.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/large.ico =================================================================== diff -u -N Binary files differ Index: ch/res/large.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/list.ico =================================================================== diff -u -N Binary files differ Index: ch/res/list.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/main_toolbar.bmp =================================================================== diff -u -N Binary files differ Index: ch/res/main_toolbar.bmp =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/net.ico =================================================================== diff -u -N Binary files differ Index: ch/res/net.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/newdir.ico =================================================================== diff -u -N Binary files differ Index: ch/res/newdir.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/paused.ico =================================================================== diff -u -N Binary files differ Index: ch/res/paused.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/question.ico =================================================================== diff -u -N Binary files differ Index: ch/res/question.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/report.ico =================================================================== diff -u -N Binary files differ Index: ch/res/report.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/shut.ico =================================================================== diff -u -N Binary files differ Index: ch/res/shut.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/small.ico =================================================================== diff -u -N Binary files differ Index: ch/res/small.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/tribe.ico =================================================================== diff -u -N Binary files differ Index: ch/res/tribe.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/waiting.ico =================================================================== diff -u -N Binary files differ Index: ch/res/waiting.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/warning.ico =================================================================== diff -u -N Binary files differ Index: ch/res/warning.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/res/working.ico =================================================================== diff -u -N Binary files differ Index: ch/res/working.ico =================================================================== diff -u -N -r6472716fec44f80b223922d89f269e365aeaba60 -r3493e9fc470285b0a0b417d50be281467a071eb7 Binary files differ Index: src/ch/resource.h =================================================================== diff -u -N --- src/ch/resource.h (revision 0) +++ src/ch/resource.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,641 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Copy Handler.rc +// +#define IDR_MANIFEST 1 +#define RT_TEXT 25 +#define IDD_ABOUTBOX 100 +#define IDR_MAINFRAME 128 +#define IDR_SYSTEMTYPE 129 +#define IDR_POPUP_MENU 130 +#define IDD_STATUS_DIALOG 131 +#define IDR_PRIORITY_MENU 135 +#define IDR_BUFFERSIZE_MENU 136 +#define IDD_BUFFERSIZE_DIALOG 137 +#define IDR_PAUSE_LIST_MENU 138 +#define IDI_ERROR_ICON 139 +#define IDI_WORKING_ICON 140 +#define IDI_PAUSED_ICON 141 +#define IDI_FINISHED_ICON 142 +#define IDI_CANCELLED_ICON 143 +#define IDD_OPTIONS_DIALOG 144 +#define IDD_MINIVIEW_DIALOG 145 +#define IDI_WAITING_ICON 146 +#define IDD_CUSTOM_COPY_DIALOG 149 +#define IDD_FOLDER_BROWSING_DIALOG 150 +#define IDD_NEW_FOLDER_DIALOG 151 +#define IDD_NEW_QUICK_ACCESS_DIALOG 152 +#define IDR_ADVANCED_MENU 160 +#define IDD_REPLACE_PATHS_DIALOG 161 +#define IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG 162 +#define IDI_QUESTION_ICON 163 +#define IDD_FEEDBACK_REPLACE_FILES_DIALOG 164 +#define IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG 165 +#define IDD_FEEDBACK_DSTFILE_DIALOG 167 +#define IDR_POPUP_TOOLBAR 170 +#define IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG 173 +#define IDI_INFO_ICON 175 +#define IDI_ERR_ICON 176 +#define IDI_WARNING_ICON 177 +#define IDD_SHUTDOWN_DIALOG 182 +#define IDI_SHUTDOWN_ICON 185 +#define IDI_NET_ICON 186 +#define IDI_HDD_ICON 188 +#define IDI_CD_ICON 189 +#define IDI_HDD2_ICON 190 +#define IDI_TRIBE_ICON 191 +#define IDI_FOLDER_ICON 192 +#define IDD_FILTER_DIALOG 195 +#define IDI_ADDSHORTCUT_ICON 198 +#define IDI_DELETESHORTCUT_ICON 199 +#define IDI_LARGEICONS_ICON 200 +#define IDI_LIST_ICON 201 +#define IDI_NEWFOLDER_ICON 202 +#define IDI_REPORT_ICON 203 +#define IDI_SMALLICONS_ICON 204 +#define IDD_SHORTCUTEDIT_DIALOG 208 +#define IDD_RECENTEDIT_DIALOG 209 +#define IDC_ABOUTBOX 210 +#define IDR_THANKS_TEXT 211 +#define IDC_PROGRAM_STATIC 1000 +#define IDC_ADDFILE_BUTTON 1002 +#define IDC_STATUS_LIST 1003 +#define IDC_REMOVEFILEFOLDER_BUTTON 1004 +#define IDC_ALL_PROGRESS 1005 +#define IDC_DESTPATH_EDIT 1006 +#define IDC_TASK_PROGRESS 1007 +#define IDC_DESTBROWSE_BUTTON 1008 +#define IDC_OPERATION_COMBO 1009 +#define IDC_FILTERS_LIST 1010 +#define IDC_ADDDIR_BUTTON 1011 +#define IDC_BUFFERSIZES_LIST 1012 +#define IDC_SET_BUFFERSIZE_BUTTON 1013 +#define IDC_FILTERS_CHECK 1014 +#define IDC_IGNOREFOLDERS_CHECK 1015 +#define IDC_SET_PRIORITY_BUTTON 1016 +#define IDC_ONLYSTRUCTURE_CHECK 1017 +#define IDC_PAUSE_BUTTON 1018 +#define IDC_STANDARD_CHECK 1019 +#define IDC_FORCEDIRECTORIES_CHECK 1020 +#define IDC_RESUME_BUTTON 1021 +#define IDC_CANCEL_BUTTON 1022 +#define IDC_ADVANCED_CHECK 1023 +#define IDC_BUFFERSIZES_BUTTON 1024 +#define IDC_ADDFILTER_BUTTON 1025 +#define IDC_REMOVEFILTER_BUTTON 1026 +#define IDC_SOURCE_STATIC 1027 +#define IDC_DESTINATION_STATIC 1028 +#define IDC_OPERATION_STATIC 1029 +#define IDC_BUFFERSIZE_STATIC 1030 +#define IDC_PRIORITY_STATIC 1031 +#define IDC_ERRORS_STATIC 1032 +#define IDC_PROGRESS_STATIC 1033 +#define IDC_TRANSFER_STATIC 1034 +#define IDC_OVERALL_PROGRESS_STATIC 1035 +#define IDC_OVERALL_TRANSFER_STATIC 1036 +#define IDC_TIME_STATIC 1037 +#define IDC_ROLL_UNROLL_BUTTON 1038 +#define IDC_SIZE_EDIT 1039 +#define IDC_ASSOCIATEDFILES__STATIC 1040 +#define IDC_START_ALL_BUTTON 1041 +#define IDC_RESTART_BUTTON 1042 +#define IDC_DELETE_BUTTON 1043 +#define IDC_PAUSE_ALL_BUTTON 1044 +#define IDC_RESTART_ALL_BUTTON 1045 +#define IDC_CANCEL_ALL_BUTTON 1046 +#define IDC_REMOVE_FINISHED_BUTTON 1047 +#define IDC_PROPERTIES_LIST 1048 +#define IDC_PROGRESS_LIST 1049 +#define IDC_SOURCE_EDIT 1050 +#define IDC_DESTINATION_EDIT 1051 +#define IDC_DIRECTORY_TREE 1053 +#define IDC_QUICK_ACCESS_LIST 1054 +#define IDC_PATH_EDIT 1055 +#define IDC_HEADER_TEXT_STATIC 1056 +#define IDC_FIND_PATH_BUTTON 1057 +#define IDC_NEW_FOLDER_BUTTON 1058 +#define IDC_PATH_STATIC 1059 +#define IDC_ADD_BUTTON 1060 +#define IDC_REMOVE_BUTTON 1061 +#define IDC_TITLE_EDIT 1062 +#define IDC_BROWSE_BUTTON 1064 +#define IDC_FILES_LIST 1065 +#define IDC_ADD_DIRECTORY_BUTTON 1066 +#define IDC_MASK_EDIT 1067 +#define IDC_OPERATION_TYPE_COMBO 1068 +#define IDC_ADD_FILES_BUTTON 1069 +#define IDC_BUFFERSIZE_EDIT 1070 +#define IDC_PRIORITY_COMBO 1071 +#define IDC_IGNORE_FOLDERS_CHECK 1073 +#define IDC_ONLY_CREATE_CHECK 1074 +#define IDC_ADVANCED_BUTTON 1077 +#define IDC_PATHS_LIST 1078 +#define IDC_FILENAME_EDIT 1088 +#define IDC_FILESIZE_EDIT 1089 +#define IDC_DESTFILENAME_EDIT 1090 +#define IDC_CREATETIME_EDIT 1091 +#define IDC_MODIFY_TIME_EDIT 1092 +#define IDC_DEST_FILENAME_EDIT 1093 +#define IDC_DEST_FILESIZE_EDIT 1094 +#define IDC_DEST_CREATETIME_EDIT 1095 +#define IDC_DEST_MODIFYTIME_EDIT 1096 +#define IDC_IGNORE_BUTTON 1097 +#define IDC_IGNORE_ALL_BUTTON 1098 +#define IDC_WAIT_BUTTON 1099 +#define IDC_RETRY_BUTTON 1100 +#define IDC_COPY_REST_BUTTON 1103 +#define IDC_RECOPY_BUTTON 1104 +#define IDC_COPY_REST_ALL_BUTTON 1106 +#define IDC_RECOPY_ALL_BUTTON 1107 +#define IDC_MESSAGE_EDIT 1112 +#define IDC_COUNT_EDIT 1119 +#define IDC_SHOW_LOG_BUTTON 1120 +#define IDC_STICK_BUTTON 1122 +#define IDC_FREESPACE_STATIC 1123 +#define IDC_DISK_STATIC 1124 +#define IDC_REQUIRED_STATIC 1127 +#define IDC_AVAILABLE_STATIC 1128 +#define IDC_TEST_BUTTON 1129 +#define IDC_SOURCEFILENAME_EDIT 1130 +#define IDC_YESALL_BUTTON 1131 +#define IDC_NOALL_BUTTON 1132 +#define IDC_DEFAULTMULTIPLIER_COMBO 1133 +#define IDC_DEFAULTSIZE_EDIT 1134 +#define IDC_ONEDISKSIZE_EDIT 1135 +#define IDC_CHANGEBUFFER_BUTTON 1137 +#define IDC_ONEDISKMULTIPLIER_COMBO 1138 +#define IDC_TWODISKSSIZE_EDIT 1139 +#define IDC_TWODISKSMULTIPLIER_COMBO 1140 +#define IDC_CDROMSIZE_EDIT 1141 +#define IDC_CDROMMULTIPLIER_COMBO 1142 +#define IDC_LANSIZE_EDIT 1143 +#define IDC_LANMULTIPLIER_COMBO 1144 +#define IDC_ONLYDEFAULT_CHECK 1145 +#define IDC_TIME_PROGRESS 1146 +#define IDC_ERRORS_EDIT 1147 +#define IDC_FILTER_COMBO 1149 +#define IDC_FILTER_CHECK 1150 +#define IDC_SIZE_CHECK 1151 +#define IDC_SIZE1_EDIT 1152 +#define IDC_SIZE1MULTI_COMBO 1153 +#define IDC_SIZETYPE1_COMBO 1154 +#define IDC_SIZE1_SPIN 1155 +#define IDC_SIZE2_EDIT 1156 +#define IDC_SIZE2MULTI_COMBO 1157 +#define IDC_SIZETYPE2_COMBO 1158 +#define IDC_SIZE2_SPIN 1159 +#define IDC_SIZE2_CHECK 1160 +#define IDC_DATE_CHECK 1161 +#define IDC_ATTRIBUTES_CHECK 1162 +#define IDC_ARCHIVE_CHECK 1163 +#define IDC_READONLY_CHECK 1164 +#define IDC_HIDDEN_CHECK 1165 +#define IDC_SYSTEM_CHECK 1166 +#define IDC_DATETYPE_COMBO 1167 +#define IDC_DATE1TYPE_COMBO 1168 +#define IDC_DATE1_DATETIMEPICKER 1169 +#define IDC_TIME1_DATETIMEPICKER 1170 +#define IDC_DATE2_CHECK 1171 +#define IDC_DATE2TYPE_COMBO 1172 +#define IDC_DATE2_DATETIMEPICKER 1173 +#define IDC_TIME2_DATETIMEPICKER 1174 +#define IDC_DIRECTORY_CHECK 1175 +#define IDC_FILTEREXCLUDE_COMBO 1176 +#define IDC_EXCLUDEMASK_CHECK 1177 +#define IDC_COUNT_SPIN 1178 +#define IDC_DESTPATH_COMBOBOXEX 1179 +#define IDC_SHORTCUT_LIST 1180 +#define IDC_NAME_EDIT 1181 +#define IDC_PATH_COMBOBOXEX 1182 +#define IDC_CHANGE_BUTTON 1185 +#define IDC_RECENT_LIST 1190 +#define IDC_IMPORT_BUTTON 1191 +#define IDC_UP_BUTTON 1192 +#define IDC_DOWN_BUTTON 1193 +#define IDC_THANX_EDIT 1198 +#define IDC_COPYRIGHT_STATIC 1199 +#define IDC_FOLDER_TREE 1200 +#define IDC_DISTRIBUTION_STATIC 1200 +#define IDC_NEWFOLDER_BUTTON 1201 +#define IDC_HOMEPAGE_STATIC 1201 +#define IDC_TITLE_STATIC 1202 +#define IDC_HOMEPAGELINK_STATIC 1202 +#define IDC_LARGEICONS_BUTTON 1203 +#define IDC_CONTACT_STATIC 1203 +#define IDC_HOMEPAGELINK2_STATIC 1203 +#define IDC_SMALLICONS_BUTTON 1204 +#define IDC_GENFORUM_STATIC 1204 +#define IDC_LIST_BUTTON 1205 +#define IDC_DEVFORUM_STATIC 1205 +#define IDC_REPORT_BUTTON 1206 +#define IDC_CONTACT1LINK_STATIC 1206 +#define IDC_CONTACT2LINK_STATIC 1207 +#define IDC_GENFORUMPAGELINK_STATIC 1208 +#define IDC_TOGGLE_BUTTON 1209 +#define IDC_GENFORUMSUBSCRIBELINK_STATIC 1209 +#define IDC_ADDSHORTCUT_BUTTON 1210 +#define IDC_GENFORUMUNSUBSCRIBELINK_STATIC 1210 +#define IDC_REMOVESHORTCUT_BUTTON 1211 +#define IDC_GENFORUMSENDLINK_STATIC 1211 +#define IDC_DEVFORUMPAGELINK_STATIC 1212 +#define IDC_DEVFORUMSUBSCRIBELINK_STATIC 1213 +#define IDC_DEVFORUMUNSUBSCRIBELINK_STATIC 1214 +#define IDC_DEVFORUMSENDLINK_STATIC 1215 +#define IDC_THANX_STATIC 1216 +#define IDC_UPX_STATIC 1217 +#define IDC_CONTACT3LINK_STATIC 1217 +#define IDC_APPLY_BUTTON 1218 +#define IDC_001_STATIC 1219 +#define IDC_002_STATIC 1220 +#define IDC_003_STATIC 1221 +#define IDC_004_STATIC 1222 +#define IDC_005_STATIC 1223 +#define IDC_006_STATIC 1224 +#define IDC_007_STATIC 1225 +#define IDC_008_STATIC 1226 +#define IDC_009_STATIC 1227 +#define IDC_010_STATIC 1228 +#define IDC_011_STATIC 1229 +#define IDC_012_STATIC 1230 +#define IDC_013_STATIC 1231 +#define IDC_014_STATIC 1232 +#define IDC_015_STATIC 1233 +#define IDC_016_STATIC 1234 +#define IDC_017_STATIC 1235 +#define IDC_018_STATIC 1236 +#define IDC_019_STATIC 1237 +#define IDC_020_STATIC 1238 +#define IDC_021_STATIC 1239 +#define IDC_022_STATIC 1240 +#define IDC_023_STATIC 1241 +#define IDC_024_STATIC 1242 +#define IDC_025_STATIC 1243 +#define IDC_026_STATIC 1244 +#define IDC_027_STATIC 1245 +#define IDC_028_STATIC 1246 +#define IDC_029_STATIC 1247 +#define IDC_030_STATIC 1248 +#define IDC_BAR1_STATIC 1249 +#define IDC_BAR2_STATIC 1250 +#define IDC_BAR3_STATIC 1251 +#define IDC_BAR4_STATIC 1252 +#define IDC_BAR5_STATIC 1253 +#define IDC_HEADER_STATIC 1254 +#define IDC_HOSTLINK_STATIC 1255 +#define IDC_HELP_BUTTON 1257 +#define IDC_PROGRAM_STATICEX 1263 +#define IDC_FULLVERSION_STATICEX 1264 +#define IDC_HOMEPAGE_STATICEX 1265 +#define IDC_CONTACT_STATICEX 1266 +#define IDC_LICENSE_STATICEX 1267 +#define IDC_CONTACTAUTHOR_STATICEX 1268 +#define IDC_CONTACTSUPPORT_STATICEX 1269 +#define IDS_APPNAME_STRING 5000 +#define IDS_PRIORITY0_STRING 5001 +#define IDS_PRIORITY1_STRING 5002 +#define IDS_PRIORITY2_STRING 5003 +#define IDS_PRIORITY3_STRING 5004 +#define IDS_PRIORITY4_STRING 5005 +#define IDS_PRIORITY5_STRING 5006 +#define IDS_PRIORITY6_STRING 5007 +#define IDS_FIRSTCOPY_STRING 5008 +#define IDS_NEXTCOPY_STRING 5009 +#define IDS_NOTFOUND_STRING 5010 +#define IDS_BYTE_STRING 5011 +#define IDS_KBYTE_STRING 5012 +#define IDS_MBYTE_STRING 5013 +#define IDS_GBYTE_STRING 5014 +#define IDS_TBYTE_STRING 5015 +#define IDS_PBYTE_STRING 5016 +#define IDS_LT_STRING 5017 +#define IDS_LE_STRING 5018 +#define IDS_EQ_STRING 5019 +#define IDS_GE_STRING 5020 +#define IDS_GT_STRING 5021 +#define IDS_ONECOPY_STRING 6000 +#define IDS_REGISTEROK_STRING 6001 +#define IDS_REGISTERERR_STRING 6002 +#define IDS_UNREGISTEROK_STRING 6003 +#define IDS_UNREGISTERERR_STRING 6004 +#define IDS_HELPERR_STRING 6005 +#define IDS_OTFSEARCHINGFORFILES_STRING 7000 +#define IDS_OTFMISSINGCLIPBOARDINPUT_STRING 7001 +#define IDS_OTFADDINGCLIPBOARDFILE_STRING 7002 +#define IDS_OTFADDEDFOLDER_STRING 7003 +#define IDS_OTFRECURSINGFOLDER_STRING 7004 +#define IDS_OTFADDINGKILLREQEST_STRING 7005 +#define IDS_OTFADDEDFILE_STRING 7006 +#define IDS_OTFSEARCHINGFINISHED_STRING 7007 +#define IDS_OTFDELETINGFILES_STRING 7008 +#define IDS_OTFDELETINGKILLREQUEST_STRING 7009 +#define IDS_OTFDELETINGERROR_STRING 7010 +#define IDS_OTFDELETINGFINISHED_STRING 7011 +#define IDS_OTFPRECHECKCANCELREQUEST_STRING 7012 +#define IDS_OTFOPENINGERROR_STRING 7013 +#define IDS_OTFOPENINGCANCELREQUEST_STRING 7014 +#define IDS_OTFOPENINGWAITREQUEST_STRING 7015 +#define IDS_OTFOPENINGRETRY_STRING 7016 +#define IDS_OTFDESTOPENINGERROR_STRING 7017 +#define IDS_OTFDESTOPENINGRETRY_STRING 7018 +#define IDS_OTFDESTOPENINGCANCELREQUEST_STRING 7019 +#define IDS_OTFDESTOPENINGWAITREQUEST_STRING 7020 +#define IDS_OTFMOVINGPOINTERSERROR_STRING 7021 +#define IDS_OTFRESTORINGPOINTERSERROR_STRING 7022 +#define IDS_OTFSETTINGZEROSIZEERROR_STRING 7023 +#define IDS_OTFCOPYINGKILLREQUEST_STRING 7024 +#define IDS_OTFCHANGINGBUFFERSIZE_STRING 7025 +#define IDS_OTFREADINGERROR_STRING 7026 +#define IDS_OTFWRITINGERROR_STRING 7027 +#define IDS_OTFCAUGHTEXCEPTIONCCF_STRING 7028 +#define IDS_OTFPROCESSINGFILES_STRING 7029 +#define IDS_OTFPROCESSINGFILESDATA_STRING 7030 +#define IDS_OTFPROCESSINGKILLREQUEST_STRING 7031 +#define IDS_OTFMOVEFILEERROR_STRING 7032 +#define IDS_OTFCREATEDIRECTORYERROR_STRING 7033 +#define IDS_OTFPROCESSINGFINISHED_STRING 7034 +#define IDS_OTFTHREADSTART_STRING 7035 +#define IDS_OTFWAITINGFINISHED_STRING 7036 +#define IDS_OTFWAITINGKILLREQUEST_STRING 7037 +#define IDS_OTFTHREADFINISHED_STRING 7038 +#define IDS_OTFCAUGHTEXCEPTIONMAIN_STRING 7039 +#define IDS_OTFCHECKINGSPACE_STRING 7040 +#define IDS_OTFNOTENOUGHFREESPACE_STRING 7041 +#define IDS_OTFFREESPACECANCELREQUEST_STRING 7042 +#define IDS_OTFFREESPACERETRYING_STRING 7043 +#define IDS_OTFFREESPACEIGNORE_STRING 7044 +#define IDS_OTFSHRINKERROR_STRING 7045 +#define IDS_OTFEXTMOVEFILEERROR_STRING 7046 +#define IDS_OTFMOVEFILECANCELREQUEST_STRING 7047 +#define IDS_PROGRAM_STRING 8000 +#define IDS_CLIPBOARDMONITORING_STRING 8001 +#define IDS_CLIPBOARDINTERVAL_STRING 8002 +#define IDS_AUTORUNPROGRAM_STRING 8003 +#define IDS_AUTOSHUTDOWN_STRING 8004 +#define IDS_AUTOSAVEINTERVAL_STRING 8005 +#define IDS_TEMPFOLDER_STRING 8006 +#define IDS_STATUSWINDOW_STRING 8007 +#define IDS_REFRESHSTATUSINTERVAL_STRING 8008 +#define IDS_STATUSSHOWDETAILS_STRING 8009 +#define IDS_STATUSAUTOREMOVE_STRING 8010 +#define IDS_MINIVIEW_STRING 8011 +#define IDS_SHOWFILENAMES_STRING 8012 +#define IDS_SHOWSINGLETASKS_STRING 8013 +#define IDS_MINIVIEWREFRESHINTERVAL_STRING 8014 +#define IDS_MINIVIEWSHOWAFTERSTART_STRING 8015 +#define IDS_MINIVIEWAUTOHIDE_STRING 8016 +#define IDS_PROCESSINGTHREAD_STRING 8017 +#define IDS_AUTOCOPYREST_STRING 8018 +#define IDS_SETDESTATTRIB_STRING 8019 +#define IDS_SETDESTTIME_STRING 8020 +#define IDS_PROTECTROFILES_STRING 8021 +#define IDS_LIMITOPERATIONS_STRING 8022 +#define IDS_SHOWVISUALFEEDBACK_STRING 8023 +#define IDS_USETIMEDDIALOGS_STRING 8024 +#define IDS_TIMEDDIALOGINTERVAL_STRING 8025 +#define IDS_AUTORETRYONERROR_STRING 8026 +#define IDS_AUTORETRYINTERVAL_STRING 8027 +#define IDS_DEFAULTPRIORITY_STRING 8028 +#define IDS_AUTODETECTBUFFERSIZE_STRING 8029 +#define IDS_DEFAULTBUFFERSIZE_STRING 8030 +#define IDS_DELETEAFTERFINISHED_STRING 8031 +#define IDS_CREATELOGFILES_STRING 8032 +#define IDS_SOUNDS_STRING 8033 +#define IDS_PLAYSOUNDS_STRING 8034 +#define IDS_SOUNDONERROR_STRING 8035 +#define IDS_SOUNDONFINISH_STRING 8036 +#define IDS_LANGUAGE_STRING 8037 +#define IDS_READSIZEBEFOREBLOCK_STRING 8038 +#define IDS_USENOBUFFERING_STRING 8039 +#define IDS_LARGEFILESMINSIZE_STRING 8040 +#define IDS_OPTIONSBUFFER_STRING 8041 +#define IDS_ONEDISKBUFFERSIZE_STRING 8042 +#define IDS_TWODISKSBUFFERSIZE_STRING 8043 +#define IDS_CDBUFFERSIZE_STRING 8044 +#define IDS_LANBUFFERSIZE_STRING 8045 +#define IDS_SHUTDOWNTIME_STRING 8046 +#define IDS_FORCESHUTDOWN_STRING 8047 +#define IDS_MINIVIEWSMOOTHPROGRESS_STRING 8048 +#define IDS_CFGFOLDERDIALOG_STRING 8049 +#define IDS_CFGFDEXTVIEW_STRING 8050 +#define IDS_CFGFDWIDTH_STRING 8051 +#define IDS_CFGFDHEIGHT_STRING 8052 +#define IDS_CFGFDSHORTCUTS_STRING 8053 +#define IDS_CFGFDIGNOREDIALOGS_STRING 8054 +#define IDS_CFGSHCOPY_STRING 8055 +#define IDS_CFGSHMOVE_STRING 8056 +#define IDS_CFGSHCMSPECIAL_STRING 8057 +#define IDS_CFGSHPASTE_STRING 8058 +#define IDS_CFGSHPASTESPECIAL_STRING 8059 +#define IDS_CFGSHCOPYTO_STRING 8060 +#define IDS_CFGSHMOVETO_STRING 8061 +#define IDS_CFGSHCMTOSPECIAL_STRING 8062 +#define IDS_CFGSHSHOWFREESPACE_STRING 8063 +#define IDS_CFGSHSHOWICONS_STRING 8064 +#define IDS_CFGSHOVERRIDEDRAG_STRING 8065 +#define IDS_CFGSHORTCUTS_STRING 8066 +#define IDS_CFGRECENT_STRING 8067 +#define IDS_CFGSHELL_STRING 8068 +#define IDS_CFGSCCOUNT_STRING 8069 +#define IDS_CFGRPCOUNT_STRING 8070 +#define IDS_CFGOVERRIDEDEFACTION_STRING 8071 +#define IDS_CFGPRIORITYCLASS_STRING 8072 +#define IDS_CFGDISABLEPRIORITYBOOST_STRING 8073 +#define IDS_BOOLTEXT_STRING 8074 +#define IDS_TEMPFOLDERCHOOSE_STRING 8075 +#define IDS_FEEDBACKTYPE_STRING 8076 +#define IDS_SOUNDSWAVFILTER_STRING 8077 +#define IDS_LANGUAGELIST_STRING 8078 +#define IDS_FORCESHUTDOWNVALUES_STRING 8079 +#define IDS_CFGFDSHORTCUTSSTYLES_STRING 8080 +#define IDS_CFGPRIORITYCLASSITEMS_STRING 8081 +#define IDS_CFGACTIONS_STRING 8082 +#define IDS_PLUGSFOLDER_STRING 8083 +#define IDS_PLUGSFOLDERCHOOSE_STRING 8084 +#define IDS_CFGLOGFILE_STRING 8085 +#define IDS_CFGENABLELOGGING_STRING 8086 +#define IDS_CFGLIMITATION_STRING 8087 +#define IDS_CFGMAXLIMIT_STRING 8088 +#define IDS_CFGLOGPRECISELIMITING_STRING 8089 +#define IDS_CFGTRUNCBUFFERSIZE_STRING 8090 +#define IDS_CFGHELPDIR_STRING 8091 +#define IDS_CFGHELPDIRCHOOSE_STRING 8092 +#define IDS_LANGUAGESFOLDER_STRING 8093 +#define IDS_LANGSFOLDERCHOOSE_STRING 8094 +#define IDS_MENUCOPY_STRING 9000 +#define IDS_MENUMOVE_STRING 9001 +#define IDS_MENUCOPYMOVESPECIAL_STRING 9002 +#define IDS_MENUPASTE_STRING 9003 +#define IDS_MENUPASTESPECIAL_STRING 9004 +#define IDS_MENUCOPYTO_STRING 9005 +#define IDS_MENUMOVETO_STRING 9006 +#define IDS_MENUCOPYMOVETOSPECIAL_STRING 9007 +#define IDS_MENUTIPCOPY_STRING 9008 +#define IDS_MENUTIPMOVE_STRING 9009 +#define IDS_MENUTIPCOPYMOVESPECIAL_STRING 9010 +#define IDS_MENUTIPPASTE_STRING 9011 +#define IDS_MENUTIPPASTESPECIAL_STRING 9012 +#define IDS_MENUTIPCOPYTO_STRING 9013 +#define IDS_MENUTIPMOVETO_STRING 9014 +#define IDS_MENUTIPCOPYMOVETOSPECIAL_STRING 9015 +#define IDS_BROWSE_STRING 13000 +#define IDS_BDREMOTENAME_STRING 13001 +#define IDS_BDLOCALNAME_STRING 13002 +#define IDS_BDTYPE_STRING 13003 +#define IDS_BDNETTYPE_STRING 13004 +#define IDS_BDDESCRIPTION_STRING 13005 +#define IDS_BDFREESPACE_STRING 13006 +#define IDS_BDCAPACITY_STRING 13007 +#define IDS_BDOK_STRING 13008 +#define IDS_BDCANCEL_STRING 13009 +#define IDS_BDCANNOTCREATEFOLDER_STRING 13010 +#define IDS_BDPATHDOESNTEXIST_STRING 13011 +#define IDS_BDNAME_STRING 13012 +#define IDS_BDPATH_STRING 13013 +#define IDS_BDPATH2_STRING 13014 +#define IDS_BDRIGHT_STRING 13015 +#define IDS_BDLEFT_STRING 13016 +#define IDS_BDNOSHORTCUTPATH_STRING 13017 +#define IDS_BDNEWFOLDER_STRING 13018 +#define IDS_BDLARGEICONS_STRING 13019 +#define IDS_BDSMALLICONS_STRING 13020 +#define IDS_BDLIST_STRING 13021 +#define IDS_BDREPORT_STRING 13022 +#define IDS_BDDETAILS_STRING 13023 +#define IDS_BDADDSHORTCUT_STRING 13024 +#define IDS_BDREMOVESHORTCUT_STRING 13025 +#define IDS_BDDOMAIN_STRING 13026 +#define IDS_BDSERVER_STRING 13027 +#define IDS_BDSHARE_STRING 13028 +#define IDS_BDFILE_STRING 13029 +#define IDS_BDGROUP_STRING 13030 +#define IDS_BDNETWORK_STRING 13031 +#define IDS_BDROOT_STRING 13032 +#define IDS_BDADMINSHARE_STRING 13033 +#define IDS_BDDIR_STRING 13034 +#define IDS_BDTREE_STRING 13035 +#define IDS_BDNDSCONTAINER_STRING 13036 +#define IDS_TITLECOPY_STRING 13500 +#define IDS_TITLEMOVE_STRING 13501 +#define IDS_TITLEUNKNOWNOPERATION_STRING 13502 +#define IDS_MAINBROWSETEXT_STRING 13503 +#define IDS_ABTNOTHANX_STRING 14000 +#define IDS_ABOUTVERSION_STRING 14001 +#define IDS_LANGCODE_STRING 14002 +#define IDS_LANGVER_STRING 14003 +#define IDS_BUFFERSIZEZERO_STRING 14500 +#define IDS_FILEDLGALLFILTER_STRING 15000 +#define IDS_DSTFOLDERBROWSE_STRING 15001 +#define IDS_MISSINGDATA_STRING 15002 +#define IDS_CCDCOPY_STRING 15003 +#define IDS_CCDMOVE_STRING 15004 +#define IDS_BSEDEFAULT_STRING 15005 +#define IDS_BSEONEDISK_STRING 15006 +#define IDS_BSETWODISKS_STRING 15007 +#define IDS_BSECD_STRING 15008 +#define IDS_BSELAN_STRING 15009 +#define IDS_HDRMASK_STRING 15010 +#define IDS_HDRSIZE_STRING 15011 +#define IDS_HDRDATE_STRING 15012 +#define IDS_HDRATTRIB_STRING 15013 +#define IDS_AND_STRING 15014 +#define IDS_FILTERMASKEMPTY_STRING 15015 +#define IDS_FILTERSIZE_STRING 15016 +#define IDS_FILTERDATE_STRING 15017 +#define IDS_HDREXCLUDEMASK_STRING 15018 +#define IDS_HDREXCLUDEATTRIB_STRING 15019 +#define IDS_FILTERATTRIB_STRING 15020 +#define IDS_EMPTYFILTER_STRING 15021 +#define IDS_FLTALLFILTER_STRING 15022 +#define IDS_IMPORTREPORT_STRING 15023 +#define IDS_NERPATH_STRING 16500 +#define IDS_DATECREATED_STRING 18000 +#define IDS_DATELASTWRITE_STRING 18001 +#define IDS_DATEACCESSED_STRING 18002 +#define IDS_MINIVIEWALL_STRING 18500 +#define IDS_SOURCESTRINGMISSING_STRING 20000 +#define IDS_SHORTCUTNAME_STRING 20500 +#define IDS_SHORTCUTPATH_STRING 20501 +#define IDS_SHUTDOWNERROR_STRING 21000 +#define IDS_COLUMNSTATUS_STRING 21500 +#define IDS_COLUMNSOURCE_STRING 21501 +#define IDS_COLUMNDESTINATION_STRING 21502 +#define IDS_COLUMNPROGRESS_STRING 21503 +#define IDS_EMPTYOPERATIONTEXT_STRING 21504 +#define IDS_EMPTYSOURCETEXT_STRING 21505 +#define IDS_EMPTYDESTINATIONTEXT_STRING 21506 +#define IDS_EMPTYBUFFERSIZETEXT_STRING 21507 +#define IDS_EMPTYPRIORITYTEXT_STRING 21508 +#define IDS_EMPTYERRORTEXT_STRING 21509 +#define IDS_EMPTYPROCESSEDTEXT_STRING 21510 +#define IDS_EMPTYTRANSFERTEXT_STRING 21511 +#define IDS_EMPTYTIMETEXT_STRING 21512 +#define IDS_CURRENTPASS_STRING 21513 +#define IDS_AVERAGEWORD_STRING 21514 +#define IDS_STATUSTITLE_STRING 21515 +#define IDS_REPLACEPATHSTEXT_STRING 21516 +#define IDS_TASKNOTPAUSED_STRING 21517 +#define IDS_TASKNOTSELECTED_STRING 21518 +#define IDS_NONEINPUTFILE_STRING 21519 +#define IDS_COPYWORDLESSFIVE_STRING 21520 +#define IDS_COPYWORDMOREFOUR_STRING 21521 +#define IDS_STATUS0_STRING 21522 +#define IDS_STATUS1_STRING 21523 +#define IDS_STATUS2_STRING 21524 +#define IDS_STATUS3_STRING 21525 +#define IDS_STATUS4_STRING 21526 +#define IDS_STATUS5_STRING 21527 +#define IDS_STATUS6_STRING 21528 +#define IDS_STATUS7_STRING 21529 +#define IDS_STATUS8_STRING 21530 +#define IDS_STATUS9_STRING 21531 +#define IDS_STATUS10_STRING 21532 +#define IDS_STATUS11_STRING 21533 +#define IDS_SHELLEXECUTEERROR_STRING 21534 +#define IDS_BSDEFAULT_STRING 21535 +#define IDS_BSONEDISK_STRING 21536 +#define IDS_BSTWODISKS_STRING 21537 +#define IDS_BSCD_STRING 21538 +#define IDS_BSLAN_STRING 21539 +#define IDS_CPEDELETINGERROR_STRING 21540 +#define IDS_CPEOPENINGERROR_STRING 21541 +#define IDS_CPEDESTOPENINGERROR_STRING 21542 +#define IDS_CPERESTORINGPOINTERSERROR_STRING 21543 +#define IDS_CPESETTINGZEROSIZEERROR_STRING 21544 +#define IDS_CPEREADINGERROR_STRING 21545 +#define IDS_CPEWRITINGERROR_STRING 21546 +#define IDS_CPEMOVEFILEERROR_STRING 21547 +#define IDS_CPECREATEDIRECTORYERROR_STRING 21548 +#define IDS_EMPTYASSOCFILE_STRING 21549 +#define IDS_FILTERING_STRING 21550 +#define IDS_CONFIRMCANCEL_STRING 21551 +#define ID_POPUP_SHOW_STATUS 32773 +#define ID_POPUP_TIME_CRITICAL 32774 +#define ID_POPUP_HIGHEST 32775 +#define ID_POPUP_ABOVE_NORMAL 32776 +#define ID_POPUP_NORMAL 32777 +#define ID_POPUP_BELOW_NORMAL 32778 +#define ID_POPUP_LOWEST 32779 +#define ID_POPUP_IDLE 32780 +#define ID_POPUP_CUSTOM_BUFFERSIZE 32793 +#define ID_POPUP_OPTIONS 32802 +#define ID_SHOW_MINI_VIEW 32803 +#define ID_POPUP_CUSTOM_COPY 32804 +#define ID_POPUP_REPLACE_PATHS 32805 +#define ID_POPUP_MONITORING 32806 +#define ID_POPUP_SHUTAFTERFINISHED 32807 +#define ID_POPUP_REGISTERDLL 32809 +#define ID_POPUP_UNREGISTERDLL 32810 +#define ID_POPUP_HELP 32814 +#define ID_POPUP_TEMP 32815 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 212 +#define _APS_NEXT_COMMAND_VALUE 32816 +#define _APS_NEXT_CONTROL_VALUE 1268 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif Index: ch/resource.h =================================================================== diff -u -N --- ch/resource.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/resource.h (revision 0) @@ -1,641 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Copy Handler.rc -// -#define IDR_MANIFEST 1 -#define RT_TEXT 25 -#define IDD_ABOUTBOX 100 -#define IDR_MAINFRAME 128 -#define IDR_SYSTEMTYPE 129 -#define IDR_POPUP_MENU 130 -#define IDD_STATUS_DIALOG 131 -#define IDR_PRIORITY_MENU 135 -#define IDR_BUFFERSIZE_MENU 136 -#define IDD_BUFFERSIZE_DIALOG 137 -#define IDR_PAUSE_LIST_MENU 138 -#define IDI_ERROR_ICON 139 -#define IDI_WORKING_ICON 140 -#define IDI_PAUSED_ICON 141 -#define IDI_FINISHED_ICON 142 -#define IDI_CANCELLED_ICON 143 -#define IDD_OPTIONS_DIALOG 144 -#define IDD_MINIVIEW_DIALOG 145 -#define IDI_WAITING_ICON 146 -#define IDD_CUSTOM_COPY_DIALOG 149 -#define IDD_FOLDER_BROWSING_DIALOG 150 -#define IDD_NEW_FOLDER_DIALOG 151 -#define IDD_NEW_QUICK_ACCESS_DIALOG 152 -#define IDR_ADVANCED_MENU 160 -#define IDD_REPLACE_PATHS_DIALOG 161 -#define IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG 162 -#define IDI_QUESTION_ICON 163 -#define IDD_FEEDBACK_REPLACE_FILES_DIALOG 164 -#define IDD_FEEDBACK_SMALL_REPLACE_FILES_DIALOG 165 -#define IDD_FEEDBACK_DSTFILE_DIALOG 167 -#define IDR_POPUP_TOOLBAR 170 -#define IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG 173 -#define IDI_INFO_ICON 175 -#define IDI_ERR_ICON 176 -#define IDI_WARNING_ICON 177 -#define IDD_SHUTDOWN_DIALOG 182 -#define IDI_SHUTDOWN_ICON 185 -#define IDI_NET_ICON 186 -#define IDI_HDD_ICON 188 -#define IDI_CD_ICON 189 -#define IDI_HDD2_ICON 190 -#define IDI_TRIBE_ICON 191 -#define IDI_FOLDER_ICON 192 -#define IDD_FILTER_DIALOG 195 -#define IDI_ADDSHORTCUT_ICON 198 -#define IDI_DELETESHORTCUT_ICON 199 -#define IDI_LARGEICONS_ICON 200 -#define IDI_LIST_ICON 201 -#define IDI_NEWFOLDER_ICON 202 -#define IDI_REPORT_ICON 203 -#define IDI_SMALLICONS_ICON 204 -#define IDD_SHORTCUTEDIT_DIALOG 208 -#define IDD_RECENTEDIT_DIALOG 209 -#define IDC_ABOUTBOX 210 -#define IDR_THANKS_TEXT 211 -#define IDC_PROGRAM_STATIC 1000 -#define IDC_ADDFILE_BUTTON 1002 -#define IDC_STATUS_LIST 1003 -#define IDC_REMOVEFILEFOLDER_BUTTON 1004 -#define IDC_ALL_PROGRESS 1005 -#define IDC_DESTPATH_EDIT 1006 -#define IDC_TASK_PROGRESS 1007 -#define IDC_DESTBROWSE_BUTTON 1008 -#define IDC_OPERATION_COMBO 1009 -#define IDC_FILTERS_LIST 1010 -#define IDC_ADDDIR_BUTTON 1011 -#define IDC_BUFFERSIZES_LIST 1012 -#define IDC_SET_BUFFERSIZE_BUTTON 1013 -#define IDC_FILTERS_CHECK 1014 -#define IDC_IGNOREFOLDERS_CHECK 1015 -#define IDC_SET_PRIORITY_BUTTON 1016 -#define IDC_ONLYSTRUCTURE_CHECK 1017 -#define IDC_PAUSE_BUTTON 1018 -#define IDC_STANDARD_CHECK 1019 -#define IDC_FORCEDIRECTORIES_CHECK 1020 -#define IDC_RESUME_BUTTON 1021 -#define IDC_CANCEL_BUTTON 1022 -#define IDC_ADVANCED_CHECK 1023 -#define IDC_BUFFERSIZES_BUTTON 1024 -#define IDC_ADDFILTER_BUTTON 1025 -#define IDC_REMOVEFILTER_BUTTON 1026 -#define IDC_SOURCE_STATIC 1027 -#define IDC_DESTINATION_STATIC 1028 -#define IDC_OPERATION_STATIC 1029 -#define IDC_BUFFERSIZE_STATIC 1030 -#define IDC_PRIORITY_STATIC 1031 -#define IDC_ERRORS_STATIC 1032 -#define IDC_PROGRESS_STATIC 1033 -#define IDC_TRANSFER_STATIC 1034 -#define IDC_OVERALL_PROGRESS_STATIC 1035 -#define IDC_OVERALL_TRANSFER_STATIC 1036 -#define IDC_TIME_STATIC 1037 -#define IDC_ROLL_UNROLL_BUTTON 1038 -#define IDC_SIZE_EDIT 1039 -#define IDC_ASSOCIATEDFILES__STATIC 1040 -#define IDC_START_ALL_BUTTON 1041 -#define IDC_RESTART_BUTTON 1042 -#define IDC_DELETE_BUTTON 1043 -#define IDC_PAUSE_ALL_BUTTON 1044 -#define IDC_RESTART_ALL_BUTTON 1045 -#define IDC_CANCEL_ALL_BUTTON 1046 -#define IDC_REMOVE_FINISHED_BUTTON 1047 -#define IDC_PROPERTIES_LIST 1048 -#define IDC_PROGRESS_LIST 1049 -#define IDC_SOURCE_EDIT 1050 -#define IDC_DESTINATION_EDIT 1051 -#define IDC_DIRECTORY_TREE 1053 -#define IDC_QUICK_ACCESS_LIST 1054 -#define IDC_PATH_EDIT 1055 -#define IDC_HEADER_TEXT_STATIC 1056 -#define IDC_FIND_PATH_BUTTON 1057 -#define IDC_NEW_FOLDER_BUTTON 1058 -#define IDC_PATH_STATIC 1059 -#define IDC_ADD_BUTTON 1060 -#define IDC_REMOVE_BUTTON 1061 -#define IDC_TITLE_EDIT 1062 -#define IDC_BROWSE_BUTTON 1064 -#define IDC_FILES_LIST 1065 -#define IDC_ADD_DIRECTORY_BUTTON 1066 -#define IDC_MASK_EDIT 1067 -#define IDC_OPERATION_TYPE_COMBO 1068 -#define IDC_ADD_FILES_BUTTON 1069 -#define IDC_BUFFERSIZE_EDIT 1070 -#define IDC_PRIORITY_COMBO 1071 -#define IDC_IGNORE_FOLDERS_CHECK 1073 -#define IDC_ONLY_CREATE_CHECK 1074 -#define IDC_ADVANCED_BUTTON 1077 -#define IDC_PATHS_LIST 1078 -#define IDC_FILENAME_EDIT 1088 -#define IDC_FILESIZE_EDIT 1089 -#define IDC_DESTFILENAME_EDIT 1090 -#define IDC_CREATETIME_EDIT 1091 -#define IDC_MODIFY_TIME_EDIT 1092 -#define IDC_DEST_FILENAME_EDIT 1093 -#define IDC_DEST_FILESIZE_EDIT 1094 -#define IDC_DEST_CREATETIME_EDIT 1095 -#define IDC_DEST_MODIFYTIME_EDIT 1096 -#define IDC_IGNORE_BUTTON 1097 -#define IDC_IGNORE_ALL_BUTTON 1098 -#define IDC_WAIT_BUTTON 1099 -#define IDC_RETRY_BUTTON 1100 -#define IDC_COPY_REST_BUTTON 1103 -#define IDC_RECOPY_BUTTON 1104 -#define IDC_COPY_REST_ALL_BUTTON 1106 -#define IDC_RECOPY_ALL_BUTTON 1107 -#define IDC_MESSAGE_EDIT 1112 -#define IDC_COUNT_EDIT 1119 -#define IDC_SHOW_LOG_BUTTON 1120 -#define IDC_STICK_BUTTON 1122 -#define IDC_FREESPACE_STATIC 1123 -#define IDC_DISK_STATIC 1124 -#define IDC_REQUIRED_STATIC 1127 -#define IDC_AVAILABLE_STATIC 1128 -#define IDC_TEST_BUTTON 1129 -#define IDC_SOURCEFILENAME_EDIT 1130 -#define IDC_YESALL_BUTTON 1131 -#define IDC_NOALL_BUTTON 1132 -#define IDC_DEFAULTMULTIPLIER_COMBO 1133 -#define IDC_DEFAULTSIZE_EDIT 1134 -#define IDC_ONEDISKSIZE_EDIT 1135 -#define IDC_CHANGEBUFFER_BUTTON 1137 -#define IDC_ONEDISKMULTIPLIER_COMBO 1138 -#define IDC_TWODISKSSIZE_EDIT 1139 -#define IDC_TWODISKSMULTIPLIER_COMBO 1140 -#define IDC_CDROMSIZE_EDIT 1141 -#define IDC_CDROMMULTIPLIER_COMBO 1142 -#define IDC_LANSIZE_EDIT 1143 -#define IDC_LANMULTIPLIER_COMBO 1144 -#define IDC_ONLYDEFAULT_CHECK 1145 -#define IDC_TIME_PROGRESS 1146 -#define IDC_ERRORS_EDIT 1147 -#define IDC_FILTER_COMBO 1149 -#define IDC_FILTER_CHECK 1150 -#define IDC_SIZE_CHECK 1151 -#define IDC_SIZE1_EDIT 1152 -#define IDC_SIZE1MULTI_COMBO 1153 -#define IDC_SIZETYPE1_COMBO 1154 -#define IDC_SIZE1_SPIN 1155 -#define IDC_SIZE2_EDIT 1156 -#define IDC_SIZE2MULTI_COMBO 1157 -#define IDC_SIZETYPE2_COMBO 1158 -#define IDC_SIZE2_SPIN 1159 -#define IDC_SIZE2_CHECK 1160 -#define IDC_DATE_CHECK 1161 -#define IDC_ATTRIBUTES_CHECK 1162 -#define IDC_ARCHIVE_CHECK 1163 -#define IDC_READONLY_CHECK 1164 -#define IDC_HIDDEN_CHECK 1165 -#define IDC_SYSTEM_CHECK 1166 -#define IDC_DATETYPE_COMBO 1167 -#define IDC_DATE1TYPE_COMBO 1168 -#define IDC_DATE1_DATETIMEPICKER 1169 -#define IDC_TIME1_DATETIMEPICKER 1170 -#define IDC_DATE2_CHECK 1171 -#define IDC_DATE2TYPE_COMBO 1172 -#define IDC_DATE2_DATETIMEPICKER 1173 -#define IDC_TIME2_DATETIMEPICKER 1174 -#define IDC_DIRECTORY_CHECK 1175 -#define IDC_FILTEREXCLUDE_COMBO 1176 -#define IDC_EXCLUDEMASK_CHECK 1177 -#define IDC_COUNT_SPIN 1178 -#define IDC_DESTPATH_COMBOBOXEX 1179 -#define IDC_SHORTCUT_LIST 1180 -#define IDC_NAME_EDIT 1181 -#define IDC_PATH_COMBOBOXEX 1182 -#define IDC_CHANGE_BUTTON 1185 -#define IDC_RECENT_LIST 1190 -#define IDC_IMPORT_BUTTON 1191 -#define IDC_UP_BUTTON 1192 -#define IDC_DOWN_BUTTON 1193 -#define IDC_THANX_EDIT 1198 -#define IDC_COPYRIGHT_STATIC 1199 -#define IDC_FOLDER_TREE 1200 -#define IDC_DISTRIBUTION_STATIC 1200 -#define IDC_NEWFOLDER_BUTTON 1201 -#define IDC_HOMEPAGE_STATIC 1201 -#define IDC_TITLE_STATIC 1202 -#define IDC_HOMEPAGELINK_STATIC 1202 -#define IDC_LARGEICONS_BUTTON 1203 -#define IDC_CONTACT_STATIC 1203 -#define IDC_HOMEPAGELINK2_STATIC 1203 -#define IDC_SMALLICONS_BUTTON 1204 -#define IDC_GENFORUM_STATIC 1204 -#define IDC_LIST_BUTTON 1205 -#define IDC_DEVFORUM_STATIC 1205 -#define IDC_REPORT_BUTTON 1206 -#define IDC_CONTACT1LINK_STATIC 1206 -#define IDC_CONTACT2LINK_STATIC 1207 -#define IDC_GENFORUMPAGELINK_STATIC 1208 -#define IDC_TOGGLE_BUTTON 1209 -#define IDC_GENFORUMSUBSCRIBELINK_STATIC 1209 -#define IDC_ADDSHORTCUT_BUTTON 1210 -#define IDC_GENFORUMUNSUBSCRIBELINK_STATIC 1210 -#define IDC_REMOVESHORTCUT_BUTTON 1211 -#define IDC_GENFORUMSENDLINK_STATIC 1211 -#define IDC_DEVFORUMPAGELINK_STATIC 1212 -#define IDC_DEVFORUMSUBSCRIBELINK_STATIC 1213 -#define IDC_DEVFORUMUNSUBSCRIBELINK_STATIC 1214 -#define IDC_DEVFORUMSENDLINK_STATIC 1215 -#define IDC_THANX_STATIC 1216 -#define IDC_UPX_STATIC 1217 -#define IDC_CONTACT3LINK_STATIC 1217 -#define IDC_APPLY_BUTTON 1218 -#define IDC_001_STATIC 1219 -#define IDC_002_STATIC 1220 -#define IDC_003_STATIC 1221 -#define IDC_004_STATIC 1222 -#define IDC_005_STATIC 1223 -#define IDC_006_STATIC 1224 -#define IDC_007_STATIC 1225 -#define IDC_008_STATIC 1226 -#define IDC_009_STATIC 1227 -#define IDC_010_STATIC 1228 -#define IDC_011_STATIC 1229 -#define IDC_012_STATIC 1230 -#define IDC_013_STATIC 1231 -#define IDC_014_STATIC 1232 -#define IDC_015_STATIC 1233 -#define IDC_016_STATIC 1234 -#define IDC_017_STATIC 1235 -#define IDC_018_STATIC 1236 -#define IDC_019_STATIC 1237 -#define IDC_020_STATIC 1238 -#define IDC_021_STATIC 1239 -#define IDC_022_STATIC 1240 -#define IDC_023_STATIC 1241 -#define IDC_024_STATIC 1242 -#define IDC_025_STATIC 1243 -#define IDC_026_STATIC 1244 -#define IDC_027_STATIC 1245 -#define IDC_028_STATIC 1246 -#define IDC_029_STATIC 1247 -#define IDC_030_STATIC 1248 -#define IDC_BAR1_STATIC 1249 -#define IDC_BAR2_STATIC 1250 -#define IDC_BAR3_STATIC 1251 -#define IDC_BAR4_STATIC 1252 -#define IDC_BAR5_STATIC 1253 -#define IDC_HEADER_STATIC 1254 -#define IDC_HOSTLINK_STATIC 1255 -#define IDC_HELP_BUTTON 1257 -#define IDC_PROGRAM_STATICEX 1263 -#define IDC_FULLVERSION_STATICEX 1264 -#define IDC_HOMEPAGE_STATICEX 1265 -#define IDC_CONTACT_STATICEX 1266 -#define IDC_LICENSE_STATICEX 1267 -#define IDC_CONTACTAUTHOR_STATICEX 1268 -#define IDC_CONTACTSUPPORT_STATICEX 1269 -#define IDS_APPNAME_STRING 5000 -#define IDS_PRIORITY0_STRING 5001 -#define IDS_PRIORITY1_STRING 5002 -#define IDS_PRIORITY2_STRING 5003 -#define IDS_PRIORITY3_STRING 5004 -#define IDS_PRIORITY4_STRING 5005 -#define IDS_PRIORITY5_STRING 5006 -#define IDS_PRIORITY6_STRING 5007 -#define IDS_FIRSTCOPY_STRING 5008 -#define IDS_NEXTCOPY_STRING 5009 -#define IDS_NOTFOUND_STRING 5010 -#define IDS_BYTE_STRING 5011 -#define IDS_KBYTE_STRING 5012 -#define IDS_MBYTE_STRING 5013 -#define IDS_GBYTE_STRING 5014 -#define IDS_TBYTE_STRING 5015 -#define IDS_PBYTE_STRING 5016 -#define IDS_LT_STRING 5017 -#define IDS_LE_STRING 5018 -#define IDS_EQ_STRING 5019 -#define IDS_GE_STRING 5020 -#define IDS_GT_STRING 5021 -#define IDS_ONECOPY_STRING 6000 -#define IDS_REGISTEROK_STRING 6001 -#define IDS_REGISTERERR_STRING 6002 -#define IDS_UNREGISTEROK_STRING 6003 -#define IDS_UNREGISTERERR_STRING 6004 -#define IDS_HELPERR_STRING 6005 -#define IDS_OTFSEARCHINGFORFILES_STRING 7000 -#define IDS_OTFMISSINGCLIPBOARDINPUT_STRING 7001 -#define IDS_OTFADDINGCLIPBOARDFILE_STRING 7002 -#define IDS_OTFADDEDFOLDER_STRING 7003 -#define IDS_OTFRECURSINGFOLDER_STRING 7004 -#define IDS_OTFADDINGKILLREQEST_STRING 7005 -#define IDS_OTFADDEDFILE_STRING 7006 -#define IDS_OTFSEARCHINGFINISHED_STRING 7007 -#define IDS_OTFDELETINGFILES_STRING 7008 -#define IDS_OTFDELETINGKILLREQUEST_STRING 7009 -#define IDS_OTFDELETINGERROR_STRING 7010 -#define IDS_OTFDELETINGFINISHED_STRING 7011 -#define IDS_OTFPRECHECKCANCELREQUEST_STRING 7012 -#define IDS_OTFOPENINGERROR_STRING 7013 -#define IDS_OTFOPENINGCANCELREQUEST_STRING 7014 -#define IDS_OTFOPENINGWAITREQUEST_STRING 7015 -#define IDS_OTFOPENINGRETRY_STRING 7016 -#define IDS_OTFDESTOPENINGERROR_STRING 7017 -#define IDS_OTFDESTOPENINGRETRY_STRING 7018 -#define IDS_OTFDESTOPENINGCANCELREQUEST_STRING 7019 -#define IDS_OTFDESTOPENINGWAITREQUEST_STRING 7020 -#define IDS_OTFMOVINGPOINTERSERROR_STRING 7021 -#define IDS_OTFRESTORINGPOINTERSERROR_STRING 7022 -#define IDS_OTFSETTINGZEROSIZEERROR_STRING 7023 -#define IDS_OTFCOPYINGKILLREQUEST_STRING 7024 -#define IDS_OTFCHANGINGBUFFERSIZE_STRING 7025 -#define IDS_OTFREADINGERROR_STRING 7026 -#define IDS_OTFWRITINGERROR_STRING 7027 -#define IDS_OTFCAUGHTEXCEPTIONCCF_STRING 7028 -#define IDS_OTFPROCESSINGFILES_STRING 7029 -#define IDS_OTFPROCESSINGFILESDATA_STRING 7030 -#define IDS_OTFPROCESSINGKILLREQUEST_STRING 7031 -#define IDS_OTFMOVEFILEERROR_STRING 7032 -#define IDS_OTFCREATEDIRECTORYERROR_STRING 7033 -#define IDS_OTFPROCESSINGFINISHED_STRING 7034 -#define IDS_OTFTHREADSTART_STRING 7035 -#define IDS_OTFWAITINGFINISHED_STRING 7036 -#define IDS_OTFWAITINGKILLREQUEST_STRING 7037 -#define IDS_OTFTHREADFINISHED_STRING 7038 -#define IDS_OTFCAUGHTEXCEPTIONMAIN_STRING 7039 -#define IDS_OTFCHECKINGSPACE_STRING 7040 -#define IDS_OTFNOTENOUGHFREESPACE_STRING 7041 -#define IDS_OTFFREESPACECANCELREQUEST_STRING 7042 -#define IDS_OTFFREESPACERETRYING_STRING 7043 -#define IDS_OTFFREESPACEIGNORE_STRING 7044 -#define IDS_OTFSHRINKERROR_STRING 7045 -#define IDS_OTFEXTMOVEFILEERROR_STRING 7046 -#define IDS_OTFMOVEFILECANCELREQUEST_STRING 7047 -#define IDS_PROGRAM_STRING 8000 -#define IDS_CLIPBOARDMONITORING_STRING 8001 -#define IDS_CLIPBOARDINTERVAL_STRING 8002 -#define IDS_AUTORUNPROGRAM_STRING 8003 -#define IDS_AUTOSHUTDOWN_STRING 8004 -#define IDS_AUTOSAVEINTERVAL_STRING 8005 -#define IDS_TEMPFOLDER_STRING 8006 -#define IDS_STATUSWINDOW_STRING 8007 -#define IDS_REFRESHSTATUSINTERVAL_STRING 8008 -#define IDS_STATUSSHOWDETAILS_STRING 8009 -#define IDS_STATUSAUTOREMOVE_STRING 8010 -#define IDS_MINIVIEW_STRING 8011 -#define IDS_SHOWFILENAMES_STRING 8012 -#define IDS_SHOWSINGLETASKS_STRING 8013 -#define IDS_MINIVIEWREFRESHINTERVAL_STRING 8014 -#define IDS_MINIVIEWSHOWAFTERSTART_STRING 8015 -#define IDS_MINIVIEWAUTOHIDE_STRING 8016 -#define IDS_PROCESSINGTHREAD_STRING 8017 -#define IDS_AUTOCOPYREST_STRING 8018 -#define IDS_SETDESTATTRIB_STRING 8019 -#define IDS_SETDESTTIME_STRING 8020 -#define IDS_PROTECTROFILES_STRING 8021 -#define IDS_LIMITOPERATIONS_STRING 8022 -#define IDS_SHOWVISUALFEEDBACK_STRING 8023 -#define IDS_USETIMEDDIALOGS_STRING 8024 -#define IDS_TIMEDDIALOGINTERVAL_STRING 8025 -#define IDS_AUTORETRYONERROR_STRING 8026 -#define IDS_AUTORETRYINTERVAL_STRING 8027 -#define IDS_DEFAULTPRIORITY_STRING 8028 -#define IDS_AUTODETECTBUFFERSIZE_STRING 8029 -#define IDS_DEFAULTBUFFERSIZE_STRING 8030 -#define IDS_DELETEAFTERFINISHED_STRING 8031 -#define IDS_CREATELOGFILES_STRING 8032 -#define IDS_SOUNDS_STRING 8033 -#define IDS_PLAYSOUNDS_STRING 8034 -#define IDS_SOUNDONERROR_STRING 8035 -#define IDS_SOUNDONFINISH_STRING 8036 -#define IDS_LANGUAGE_STRING 8037 -#define IDS_READSIZEBEFOREBLOCK_STRING 8038 -#define IDS_USENOBUFFERING_STRING 8039 -#define IDS_LARGEFILESMINSIZE_STRING 8040 -#define IDS_OPTIONSBUFFER_STRING 8041 -#define IDS_ONEDISKBUFFERSIZE_STRING 8042 -#define IDS_TWODISKSBUFFERSIZE_STRING 8043 -#define IDS_CDBUFFERSIZE_STRING 8044 -#define IDS_LANBUFFERSIZE_STRING 8045 -#define IDS_SHUTDOWNTIME_STRING 8046 -#define IDS_FORCESHUTDOWN_STRING 8047 -#define IDS_MINIVIEWSMOOTHPROGRESS_STRING 8048 -#define IDS_CFGFOLDERDIALOG_STRING 8049 -#define IDS_CFGFDEXTVIEW_STRING 8050 -#define IDS_CFGFDWIDTH_STRING 8051 -#define IDS_CFGFDHEIGHT_STRING 8052 -#define IDS_CFGFDSHORTCUTS_STRING 8053 -#define IDS_CFGFDIGNOREDIALOGS_STRING 8054 -#define IDS_CFGSHCOPY_STRING 8055 -#define IDS_CFGSHMOVE_STRING 8056 -#define IDS_CFGSHCMSPECIAL_STRING 8057 -#define IDS_CFGSHPASTE_STRING 8058 -#define IDS_CFGSHPASTESPECIAL_STRING 8059 -#define IDS_CFGSHCOPYTO_STRING 8060 -#define IDS_CFGSHMOVETO_STRING 8061 -#define IDS_CFGSHCMTOSPECIAL_STRING 8062 -#define IDS_CFGSHSHOWFREESPACE_STRING 8063 -#define IDS_CFGSHSHOWICONS_STRING 8064 -#define IDS_CFGSHOVERRIDEDRAG_STRING 8065 -#define IDS_CFGSHORTCUTS_STRING 8066 -#define IDS_CFGRECENT_STRING 8067 -#define IDS_CFGSHELL_STRING 8068 -#define IDS_CFGSCCOUNT_STRING 8069 -#define IDS_CFGRPCOUNT_STRING 8070 -#define IDS_CFGOVERRIDEDEFACTION_STRING 8071 -#define IDS_CFGPRIORITYCLASS_STRING 8072 -#define IDS_CFGDISABLEPRIORITYBOOST_STRING 8073 -#define IDS_BOOLTEXT_STRING 8074 -#define IDS_TEMPFOLDERCHOOSE_STRING 8075 -#define IDS_FEEDBACKTYPE_STRING 8076 -#define IDS_SOUNDSWAVFILTER_STRING 8077 -#define IDS_LANGUAGELIST_STRING 8078 -#define IDS_FORCESHUTDOWNVALUES_STRING 8079 -#define IDS_CFGFDSHORTCUTSSTYLES_STRING 8080 -#define IDS_CFGPRIORITYCLASSITEMS_STRING 8081 -#define IDS_CFGACTIONS_STRING 8082 -#define IDS_PLUGSFOLDER_STRING 8083 -#define IDS_PLUGSFOLDERCHOOSE_STRING 8084 -#define IDS_CFGLOGFILE_STRING 8085 -#define IDS_CFGENABLELOGGING_STRING 8086 -#define IDS_CFGLIMITATION_STRING 8087 -#define IDS_CFGMAXLIMIT_STRING 8088 -#define IDS_CFGLOGPRECISELIMITING_STRING 8089 -#define IDS_CFGTRUNCBUFFERSIZE_STRING 8090 -#define IDS_CFGHELPDIR_STRING 8091 -#define IDS_CFGHELPDIRCHOOSE_STRING 8092 -#define IDS_LANGUAGESFOLDER_STRING 8093 -#define IDS_LANGSFOLDERCHOOSE_STRING 8094 -#define IDS_MENUCOPY_STRING 9000 -#define IDS_MENUMOVE_STRING 9001 -#define IDS_MENUCOPYMOVESPECIAL_STRING 9002 -#define IDS_MENUPASTE_STRING 9003 -#define IDS_MENUPASTESPECIAL_STRING 9004 -#define IDS_MENUCOPYTO_STRING 9005 -#define IDS_MENUMOVETO_STRING 9006 -#define IDS_MENUCOPYMOVETOSPECIAL_STRING 9007 -#define IDS_MENUTIPCOPY_STRING 9008 -#define IDS_MENUTIPMOVE_STRING 9009 -#define IDS_MENUTIPCOPYMOVESPECIAL_STRING 9010 -#define IDS_MENUTIPPASTE_STRING 9011 -#define IDS_MENUTIPPASTESPECIAL_STRING 9012 -#define IDS_MENUTIPCOPYTO_STRING 9013 -#define IDS_MENUTIPMOVETO_STRING 9014 -#define IDS_MENUTIPCOPYMOVETOSPECIAL_STRING 9015 -#define IDS_BROWSE_STRING 13000 -#define IDS_BDREMOTENAME_STRING 13001 -#define IDS_BDLOCALNAME_STRING 13002 -#define IDS_BDTYPE_STRING 13003 -#define IDS_BDNETTYPE_STRING 13004 -#define IDS_BDDESCRIPTION_STRING 13005 -#define IDS_BDFREESPACE_STRING 13006 -#define IDS_BDCAPACITY_STRING 13007 -#define IDS_BDOK_STRING 13008 -#define IDS_BDCANCEL_STRING 13009 -#define IDS_BDCANNOTCREATEFOLDER_STRING 13010 -#define IDS_BDPATHDOESNTEXIST_STRING 13011 -#define IDS_BDNAME_STRING 13012 -#define IDS_BDPATH_STRING 13013 -#define IDS_BDPATH2_STRING 13014 -#define IDS_BDRIGHT_STRING 13015 -#define IDS_BDLEFT_STRING 13016 -#define IDS_BDNOSHORTCUTPATH_STRING 13017 -#define IDS_BDNEWFOLDER_STRING 13018 -#define IDS_BDLARGEICONS_STRING 13019 -#define IDS_BDSMALLICONS_STRING 13020 -#define IDS_BDLIST_STRING 13021 -#define IDS_BDREPORT_STRING 13022 -#define IDS_BDDETAILS_STRING 13023 -#define IDS_BDADDSHORTCUT_STRING 13024 -#define IDS_BDREMOVESHORTCUT_STRING 13025 -#define IDS_BDDOMAIN_STRING 13026 -#define IDS_BDSERVER_STRING 13027 -#define IDS_BDSHARE_STRING 13028 -#define IDS_BDFILE_STRING 13029 -#define IDS_BDGROUP_STRING 13030 -#define IDS_BDNETWORK_STRING 13031 -#define IDS_BDROOT_STRING 13032 -#define IDS_BDADMINSHARE_STRING 13033 -#define IDS_BDDIR_STRING 13034 -#define IDS_BDTREE_STRING 13035 -#define IDS_BDNDSCONTAINER_STRING 13036 -#define IDS_TITLECOPY_STRING 13500 -#define IDS_TITLEMOVE_STRING 13501 -#define IDS_TITLEUNKNOWNOPERATION_STRING 13502 -#define IDS_MAINBROWSETEXT_STRING 13503 -#define IDS_ABTNOTHANX_STRING 14000 -#define IDS_ABOUTVERSION_STRING 14001 -#define IDS_LANGCODE_STRING 14002 -#define IDS_LANGVER_STRING 14003 -#define IDS_BUFFERSIZEZERO_STRING 14500 -#define IDS_FILEDLGALLFILTER_STRING 15000 -#define IDS_DSTFOLDERBROWSE_STRING 15001 -#define IDS_MISSINGDATA_STRING 15002 -#define IDS_CCDCOPY_STRING 15003 -#define IDS_CCDMOVE_STRING 15004 -#define IDS_BSEDEFAULT_STRING 15005 -#define IDS_BSEONEDISK_STRING 15006 -#define IDS_BSETWODISKS_STRING 15007 -#define IDS_BSECD_STRING 15008 -#define IDS_BSELAN_STRING 15009 -#define IDS_HDRMASK_STRING 15010 -#define IDS_HDRSIZE_STRING 15011 -#define IDS_HDRDATE_STRING 15012 -#define IDS_HDRATTRIB_STRING 15013 -#define IDS_AND_STRING 15014 -#define IDS_FILTERMASKEMPTY_STRING 15015 -#define IDS_FILTERSIZE_STRING 15016 -#define IDS_FILTERDATE_STRING 15017 -#define IDS_HDREXCLUDEMASK_STRING 15018 -#define IDS_HDREXCLUDEATTRIB_STRING 15019 -#define IDS_FILTERATTRIB_STRING 15020 -#define IDS_EMPTYFILTER_STRING 15021 -#define IDS_FLTALLFILTER_STRING 15022 -#define IDS_IMPORTREPORT_STRING 15023 -#define IDS_NERPATH_STRING 16500 -#define IDS_DATECREATED_STRING 18000 -#define IDS_DATELASTWRITE_STRING 18001 -#define IDS_DATEACCESSED_STRING 18002 -#define IDS_MINIVIEWALL_STRING 18500 -#define IDS_SOURCESTRINGMISSING_STRING 20000 -#define IDS_SHORTCUTNAME_STRING 20500 -#define IDS_SHORTCUTPATH_STRING 20501 -#define IDS_SHUTDOWNERROR_STRING 21000 -#define IDS_COLUMNSTATUS_STRING 21500 -#define IDS_COLUMNSOURCE_STRING 21501 -#define IDS_COLUMNDESTINATION_STRING 21502 -#define IDS_COLUMNPROGRESS_STRING 21503 -#define IDS_EMPTYOPERATIONTEXT_STRING 21504 -#define IDS_EMPTYSOURCETEXT_STRING 21505 -#define IDS_EMPTYDESTINATIONTEXT_STRING 21506 -#define IDS_EMPTYBUFFERSIZETEXT_STRING 21507 -#define IDS_EMPTYPRIORITYTEXT_STRING 21508 -#define IDS_EMPTYERRORTEXT_STRING 21509 -#define IDS_EMPTYPROCESSEDTEXT_STRING 21510 -#define IDS_EMPTYTRANSFERTEXT_STRING 21511 -#define IDS_EMPTYTIMETEXT_STRING 21512 -#define IDS_CURRENTPASS_STRING 21513 -#define IDS_AVERAGEWORD_STRING 21514 -#define IDS_STATUSTITLE_STRING 21515 -#define IDS_REPLACEPATHSTEXT_STRING 21516 -#define IDS_TASKNOTPAUSED_STRING 21517 -#define IDS_TASKNOTSELECTED_STRING 21518 -#define IDS_NONEINPUTFILE_STRING 21519 -#define IDS_COPYWORDLESSFIVE_STRING 21520 -#define IDS_COPYWORDMOREFOUR_STRING 21521 -#define IDS_STATUS0_STRING 21522 -#define IDS_STATUS1_STRING 21523 -#define IDS_STATUS2_STRING 21524 -#define IDS_STATUS3_STRING 21525 -#define IDS_STATUS4_STRING 21526 -#define IDS_STATUS5_STRING 21527 -#define IDS_STATUS6_STRING 21528 -#define IDS_STATUS7_STRING 21529 -#define IDS_STATUS8_STRING 21530 -#define IDS_STATUS9_STRING 21531 -#define IDS_STATUS10_STRING 21532 -#define IDS_STATUS11_STRING 21533 -#define IDS_SHELLEXECUTEERROR_STRING 21534 -#define IDS_BSDEFAULT_STRING 21535 -#define IDS_BSONEDISK_STRING 21536 -#define IDS_BSTWODISKS_STRING 21537 -#define IDS_BSCD_STRING 21538 -#define IDS_BSLAN_STRING 21539 -#define IDS_CPEDELETINGERROR_STRING 21540 -#define IDS_CPEOPENINGERROR_STRING 21541 -#define IDS_CPEDESTOPENINGERROR_STRING 21542 -#define IDS_CPERESTORINGPOINTERSERROR_STRING 21543 -#define IDS_CPESETTINGZEROSIZEERROR_STRING 21544 -#define IDS_CPEREADINGERROR_STRING 21545 -#define IDS_CPEWRITINGERROR_STRING 21546 -#define IDS_CPEMOVEFILEERROR_STRING 21547 -#define IDS_CPECREATEDIRECTORYERROR_STRING 21548 -#define IDS_EMPTYASSOCFILE_STRING 21549 -#define IDS_FILTERING_STRING 21550 -#define IDS_CONFIRMCANCEL_STRING 21551 -#define ID_POPUP_SHOW_STATUS 32773 -#define ID_POPUP_TIME_CRITICAL 32774 -#define ID_POPUP_HIGHEST 32775 -#define ID_POPUP_ABOVE_NORMAL 32776 -#define ID_POPUP_NORMAL 32777 -#define ID_POPUP_BELOW_NORMAL 32778 -#define ID_POPUP_LOWEST 32779 -#define ID_POPUP_IDLE 32780 -#define ID_POPUP_CUSTOM_BUFFERSIZE 32793 -#define ID_POPUP_OPTIONS 32802 -#define ID_SHOW_MINI_VIEW 32803 -#define ID_POPUP_CUSTOM_COPY 32804 -#define ID_POPUP_REPLACE_PATHS 32805 -#define ID_POPUP_MONITORING 32806 -#define ID_POPUP_SHUTAFTERFINISHED 32807 -#define ID_POPUP_REGISTERDLL 32809 -#define ID_POPUP_UNREGISTERDLL 32810 -#define ID_POPUP_HELP 32814 -#define ID_POPUP_TEMP 32815 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 212 -#define _APS_NEXT_COMMAND_VALUE 32816 -#define _APS_NEXT_CONTROL_VALUE 1268 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif Index: src/ch/resource.hm =================================================================== diff -u -N --- src/ch/resource.hm (revision 0) +++ src/ch/resource.hm (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,148 @@ +// Microsoft Developer Studio generated Help ID include file. +// Used by Copy Handler.rc +// +#define HIDCANCEL 0x80890002 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_ADDDIR_BUTTON 0x809503f3 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_ADDFILE_BUTTON 0x809503ea // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_ADDFILTER_BUTTON 0x80950401 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_ADD_BUTTON 0x80d10424 // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_ADVANCED_BUTTON 0x80830435 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_ADVANCED_CHECK 0x809503ff // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_APPLY_BUTTON 0x809004c2 // IDD_OPTIONS_DIALOG [English (U.S.)] +#define HIDC_ARCHIVE_CHECK 0x80c3048b // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_ASSOCIATEDFILES__STATIC 0x80830410 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_ATTRIBUTES_CHECK 0x80c3048a // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_AVAILABLE_STATIC 0x80ad0468 // IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG [English (U.S.)] +#define HIDC_BROWSE_BUTTON 0x80d10428 // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_BUFFERSIZES_BUTTON 0x80950400 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_BUFFERSIZES_LIST 0x809503f4 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_BUFFERSIZE_STATIC 0x80830406 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_CANCEL_ALL_BUTTON 0x80830416 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_CANCEL_BUTTON 0x808303fe // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_CDROMMULTIPLIER_COMBO 0x80890476 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_CDROMSIZE_EDIT 0x80890475 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_CHANGE_BUTTON 0x80d104a1 // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_CONTACT1LINK_STATIC 0x806404b6 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_CONTACT2LINK_STATIC 0x806404b7 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_CONTACT3LINK_STATIC 0x806404c1 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_COPY_REST_ALL_BUTTON 0x80a40452 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] +#define HIDC_COPY_REST_BUTTON 0x80a4044f // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] +#define HIDC_COUNT_EDIT 0x8095045f // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_CREATETIME_EDIT 0x80a20443 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_DATE1TYPE_COMBO 0x80c30490 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATE1_DATETIMEPICKER 0x80c30491 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATE2TYPE_COMBO 0x80c30494 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATE2_CHECK 0x80c30493 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATE2_DATETIMEPICKER 0x80c30495 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATETYPE_COMBO 0x80c3048f // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DATE_CHECK 0x80c30489 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DEFAULTMULTIPLIER_COMBO 0x8089046d // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_DEFAULTSIZE_EDIT 0x8089046e // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_DELETE_BUTTON 0x80d10413 // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_DESTBROWSE_BUTTON 0x809503f0 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_DESTINATION_EDIT 0x80a1041b // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] +#define HIDC_DESTINATION_STATIC 0x80830404 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_DESTPATH_COMBOBOXEX 0x8095049b // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_DEST_CREATETIME_EDIT 0x80a20447 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_DEST_FILENAME_EDIT 0x80a20445 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_DEST_FILESIZE_EDIT 0x80a20446 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_DEST_MODIFYTIME_EDIT 0x80a20448 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_DEVFORUMPAGELINK_STATIC 0x806404bc // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_DEVFORUMSENDLINK_STATIC 0x806404bf // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_DEVFORUMSUBSCRIBELINK_STATIC \ + 0x806404bd // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_DEVFORUMUNSUBSCRIBELINK_STATIC \ + 0x806404be // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_DIRECTORY_CHECK 0x80c30497 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_DOWN_BUTTON 0x80d004a9 // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] +#define HIDC_ERRORS_EDIT 0x8083047b // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_EXCLUDEMASK_CHECK 0x80c30499 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_FILENAME_EDIT 0x80a70440 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDC_FILESIZE_EDIT 0x80a20441 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_FILES_LIST 0x80950429 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_FILTEREXCLUDE_COMBO 0x80c30498 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_FILTERS_CHECK 0x809503f6 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_FILTERS_LIST 0x809503f2 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_FILTER_CHECK 0x80c3047e // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_FILTER_COMBO 0x80c3047d // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_FORCEDIRECTORIES_CHECK 0x809503fc // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_GENFORUMPAGELINK_STATIC 0x806404b8 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_GENFORUMSENDLINK_STATIC 0x806404bb // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_GENFORUMSUBSCRIBELINK_STATIC \ + 0x806404b9 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_GENFORUMUNSUBSCRIBELINK_STATIC \ + 0x806404ba // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_HELP_BUTTON 0x808904e9 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_HIDDEN_CHECK 0x80c3048d // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_HOMEPAGELINK2_STATIC 0x806404b3 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_HOMEPAGELINK_STATIC 0x806404b2 // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_IGNOREFOLDERS_CHECK 0x809503f7 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_IGNORE_ALL_BUTTON 0x80a7044a // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDC_IGNORE_BUTTON 0x80a70449 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDC_IMPORT_BUTTON 0x809504a7 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_LANMULTIPLIER_COMBO 0x80890478 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_LANSIZE_EDIT 0x80890477 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_MESSAGE_EDIT 0x80a70458 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDC_MODIFY_TIME_EDIT 0x80a20444 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] +#define HIDC_NAME_EDIT 0x80d0049d // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] +#define HIDC_ONEDISKMULTIPLIER_COMBO 0x80890472 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_ONEDISKSIZE_EDIT 0x8089046f // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_ONLYDEFAULT_CHECK 0x80890479 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_ONLYSTRUCTURE_CHECK 0x809503f9 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_OPERATION_COMBO 0x809503f1 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_OPERATION_STATIC 0x80830405 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_OVERALL_PROGRESS_STATIC 0x8083040b // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_OVERALL_TRANSFER_STATIC 0x8083040c // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_PATHS_LIST 0x80a10436 // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] +#define HIDC_PATH_COMBOBOXEX 0x80d0049e // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] +#define HIDC_PATH_EDIT 0x80d1041f // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_PAUSE_ALL_BUTTON 0x80830414 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_PAUSE_BUTTON 0x808303fa // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_PRIORITY_COMBO 0x8095042f // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_PRIORITY_STATIC 0x80830407 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_PROGRESS_LIST 0x80910419 // IDD_MINIVIEW_DIALOG [English (U.S.)] +#define HIDC_PROGRESS_STATIC 0x80830409 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_PROPERTIES_LIST 0x80900418 // IDD_OPTIONS_DIALOG [English (U.S.)] +#define HIDC_READONLY_CHECK 0x80c3048c // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_RECENT_LIST 0x80d104a6 // IDD_RECENTEDIT_DIALOG [English (U.S.)] +#define HIDC_RECOPY_ALL_BUTTON 0x80a40453 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] +#define HIDC_RECOPY_BUTTON 0x80a40450 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] +#define HIDC_REMOVEFILEFOLDER_BUTTON 0x809503ec // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_REMOVEFILTER_BUTTON 0x80950402 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] +#define HIDC_REMOVE_FINISHED_BUTTON 0x80830417 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_REQUIRED_STATIC 0x80ad0467 // IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG [English (U.S.)] +#define HIDC_RESTART_ALL_BUTTON 0x80830415 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_RESTART_BUTTON 0x80830412 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_RESUME_BUTTON 0x808303fd // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_RETRY_BUTTON 0x80a7044c // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDC_ROLL_UNROLL_BUTTON 0x8083040e // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_SET_BUFFERSIZE_BUTTON 0x808303f5 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_SET_PRIORITY_BUTTON 0x808303f8 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_SHORTCUT_LIST 0x80d0049c // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] +#define HIDC_SHOW_LOG_BUTTON 0x80830460 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_SIZE1MULTI_COMBO 0x80c30481 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE1_EDIT 0x80c30480 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE1_SPIN 0x80c30483 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE2MULTI_COMBO 0x80c30485 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE2_CHECK 0x80c30488 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE2_EDIT 0x80c30484 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE2_SPIN 0x80c30487 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZETYPE1_COMBO 0x80c30482 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZETYPE2_COMBO 0x80c30486 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SIZE_CHECK 0x80c3047f // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_SOURCE_EDIT 0x80a1041a // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] +#define HIDC_SOURCE_STATIC 0x80830403 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_START_ALL_BUTTON 0x80830411 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_STATUS_LIST 0x808303eb // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_STICK_BUTTON 0x80830462 // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_SYSTEM_CHECK 0x80c3048e // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_THANX_EDIT 0x806404ae // IDD_ABOUTBOX [English (U.S.)] +#define HIDC_TIME1_DATETIMEPICKER 0x80c30492 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_TIME2_DATETIMEPICKER 0x80c30496 // IDD_FILTER_DIALOG [English (U.S.)] +#define HIDC_TIME_STATIC 0x8083040d // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_TRANSFER_STATIC 0x8083040a // IDD_STATUS_DIALOG [English (U.S.)] +#define HIDC_TWODISKSMULTIPLIER_COMBO 0x80890474 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_TWODISKSSIZE_EDIT 0x80890473 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] +#define HIDC_UP_BUTTON 0x80d004a8 // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] +#define HIDC_WAIT_BUTTON 0x80a7044b // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] +#define HIDOK 0x80640001 // IDD_ABOUTBOX [English (U.S.)] Index: ch/resource.hm =================================================================== diff -u -N --- ch/resource.hm (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/resource.hm (revision 0) @@ -1,148 +0,0 @@ -// Microsoft Developer Studio generated Help ID include file. -// Used by Copy Handler.rc -// -#define HIDCANCEL 0x80890002 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_ADDDIR_BUTTON 0x809503f3 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_ADDFILE_BUTTON 0x809503ea // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_ADDFILTER_BUTTON 0x80950401 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_ADD_BUTTON 0x80d10424 // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_ADVANCED_BUTTON 0x80830435 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_ADVANCED_CHECK 0x809503ff // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_APPLY_BUTTON 0x809004c2 // IDD_OPTIONS_DIALOG [English (U.S.)] -#define HIDC_ARCHIVE_CHECK 0x80c3048b // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_ASSOCIATEDFILES__STATIC 0x80830410 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_ATTRIBUTES_CHECK 0x80c3048a // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_AVAILABLE_STATIC 0x80ad0468 // IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG [English (U.S.)] -#define HIDC_BROWSE_BUTTON 0x80d10428 // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_BUFFERSIZES_BUTTON 0x80950400 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_BUFFERSIZES_LIST 0x809503f4 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_BUFFERSIZE_STATIC 0x80830406 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_CANCEL_ALL_BUTTON 0x80830416 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_CANCEL_BUTTON 0x808303fe // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_CDROMMULTIPLIER_COMBO 0x80890476 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_CDROMSIZE_EDIT 0x80890475 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_CHANGE_BUTTON 0x80d104a1 // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_CONTACT1LINK_STATIC 0x806404b6 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_CONTACT2LINK_STATIC 0x806404b7 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_CONTACT3LINK_STATIC 0x806404c1 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_COPY_REST_ALL_BUTTON 0x80a40452 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] -#define HIDC_COPY_REST_BUTTON 0x80a4044f // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] -#define HIDC_COUNT_EDIT 0x8095045f // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_CREATETIME_EDIT 0x80a20443 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_DATE1TYPE_COMBO 0x80c30490 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATE1_DATETIMEPICKER 0x80c30491 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATE2TYPE_COMBO 0x80c30494 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATE2_CHECK 0x80c30493 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATE2_DATETIMEPICKER 0x80c30495 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATETYPE_COMBO 0x80c3048f // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DATE_CHECK 0x80c30489 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DEFAULTMULTIPLIER_COMBO 0x8089046d // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_DEFAULTSIZE_EDIT 0x8089046e // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_DELETE_BUTTON 0x80d10413 // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_DESTBROWSE_BUTTON 0x809503f0 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_DESTINATION_EDIT 0x80a1041b // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] -#define HIDC_DESTINATION_STATIC 0x80830404 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_DESTPATH_COMBOBOXEX 0x8095049b // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_DEST_CREATETIME_EDIT 0x80a20447 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_DEST_FILENAME_EDIT 0x80a20445 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_DEST_FILESIZE_EDIT 0x80a20446 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_DEST_MODIFYTIME_EDIT 0x80a20448 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_DEVFORUMPAGELINK_STATIC 0x806404bc // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_DEVFORUMSENDLINK_STATIC 0x806404bf // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_DEVFORUMSUBSCRIBELINK_STATIC \ - 0x806404bd // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_DEVFORUMUNSUBSCRIBELINK_STATIC \ - 0x806404be // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_DIRECTORY_CHECK 0x80c30497 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_DOWN_BUTTON 0x80d004a9 // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] -#define HIDC_ERRORS_EDIT 0x8083047b // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_EXCLUDEMASK_CHECK 0x80c30499 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_FILENAME_EDIT 0x80a70440 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDC_FILESIZE_EDIT 0x80a20441 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_FILES_LIST 0x80950429 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_FILTEREXCLUDE_COMBO 0x80c30498 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_FILTERS_CHECK 0x809503f6 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_FILTERS_LIST 0x809503f2 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_FILTER_CHECK 0x80c3047e // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_FILTER_COMBO 0x80c3047d // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_FORCEDIRECTORIES_CHECK 0x809503fc // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_GENFORUMPAGELINK_STATIC 0x806404b8 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_GENFORUMSENDLINK_STATIC 0x806404bb // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_GENFORUMSUBSCRIBELINK_STATIC \ - 0x806404b9 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_GENFORUMUNSUBSCRIBELINK_STATIC \ - 0x806404ba // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_HELP_BUTTON 0x808904e9 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_HIDDEN_CHECK 0x80c3048d // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_HOMEPAGELINK2_STATIC 0x806404b3 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_HOMEPAGELINK_STATIC 0x806404b2 // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_IGNOREFOLDERS_CHECK 0x809503f7 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_IGNORE_ALL_BUTTON 0x80a7044a // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDC_IGNORE_BUTTON 0x80a70449 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDC_IMPORT_BUTTON 0x809504a7 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_LANMULTIPLIER_COMBO 0x80890478 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_LANSIZE_EDIT 0x80890477 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_MESSAGE_EDIT 0x80a70458 // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDC_MODIFY_TIME_EDIT 0x80a20444 // IDD_FEEDBACK_IGNOREWAITRETRY_DIALOG [English (U.S.)] -#define HIDC_NAME_EDIT 0x80d0049d // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] -#define HIDC_ONEDISKMULTIPLIER_COMBO 0x80890472 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_ONEDISKSIZE_EDIT 0x8089046f // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_ONLYDEFAULT_CHECK 0x80890479 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_ONLYSTRUCTURE_CHECK 0x809503f9 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_OPERATION_COMBO 0x809503f1 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_OPERATION_STATIC 0x80830405 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_OVERALL_PROGRESS_STATIC 0x8083040b // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_OVERALL_TRANSFER_STATIC 0x8083040c // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_PATHS_LIST 0x80a10436 // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] -#define HIDC_PATH_COMBOBOXEX 0x80d0049e // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] -#define HIDC_PATH_EDIT 0x80d1041f // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_PAUSE_ALL_BUTTON 0x80830414 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_PAUSE_BUTTON 0x808303fa // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_PRIORITY_COMBO 0x8095042f // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_PRIORITY_STATIC 0x80830407 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_PROGRESS_LIST 0x80910419 // IDD_MINIVIEW_DIALOG [English (U.S.)] -#define HIDC_PROGRESS_STATIC 0x80830409 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_PROPERTIES_LIST 0x80900418 // IDD_OPTIONS_DIALOG [English (U.S.)] -#define HIDC_READONLY_CHECK 0x80c3048c // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_RECENT_LIST 0x80d104a6 // IDD_RECENTEDIT_DIALOG [English (U.S.)] -#define HIDC_RECOPY_ALL_BUTTON 0x80a40453 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] -#define HIDC_RECOPY_BUTTON 0x80a40450 // IDD_FEEDBACK_REPLACE_FILES_DIALOG [English (U.S.)] -#define HIDC_REMOVEFILEFOLDER_BUTTON 0x809503ec // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_REMOVEFILTER_BUTTON 0x80950402 // IDD_CUSTOM_COPY_DIALOG [English (U.S.)] -#define HIDC_REMOVE_FINISHED_BUTTON 0x80830417 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_REQUIRED_STATIC 0x80ad0467 // IDD_FEEDBACK_NOTENOUGHPLACE_DIALOG [English (U.S.)] -#define HIDC_RESTART_ALL_BUTTON 0x80830415 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_RESTART_BUTTON 0x80830412 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_RESUME_BUTTON 0x808303fd // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_RETRY_BUTTON 0x80a7044c // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDC_ROLL_UNROLL_BUTTON 0x8083040e // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_SET_BUFFERSIZE_BUTTON 0x808303f5 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_SET_PRIORITY_BUTTON 0x808303f8 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_SHORTCUT_LIST 0x80d0049c // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] -#define HIDC_SHOW_LOG_BUTTON 0x80830460 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_SIZE1MULTI_COMBO 0x80c30481 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE1_EDIT 0x80c30480 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE1_SPIN 0x80c30483 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE2MULTI_COMBO 0x80c30485 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE2_CHECK 0x80c30488 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE2_EDIT 0x80c30484 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE2_SPIN 0x80c30487 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZETYPE1_COMBO 0x80c30482 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZETYPE2_COMBO 0x80c30486 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SIZE_CHECK 0x80c3047f // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_SOURCE_EDIT 0x80a1041a // IDD_REPLACE_PATHS_DIALOG [English (U.S.)] -#define HIDC_SOURCE_STATIC 0x80830403 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_START_ALL_BUTTON 0x80830411 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_STATUS_LIST 0x808303eb // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_STICK_BUTTON 0x80830462 // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_SYSTEM_CHECK 0x80c3048e // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_THANX_EDIT 0x806404ae // IDD_ABOUTBOX [English (U.S.)] -#define HIDC_TIME1_DATETIMEPICKER 0x80c30492 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_TIME2_DATETIMEPICKER 0x80c30496 // IDD_FILTER_DIALOG [English (U.S.)] -#define HIDC_TIME_STATIC 0x8083040d // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_TRANSFER_STATIC 0x8083040a // IDD_STATUS_DIALOG [English (U.S.)] -#define HIDC_TWODISKSMULTIPLIER_COMBO 0x80890474 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_TWODISKSSIZE_EDIT 0x80890473 // IDD_BUFFERSIZE_DIALOG [English (U.S.)] -#define HIDC_UP_BUTTON 0x80d004a8 // IDD_SHORTCUTEDIT_DIALOG [English (U.S.)] -#define HIDC_WAIT_BUTTON 0x80a7044b // IDD_FEEDBACK_DSTFILE_DIALOG [English (U.S.)] -#define HIDOK 0x80640001 // IDD_ABOUTBOX [English (U.S.)] Index: src/ch/scripts/header.lng =================================================================== diff -u -N Binary files differ Index: ch/scripts/header.lng =================================================================== diff -u -N --- ch/scripts/header.lng (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ ch/scripts/header.lng (revision 0) @@ -1,12 +0,0 @@ -# Info section -[Info] -Lang Name=English -Lang Code=1033 -Base Language= -Font Face=Tahoma -Charset=1 -Size=8 -RTL reading order=0 -Help name=english.chm -Author=J�zef Starosczyk -Version=1.28 \ No newline at end of file Index: src/ch/shortcuts.cpp =================================================================== diff -u -N --- src/ch/shortcuts.cpp (revision 0) +++ src/ch/shortcuts.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,52 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "shortcuts.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +bool CShortcut::FromString(const CString& strText) +{ + int iPos=strText.ReverseFind(_T('|')); + if (iPos != -1 && iPos < strText.GetLength()-1) + { + m_strName=strText.Left(iPos); + m_strPath=strText.Mid(iPos+1); + + return true; + } + else + return false; +} + +CShortcut::CShortcut(const CString& strText) +{ + FromString(strText); +} + +CShortcut::operator CString() +{ + if (m_strPath.IsEmpty()) + return _T(""); + else + return m_strName+_T("|")+m_strPath; +} Index: ch/shortcuts.cpp =================================================================== diff -u -N --- ch/shortcuts.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/shortcuts.cpp (revision 0) @@ -1,52 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "shortcuts.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#endif - -bool CShortcut::FromString(const CString& strText) -{ - int iPos=strText.ReverseFind(_T('|')); - if (iPos != -1 && iPos < strText.GetLength()-1) - { - m_strName=strText.Left(iPos); - m_strPath=strText.Mid(iPos+1); - - return true; - } - else - return false; -} - -CShortcut::CShortcut(const CString& strText) -{ - FromString(strText); -} - -CShortcut::operator CString() -{ - if (m_strPath.IsEmpty()) - return _T(""); - else - return m_strName+_T("|")+m_strPath; -} Index: src/ch/shortcuts.h =================================================================== diff -u -N --- src/ch/shortcuts.h (revision 0) +++ src/ch/shortcuts.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,37 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __SHORTCUT_H__ +#define __SHORTCUT_H__ + +class CShortcut +{ +public: + CShortcut() { }; + CShortcut(const CString& strText); + operator CString(); + + bool FromString(const CString& strText); + +public: + CString m_strName; + CString m_strPath; +}; + +#endif \ No newline at end of file Index: ch/shortcuts.h =================================================================== diff -u -N --- ch/shortcuts.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/shortcuts.h (revision 0) @@ -1,37 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __SHORTCUT_H__ -#define __SHORTCUT_H__ - -class CShortcut -{ -public: - CShortcut() { }; - CShortcut(const CString& strText); - operator CString(); - - bool FromString(const CString& strText); - -public: - CString m_strName; - CString m_strPath; -}; - -#endif \ No newline at end of file Index: src/ch/shortcutsdlg.h =================================================================== diff -u -N --- src/ch/shortcutsdlg.h (revision 0) +++ src/ch/shortcutsdlg.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,80 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __SHORTCUTSDLG_H__ +#define __SHORTCUTSDLG_H__ + +#include "afxtempl.h" +#include "shortcuts.h" +#include "charvect.h" + +///////////////////////////////////////////////////////////////////////////// +// CShortcutsDlg dialog + +class CShortcutsDlg : public CHLanguageDialog +{ +// Construction +public: + CShortcutsDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CShortcutsDlg) + enum { IDD = IDD_SHORTCUTEDIT_DIALOG }; + CComboBoxEx m_ctlPath; + CListCtrl m_ctlShortcuts; + CString m_strName; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CShortcutsDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +public: + const char_vector *m_pcvRecent; // one way only + char_vector m_cvShortcuts; // two-way - shortcuts are being returned through this member +protected: + void UpdateComboIcon(); + void SetComboPath(LPCTSTR lpszPath); + HIMAGELIST m_himl, m_hliml; + bool m_bActualisation; + + // Generated message map functions + //{{AFX_MSG(CShortcutsDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnEditchangePathComboboxex(); + afx_msg void OnAddButton(); + afx_msg void OnChangeButton(); + afx_msg void OnDeleteButton(); + afx_msg void OnBrowseButton(); + afx_msg void OnUpButton(); + afx_msg void OnDownButton(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: ch/shortcutsdlg.h =================================================================== diff -u -N --- ch/shortcutsdlg.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/shortcutsdlg.h (revision 0) @@ -1,80 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __SHORTCUTSDLG_H__ -#define __SHORTCUTSDLG_H__ - -#include "afxtempl.h" -#include "shortcuts.h" -#include "charvect.h" - -///////////////////////////////////////////////////////////////////////////// -// CShortcutsDlg dialog - -class CShortcutsDlg : public CHLanguageDialog -{ -// Construction -public: - CShortcutsDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CShortcutsDlg) - enum { IDD = IDD_SHORTCUTEDIT_DIALOG }; - CComboBoxEx m_ctlPath; - CListCtrl m_ctlShortcuts; - CString m_strName; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CShortcutsDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -public: - const char_vector *m_pcvRecent; // one way only - char_vector m_cvShortcuts; // two-way - shortcuts are being returned through this member -protected: - void UpdateComboIcon(); - void SetComboPath(LPCTSTR lpszPath); - HIMAGELIST m_himl, m_hliml; - bool m_bActualisation; - - // Generated message map functions - //{{AFX_MSG(CShortcutsDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnItemchangedShortcutList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnEditchangePathComboboxex(); - afx_msg void OnAddButton(); - afx_msg void OnChangeButton(); - afx_msg void OnDeleteButton(); - afx_msg void OnBrowseButton(); - afx_msg void OnUpButton(); - afx_msg void OnDownButton(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/ch/stdafx.cpp =================================================================== diff -u -N --- src/ch/stdafx.cpp (revision 0) +++ src/ch/stdafx.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,22 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" + Index: ch/stdafx.cpp =================================================================== diff -u -N --- ch/stdafx.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ ch/stdafx.cpp (revision 0) @@ -1,22 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" - Index: src/chext/DropMenuExt.cpp =================================================================== diff -u -N --- src/chext/DropMenuExt.cpp (revision 0) +++ src/chext/DropMenuExt.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,324 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "CopyHandlerShellExt.h" +#include "DropMenuExt.h" +#include "clipboard.h" +///////////////////////////////////////////////////////////////////////////// +// CDropMenuExt + +extern CSharedConfigStruct* g_pscsShared; + +#define DE_COPY 0 +#define DE_MOVE 1 +#define DE_SPECIAL 2 +#define DE_AUTO 3 + +STDMETHODIMP CDropMenuExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) +{ + // find CH's window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (hWnd) + { + // get state of keys + bool bShift=(GetKeyState(VK_SHIFT) & 0x80) != 0; + bool bCtrl=(GetKeyState(VK_CONTROL) & 0x80) != 0; + bool bAlt=(GetKeyState(VK_MENU) & 0x80) != 0; + +/* OTF2("CDropMenuExt::QueryContextMenu - uFlags=%lu (", uFlags); + if (uFlags & CMF_CANRENAME) + OTF2("CMF_CANRENAME "); + if (uFlags & CMF_DEFAULTONLY) + OTF2("CMF_DEFAULTONLY "); + if (uFlags & CMF_EXPLORE) + OTF2("CMF_EXPLORE "); + if (uFlags & CMF_EXTENDEDVERBS) + OTF2("CMF_EXTENDEDVERBS "); + if (uFlags & CMF_INCLUDESTATIC) + OTF2("CMF_INCLUDESTATIC "); + if (uFlags & CMF_NODEFAULT) + OTF2("CMF_NODEFAULT "); + if (uFlags & CMF_NORMAL) + OTF2("CMF_NORMAL "); + if (uFlags & CMF_NOVERBS) + OTF2("CMF_NOVERBS "); + if (uFlags & CMF_VERBSONLY) + OTF2("CMF_VERBSONLY "); + OTF2(")\r\n"); + OTF2("Keys State: Shift:%u, ctrl:%u, alt:%u\r\n", bShift, bCtrl, bAlt); +*/ + // got a config + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + int iCommandCount=0; + + if (g_pscsShared->uiFlags & DD_COPY_FLAG) + { + ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+0, pCommand[0].szCommand); + if (g_pscsShared->bOverrideDefault) + ::SetMenuDefaultItem(hmenu, idCmdFirst+0, FALSE); + iCommandCount++; + } + + if (g_pscsShared->uiFlags & DD_MOVE_FLAG) + { + ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+1, pCommand[1].szCommand); + if (g_pscsShared->bOverrideDefault && (bShift || (m_uiDropEffect == DE_MOVE && (m_bExplorer || !bCtrl))) ) + ::SetMenuDefaultItem(hmenu, idCmdFirst+1, FALSE); + iCommandCount++; + } + + if (g_pscsShared->uiFlags & DD_COPYMOVESPECIAL_FLAG) + { + ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+2, pCommand[2].szCommand); + if (g_pscsShared->bOverrideDefault && (bAlt || (bCtrl && bShift) || m_uiDropEffect == DE_SPECIAL) && !(m_uiDropEffect == DE_MOVE)) + ::SetMenuDefaultItem(hmenu, idCmdFirst+2, FALSE); + iCommandCount++; + } + + if (iCommandCount) + { + ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst+3, NULL); + iCommandCount++; + } + + return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 4); + } + else + return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); +} + +STDMETHODIMP CDropMenuExt::GetCommandString(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax) +{ + if (uFlags == GCS_HELPTEXTW) + { + USES_CONVERSION; + + // find CH's window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (hWnd) + { + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + + switch (idCmd) + { + case 0: + case 1: + case 2: + wcsncpy(reinterpret_cast(pszName), A2W(pCommand[idCmd].szDesc), cchMax); + break; + default: + wcsncpy(reinterpret_cast(pszName), L"", cchMax); + break; + } + } + else + wcsncpy(reinterpret_cast(pszName), L"", cchMax); + } + if (uFlags == GCS_HELPTEXTA) + { + // find CH's window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + + if (hWnd) + { + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + + switch (idCmd) + { + case 0: + case 1: + case 2: + strncpy(pszName, pCommand[idCmd].szDesc, cchMax); + break; + default: + strncpy(pszName, "", cchMax); + break; + } + } + else + strncpy(pszName, "", cchMax); + } + + return S_OK; +} + +STDMETHODIMP CDropMenuExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/) +{ +// OTF2("Initialize cdropmenuext\r\n"); + // find window + HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (hWnd == NULL) + return E_FAIL; + + // gets the config from CH + ::SendMessage(hWnd, WM_GETCONFIG, GC_DRAGDROP, 0); + +// OTF2("========================================================\r\n"); +// OTF2("Initialize drag&drop context menu handler pidlFolder=%lu, lpdobj=%lu\r\n", pidlFolder, lpdobj); + + // get dest folder + m_szDstPath[0]=_T('\0'); + if (!SHGetPathFromIDList(pidlFolder, m_szDstPath)) + return E_FAIL; + + // get data from IDataObject - files to copy/move + if (lpdobj) + { +// ReportAvailableFormats(lpdobj); + // file list + STGMEDIUM medium; + FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + + HRESULT hr = lpdobj->GetData(&fe, &medium); + if (FAILED(hr)) + return E_FAIL; + + GetDataFromClipboard(static_cast(medium.hGlobal), m_szDstPath, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); + + // set std text + switch (g_pscsShared->uiDefaultAction) + { + case 1: + // move action + m_uiDropEffect=DE_MOVE; + break; + case 2: + // special operation + m_uiDropEffect=DE_SPECIAL; + break; + case 3: + { + // autodetecting - copy or move - check the last path + UINT uiCount=DragQueryFile((HDROP)medium.hGlobal, 0xffffffff, NULL, 0); + TCHAR szPath[_MAX_PATH]; + if (DragQueryFile((HDROP)medium.hGlobal, uiCount-1, szPath, _MAX_PATH)) + { + if (_tcsncmp(szPath, _T("\\\\"), 2) == 0) + { + TCHAR* pFnd=_tcsstr(szPath+2, _T("\\")); + + if (pFnd) + { + int iCount; + // find another + TCHAR *pSecond=_tcsstr(pFnd+1, _T("\\")); + if (pSecond) + { + iCount=pSecond-szPath; +// OTF2("Counted: %lu\r\n", iCount); + } + else + iCount=_tcslen(szPath); + + // found - compare +// OTF2("Compare %s and %s\r\n", szPath, m_szDstPath); + if (_tcsnicmp(szPath, m_szDstPath, iCount) == 0) + { +// OTF2("OP: MOVE\r\n"); + m_uiDropEffect=DE_MOVE; + } + else + { +// OTF2("OP: COPY\r\n"); + m_uiDropEffect=DE_COPY; + } + } + else + m_uiDropEffect=DE_COPY; + + } + else + { + // local path - check drive letter + if (m_szDstPath[0] == szPath[0]) + m_uiDropEffect=DE_MOVE; + else + m_uiDropEffect=DE_COPY; + } + } + else + m_uiDropEffect=DE_COPY; + } + break; + + default: + m_uiDropEffect=DE_COPY; // std copying + break; + } + + ReleaseStgMedium(&medium); + + // get operation type + UINT cf=RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT); + fe.cfFormat=(unsigned short)cf; + + // if explorer knows better - change effect + m_bExplorer=false; + hr=lpdobj->GetData(&fe, &medium); + if (SUCCEEDED(hr)) + { + // specify operation + LPVOID lpv=GlobalLock(medium.hGlobal); + if (lpv) + { + UINT uiDrop=*((DWORD*)lpv); + if (uiDrop & DROPEFFECT_MOVE) + m_uiDropEffect=DE_MOVE; + else + m_uiDropEffect=DE_COPY; + m_bExplorer=true; + +// OTF2("Detected operation %lu\r\n", m_uiDropEffect); + GlobalUnlock(medium.hGlobal); + } + + ReleaseStgMedium(&medium); + } + } + + return S_OK; +} + +STDMETHODIMP CDropMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) +{ + // find window + HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (hWnd == NULL) + return E_FAIL; + + // commands + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + + // IPC struct + COPYDATASTRUCT cds; + cds.dwData=pCommand[LOWORD(lpici->lpVerb)].uiCommandID; // based on command's number (0-copy, 1-move, 2-special (copy), 3-special (move)) + cds.cbData=m_bBuffer.m_iDataSize; + cds.lpData=m_bBuffer.m_pszFiles; + + // send a message to ch + ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); + + m_bBuffer.Destroy(); + + return S_OK; +} \ No newline at end of file Index: chext/DropMenuExt.cpp =================================================================== diff -u -N --- chext/DropMenuExt.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/DropMenuExt.cpp (revision 0) @@ -1,324 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "CopyHandlerShellExt.h" -#include "DropMenuExt.h" -#include "clipboard.h" -///////////////////////////////////////////////////////////////////////////// -// CDropMenuExt - -extern CSharedConfigStruct* g_pscsShared; - -#define DE_COPY 0 -#define DE_MOVE 1 -#define DE_SPECIAL 2 -#define DE_AUTO 3 - -STDMETHODIMP CDropMenuExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) -{ - // find CH's window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd) - { - // get state of keys - bool bShift=(GetKeyState(VK_SHIFT) & 0x80) != 0; - bool bCtrl=(GetKeyState(VK_CONTROL) & 0x80) != 0; - bool bAlt=(GetKeyState(VK_MENU) & 0x80) != 0; - -/* OTF2("CDropMenuExt::QueryContextMenu - uFlags=%lu (", uFlags); - if (uFlags & CMF_CANRENAME) - OTF2("CMF_CANRENAME "); - if (uFlags & CMF_DEFAULTONLY) - OTF2("CMF_DEFAULTONLY "); - if (uFlags & CMF_EXPLORE) - OTF2("CMF_EXPLORE "); - if (uFlags & CMF_EXTENDEDVERBS) - OTF2("CMF_EXTENDEDVERBS "); - if (uFlags & CMF_INCLUDESTATIC) - OTF2("CMF_INCLUDESTATIC "); - if (uFlags & CMF_NODEFAULT) - OTF2("CMF_NODEFAULT "); - if (uFlags & CMF_NORMAL) - OTF2("CMF_NORMAL "); - if (uFlags & CMF_NOVERBS) - OTF2("CMF_NOVERBS "); - if (uFlags & CMF_VERBSONLY) - OTF2("CMF_VERBSONLY "); - OTF2(")\r\n"); - OTF2("Keys State: Shift:%u, ctrl:%u, alt:%u\r\n", bShift, bCtrl, bAlt); -*/ - // got a config - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - int iCommandCount=0; - - if (g_pscsShared->uiFlags & DD_COPY_FLAG) - { - ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+0, pCommand[0].szCommand); - if (g_pscsShared->bOverrideDefault) - ::SetMenuDefaultItem(hmenu, idCmdFirst+0, FALSE); - iCommandCount++; - } - - if (g_pscsShared->uiFlags & DD_MOVE_FLAG) - { - ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+1, pCommand[1].szCommand); - if (g_pscsShared->bOverrideDefault && (bShift || (m_uiDropEffect == DE_MOVE && (m_bExplorer || !bCtrl))) ) - ::SetMenuDefaultItem(hmenu, idCmdFirst+1, FALSE); - iCommandCount++; - } - - if (g_pscsShared->uiFlags & DD_COPYMOVESPECIAL_FLAG) - { - ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_STRING, idCmdFirst+2, pCommand[2].szCommand); - if (g_pscsShared->bOverrideDefault && (bAlt || (bCtrl && bShift) || m_uiDropEffect == DE_SPECIAL) && !(m_uiDropEffect == DE_MOVE)) - ::SetMenuDefaultItem(hmenu, idCmdFirst+2, FALSE); - iCommandCount++; - } - - if (iCommandCount) - { - ::InsertMenu(hmenu, indexMenu+iCommandCount, MF_BYPOSITION | MF_SEPARATOR, idCmdFirst+3, NULL); - iCommandCount++; - } - - return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 4); - } - else - return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); -} - -STDMETHODIMP CDropMenuExt::GetCommandString(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax) -{ - if (uFlags == GCS_HELPTEXTW) - { - USES_CONVERSION; - - // find CH's window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd) - { - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - - switch (idCmd) - { - case 0: - case 1: - case 2: - wcsncpy(reinterpret_cast(pszName), A2W(pCommand[idCmd].szDesc), cchMax); - break; - default: - wcsncpy(reinterpret_cast(pszName), L"", cchMax); - break; - } - } - else - wcsncpy(reinterpret_cast(pszName), L"", cchMax); - } - if (uFlags == GCS_HELPTEXTA) - { - // find CH's window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - - if (hWnd) - { - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - - switch (idCmd) - { - case 0: - case 1: - case 2: - strncpy(pszName, pCommand[idCmd].szDesc, cchMax); - break; - default: - strncpy(pszName, "", cchMax); - break; - } - } - else - strncpy(pszName, "", cchMax); - } - - return S_OK; -} - -STDMETHODIMP CDropMenuExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/) -{ -// OTF2("Initialize cdropmenuext\r\n"); - // find window - HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd == NULL) - return E_FAIL; - - // gets the config from CH - ::SendMessage(hWnd, WM_GETCONFIG, GC_DRAGDROP, 0); - -// OTF2("========================================================\r\n"); -// OTF2("Initialize drag&drop context menu handler pidlFolder=%lu, lpdobj=%lu\r\n", pidlFolder, lpdobj); - - // get dest folder - m_szDstPath[0]=_T('\0'); - if (!SHGetPathFromIDList(pidlFolder, m_szDstPath)) - return E_FAIL; - - // get data from IDataObject - files to copy/move - if (lpdobj) - { -// ReportAvailableFormats(lpdobj); - // file list - STGMEDIUM medium; - FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - - HRESULT hr = lpdobj->GetData(&fe, &medium); - if (FAILED(hr)) - return E_FAIL; - - GetDataFromClipboard(static_cast(medium.hGlobal), m_szDstPath, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); - - // set std text - switch (g_pscsShared->uiDefaultAction) - { - case 1: - // move action - m_uiDropEffect=DE_MOVE; - break; - case 2: - // special operation - m_uiDropEffect=DE_SPECIAL; - break; - case 3: - { - // autodetecting - copy or move - check the last path - UINT uiCount=DragQueryFile((HDROP)medium.hGlobal, 0xffffffff, NULL, 0); - TCHAR szPath[_MAX_PATH]; - if (DragQueryFile((HDROP)medium.hGlobal, uiCount-1, szPath, _MAX_PATH)) - { - if (_tcsncmp(szPath, _T("\\\\"), 2) == 0) - { - TCHAR* pFnd=_tcsstr(szPath+2, _T("\\")); - - if (pFnd) - { - int iCount; - // find another - TCHAR *pSecond=_tcsstr(pFnd+1, _T("\\")); - if (pSecond) - { - iCount=pSecond-szPath; -// OTF2("Counted: %lu\r\n", iCount); - } - else - iCount=_tcslen(szPath); - - // found - compare -// OTF2("Compare %s and %s\r\n", szPath, m_szDstPath); - if (_tcsnicmp(szPath, m_szDstPath, iCount) == 0) - { -// OTF2("OP: MOVE\r\n"); - m_uiDropEffect=DE_MOVE; - } - else - { -// OTF2("OP: COPY\r\n"); - m_uiDropEffect=DE_COPY; - } - } - else - m_uiDropEffect=DE_COPY; - - } - else - { - // local path - check drive letter - if (m_szDstPath[0] == szPath[0]) - m_uiDropEffect=DE_MOVE; - else - m_uiDropEffect=DE_COPY; - } - } - else - m_uiDropEffect=DE_COPY; - } - break; - - default: - m_uiDropEffect=DE_COPY; // std copying - break; - } - - ReleaseStgMedium(&medium); - - // get operation type - UINT cf=RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT); - fe.cfFormat=(unsigned short)cf; - - // if explorer knows better - change effect - m_bExplorer=false; - hr=lpdobj->GetData(&fe, &medium); - if (SUCCEEDED(hr)) - { - // specify operation - LPVOID lpv=GlobalLock(medium.hGlobal); - if (lpv) - { - UINT uiDrop=*((DWORD*)lpv); - if (uiDrop & DROPEFFECT_MOVE) - m_uiDropEffect=DE_MOVE; - else - m_uiDropEffect=DE_COPY; - m_bExplorer=true; - -// OTF2("Detected operation %lu\r\n", m_uiDropEffect); - GlobalUnlock(medium.hGlobal); - } - - ReleaseStgMedium(&medium); - } - } - - return S_OK; -} - -STDMETHODIMP CDropMenuExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpici) -{ - // find window - HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd == NULL) - return E_FAIL; - - // commands - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - - // IPC struct - COPYDATASTRUCT cds; - cds.dwData=pCommand[LOWORD(lpici->lpVerb)].uiCommandID; // based on command's number (0-copy, 1-move, 2-special (copy), 3-special (move)) - cds.cbData=m_bBuffer.m_iDataSize; - cds.lpData=m_bBuffer.m_pszFiles; - - // send a message to ch - ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - m_bBuffer.Destroy(); - - return S_OK; -} \ No newline at end of file Index: src/chext/DropMenuExt.h =================================================================== diff -u -N --- src/chext/DropMenuExt.h (revision 0) +++ src/chext/DropMenuExt.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,82 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __DROPMENUEXT_H_ +#define __DROPMENUEXT_H_ + +#include "resource.h" // main symbols +#include "IShellExtInitImpl.h" +#include "IContextMenuImpl.h" +#include "comdef.h" +#include "..\Common\ipcstructs.h" + +///////////////////////////////////////////////////////////////////////////// +// CDropMenuExt +class ATL_NO_VTABLE CDropMenuExt : + public CComObjectRootEx, + public CComCoClass, + public IObjectWithSiteImpl, + public IDispatchImpl, + public IShellExtInitImpl, + public IContextMenuImpl +{ +public: + CDropMenuExt() + { + } +public: + class CBuffer + { + public: + CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; + void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; + ~CBuffer() { Destroy(); }; + + public: + TCHAR *m_pszFiles; + UINT m_iDataSize; + } m_bBuffer; + + TCHAR m_szDstPath[_MAX_PATH]; + UINT m_uiDropEffect; + bool m_bExplorer; // if the operation has been retrieved from explorer or from the program + +DECLARE_REGISTRY_RESOURCEID(IDR_DROPMENUEXT) +DECLARE_NOT_AGGREGATABLE(CDropMenuExt) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CDropMenuExt) + COM_INTERFACE_ENTRY(IDropMenuExt) + COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(IShellExtInit) + COM_INTERFACE_ENTRY(IContextMenu) + COM_INTERFACE_ENTRY(IObjectWithSite) +END_COM_MAP() + +// IDropMenuExt +public: + STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); + STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/); + STDMETHOD(GetCommandString)(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax); + STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags); +}; + +#endif //__DROPMENUEXT_H_ Index: chext/DropMenuExt.h =================================================================== diff -u -N --- chext/DropMenuExt.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/DropMenuExt.h (revision 0) @@ -1,82 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __DROPMENUEXT_H_ -#define __DROPMENUEXT_H_ - -#include "resource.h" // main symbols -#include "IShellExtInitImpl.h" -#include "IContextMenuImpl.h" -#include "comdef.h" -#include "..\Common\ipcstructs.h" - -///////////////////////////////////////////////////////////////////////////// -// CDropMenuExt -class ATL_NO_VTABLE CDropMenuExt : - public CComObjectRootEx, - public CComCoClass, - public IObjectWithSiteImpl, - public IDispatchImpl, - public IShellExtInitImpl, - public IContextMenuImpl -{ -public: - CDropMenuExt() - { - } -public: - class CBuffer - { - public: - CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; - void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; - ~CBuffer() { Destroy(); }; - - public: - TCHAR *m_pszFiles; - UINT m_iDataSize; - } m_bBuffer; - - TCHAR m_szDstPath[_MAX_PATH]; - UINT m_uiDropEffect; - bool m_bExplorer; // if the operation has been retrieved from explorer or from the program - -DECLARE_REGISTRY_RESOURCEID(IDR_DROPMENUEXT) -DECLARE_NOT_AGGREGATABLE(CDropMenuExt) - -DECLARE_PROTECT_FINAL_CONSTRUCT() - -BEGIN_COM_MAP(CDropMenuExt) - COM_INTERFACE_ENTRY(IDropMenuExt) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(IShellExtInit) - COM_INTERFACE_ENTRY(IContextMenu) - COM_INTERFACE_ENTRY(IObjectWithSite) -END_COM_MAP() - -// IDropMenuExt -public: - STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); - STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/); - STDMETHOD(GetCommandString)(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax); - STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags); -}; - -#endif //__DROPMENUEXT_H_ Index: src/chext/DropMenuExt.htm =================================================================== diff -u -N --- src/chext/DropMenuExt.htm (revision 0) +++ src/chext/DropMenuExt.htm (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,8 @@ + + +ATL 3.0 test page for object DropMenuExt + + + + + \ No newline at end of file Index: chext/DropMenuExt.htm =================================================================== diff -u -N --- chext/DropMenuExt.htm (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/DropMenuExt.htm (revision 0) @@ -1,8 +0,0 @@ - - -ATL 3.0 test page for object DropMenuExt - - - - - \ No newline at end of file Index: src/chext/DropMenuExt.rgs =================================================================== diff -u -N --- src/chext/DropMenuExt.rgs (revision 0) +++ src/chext/DropMenuExt.rgs (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,63 @@ +HKCR +{ + CopyHandlerShellExt.DropMenuExt.1 = s 'DropMenuExt Class' + { + CLSID = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' + } + CopyHandlerShellExt.DropMenuExt = s 'DropMenuExt Class' + { + CLSID = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' + CurVer = s 'CopyHandlerShellExt.DropMenuExt.1' + } + NoRemove CLSID + { + ForceRemove {B46F8244-86E6-43CF-B8AB-8C3A89928A48} = s 'DropMenuExt Class' + { + ProgID = s 'CopyHandlerShellExt.DropMenuExt.1' + VersionIndependentProgID = s 'CopyHandlerShellExt.DropMenuExt' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{68FAFC14-8EB8-4DA1-90EB-6B3D22010505}' + ForceRemove shellex + { + ForceRemove MayChangeDefaultMenu + } + } + } + + NoRemove Directory + { + NoRemove Shellex + { + NoRemove DragDropHandlers + { + CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' + } + } + } + + NoRemove Drive + { + NoRemove Shellex + { + NoRemove DragDropHandlers + { + CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' + } + } + } + + NoRemove Folder + { + NoRemove Shellex + { + NoRemove DragDropHandlers + { + CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' + } + } + } +} Index: chext/DropMenuExt.rgs =================================================================== diff -u -N --- chext/DropMenuExt.rgs (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/DropMenuExt.rgs (revision 0) @@ -1,63 +0,0 @@ -HKCR -{ - CopyHandlerShellExt.DropMenuExt.1 = s 'DropMenuExt Class' - { - CLSID = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' - } - CopyHandlerShellExt.DropMenuExt = s 'DropMenuExt Class' - { - CLSID = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' - CurVer = s 'CopyHandlerShellExt.DropMenuExt.1' - } - NoRemove CLSID - { - ForceRemove {B46F8244-86E6-43CF-B8AB-8C3A89928A48} = s 'DropMenuExt Class' - { - ProgID = s 'CopyHandlerShellExt.DropMenuExt.1' - VersionIndependentProgID = s 'CopyHandlerShellExt.DropMenuExt' - ForceRemove 'Programmable' - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - 'TypeLib' = s '{68FAFC14-8EB8-4DA1-90EB-6B3D22010505}' - ForceRemove shellex - { - ForceRemove MayChangeDefaultMenu - } - } - } - - NoRemove Directory - { - NoRemove Shellex - { - NoRemove DragDropHandlers - { - CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' - } - } - } - - NoRemove Drive - { - NoRemove Shellex - { - NoRemove DragDropHandlers - { - CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' - } - } - } - - NoRemove Folder - { - NoRemove Shellex - { - NoRemove DragDropHandlers - { - CopyHandlerShellExt = s '{B46F8244-86E6-43CF-B8AB-8C3A89928A48}' - } - } - } -} Index: src/chext/IContextMenuImpl.h =================================================================== diff -u -N --- src/chext/IContextMenuImpl.h (revision 0) +++ src/chext/IContextMenuImpl.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,68 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __ICONTEXTMENUIMPL_H__ +#define __ICONTEXTMENUIMPL_H__ + +// IContextMenuImpl.h +// +////////////////////////////////////////////////////////////////////// +#include +#include + + +class ATL_NO_VTABLE IContextMenuImpl : public IContextMenu3 +{ +public: + + // IUnknown + // + STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) = 0; + _ATL_DEBUG_ADDREF_RELEASE_IMPL( IContextMenuImpl ) + + + // IContextMenu + // + STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT) + { + return S_FALSE; + } + + STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO) + { + return S_FALSE; + } + + STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT , UINT, UINT) + { + return S_FALSE; + } + + STDMETHOD(HandleMenuMsg)(UINT, WPARAM, LPARAM) + { + return S_FALSE; + } + + STDMETHOD(HandleMenuMsg2)(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, LRESULT* /*plResult*/) + { + return S_FALSE; + } +}; + +#endif \ No newline at end of file Index: chext/IContextMenuImpl.h =================================================================== diff -u -N --- chext/IContextMenuImpl.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/IContextMenuImpl.h (revision 0) @@ -1,68 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __ICONTEXTMENUIMPL_H__ -#define __ICONTEXTMENUIMPL_H__ - -// IContextMenuImpl.h -// -////////////////////////////////////////////////////////////////////// -#include -#include - - -class ATL_NO_VTABLE IContextMenuImpl : public IContextMenu3 -{ -public: - - // IUnknown - // - STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) = 0; - _ATL_DEBUG_ADDREF_RELEASE_IMPL( IContextMenuImpl ) - - - // IContextMenu - // - STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT) - { - return S_FALSE; - } - - STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO) - { - return S_FALSE; - } - - STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT , UINT, UINT) - { - return S_FALSE; - } - - STDMETHOD(HandleMenuMsg)(UINT, WPARAM, LPARAM) - { - return S_FALSE; - } - - STDMETHOD(HandleMenuMsg2)(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, LRESULT* /*plResult*/) - { - return S_FALSE; - } -}; - -#endif \ No newline at end of file Index: src/chext/IShellExtInitImpl.h =================================================================== diff -u -N --- src/chext/IShellExtInitImpl.h (revision 0) +++ src/chext/IShellExtInitImpl.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,49 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __ISHELLEXTINITIMPL_H__ +#define __ISHELLEXTINITIMPL_H__ + +// IShellExtInitImpl.h +// +////////////////////////////////////////////////////////////////////// +#include +#include + + +class ATL_NO_VTABLE IShellExtInitImpl : public IShellExtInit +{ +public: + + // IUnknown + // + STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) = 0; + _ATL_DEBUG_ADDREF_RELEASE_IMPL( IShellExtInitImpl ) + + + // IShellExtInit + // + STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY) + { + return S_FALSE; + }; + +}; + +#endif \ No newline at end of file Index: chext/IShellExtInitImpl.h =================================================================== diff -u -N --- chext/IShellExtInitImpl.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/IShellExtInitImpl.h (revision 0) @@ -1,49 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __ISHELLEXTINITIMPL_H__ -#define __ISHELLEXTINITIMPL_H__ - -// IShellExtInitImpl.h -// -////////////////////////////////////////////////////////////////////// -#include -#include - - -class ATL_NO_VTABLE IShellExtInitImpl : public IShellExtInit -{ -public: - - // IUnknown - // - STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject) = 0; - _ATL_DEBUG_ADDREF_RELEASE_IMPL( IShellExtInitImpl ) - - - // IShellExtInit - // - STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY) - { - return S_FALSE; - }; - -}; - -#endif \ No newline at end of file Index: src/chext/MenuExt.cpp =================================================================== diff -u -N --- src/chext/MenuExt.cpp (revision 0) +++ src/chext/MenuExt.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,608 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "CopyHandlerShellExt.h" +#include "MenuExt.h" +#include "clipboard.h" +#include "..\Common\ipcstructs.h" +#include "..\Common\FileSupport.h" +#include "stdio.h" +#include "memory.h" +#include "StringHelpers.h" + +extern CSharedConfigStruct* g_pscsShared; + +// globals +void CutAmpersands(LPTSTR lpszString) +{ + int iOffset=0; + int iLength=_tcslen(lpszString); + for (int j=0;jitemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; + _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + + // measure the text + HWND hDesktop=GetDesktopWindow(); + HDC hDC=GetDC(hDesktop); + + // get menu logfont + NONCLIENTMETRICS ncm; + ncm.cbSize=sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); + + HFONT hFont=CreateFontIndirect(&ncm.lfMenuFont); + HFONT hOldFont=(HFONT)SelectObject(hDC, hFont); + + // calc text size + SIZE size; + GetTextExtentPoint32(hDC, pShortcuts[iShortcutIndex].szName, _tcslen(pShortcuts[iShortcutIndex].szName), &size); + + // restore old settings + SelectObject(hDC, hOldFont); + ReleaseDC(hDesktop, hDC); + + // set + lpmis->itemWidth=size.cx+GetSystemMetrics(SM_CXMENUCHECK)+2*GetSystemMetrics(SM_CXSMICON); + lpmis->itemHeight = __max(size.cy+3, GetSystemMetrics(SM_CYMENU)+3); + + break; + } + } + + return S_OK; +} + +void CMenuExt::DrawMenuItem(LPDRAWITEMSTRUCT lpdis) +{ + // check if menu + if (lpdis->CtlType != ODT_MENU) + return; + + // margins and other stuff + const int iSmallIconWidth=GetSystemMetrics(SM_CXSMICON); + const int iSmallIconHeight=GetSystemMetrics(SM_CYSMICON); + const int iLeftMargin=GetSystemMetrics(SM_CXMENUCHECK)/2; + const int iRightMargin=GetSystemMetrics(SM_CXMENUCHECK)-iLeftMargin; + + int iShortcutIndex=(lpdis->itemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; + _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + + // text color + HBRUSH hbr; + if (lpdis->itemState & ODS_SELECTED) + { + SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); + hbr=CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); + } + else + { + SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT)); + SetBkColor(lpdis->hDC, GetSysColor(COLOR_MENU)); + hbr=CreateSolidBrush(GetSysColor(COLOR_MENU)); + } + + // draw background + RECT rcSelect=lpdis->rcItem; + rcSelect.top++; + rcSelect.bottom--; + + FillRect(lpdis->hDC, &rcSelect, hbr); + DeleteObject(hbr); + + // get img list + SHFILEINFO sfi; + HIMAGELIST himl=(HIMAGELIST)SHGetFileInfo(pShortcuts[iShortcutIndex].szPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_ICON | SHGFI_SYSICONINDEX); + ImageList_Draw(himl, sfi.iIcon, lpdis->hDC, lpdis->rcItem.left+iLeftMargin, + lpdis->rcItem.top+(lpdis->rcItem.bottom-lpdis->rcItem.top+1-iSmallIconHeight)/2, ILD_TRANSPARENT); + + RECT rcText; + rcText.left=iLeftMargin+iSmallIconWidth+iRightMargin; + rcText.top=lpdis->rcItem.top; + rcText.right=lpdis->rcItem.right; + rcText.bottom=lpdis->rcItem.bottom; + +// OTF("Drawing text: %s\r\n", pShortcuts[iShortcutIndex].szName); + DrawText(lpdis->hDC, pShortcuts[iShortcutIndex].szName, -1, &rcText, DT_LEFT | DT_SINGLELINE | DT_VCENTER); +} + +STDMETHODIMP CMenuExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) +{ + // find ch window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (!hWnd) + return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); + +/* OTF("CMenuExt::QueryContextMenu - idCmdFirst=%lu, uFlags=%lu (", idCmdFirst, uFlags); + if (uFlags & CMF_CANRENAME) + OTF("CMF_CANRENAME "); + if (uFlags & CMF_DEFAULTONLY) + OTF("CMF_DEFAULTONLY "); + if (uFlags & CMF_EXPLORE) + OTF("CMF_EXPLORE "); + if (uFlags & CMF_EXTENDEDVERBS) + OTF("CMF_EXTENDEDVERBS "); + if (uFlags & CMF_INCLUDESTATIC) + OTF("CMF_INCLUDESTATIC "); + if (uFlags & CMF_NODEFAULT) + OTF("CMF_NODEFAULT "); + if (uFlags & CMF_NORMAL) + OTF("CMF_NORMAL "); + if (uFlags & CMF_NOVERBS) + OTF("CMF_NOVERBS "); + if (uFlags & CMF_VERBSONLY) + OTF("CMF_VERBSONLY "); + OTF(")\r\n"); +*/ + // remember ID of the first command + m_uiFirstID=idCmdFirst; + + // current commands count in menu + TCHAR szText[_MAX_PATH]; + int iCount=::GetMenuItemCount(hmenu); + + MENUITEMINFO mii; + mii.cbSize=sizeof(mii); + mii.fMask=MIIM_TYPE; + mii.dwTypeData=szText; + mii.cch=_MAX_PATH; + + // find a place where the commands should be inserted + for (int i=0;iszData; + + // data about commands + int iCommandCount=0; + + if (!m_bGroupFiles) + { + // paste + if (g_pscsShared->uiFlags & EC_PASTE_FLAG) + { + ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING | (IsClipboardFormatAvailable(CF_HDROP) ? MF_ENABLED : MF_GRAYED), + idCmdFirst+0, pCommand[0].szCommand); + iCommandCount++; + } + + if (g_pscsShared->uiFlags & EC_PASTESPECIAL_FLAG) + { + ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING | (IsClipboardFormatAvailable(CF_HDROP) ? MF_ENABLED : MF_GRAYED), + idCmdFirst+1, pCommand[1].szCommand); + iCommandCount++; + } + } + +// OTF("After group files\r\n"); + + if (!m_bBackground) + { + CreateShortcutsMenu(idCmdFirst+5, g_pscsShared->bShowShortcutIcons); +// OTF("after creating shortcuts menu\r\n"); + + // copy to > + if (g_pscsShared->uiFlags & EC_COPYTO_FLAG) + { + MENUITEMINFO mii; + mii.cbSize=sizeof(MENUITEMINFO); + mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; + mii.fType=MFT_STRING; + mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; + mii.wID=idCmdFirst+2; + mii.hSubMenu=m_mMenus.hShortcuts[0]; + mii.dwTypeData=pCommand[2].szCommand; + mii.cch=_tcslen(pCommand[2].szCommand); + + ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); +// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), +// (UINT)m_mMenus.hShortcuts[0], pCommand[2].szCommand); + iCommandCount++; +// OTF("added menu item\r\n"); + } + + // move to > + if (g_pscsShared->uiFlags & EC_MOVETO_FLAG) + { + MENUITEMINFO mii; + mii.cbSize=sizeof(MENUITEMINFO); + mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; + mii.fType=MFT_STRING; + mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; + mii.wID=idCmdFirst+3; + mii.hSubMenu=m_mMenus.hShortcuts[1]; + mii.dwTypeData=pCommand[3].szCommand; + mii.cch=_tcslen(pCommand[3].szCommand); + + ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); +// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), +// (UINT)m_mMenus.hShortcuts[1], pCommand[3].szCommand); + iCommandCount++; + } + + // copy/move to special... > + if (g_pscsShared->uiFlags & EC_COPYMOVETOSPECIAL_FLAG) + { + MENUITEMINFO mii; + mii.cbSize=sizeof(MENUITEMINFO); + mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; + mii.fType=MFT_STRING; + mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; + mii.wID=idCmdFirst+4; + mii.hSubMenu=m_mMenus.hShortcuts[2]; + mii.dwTypeData=pCommand[4].szCommand; + mii.cch=_tcslen(pCommand[4].szCommand); + + ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); +// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), +// (UINT)m_mMenus.hShortcuts[2], pCommand[4].szCommand); + iCommandCount++; + } + } + +// OTF("before return\r\n"); + return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)); +} + +void CMenuExt::CreateShortcutsMenu(UINT uiIDBase, bool bOwnerDrawn) +{ +// OTF("CreateShortcutsMenu\r\n"); + + // tw�rz puste menu + m_mMenus.hShortcuts[0]=CreatePopupMenu(); + m_mMenus.hShortcuts[1]=CreatePopupMenu(); + m_mMenus.hShortcuts[2]=CreatePopupMenu(); + + // fill with shortcuts + _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + TCHAR szText[256], szSize[32]; + __int64 iiFree; + + for (int i=0;iiShortcutsCount;i++) + { + // modify text + if (g_pscsShared->bShowFreeSpace && GetDynamicFreeSpace(pShortcuts[i].szPath, &iiFree, NULL)) + { + _stprintf(szText, _T("%s (%s)"), pShortcuts[i].szName, GetSizeString(iiFree, szSize)); + _tcsncpy(pShortcuts[i].szName, szText, 127); +// OTF("Text to display=%s\r\n", pShortcuts[i].szName); + pShortcuts[i].szName[127]=_T('\0'); + } + + // add to all menus + for (int j=0;j<3;j++) + ::InsertMenu(m_mMenus.hShortcuts[j], i, MF_BYPOSITION | MF_ENABLED | (bOwnerDrawn ? MF_OWNERDRAW : 0), uiIDBase+i+j*g_pscsShared->iShortcutsCount, (bOwnerDrawn ? NULL : pShortcuts[i].szName)); + } +} + +STDMETHODIMP CMenuExt::GetCommandString(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax) +{ + if (uFlags == GCS_HELPTEXTW) + { + USES_CONVERSION; + // find window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (!hWnd) + wcscpy(reinterpret_cast(pszName), L""); + + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + + switch (idCmd) + { + case 0: + case 1: + case 2: + case 3: + case 4: + wcsncpy(reinterpret_cast(pszName), A2W(pCommand[idCmd].szDesc), cchMax); + break; + default: + _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) + wcsncpy(reinterpret_cast(pszName), A2W(pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath), cchMax); + else + wcsncpy(reinterpret_cast(pszName), L"", cchMax); + } + } + if (uFlags == GCS_HELPTEXTA) + { + // find window + HWND hWnd; + hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + + if (!hWnd) + strcpy(pszName, ""); + + _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; + + switch (idCmd) + { + case 0: + case 1: + case 2: + case 3: + case 4: + strncpy(pszName, pCommand[idCmd].szDesc, cchMax); + break; + default: // rest of commands + _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) + strncpy(pszName, pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath, cchMax); + else + strncpy(pszName, "", cchMax); + } + } + + return S_OK; +} + + +STDMETHODIMP CMenuExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/) +{ + // find ch window + HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); + if (hWnd == NULL) + return E_FAIL; + + // get cfg from ch + ::SendMessage(hWnd, WM_GETCONFIG, GC_EXPLORER, 0); + + // read dest folder + m_szDstPath[0]=_T('\0'); + + // TEMP +// OTF("****************************************************************\r\n"); +// OTF("CMenuExt::Initialize: pidlFolder=%lu, lpdobj=%lu\r\n", pidlFolder, lpdobj); + + // get data from IDataObject - files to copy/move + bool bPathFound=false; + m_bGroupFiles=false; + if (lpdobj) + { + STGMEDIUM medium; + FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + + HRESULT hr = lpdobj->GetData(&fe, &medium); + if (FAILED(hr)) + return E_FAIL; + + // copy all filenames to a table + GetDataFromClipboard(static_cast(medium.hGlobal), NULL, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); + + // find the first non-empty entry + UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0); + TCHAR szPath[_MAX_PATH]; + UINT uiRes; + for (UINT i=0;iszData; + +// OTF("Invoke Command\r\n"); + // command type + switch (LOWORD(lpici->lpVerb)) + { + // paste & paste special + case 0: + case 1: + { + // search for data in a clipboard + if (IsClipboardFormatAvailable(CF_HDROP)) + { + bool bMove=false; // 0-copy, 1-move + + // get data + OpenClipboard(lpici->hwnd); + HANDLE handle=GetClipboardData(CF_HDROP); + char *pchBuffer=NULL; + UINT uiSize; + + GetDataFromClipboard(static_cast(handle), m_szDstPath, &pchBuffer, &uiSize); + + // register clipboard format nad if exists in it + UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); + if (IsClipboardFormatAvailable(nFormat)) + { + HANDLE handle=GetClipboardData(nFormat); + LPVOID addr=GlobalLock(handle); + + DWORD dwData=((DWORD*)addr)[0]; + if (dwData & DROPEFFECT_MOVE) + bMove=true; + + GlobalUnlock(handle); + } + + CloseClipboard(); + + // fill struct + COPYDATASTRUCT cds; + cds.dwData=(((DWORD)bMove) << 31) | pCommand[LOWORD(lpici->lpVerb)].uiCommandID; + cds.lpData=pchBuffer; + cds.cbData=uiSize; + + // send a message + ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); + + // delete buffer + delete [] pchBuffer; + } + } + break; + +// case 2: +// case 3: +// case 4: + default: + { + // out of range - may be a shortcut + if (LOWORD(lpici->lpVerb) < g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)) + { + // addr of a table with shortcuts + _SHORTCUT* stShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); + + // find command for which this command is generated + int iCommandIndex=(int)(((LOWORD(lpici->lpVerb)-5) / g_pscsShared->iShortcutsCount))+2; // command index + int iShortcutIndex=((LOWORD(lpici->lpVerb)-5) % g_pscsShared->iShortcutsCount); // shortcut index + + // buffer for data + UINT uiSize=_tcslen(stShortcuts[iShortcutIndex].szPath)+1+m_bBuffer.m_iDataSize; + TCHAR *pszBuffer=new TCHAR[uiSize]; + _tcscpy(pszBuffer, stShortcuts[iShortcutIndex].szPath); // �cie�ka docelowa + + // buffer with files + memcpy(pszBuffer+_tcslen(stShortcuts[iShortcutIndex].szPath)+1, m_bBuffer.m_pszFiles, m_bBuffer.m_iDataSize*sizeof(TCHAR)); + + // fill struct + COPYDATASTRUCT cds; + cds.dwData=pCommand[iCommandIndex].uiCommandID; + cds.lpData=pszBuffer; + cds.cbData=uiSize; + + // send message + ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); + + // delete bufor + delete [] pszBuffer; + m_bBuffer.Destroy(); + } + else + return E_FAIL; + } + break; + } + + return S_OK; +} Index: chext/MenuExt.cpp =================================================================== diff -u -N --- chext/MenuExt.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/MenuExt.cpp (revision 0) @@ -1,608 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "CopyHandlerShellExt.h" -#include "MenuExt.h" -#include "clipboard.h" -#include "..\Common\ipcstructs.h" -#include "..\Common\FileSupport.h" -#include "stdio.h" -#include "memory.h" -#include "StringHelpers.h" - -extern CSharedConfigStruct* g_pscsShared; - -// globals -void CutAmpersands(LPTSTR lpszString) -{ - int iOffset=0; - int iLength=_tcslen(lpszString); - for (int j=0;jitemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - - // measure the text - HWND hDesktop=GetDesktopWindow(); - HDC hDC=GetDC(hDesktop); - - // get menu logfont - NONCLIENTMETRICS ncm; - ncm.cbSize=sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); - - HFONT hFont=CreateFontIndirect(&ncm.lfMenuFont); - HFONT hOldFont=(HFONT)SelectObject(hDC, hFont); - - // calc text size - SIZE size; - GetTextExtentPoint32(hDC, pShortcuts[iShortcutIndex].szName, _tcslen(pShortcuts[iShortcutIndex].szName), &size); - - // restore old settings - SelectObject(hDC, hOldFont); - ReleaseDC(hDesktop, hDC); - - // set - lpmis->itemWidth=size.cx+GetSystemMetrics(SM_CXMENUCHECK)+2*GetSystemMetrics(SM_CXSMICON); - lpmis->itemHeight = __max(size.cy+3, GetSystemMetrics(SM_CYMENU)+3); - - break; - } - } - - return S_OK; -} - -void CMenuExt::DrawMenuItem(LPDRAWITEMSTRUCT lpdis) -{ - // check if menu - if (lpdis->CtlType != ODT_MENU) - return; - - // margins and other stuff - const int iSmallIconWidth=GetSystemMetrics(SM_CXSMICON); - const int iSmallIconHeight=GetSystemMetrics(SM_CYSMICON); - const int iLeftMargin=GetSystemMetrics(SM_CXMENUCHECK)/2; - const int iRightMargin=GetSystemMetrics(SM_CXMENUCHECK)-iLeftMargin; - - int iShortcutIndex=(lpdis->itemID-m_uiFirstID-5)%g_pscsShared->iShortcutsCount; - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - - // text color - HBRUSH hbr; - if (lpdis->itemState & ODS_SELECTED) - { - SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); - SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); - hbr=CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); - } - else - { - SetTextColor(lpdis->hDC, GetSysColor(COLOR_MENUTEXT)); - SetBkColor(lpdis->hDC, GetSysColor(COLOR_MENU)); - hbr=CreateSolidBrush(GetSysColor(COLOR_MENU)); - } - - // draw background - RECT rcSelect=lpdis->rcItem; - rcSelect.top++; - rcSelect.bottom--; - - FillRect(lpdis->hDC, &rcSelect, hbr); - DeleteObject(hbr); - - // get img list - SHFILEINFO sfi; - HIMAGELIST himl=(HIMAGELIST)SHGetFileInfo(pShortcuts[iShortcutIndex].szPath, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_SMALLICON | SHGFI_ICON | SHGFI_SYSICONINDEX); - ImageList_Draw(himl, sfi.iIcon, lpdis->hDC, lpdis->rcItem.left+iLeftMargin, - lpdis->rcItem.top+(lpdis->rcItem.bottom-lpdis->rcItem.top+1-iSmallIconHeight)/2, ILD_TRANSPARENT); - - RECT rcText; - rcText.left=iLeftMargin+iSmallIconWidth+iRightMargin; - rcText.top=lpdis->rcItem.top; - rcText.right=lpdis->rcItem.right; - rcText.bottom=lpdis->rcItem.bottom; - -// OTF("Drawing text: %s\r\n", pShortcuts[iShortcutIndex].szName); - DrawText(lpdis->hDC, pShortcuts[iShortcutIndex].szName, -1, &rcText, DT_LEFT | DT_SINGLELINE | DT_VCENTER); -} - -STDMETHODIMP CMenuExt::QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) -{ - // find ch window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (!hWnd) - return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0); - -/* OTF("CMenuExt::QueryContextMenu - idCmdFirst=%lu, uFlags=%lu (", idCmdFirst, uFlags); - if (uFlags & CMF_CANRENAME) - OTF("CMF_CANRENAME "); - if (uFlags & CMF_DEFAULTONLY) - OTF("CMF_DEFAULTONLY "); - if (uFlags & CMF_EXPLORE) - OTF("CMF_EXPLORE "); - if (uFlags & CMF_EXTENDEDVERBS) - OTF("CMF_EXTENDEDVERBS "); - if (uFlags & CMF_INCLUDESTATIC) - OTF("CMF_INCLUDESTATIC "); - if (uFlags & CMF_NODEFAULT) - OTF("CMF_NODEFAULT "); - if (uFlags & CMF_NORMAL) - OTF("CMF_NORMAL "); - if (uFlags & CMF_NOVERBS) - OTF("CMF_NOVERBS "); - if (uFlags & CMF_VERBSONLY) - OTF("CMF_VERBSONLY "); - OTF(")\r\n"); -*/ - // remember ID of the first command - m_uiFirstID=idCmdFirst; - - // current commands count in menu - TCHAR szText[_MAX_PATH]; - int iCount=::GetMenuItemCount(hmenu); - - MENUITEMINFO mii; - mii.cbSize=sizeof(mii); - mii.fMask=MIIM_TYPE; - mii.dwTypeData=szText; - mii.cch=_MAX_PATH; - - // find a place where the commands should be inserted - for (int i=0;iszData; - - // data about commands - int iCommandCount=0; - - if (!m_bGroupFiles) - { - // paste - if (g_pscsShared->uiFlags & EC_PASTE_FLAG) - { - ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING | (IsClipboardFormatAvailable(CF_HDROP) ? MF_ENABLED : MF_GRAYED), - idCmdFirst+0, pCommand[0].szCommand); - iCommandCount++; - } - - if (g_pscsShared->uiFlags & EC_PASTESPECIAL_FLAG) - { - ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_STRING | (IsClipboardFormatAvailable(CF_HDROP) ? MF_ENABLED : MF_GRAYED), - idCmdFirst+1, pCommand[1].szCommand); - iCommandCount++; - } - } - -// OTF("After group files\r\n"); - - if (!m_bBackground) - { - CreateShortcutsMenu(idCmdFirst+5, g_pscsShared->bShowShortcutIcons); -// OTF("after creating shortcuts menu\r\n"); - - // copy to > - if (g_pscsShared->uiFlags & EC_COPYTO_FLAG) - { - MENUITEMINFO mii; - mii.cbSize=sizeof(MENUITEMINFO); - mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; - mii.fType=MFT_STRING; - mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; - mii.wID=idCmdFirst+2; - mii.hSubMenu=m_mMenus.hShortcuts[0]; - mii.dwTypeData=pCommand[2].szCommand; - mii.cch=_tcslen(pCommand[2].szCommand); - - ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); -// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), -// (UINT)m_mMenus.hShortcuts[0], pCommand[2].szCommand); - iCommandCount++; -// OTF("added menu item\r\n"); - } - - // move to > - if (g_pscsShared->uiFlags & EC_MOVETO_FLAG) - { - MENUITEMINFO mii; - mii.cbSize=sizeof(MENUITEMINFO); - mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; - mii.fType=MFT_STRING; - mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; - mii.wID=idCmdFirst+3; - mii.hSubMenu=m_mMenus.hShortcuts[1]; - mii.dwTypeData=pCommand[3].szCommand; - mii.cch=_tcslen(pCommand[3].szCommand); - - ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); -// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), -// (UINT)m_mMenus.hShortcuts[1], pCommand[3].szCommand); - iCommandCount++; - } - - // copy/move to special... > - if (g_pscsShared->uiFlags & EC_COPYMOVETOSPECIAL_FLAG) - { - MENUITEMINFO mii; - mii.cbSize=sizeof(MENUITEMINFO); - mii.fMask=MIIM_ID | MIIM_STATE | MIIM_SUBMENU | MIIM_TYPE; - mii.fType=MFT_STRING; - mii.fState=(g_pscsShared->iShortcutsCount > 0) ? MFS_ENABLED : MFS_GRAYED; - mii.wID=idCmdFirst+4; - mii.hSubMenu=m_mMenus.hShortcuts[2]; - mii.dwTypeData=pCommand[4].szCommand; - mii.cch=_tcslen(pCommand[4].szCommand); - - ::InsertMenuItem(hmenu, indexMenu++, TRUE, &mii); -// ::InsertMenu(hmenu, indexMenu++, MF_BYPOSITION | MF_POPUP | MF_STRING | ((g_pscsShared->iShortcutsCount > 0) ? MF_ENABLED : MF_GRAYED), -// (UINT)m_mMenus.hShortcuts[2], pCommand[4].szCommand); - iCommandCount++; - } - } - -// OTF("before return\r\n"); - return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)); -} - -void CMenuExt::CreateShortcutsMenu(UINT uiIDBase, bool bOwnerDrawn) -{ -// OTF("CreateShortcutsMenu\r\n"); - - // tw�rz puste menu - m_mMenus.hShortcuts[0]=CreatePopupMenu(); - m_mMenus.hShortcuts[1]=CreatePopupMenu(); - m_mMenus.hShortcuts[2]=CreatePopupMenu(); - - // fill with shortcuts - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - TCHAR szText[256], szSize[32]; - __int64 iiFree; - - for (int i=0;iiShortcutsCount;i++) - { - // modify text - if (g_pscsShared->bShowFreeSpace && GetDynamicFreeSpace(pShortcuts[i].szPath, &iiFree, NULL)) - { - _stprintf(szText, _T("%s (%s)"), pShortcuts[i].szName, GetSizeString(iiFree, szSize)); - _tcsncpy(pShortcuts[i].szName, szText, 127); -// OTF("Text to display=%s\r\n", pShortcuts[i].szName); - pShortcuts[i].szName[127]=_T('\0'); - } - - // add to all menus - for (int j=0;j<3;j++) - ::InsertMenu(m_mMenus.hShortcuts[j], i, MF_BYPOSITION | MF_ENABLED | (bOwnerDrawn ? MF_OWNERDRAW : 0), uiIDBase+i+j*g_pscsShared->iShortcutsCount, (bOwnerDrawn ? NULL : pShortcuts[i].szName)); - } -} - -STDMETHODIMP CMenuExt::GetCommandString(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax) -{ - if (uFlags == GCS_HELPTEXTW) - { - USES_CONVERSION; - // find window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (!hWnd) - wcscpy(reinterpret_cast(pszName), L""); - - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - - switch (idCmd) - { - case 0: - case 1: - case 2: - case 3: - case 4: - wcsncpy(reinterpret_cast(pszName), A2W(pCommand[idCmd].szDesc), cchMax); - break; - default: - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) - wcsncpy(reinterpret_cast(pszName), A2W(pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath), cchMax); - else - wcsncpy(reinterpret_cast(pszName), L"", cchMax); - } - } - if (uFlags == GCS_HELPTEXTA) - { - // find window - HWND hWnd; - hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - - if (!hWnd) - strcpy(pszName, ""); - - _COMMAND* pCommand=(_COMMAND*)g_pscsShared->szData; - - switch (idCmd) - { - case 0: - case 1: - case 2: - case 3: - case 4: - strncpy(pszName, pCommand[idCmd].szDesc, cchMax); - break; - default: // rest of commands - _SHORTCUT* pShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - if ((int)(idCmd-5) < g_pscsShared->iShortcutsCount*3) - strncpy(pszName, pShortcuts[(idCmd-5)%g_pscsShared->iShortcutsCount].szPath, cchMax); - else - strncpy(pszName, "", cchMax); - } - } - - return S_OK; -} - - -STDMETHODIMP CMenuExt::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/) -{ - // find ch window - HWND hWnd=::FindWindow(_T("Copy Handler Wnd Class"), _T("Copy handler")); - if (hWnd == NULL) - return E_FAIL; - - // get cfg from ch - ::SendMessage(hWnd, WM_GETCONFIG, GC_EXPLORER, 0); - - // read dest folder - m_szDstPath[0]=_T('\0'); - - // TEMP -// OTF("****************************************************************\r\n"); -// OTF("CMenuExt::Initialize: pidlFolder=%lu, lpdobj=%lu\r\n", pidlFolder, lpdobj); - - // get data from IDataObject - files to copy/move - bool bPathFound=false; - m_bGroupFiles=false; - if (lpdobj) - { - STGMEDIUM medium; - FORMATETC fe = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; - - HRESULT hr = lpdobj->GetData(&fe, &medium); - if (FAILED(hr)) - return E_FAIL; - - // copy all filenames to a table - GetDataFromClipboard(static_cast(medium.hGlobal), NULL, &m_bBuffer.m_pszFiles, &m_bBuffer.m_iDataSize); - - // find the first non-empty entry - UINT fileCount = DragQueryFile((HDROP)medium.hGlobal, 0xFFFFFFFF, NULL, 0); - TCHAR szPath[_MAX_PATH]; - UINT uiRes; - for (UINT i=0;iszData; - -// OTF("Invoke Command\r\n"); - // command type - switch (LOWORD(lpici->lpVerb)) - { - // paste & paste special - case 0: - case 1: - { - // search for data in a clipboard - if (IsClipboardFormatAvailable(CF_HDROP)) - { - bool bMove=false; // 0-copy, 1-move - - // get data - OpenClipboard(lpici->hwnd); - HANDLE handle=GetClipboardData(CF_HDROP); - char *pchBuffer=NULL; - UINT uiSize; - - GetDataFromClipboard(static_cast(handle), m_szDstPath, &pchBuffer, &uiSize); - - // register clipboard format nad if exists in it - UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect")); - if (IsClipboardFormatAvailable(nFormat)) - { - HANDLE handle=GetClipboardData(nFormat); - LPVOID addr=GlobalLock(handle); - - DWORD dwData=((DWORD*)addr)[0]; - if (dwData & DROPEFFECT_MOVE) - bMove=true; - - GlobalUnlock(handle); - } - - CloseClipboard(); - - // fill struct - COPYDATASTRUCT cds; - cds.dwData=(((DWORD)bMove) << 31) | pCommand[LOWORD(lpici->lpVerb)].uiCommandID; - cds.lpData=pchBuffer; - cds.cbData=uiSize; - - // send a message - ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - // delete buffer - delete [] pchBuffer; - } - } - break; - -// case 2: -// case 3: -// case 4: - default: - { - // out of range - may be a shortcut - if (LOWORD(lpici->lpVerb) < g_pscsShared->iCommandCount+(m_bBackground ? 0 : 3*g_pscsShared->iShortcutsCount)) - { - // addr of a table with shortcuts - _SHORTCUT* stShortcuts=(_SHORTCUT*)(g_pscsShared->szData+g_pscsShared->iCommandCount*sizeof(_COMMAND)); - - // find command for which this command is generated - int iCommandIndex=(int)(((LOWORD(lpici->lpVerb)-5) / g_pscsShared->iShortcutsCount))+2; // command index - int iShortcutIndex=((LOWORD(lpici->lpVerb)-5) % g_pscsShared->iShortcutsCount); // shortcut index - - // buffer for data - UINT uiSize=_tcslen(stShortcuts[iShortcutIndex].szPath)+1+m_bBuffer.m_iDataSize; - TCHAR *pszBuffer=new TCHAR[uiSize]; - _tcscpy(pszBuffer, stShortcuts[iShortcutIndex].szPath); // �cie�ka docelowa - - // buffer with files - memcpy(pszBuffer+_tcslen(stShortcuts[iShortcutIndex].szPath)+1, m_bBuffer.m_pszFiles, m_bBuffer.m_iDataSize*sizeof(TCHAR)); - - // fill struct - COPYDATASTRUCT cds; - cds.dwData=pCommand[iCommandIndex].uiCommandID; - cds.lpData=pszBuffer; - cds.cbData=uiSize; - - // send message - ::SendMessage(hWnd, WM_COPYDATA, reinterpret_cast(lpici->hwnd), reinterpret_cast(&cds)); - - // delete bufor - delete [] pszBuffer; - m_bBuffer.Destroy(); - } - else - return E_FAIL; - } - break; - } - - return S_OK; -} Index: src/chext/MenuExt.h =================================================================== diff -u -N --- src/chext/MenuExt.h (revision 0) +++ src/chext/MenuExt.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,113 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __MENUEXT_H_ +#define __MENUEXT_H_ + +#include "resource.h" // main symbols +#include "comdef.h" +#include +#include + +#include "IShellExtInitImpl.h" +#include "IContextMenuImpl.h" + +/////// +// globals +void CutAmpersands(LPTSTR lpszString); + +///////////////////////////////////////////////////////////////////////////// +// CMenuExt +class ATL_NO_VTABLE CMenuExt : + public CComObjectRootEx, + public CComCoClass, + public IObjectWithSiteImpl, + public IDispatchImpl, + public IShellExtInitImpl, + public IContextMenuImpl +{ +public: + CMenuExt() + { + } +public: + // class for making sure memory is freed + class CBuffer + { + public: + CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; + void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; + ~CBuffer() { Destroy(); }; + + public: + TCHAR *m_pszFiles; + UINT m_iDataSize; + } m_bBuffer; + + TCHAR m_szDstPath[_MAX_PATH]; + + // for making sure DestroyMenu would be called + class CSubMenus + { + public: + CSubMenus() { hShortcuts[0]=NULL; hShortcuts[1]=NULL; hShortcuts[2]=NULL; }; + void Destroy() { for (int i=0;i<3;i++) { if (hShortcuts[i] != NULL) DestroyMenu(hShortcuts[i]); } }; + ~CSubMenus() { Destroy(); }; + + public: + HMENU hShortcuts[3]; + } m_mMenus; + + bool m_bBackground; // folder or folder background + bool m_bGroupFiles; // if the group of files have a files in it + + UINT m_uiFirstID; // first menu ID + bool m_bShown; // have the menu been already shown ?czy pokazano ju� menu + +DECLARE_REGISTRY_RESOURCEID(IDR_MENUEXT) +DECLARE_NOT_AGGREGATABLE(CMenuExt) + +DECLARE_PROTECT_FINAL_CONSTRUCT() + +BEGIN_COM_MAP(CMenuExt) + COM_INTERFACE_ENTRY(IMenuExt) + COM_INTERFACE_ENTRY(IDispatch) + COM_INTERFACE_ENTRY(IShellExtInit) + COM_INTERFACE_ENTRY(IContextMenu) + COM_INTERFACE_ENTRY(IContextMenu2) + COM_INTERFACE_ENTRY(IContextMenu3) + COM_INTERFACE_ENTRY(IObjectWithSite) +END_COM_MAP() + +// IMenuExt +public: + STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/); + STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); + STDMETHOD(GetCommandString)(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax); + STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/); + STDMETHOD(HandleMenuMsg)(UINT uMsg, WPARAM wParam, LPARAM lParam); + STDMETHOD(HandleMenuMsg2)(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult); + +protected: + void DrawMenuItem(LPDRAWITEMSTRUCT lpdis); + void CreateShortcutsMenu(UINT uiIDBase, bool bOwnerDrawn); +}; + +#endif //__MENUEXT_H_ Index: chext/MenuExt.h =================================================================== diff -u -N --- chext/MenuExt.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/MenuExt.h (revision 0) @@ -1,113 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __MENUEXT_H_ -#define __MENUEXT_H_ - -#include "resource.h" // main symbols -#include "comdef.h" -#include -#include - -#include "IShellExtInitImpl.h" -#include "IContextMenuImpl.h" - -/////// -// globals -void CutAmpersands(LPTSTR lpszString); - -///////////////////////////////////////////////////////////////////////////// -// CMenuExt -class ATL_NO_VTABLE CMenuExt : - public CComObjectRootEx, - public CComCoClass, - public IObjectWithSiteImpl, - public IDispatchImpl, - public IShellExtInitImpl, - public IContextMenuImpl -{ -public: - CMenuExt() - { - } -public: - // class for making sure memory is freed - class CBuffer - { - public: - CBuffer() { m_pszFiles=NULL; m_iDataSize=0; }; - void Destroy() { delete [] m_pszFiles; m_pszFiles=NULL; m_iDataSize=0; }; - ~CBuffer() { Destroy(); }; - - public: - TCHAR *m_pszFiles; - UINT m_iDataSize; - } m_bBuffer; - - TCHAR m_szDstPath[_MAX_PATH]; - - // for making sure DestroyMenu would be called - class CSubMenus - { - public: - CSubMenus() { hShortcuts[0]=NULL; hShortcuts[1]=NULL; hShortcuts[2]=NULL; }; - void Destroy() { for (int i=0;i<3;i++) { if (hShortcuts[i] != NULL) DestroyMenu(hShortcuts[i]); } }; - ~CSubMenus() { Destroy(); }; - - public: - HMENU hShortcuts[3]; - } m_mMenus; - - bool m_bBackground; // folder or folder background - bool m_bGroupFiles; // if the group of files have a files in it - - UINT m_uiFirstID; // first menu ID - bool m_bShown; // have the menu been already shown ?czy pokazano ju� menu - -DECLARE_REGISTRY_RESOURCEID(IDR_MENUEXT) -DECLARE_NOT_AGGREGATABLE(CMenuExt) - -DECLARE_PROTECT_FINAL_CONSTRUCT() - -BEGIN_COM_MAP(CMenuExt) - COM_INTERFACE_ENTRY(IMenuExt) - COM_INTERFACE_ENTRY(IDispatch) - COM_INTERFACE_ENTRY(IShellExtInit) - COM_INTERFACE_ENTRY(IContextMenu) - COM_INTERFACE_ENTRY(IContextMenu2) - COM_INTERFACE_ENTRY(IContextMenu3) - COM_INTERFACE_ENTRY(IObjectWithSite) -END_COM_MAP() - -// IMenuExt -public: - STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY /*hkeyProgID*/); - STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); - STDMETHOD(GetCommandString)(UINT idCmd, UINT uFlags, UINT* /*pwReserved*/, LPSTR pszName, UINT cchMax); - STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/); - STDMETHOD(HandleMenuMsg)(UINT uMsg, WPARAM wParam, LPARAM lParam); - STDMETHOD(HandleMenuMsg2)(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plResult); - -protected: - void DrawMenuItem(LPDRAWITEMSTRUCT lpdis); - void CreateShortcutsMenu(UINT uiIDBase, bool bOwnerDrawn); -}; - -#endif //__MENUEXT_H_ Index: src/chext/MenuExt.htm =================================================================== diff -u -N --- src/chext/MenuExt.htm (revision 0) +++ src/chext/MenuExt.htm (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,8 @@ + + +ATL 3.0 test page for object MenuExt + + + + + \ No newline at end of file Index: chext/MenuExt.htm =================================================================== diff -u -N --- chext/MenuExt.htm (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/MenuExt.htm (revision 0) @@ -1,8 +0,0 @@ - - -ATL 3.0 test page for object MenuExt - - - - - \ No newline at end of file Index: src/chext/MenuExt.rgs =================================================================== diff -u -N --- src/chext/MenuExt.rgs (revision 0) +++ src/chext/MenuExt.rgs (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,74 @@ +HKCR +{ + CopyHandlerShellExt.MenuExt.1 = s 'MenuExt Class' + { + CLSID = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + } + CopyHandlerShellExt.MenuExt = s 'MenuExt Class' + { + CLSID = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + CurVer = s 'CopyHandlerShellExt.MenuExt.1' + } + NoRemove CLSID + { + ForceRemove {E7A4C2DA-F3AF-4145-AC19-E3B215306A54} = s 'MenuExt Class' + { + ProgID = s 'CopyHandlerShellExt.MenuExt.1' + VersionIndependentProgID = s 'CopyHandlerShellExt.MenuExt' + ForceRemove 'Programmable' + InprocServer32 = s '%MODULE%' + { + val ThreadingModel = s 'Apartment' + } + 'TypeLib' = s '{68FAFC14-8EB8-4DA1-90EB-6B3D22010505}' + } + } + + NoRemove Directory + { + NoRemove Shellex + { + NoRemove ContextMenuHandlers + { + CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + } + } + } + + NoRemove Directory + { + NoRemove Background + { + NoRemove Shellex + { + NoRemove ContextMenuHandlers + { + CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + } + } + } + } + + NoRemove Folder + { + NoRemove Shellex + { + NoRemove ContextMenuHandlers + { + CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + } + } + } + + NoRemove * + { + NoRemove Shellex + { + NoRemove ContextMenuHandlers + { + CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' + } + } + } + +} Index: chext/MenuExt.rgs =================================================================== diff -u -N --- chext/MenuExt.rgs (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/MenuExt.rgs (revision 0) @@ -1,74 +0,0 @@ -HKCR -{ - CopyHandlerShellExt.MenuExt.1 = s 'MenuExt Class' - { - CLSID = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - } - CopyHandlerShellExt.MenuExt = s 'MenuExt Class' - { - CLSID = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - CurVer = s 'CopyHandlerShellExt.MenuExt.1' - } - NoRemove CLSID - { - ForceRemove {E7A4C2DA-F3AF-4145-AC19-E3B215306A54} = s 'MenuExt Class' - { - ProgID = s 'CopyHandlerShellExt.MenuExt.1' - VersionIndependentProgID = s 'CopyHandlerShellExt.MenuExt' - ForceRemove 'Programmable' - InprocServer32 = s '%MODULE%' - { - val ThreadingModel = s 'Apartment' - } - 'TypeLib' = s '{68FAFC14-8EB8-4DA1-90EB-6B3D22010505}' - } - } - - NoRemove Directory - { - NoRemove Shellex - { - NoRemove ContextMenuHandlers - { - CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - } - } - } - - NoRemove Directory - { - NoRemove Background - { - NoRemove Shellex - { - NoRemove ContextMenuHandlers - { - CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - } - } - } - } - - NoRemove Folder - { - NoRemove Shellex - { - NoRemove ContextMenuHandlers - { - CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - } - } - } - - NoRemove * - { - NoRemove Shellex - { - NoRemove ContextMenuHandlers - { - CopyHandlerShellExt = s '{E7A4C2DA-F3AF-4145-AC19-E3B215306A54}' - } - } - } - -} Index: src/chext/StdAfx.cpp =================================================================== diff -u -N --- src/chext/StdAfx.cpp (revision 0) +++ src/chext/StdAfx.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,28 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#include "stdafx.h" + +#ifdef _ATL_STATIC_REGISTRY +#include +//#include +#endif + +//#include Index: chext/StdAfx.cpp =================================================================== diff -u -N --- chext/StdAfx.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/StdAfx.cpp (revision 0) @@ -1,28 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#include "stdafx.h" - -#ifdef _ATL_STATIC_REGISTRY -#include -//#include -#endif - -//#include Index: src/chext/StdAfx.h =================================================================== diff -u -N --- src/chext/StdAfx.h (revision 0) +++ src/chext/StdAfx.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,43 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +#ifndef __STDAFX_H__ +#define __STDAFX_H__ + +#define STRICT +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0400 +#endif +#define _ATL_APARTMENT_THREADED + +// include for MFC Support +//#include +//#include + +#include +//You may derive a class from CComModule and use it if you want to override +//something, but do not change the name of _Module +extern CComModule _Module; +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif Index: chext/StdAfx.h =================================================================== diff -u -N --- chext/StdAfx.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/StdAfx.h (revision 0) @@ -1,43 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -#ifndef __STDAFX_H__ -#define __STDAFX_H__ - -#define STRICT -#ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0400 -#endif -#define _ATL_APARTMENT_THREADED - -// include for MFC Support -//#include -//#include - -#include -//You may derive a class from CComModule and use it if you want to override -//something, but do not change the name of _Module -extern CComModule _Module; -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif Index: src/chext/StringHelpers.cpp =================================================================== diff -u -N --- src/chext/StringHelpers.cpp (revision 0) +++ src/chext/StringHelpers.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,39 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "StringHelpers.h" +#include "stdio.h" + +LPTSTR GetSizeString(double dData, LPTSTR pszBuffer) +{ + if (dData < 0.0) + dData=0.0; + + if (dData < 1200.0) + _stprintf(pszBuffer, _T("%.2f %s"), dData, g_pscsShared->szSizes[0]); + else if (dData < 1228800.0) + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1024.0, g_pscsShared->szSizes[1]); + else if (dData < 1258291200.0) + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1048576.0, g_pscsShared->szSizes[2]); + else + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1073741824.0, g_pscsShared->szSizes[3]); + + return pszBuffer; +} Index: chext/StringHelpers.cpp =================================================================== diff -u -N --- chext/StringHelpers.cpp (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/StringHelpers.cpp (revision 0) @@ -1,39 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#include "stdafx.h" -#include "StringHelpers.h" -#include "stdio.h" - -LPTSTR GetSizeString(double dData, LPTSTR pszBuffer) -{ - if (dData < 0.0) - dData=0.0; - - if (dData < 1200.0) - _stprintf(pszBuffer, _T("%.2f %s"), dData, g_pscsShared->szSizes[0]); - else if (dData < 1228800.0) - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1024.0, g_pscsShared->szSizes[1]); - else if (dData < 1258291200.0) - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1048576.0, g_pscsShared->szSizes[2]); - else - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(dData)/1073741824.0, g_pscsShared->szSizes[3]); - - return pszBuffer; -} Index: src/chext/StringHelpers.h =================================================================== diff -u -N --- src/chext/StringHelpers.h (revision 0) +++ src/chext/StringHelpers.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,56 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#ifndef __STRINGHELPERS_H__ +#define __STRINGHELPERS_H__ + +#include "..\common\ipcstructs.h" + +extern CSharedConfigStruct* g_pscsShared; + +LPTSTR GetSizeString(double dData, LPTSTR pszBuffer); + +template LPTSTR GetSizeString(T tData, LPTSTR pszBuffer, bool bStrict=false) +{ + if (tData < 0) + tData=0; + + if (tData >= 1258291200 && (!bStrict || (tData % 1073741824) == 0)) + { + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1073741824.0, g_pscsShared->szSizes[3]); + return pszBuffer; + } + else if (tData >= 1228800 && (!bStrict || (tData % 1048576) == 0)) + { + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1048576.0, g_pscsShared->szSizes[2]); + return pszBuffer; + } + else if (tData >= 1200 && (!bStrict || (tData % 1024) == 0)) + { + _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1024.0, g_pscsShared->szSizes[1]); + return pszBuffer; + } + else + { + _stprintf(pszBuffer, _T("%d %s"), tData, g_pscsShared->szSizes[0]); + return pszBuffer; + } +} + +#endif Index: chext/StringHelpers.h =================================================================== diff -u -N --- chext/StringHelpers.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/StringHelpers.h (revision 0) @@ -1,56 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ -#ifndef __STRINGHELPERS_H__ -#define __STRINGHELPERS_H__ - -#include "..\common\ipcstructs.h" - -extern CSharedConfigStruct* g_pscsShared; - -LPTSTR GetSizeString(double dData, LPTSTR pszBuffer); - -template LPTSTR GetSizeString(T tData, LPTSTR pszBuffer, bool bStrict=false) -{ - if (tData < 0) - tData=0; - - if (tData >= 1258291200 && (!bStrict || (tData % 1073741824) == 0)) - { - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1073741824.0, g_pscsShared->szSizes[3]); - return pszBuffer; - } - else if (tData >= 1228800 && (!bStrict || (tData % 1048576) == 0)) - { - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1048576.0, g_pscsShared->szSizes[2]); - return pszBuffer; - } - else if (tData >= 1200 && (!bStrict || (tData % 1024) == 0)) - { - _stprintf(pszBuffer, _T("%.2f %s"), static_cast(tData)/1024.0, g_pscsShared->szSizes[1]); - return pszBuffer; - } - else - { - _stprintf(pszBuffer, _T("%d %s"), tData, g_pscsShared->szSizes[0]); - return pszBuffer; - } -} - -#endif Index: src/chext/chext.cpp =================================================================== diff -u -N --- src/chext/chext.cpp (revision 0) +++ src/chext/chext.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,115 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f CopyHandlerShellExtps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include +#include "CopyHandlerShellExt.h" + +#include "CopyHandlerShellExt_i.c" +#include "MenuExt.h" +#include "DropMenuExt.h" + +CComModule _Module; + +// common memory - exactly 64kB +CSharedConfigStruct* g_pscsShared; +static HANDLE hMapObject=NULL; + +BEGIN_OBJECT_MAP(ObjectMap) +OBJECT_ENTRY(CLSID_MenuExt, CMenuExt) +OBJECT_ENTRY(CLSID_DropMenuExt, CDropMenuExt) +END_OBJECT_MAP() + +///////////////////////////////////////////////////////////////////////////// +// DLL Entry Point + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + if (dwReason == DLL_PROCESS_ATTACH) + { + _Module.Init(ObjectMap, hInstance, &LIBID_COPYHANDLERSHELLEXTLib); + DisableThreadLibraryCalls(hInstance); + + // memory mapped file + hMapObject = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); // name of map object + if (hMapObject == NULL) + return FALSE; + + // The first process to attach initializes memory. +// bool bInit = (GetLastError() != ERROR_ALREADY_EXISTS); + + // Get a pointer to the file-mapped shared memory. + g_pscsShared = (CSharedConfigStruct*)MapViewOfFile(hMapObject, FILE_MAP_WRITE, 0, 0, 0); + if (g_pscsShared == NULL) + return FALSE; + } + else if (dwReason == DLL_PROCESS_DETACH) + { + // Unmap shared memory from the process's address space. + UnmapViewOfFile((LPVOID)g_pscsShared); + + // Close the process's handle to the file-mapping object. + CloseHandle(hMapObject); + + _Module.Term(); + } + return TRUE; // ok +} + +///////////////////////////////////////////////////////////////////////////// +// Used to determine whether the DLL can be unloaded by OLE + +STDAPI DllCanUnloadNow(void) +{ + return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; +} + +///////////////////////////////////////////////////////////////////////////// +// Returns a class factory to create an object of the requested type + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + return _Module.GetClassObject(rclsid, riid, ppv); +} + +///////////////////////////////////////////////////////////////////////////// +// DllRegisterServer - Adds entries to the system registry + +STDAPI DllRegisterServer(void) +{ + // registers object, typelib and all interfaces in typelib + return _Module.RegisterServer(TRUE); +} + +///////////////////////////////////////////////////////////////////////////// +// DllUnregisterServer - Removes entries from the system registry + +STDAPI DllUnregisterServer(void) +{ + return _Module.UnregisterServer(TRUE); +} + + Index: chext/chext.cpp =================================================================== diff -u -N --- chext/chext.cpp (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chext.cpp (revision 0) @@ -1,115 +0,0 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ - -// Note: Proxy/Stub Information -// To build a separate proxy/stub DLL, -// run nmake -f CopyHandlerShellExtps.mk in the project directory. - -#include "stdafx.h" -#include "resource.h" -#include -#include "CopyHandlerShellExt.h" - -#include "CopyHandlerShellExt_i.c" -#include "MenuExt.h" -#include "DropMenuExt.h" - -CComModule _Module; - -// common memory - exactly 64kB -CSharedConfigStruct* g_pscsShared; -static HANDLE hMapObject=NULL; - -BEGIN_OBJECT_MAP(ObjectMap) -OBJECT_ENTRY(CLSID_MenuExt, CMenuExt) -OBJECT_ENTRY(CLSID_DropMenuExt, CDropMenuExt) -END_OBJECT_MAP() - -///////////////////////////////////////////////////////////////////////////// -// DLL Entry Point - -extern "C" -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) -{ - if (dwReason == DLL_PROCESS_ATTACH) - { - _Module.Init(ObjectMap, hInstance, &LIBID_COPYHANDLERSHELLEXTLib); - DisableThreadLibraryCalls(hInstance); - - // memory mapped file - hMapObject = CreateFileMapping((HANDLE)0xFFFFFFFF, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); // name of map object - if (hMapObject == NULL) - return FALSE; - - // The first process to attach initializes memory. -// bool bInit = (GetLastError() != ERROR_ALREADY_EXISTS); - - // Get a pointer to the file-mapped shared memory. - g_pscsShared = (CSharedConfigStruct*)MapViewOfFile(hMapObject, FILE_MAP_WRITE, 0, 0, 0); - if (g_pscsShared == NULL) - return FALSE; - } - else if (dwReason == DLL_PROCESS_DETACH) - { - // Unmap shared memory from the process's address space. - UnmapViewOfFile((LPVOID)g_pscsShared); - - // Close the process's handle to the file-mapping object. - CloseHandle(hMapObject); - - _Module.Term(); - } - return TRUE; // ok -} - -///////////////////////////////////////////////////////////////////////////// -// Used to determine whether the DLL can be unloaded by OLE - -STDAPI DllCanUnloadNow(void) -{ - return (_Module.GetLockCount()==0) ? S_OK : S_FALSE; -} - -///////////////////////////////////////////////////////////////////////////// -// Returns a class factory to create an object of the requested type - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) -{ - return _Module.GetClassObject(rclsid, riid, ppv); -} - -///////////////////////////////////////////////////////////////////////////// -// DllRegisterServer - Adds entries to the system registry - -STDAPI DllRegisterServer(void) -{ - // registers object, typelib and all interfaces in typelib - return _Module.RegisterServer(TRUE); -} - -///////////////////////////////////////////////////////////////////////////// -// DllUnregisterServer - Removes entries from the system registry - -STDAPI DllUnregisterServer(void) -{ - return _Module.UnregisterServer(TRUE); -} - - Index: src/chext/chext.def =================================================================== diff -u -N --- src/chext/chext.def (revision 0) +++ src/chext/chext.def (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,9 @@ +; CopyHandlerShellExt.def : Declares the module parameters. + +LIBRARY "chext.dll" + +EXPORTS + DllCanUnloadNow PRIVATE + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE Index: chext/chext.def =================================================================== diff -u -N --- chext/chext.def (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chext.def (revision 0) @@ -1,9 +0,0 @@ -; CopyHandlerShellExt.def : Declares the module parameters. - -LIBRARY "chext.dll" - -EXPORTS - DllCanUnloadNow PRIVATE - DllGetClassObject PRIVATE - DllRegisterServer PRIVATE - DllUnregisterServer PRIVATE Index: src/chext/chext.idl =================================================================== diff -u -N --- src/chext/chext.idl (revision 0) +++ src/chext/chext.idl (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,65 @@ +// CopyHandlerShellExt.idl : IDL source for CopyHandlerShellExt.dll +// + +// This file will be processed by the MIDL tool to +// produce the type library (CopyHandlerShellExt.tlb) and marshalling code. + +import "oaidl.idl"; +import "ocidl.idl"; + [ + object, + uuid(413AA618-E769-4E6E-A610-7BDC8A189FB2), + dual, + helpstring("IMenuExt Interface"), + pointer_default(unique) + ] + interface IMenuExt : IDispatch + { +// [id(1), helpstring("method QueryContextMenu")] HRESULT QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); +// [id(1), helpstring("method GetCommandString")] HRESULT GetCommandString(UINT idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); +// [id(2), helpstring("method InvokeCommand")] HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO lpici); +// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); +// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); + }; + [ + object, + uuid(4AEAD637-8A55-47B9-AA1A-DACEA3DE9B71), + dual, + helpstring("IDropMenuExt Interface"), + pointer_default(unique) + ] + interface IDropMenuExt : IDispatch + { +// [id(1), helpstring("method QueryContextMenu")] HRESULT QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); +// [id(1), helpstring("method GetCommandString")] HRESULT GetCommandString(UINT idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); +// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); +// [id(1), helpstring("method InvokeCommand")] HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO lpici); + }; + +[ + uuid(68FAFC14-8EB8-4DA1-90EB-6B3D22010505), + version(1.0), + helpstring("CopyHandlerShellExt 1.0 Type Library") +] +library COPYHANDLERSHELLEXTLib +{ + importlib("stdole32.tlb"); + importlib("stdole2.tlb"); + + [ + uuid(E7A4C2DA-F3AF-4145-AC19-E3B215306A54), + helpstring("MenuExt Class") + ] + coclass MenuExt + { + [default] interface IMenuExt; + }; + [ + uuid(B46F8244-86E6-43CF-B8AB-8C3A89928A48), + helpstring("DropMenuExt Class") + ] + coclass DropMenuExt + { + [default] interface IDropMenuExt; + }; +}; Index: chext/chext.idl =================================================================== diff -u -N --- chext/chext.idl (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chext.idl (revision 0) @@ -1,65 +0,0 @@ -// CopyHandlerShellExt.idl : IDL source for CopyHandlerShellExt.dll -// - -// This file will be processed by the MIDL tool to -// produce the type library (CopyHandlerShellExt.tlb) and marshalling code. - -import "oaidl.idl"; -import "ocidl.idl"; - [ - object, - uuid(413AA618-E769-4E6E-A610-7BDC8A189FB2), - dual, - helpstring("IMenuExt Interface"), - pointer_default(unique) - ] - interface IMenuExt : IDispatch - { -// [id(1), helpstring("method QueryContextMenu")] HRESULT QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); -// [id(1), helpstring("method GetCommandString")] HRESULT GetCommandString(UINT idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); -// [id(2), helpstring("method InvokeCommand")] HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO lpici); -// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); -// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); - }; - [ - object, - uuid(4AEAD637-8A55-47B9-AA1A-DACEA3DE9B71), - dual, - helpstring("IDropMenuExt Interface"), - pointer_default(unique) - ] - interface IDropMenuExt : IDispatch - { -// [id(1), helpstring("method QueryContextMenu")] HRESULT QueryContextMenu(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); -// [id(1), helpstring("method GetCommandString")] HRESULT GetCommandString(UINT idCmd, UINT uFlags, UINT *pwReserved, LPSTR pszName, UINT cchMax); -// [id(1), helpstring("method Initialize")] HRESULT Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT lpdobj, HKEY hkeyProgID); -// [id(1), helpstring("method InvokeCommand")] HRESULT InvokeCommand(LPCMINVOKECOMMANDINFO lpici); - }; - -[ - uuid(68FAFC14-8EB8-4DA1-90EB-6B3D22010505), - version(1.0), - helpstring("CopyHandlerShellExt 1.0 Type Library") -] -library COPYHANDLERSHELLEXTLib -{ - importlib("stdole32.tlb"); - importlib("stdole2.tlb"); - - [ - uuid(E7A4C2DA-F3AF-4145-AC19-E3B215306A54), - helpstring("MenuExt Class") - ] - coclass MenuExt - { - [default] interface IMenuExt; - }; - [ - uuid(B46F8244-86E6-43CF-B8AB-8C3A89928A48), - helpstring("DropMenuExt Class") - ] - coclass DropMenuExt - { - [default] interface IDropMenuExt; - }; -}; Index: src/chext/chext.rc =================================================================== diff -u -N --- src/chext/chext.rc (revision 0) +++ src/chext/chext.rc (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,114 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Polish resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) +#ifdef _WIN32 +LANGUAGE LANG_POLISH, SUBLANG_DEFAULT +#pragma code_page(1250) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "1 TYPELIB ""CopyHandlerShellExt.tlb""\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,28,20,207 + PRODUCTVERSION 1,28,20,207 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x29L +#else + FILEFLAGS 0x28L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "Copy handler Shell Extension" + VALUE "FileDescription", "CopyHandlerShellExt Module version" + VALUE "FileVersion", "1.28.20.207" + VALUE "InternalName", "CopyHandlerShellExt" + VALUE "LegalCopyright", "Copyright 2001-2006 J�zef Starosczyk" + VALUE "LegalTrademarks", " " + VALUE "OLESelfRegister", " " + VALUE "OriginalFilename", "CopyHandlerShellExt.DLL" + VALUE "PrivateBuild", " " + VALUE "ProductName", "CopyHandlerShellExt Shell Extension Library version" + VALUE "ProductVersion", "1.28.20.207" + VALUE "SpecialBuild", " " + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// REGISTRY +// + +IDR_MENUEXT REGISTRY "MenuExt.rgs" +IDR_DROPMENUEXT REGISTRY "DropMenuExt.rgs" +#endif // Polish resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// +1 TYPELIB "CopyHandlerShellExt.tlb" + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + Index: chext/chext.rc =================================================================== diff -u -N --- chext/chext.rc (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chext.rc (revision 0) @@ -1,114 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Polish resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) -#ifdef _WIN32 -LANGUAGE LANG_POLISH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "1 TYPELIB ""CopyHandlerShellExt.tlb""\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,28,20,207 - PRODUCTVERSION 1,28,20,207 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x29L -#else - FILEFLAGS 0x28L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "Copy handler Shell Extension" - VALUE "FileDescription", "CopyHandlerShellExt Module version" - VALUE "FileVersion", "1.28.20.207" - VALUE "InternalName", "CopyHandlerShellExt" - VALUE "LegalCopyright", "Copyright 2001-2006 J�zef Starosczyk" - VALUE "LegalTrademarks", " " - VALUE "OLESelfRegister", " " - VALUE "OriginalFilename", "CopyHandlerShellExt.DLL" - VALUE "PrivateBuild", " " - VALUE "ProductName", "CopyHandlerShellExt Shell Extension Library version" - VALUE "ProductVersion", "1.28.20.207" - VALUE "SpecialBuild", " " - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// REGISTRY -// - -IDR_MENUEXT REGISTRY "MenuExt.rgs" -IDR_DROPMENUEXT REGISTRY "DropMenuExt.rgs" -#endif // Polish resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -1 TYPELIB "CopyHandlerShellExt.tlb" - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - Index: src/chext/chext.vcproj =================================================================== diff -u -N --- src/chext/chext.vcproj (revision 0) +++ src/chext/chext.vcproj (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: chext/chext.vcproj =================================================================== diff -u -N --- chext/chext.vcproj (revision c6290a462071d2be616e833d9f4fbf804c63a149) +++ chext/chext.vcproj (revision 0) @@ -1,374 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Index: src/chext/chextps.def =================================================================== diff -u -N --- src/chext/chextps.def (revision 0) +++ src/chext/chextps.def (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,11 @@ + +LIBRARY "CopyHandlerShellExtPS" + +DESCRIPTION 'Proxy/Stub DLL' + +EXPORTS + DllGetClassObject @1 PRIVATE + DllCanUnloadNow @2 PRIVATE + GetProxyDllInfo @3 PRIVATE + DllRegisterServer @4 PRIVATE + DllUnregisterServer @5 PRIVATE Index: chext/chextps.def =================================================================== diff -u -N --- chext/chextps.def (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chextps.def (revision 0) @@ -1,11 +0,0 @@ - -LIBRARY "CopyHandlerShellExtPS" - -DESCRIPTION 'Proxy/Stub DLL' - -EXPORTS - DllGetClassObject @1 PRIVATE - DllCanUnloadNow @2 PRIVATE - GetProxyDllInfo @3 PRIVATE - DllRegisterServer @4 PRIVATE - DllUnregisterServer @5 PRIVATE Index: src/chext/chextps.mk =================================================================== diff -u -N --- src/chext/chextps.mk (revision 0) +++ src/chext/chextps.mk (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,16 @@ + +CopyHandlerShellExtps.dll: dlldata.obj CopyHandlerShellExt_p.obj CopyHandlerShellExt_i.obj + link /dll /out:CopyHandlerShellExtps.dll /def:CopyHandlerShellExtps.def /entry:DllMain dlldata.obj CopyHandlerShellExt_p.obj CopyHandlerShellExt_i.obj \ + kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \ + +.c.obj: + cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \ + $< + +clean: + @del CopyHandlerShellExtps.dll + @del CopyHandlerShellExtps.lib + @del CopyHandlerShellExtps.exp + @del dlldata.obj + @del CopyHandlerShellExt_p.obj + @del CopyHandlerShellExt_i.obj Index: chext/chextps.mk =================================================================== diff -u -N --- chext/chextps.mk (revision 8de412e22bd023e3f2a146ea3921eeaef0f5f1bd) +++ chext/chextps.mk (revision 0) @@ -1,16 +0,0 @@ - -CopyHandlerShellExtps.dll: dlldata.obj CopyHandlerShellExt_p.obj CopyHandlerShellExt_i.obj - link /dll /out:CopyHandlerShellExtps.dll /def:CopyHandlerShellExtps.def /entry:DllMain dlldata.obj CopyHandlerShellExt_p.obj CopyHandlerShellExt_i.obj \ - kernel32.lib rpcndr.lib rpcns4.lib rpcrt4.lib oleaut32.lib uuid.lib \ - -.c.obj: - cl /c /Ox /DWIN32 /D_WIN32_WINNT=0x0400 /DREGISTER_PROXY_DLL \ - $< - -clean: - @del CopyHandlerShellExtps.dll - @del CopyHandlerShellExtps.lib - @del CopyHandlerShellExtps.exp - @del dlldata.obj - @del CopyHandlerShellExt_p.obj - @del CopyHandlerShellExt_i.obj Index: src/chext/clipboard.cpp =================================================================== diff -u -N --- src/chext/clipboard.cpp (revision 0) +++ src/chext/clipboard.cpp (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,53 @@ +/************************************************************************ + Copy Handler 1.x - program for copying data in Microsoft Windows + systems. + Copyright (C) 2001-2004 Ixen Gerthannes (copyhandler@o2.pl) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*************************************************************************/ +#include "stdafx.h" +#include "clipboard.h" + +void GetDataFromClipboard(HDROP hdrop, LPCTSTR pszDstPath, LPTSTR *pszBuffer, UINT* pSize) +{ + // get clipboard data + UINT uiBufferSize=(pszDstPath == NULL) ? 0 : _tcslen(pszDstPath)+1; + UINT uiFilesCount=DragQueryFile(hdrop, 0xffffffff, NULL, 0); + + // count size + for (UINT i=0;i + +#ifdef __cplusplus +extern "C" { +#endif + +EXTERN_PROXY_FILE( CopyHandlerShellExt ) + + +PROXYFILE_LIST_START +/* Start of list */ + REFERENCE_PROXY_FILE( CopyHandlerShellExt ), +/* End of list */ +PROXYFILE_LIST_END + + +DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID ) + +#ifdef __cplusplus +} /*extern "C" */ +#endif + +/* end of generated dlldata file */ Index: chext/dlldata.c =================================================================== diff -u -N --- chext/dlldata.c (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/dlldata.c (revision 0) @@ -1,38 +0,0 @@ -/********************************************************* - DllData file -- generated by MIDL compiler - - DO NOT ALTER THIS FILE - - This file is regenerated by MIDL on every IDL file compile. - - To completely reconstruct this file, delete it and rerun MIDL - on all the IDL files in this DLL, specifying this file for the - /dlldata command line option - -*********************************************************/ - -#define PROXY_DELEGATION - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -EXTERN_PROXY_FILE( CopyHandlerShellExt ) - - -PROXYFILE_LIST_START -/* Start of list */ - REFERENCE_PROXY_FILE( CopyHandlerShellExt ), -/* End of list */ -PROXYFILE_LIST_END - - -DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID ) - -#ifdef __cplusplus -} /*extern "C" */ -#endif - -/* end of generated dlldata file */ Index: src/chext/resource.h =================================================================== diff -u -N --- src/chext/resource.h (revision 0) +++ src/chext/resource.h (revision 3493e9fc470285b0a0b417d50be281467a071eb7) @@ -0,0 +1,27 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by CopyHandlerShellExt.rc +// +#define IDS_COPYBYCH_STRING 1 +#define IDS_MOVEBYCH_STRING 2 +#define IDS_SPECIALCOPYMOVE_STRING 3 +#define IDS_COPYBYCHDESC_STRING 4 +#define IDS_MOVEBYCHDESC_STRING 5 +#define IDS_COPYMOVESPECIALDESC_STRING 6 +#define IDS_PASTEBYCH_STRING 7 +#define IDS_PASTEBYCHSPECIAL_STRING 8 +#define IDS_PASTEBYCHDESC_STRING 9 +#define IDS_PASTEBYCHSPECDESC_STRING 10 +#define IDR_MENUEXT 102 +#define IDR_DROPMENUEXT 103 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_COMMAND_VALUE 32768 +#define _APS_NEXT_CONTROL_VALUE 201 +#define _APS_NEXT_SYMED_VALUE 104 +#endif +#endif Index: chext/resource.h =================================================================== diff -u -N --- chext/resource.h (revision 6472716fec44f80b223922d89f269e365aeaba60) +++ chext/resource.h (revision 0) @@ -1,27 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by CopyHandlerShellExt.rc -// -#define IDS_COPYBYCH_STRING 1 -#define IDS_MOVEBYCH_STRING 2 -#define IDS_SPECIALCOPYMOVE_STRING 3 -#define IDS_COPYBYCHDESC_STRING 4 -#define IDS_MOVEBYCHDESC_STRING 5 -#define IDS_COPYMOVESPECIALDESC_STRING 6 -#define IDS_PASTEBYCH_STRING 7 -#define IDS_PASTEBYCHSPECIAL_STRING 8 -#define IDS_PASTEBYCHDESC_STRING 9 -#define IDS_PASTEBYCHSPECDESC_STRING 10 -#define IDR_MENUEXT 102 -#define IDR_DROPMENUEXT 103 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_COMMAND_VALUE 32768 -#define _APS_NEXT_CONTROL_VALUE 201 -#define _APS_NEXT_SYMED_VALUE 104 -#endif -#endif