From c99f3ebdd639c2adb03d8b44001b10af18516504 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Mon, 17 Aug 2009 00:00:00 +0000 Subject: 9.06 beta --- CPP/7zip/UI/FileManager/AboutDialog.cpp | 36 +- CPP/7zip/UI/FileManager/AboutDialog.rc | 47 +- CPP/7zip/UI/FileManager/AboutDialogRes.h | 2 +- CPP/7zip/UI/FileManager/App.cpp | 181 ++----- CPP/7zip/UI/FileManager/App.h | 181 +++---- CPP/7zip/UI/FileManager/BrowseDialog.cpp | 514 +++++++++++++++++++ CPP/7zip/UI/FileManager/BrowseDialog.h | 77 +++ CPP/7zip/UI/FileManager/BrowseDialog.rc | 17 + CPP/7zip/UI/FileManager/BrowseDialogRes.h | 4 + CPP/7zip/UI/FileManager/ClassDefs.cpp | 8 +- CPP/7zip/UI/FileManager/ComboDialog.cpp | 19 + CPP/7zip/UI/FileManager/ComboDialog.h | 8 +- CPP/7zip/UI/FileManager/ComboDialog.rc | 27 +- CPP/7zip/UI/FileManager/ComboDialogRes.h | 2 +- CPP/7zip/UI/FileManager/CopyDialog.cpp | 58 ++- CPP/7zip/UI/FileManager/CopyDialog.h | 11 +- CPP/7zip/UI/FileManager/CopyDialog.rc | 37 +- CPP/7zip/UI/FileManager/CopyDialogRes.h | 2 +- CPP/7zip/UI/FileManager/DialogSize.h | 16 + CPP/7zip/UI/FileManager/EditPage.cpp | 49 +- CPP/7zip/UI/FileManager/EditPage.h | 7 +- CPP/7zip/UI/FileManager/EditPage.rc | 19 +- CPP/7zip/UI/FileManager/EditPageRes.h | 2 +- CPP/7zip/UI/FileManager/ExtractCallback.cpp | 85 ++- CPP/7zip/UI/FileManager/ExtractCallback.h | 44 +- CPP/7zip/UI/FileManager/FM.cpp | 271 +++++----- CPP/7zip/UI/FileManager/FM.dsp | 114 +++-- CPP/7zip/UI/FileManager/FSFolder.cpp | 133 ++--- CPP/7zip/UI/FileManager/FSFolder.h | 6 +- CPP/7zip/UI/FileManager/FSFolderCopy.cpp | 42 +- CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp | 26 +- CPP/7zip/UI/FileManager/FilePlugins.cpp | 19 +- CPP/7zip/UI/FileManager/FoldersPage.cpp | 151 ++++++ CPP/7zip/UI/FileManager/FoldersPage.h | 29 ++ CPP/7zip/UI/FileManager/FoldersPage.rc | 23 + CPP/7zip/UI/FileManager/FoldersPage2.rc | 16 + CPP/7zip/UI/FileManager/FoldersPageRes.h | 13 + CPP/7zip/UI/FileManager/HelpUtils.cpp | 8 +- CPP/7zip/UI/FileManager/LangPage.cpp | 41 +- CPP/7zip/UI/FileManager/LangPage.h | 7 +- CPP/7zip/UI/FileManager/LangPage.rc | 36 +- CPP/7zip/UI/FileManager/LangPageRes.h | 4 +- CPP/7zip/UI/FileManager/ListViewDialog.cpp | 70 ++- CPP/7zip/UI/FileManager/ListViewDialog.h | 10 +- CPP/7zip/UI/FileManager/ListViewDialog.rc | 26 +- CPP/7zip/UI/FileManager/ListViewDialogRes.h | 5 +- CPP/7zip/UI/FileManager/MenuPage.cpp | 200 ++++++++ CPP/7zip/UI/FileManager/MenuPage.h | 25 + CPP/7zip/UI/FileManager/MenuPage.rc | 24 + CPP/7zip/UI/FileManager/MenuPage2.rc | 14 + CPP/7zip/UI/FileManager/MenuPageRes.h | 7 + CPP/7zip/UI/FileManager/MessagesDialog.cpp | 39 +- CPP/7zip/UI/FileManager/MessagesDialog.h | 9 +- CPP/7zip/UI/FileManager/MessagesDialog.rc | 27 +- CPP/7zip/UI/FileManager/MyLoadMenu.cpp | 305 +++++------ CPP/7zip/UI/FileManager/MyLoadMenu.h | 5 +- CPP/7zip/UI/FileManager/OpenCallback.cpp | 23 +- CPP/7zip/UI/FileManager/OpenCallback.h | 6 +- CPP/7zip/UI/FileManager/OptionsDialog.cpp | 116 ++++- CPP/7zip/UI/FileManager/OverwriteDialog.cpp | 45 +- CPP/7zip/UI/FileManager/OverwriteDialog.h | 51 +- CPP/7zip/UI/FileManager/OverwriteDialog.rc | 103 ++-- CPP/7zip/UI/FileManager/OverwriteDialogRes.h | 5 +- CPP/7zip/UI/FileManager/Panel.cpp | 167 +++--- CPP/7zip/UI/FileManager/Panel.h | 64 ++- CPP/7zip/UI/FileManager/PanelCopy.cpp | 115 +++-- CPP/7zip/UI/FileManager/PanelCrc.cpp | 437 +++++++--------- CPP/7zip/UI/FileManager/PanelDrag.cpp | 13 +- CPP/7zip/UI/FileManager/PanelFolderChange.cpp | 81 ++- CPP/7zip/UI/FileManager/PanelItemOpen.cpp | 224 ++++---- CPP/7zip/UI/FileManager/PanelItems.cpp | 16 +- CPP/7zip/UI/FileManager/PanelListNotify.cpp | 56 +- CPP/7zip/UI/FileManager/PanelMenu.cpp | 42 +- CPP/7zip/UI/FileManager/PanelOperations.cpp | 134 ++--- CPP/7zip/UI/FileManager/PanelSelect.cpp | 11 +- CPP/7zip/UI/FileManager/PanelSplitFile.cpp | 306 +++++------ CPP/7zip/UI/FileManager/PasswordDialog.cpp | 7 +- CPP/7zip/UI/FileManager/PasswordDialog.rc | 26 +- CPP/7zip/UI/FileManager/PluginLoader.h | 12 +- CPP/7zip/UI/FileManager/PluginsPage.cpp | 31 +- CPP/7zip/UI/FileManager/PluginsPage.rc | 20 +- CPP/7zip/UI/FileManager/PluginsPageRes.h | 2 +- CPP/7zip/UI/FileManager/ProgramLocation.cpp | 3 +- CPP/7zip/UI/FileManager/ProgramLocation.h | 4 +- CPP/7zip/UI/FileManager/ProgressDialog.cpp | 114 +++-- CPP/7zip/UI/FileManager/ProgressDialog.h | 111 ++-- CPP/7zip/UI/FileManager/ProgressDialog.rc | 18 +- CPP/7zip/UI/FileManager/ProgressDialog2.cpp | 625 ++++++++++++++++++++--- CPP/7zip/UI/FileManager/ProgressDialog2.h | 186 +++++-- CPP/7zip/UI/FileManager/ProgressDialog2.rc | 82 +-- CPP/7zip/UI/FileManager/ProgressDialog2Res.h | 19 +- CPP/7zip/UI/FileManager/ProgressDialog2a.rc | 78 +++ CPP/7zip/UI/FileManager/PropertyName.cpp | 4 +- CPP/7zip/UI/FileManager/RegistryAssociations.cpp | 49 +- CPP/7zip/UI/FileManager/RegistryAssociations.h | 2 + CPP/7zip/UI/FileManager/RegistryPlugins.cpp | 71 ++- CPP/7zip/UI/FileManager/RegistryUtils.cpp | 6 +- CPP/7zip/UI/FileManager/RegistryUtils.h | 3 +- CPP/7zip/UI/FileManager/RootFolder.cpp | 52 +- CPP/7zip/UI/FileManager/RootFolder.h | 8 +- CPP/7zip/UI/FileManager/SettingsPage.cpp | 18 +- CPP/7zip/UI/FileManager/SettingsPage.rc | 51 +- CPP/7zip/UI/FileManager/SettingsPage2.rc | 24 + CPP/7zip/UI/FileManager/SettingsPageRes.h | 4 +- CPP/7zip/UI/FileManager/SplitDialog.cpp | 39 +- CPP/7zip/UI/FileManager/SplitDialog.h | 7 +- CPP/7zip/UI/FileManager/SplitDialog.rc | 34 +- CPP/7zip/UI/FileManager/SplitDialogRes.h | 1 - CPP/7zip/UI/FileManager/SplitUtils.cpp | 3 +- CPP/7zip/UI/FileManager/SysIconUtils.cpp | 97 ++-- CPP/7zip/UI/FileManager/SysIconUtils.h | 52 +- CPP/7zip/UI/FileManager/SystemPage.cpp | 21 +- CPP/7zip/UI/FileManager/SystemPage.h | 7 +- CPP/7zip/UI/FileManager/SystemPage.rc | 42 +- CPP/7zip/UI/FileManager/SystemPageRes.h | 3 +- CPP/7zip/UI/FileManager/UpdateCallback100.cpp | 40 +- CPP/7zip/UI/FileManager/UpdateCallback100.h | 42 +- CPP/7zip/UI/FileManager/ViewSettings.cpp | 88 +--- CPP/7zip/UI/FileManager/ViewSettings.h | 20 +- CPP/7zip/UI/FileManager/makefile | 50 +- CPP/7zip/UI/FileManager/resource.h | 10 +- CPP/7zip/UI/FileManager/resource.rc | 67 +-- CPP/7zip/UI/FileManager/resourceGui.h | 10 + CPP/7zip/UI/FileManager/resourceGui.rc | 13 + 124 files changed, 4770 insertions(+), 2679 deletions(-) create mode 100755 CPP/7zip/UI/FileManager/BrowseDialog.cpp create mode 100755 CPP/7zip/UI/FileManager/BrowseDialog.h create mode 100755 CPP/7zip/UI/FileManager/BrowseDialog.rc create mode 100755 CPP/7zip/UI/FileManager/BrowseDialogRes.h create mode 100755 CPP/7zip/UI/FileManager/DialogSize.h create mode 100755 CPP/7zip/UI/FileManager/FoldersPage.cpp create mode 100755 CPP/7zip/UI/FileManager/FoldersPage.h create mode 100755 CPP/7zip/UI/FileManager/FoldersPage.rc create mode 100755 CPP/7zip/UI/FileManager/FoldersPage2.rc create mode 100755 CPP/7zip/UI/FileManager/FoldersPageRes.h create mode 100755 CPP/7zip/UI/FileManager/MenuPage.cpp create mode 100755 CPP/7zip/UI/FileManager/MenuPage.h create mode 100755 CPP/7zip/UI/FileManager/MenuPage.rc create mode 100755 CPP/7zip/UI/FileManager/MenuPage2.rc create mode 100755 CPP/7zip/UI/FileManager/MenuPageRes.h create mode 100755 CPP/7zip/UI/FileManager/ProgressDialog2a.rc create mode 100755 CPP/7zip/UI/FileManager/SettingsPage2.rc create mode 100755 CPP/7zip/UI/FileManager/resourceGui.h create mode 100755 CPP/7zip/UI/FileManager/resourceGui.rc (limited to 'CPP/7zip/UI/FileManager') diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp index a450a765..edfa98ba 100755 --- a/CPP/7zip/UI/FileManager/AboutDialog.cpp +++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp @@ -2,7 +2,6 @@ #include "StdAfx.h" -#include "AboutDialogRes.h" #include "AboutDialog.h" #include "HelpUtils.h" #include "LangUtils.h" @@ -18,15 +17,17 @@ static CIDLangPair kIDLangPairs[] = #define MY_HOME_PAGE TEXT("http://www.7-zip.org/") static LPCTSTR kHomePageURL = MY_HOME_PAGE; +/* static LPCTSTR kRegisterPageURL = MY_HOME_PAGE TEXT("register.html"); static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html"); - +*/ static LPCWSTR kHelpTopic = L"start.htm"; bool CAboutDialog::OnInit() { LangSetWindowText(HWND(*this), 0x01000100); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + NormalizePosition(); return CModalDialog::OnInit(); } @@ -35,26 +36,29 @@ void CAboutDialog::OnHelp() ShowHelpWindow(NULL, kHelpTopic); } -static void MyShellExecute(LPCTSTR url) -{ - ::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL); -} - bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { + LPCTSTR url; switch(buttonID) { - case IDC_ABOUT_BUTTON_HOMEPAGE: - ::MyShellExecute(kHomePageURL); - break; - case IDC_ABOUT_BUTTON_REGISTER: - ::MyShellExecute(kRegisterPageURL); - break; - case IDC_ABOUT_BUTTON_SUPPORT: - ::MyShellExecute(kSupportPageURL); - break; + case IDC_ABOUT_BUTTON_HOMEPAGE: url = kHomePageURL; break; + /* + case IDC_ABOUT_BUTTON_REGISTER: url = kRegisterPageURL; break; + case IDC_ABOUT_BUTTON_SUPPORT: url = kSupportPageURL; break; + */ default: return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + + #ifdef UNDER_CE + SHELLEXECUTEINFO s; + memset(&s, 0, sizeof(s)); + s.cbSize = sizeof(s); + s.lpFile = url; + ::ShellExecuteEx(&s); + #else + ::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL); + #endif + return true; } diff --git a/CPP/7zip/UI/FileManager/AboutDialog.rc b/CPP/7zip/UI/FileManager/AboutDialog.rc index 7e2438ff..d8f923a7 100755 --- a/CPP/7zip/UI/FileManager/AboutDialog.rc +++ b/CPP/7zip/UI/FileManager/AboutDialog.rc @@ -2,40 +2,25 @@ #include "../../GuiCommon.rc" #include "../../MyVersion.h" -#define xSize2 224 -#define ySize2 158 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 144 +#define yc 144 -#define bXPos (xSize - marg - bXSize) -#define bYPos (ySize - marg - bYSize) +#define y 80 -#undef b2XSize -#undef b2XPos -#undef infoYPos -#undef infoYSize +IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico" -#define b2XSize 94 -#define b2XPos (xSize - marg - b2XSize) -#define gSpace 2 -#define gSize (xSize2 - gSpace - b2XSize) +#ifndef SS_REALSIZEIMAGE +#define SS_REALSIZEIMAGE 0x800 +#endif -#define infoYPos 91 -#define infoYSize (ySize2 - infoYPos - bYSize - 2) - -IDI_LOGO ICON "7zipLogo.ico" - -IDD_ABOUT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_ABOUT MY_DIALOG CAPTION "About 7-Zip" -MY_FONT -BEGIN - PUSHBUTTON "OK", IDOK, bXPos, bYPos, bXSize, bYSize - PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, b2XPos, 7, b2XSize, bYSize - PUSHBUTTON "Support", IDC_ABOUT_BUTTON_SUPPORT, b2XPos, 30, b2XSize, bYSize - PUSHBUTTON "Register", IDC_ABOUT_BUTTON_REGISTER, b2XPos, 53, b2XSize, bYSize - ICON IDI_LOGO, -1, marg, marg, 20, 20, SS_REALSIZEIMAGE - LTEXT MY_7ZIP_VERSION, -1, marg, 54, gSize, 9 - LTEXT MY_COPYRIGHT, -1, marg, 67, gSize, 17 +{ + DEFPUSHBUTTON "OK", IDOK, bx1, by, bxs, bys + PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, bx2, by, bxs, bys + ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE + LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8 + LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8 LTEXT "7-Zip is free software. However, you can support development of 7-Zip by registering.", - IDC_ABOUT_STATIC_REGISTER_INFO, marg, infoYPos, xSize2, infoYSize -END + IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1) +} diff --git a/CPP/7zip/UI/FileManager/AboutDialogRes.h b/CPP/7zip/UI/FileManager/AboutDialogRes.h index 54475484..f7dd0602 100755 --- a/CPP/7zip/UI/FileManager/AboutDialogRes.h +++ b/CPP/7zip/UI/FileManager/AboutDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_ABOUT 100 +#define IDD_ABOUT 507 #define IDI_LOGO 138 #define IDC_ABOUT_STATIC_REGISTER_INFO 1010 #define IDC_ABOUT_BUTTON_HOMEPAGE 1020 diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 21942065..184d6ca0 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -71,15 +71,14 @@ void CApp::SetListSettings() extendedStyle |= LVS_EX_GRIDLINES; bool mySelectionMode = ReadAlternativeSelection(); - /* if (ReadSingleClick()) { - extendedStyle |= LVS_EX_ONECLICKACTIVATE - | LVS_EX_TRACKSELECT; + extendedStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT; + /* if (ReadUnderline()) extendedStyle |= LVS_EX_UNDERLINEHOT; + */ } - */ for (int i = 0; i < kNumPanelsMax; i++) { @@ -104,6 +103,10 @@ void CApp::SetShowSystemMenu() ShowSystemMenu = ReadShowSystemMenu(); } +#ifndef ILC_COLOR32 +#define ILC_COLOR32 0x0020 +#endif + HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted) { if (PanelsCreated[panelIndex]) @@ -124,24 +127,23 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &arch return S_OK; } -static void CreateToolbar( - HWND parent, +static void CreateToolbar(HWND parent, NWindows::NControl::CImageList &imageList, NWindows::NControl::CToolBar &toolBar, - bool LargeButtons) + bool largeButtons) { - toolBar.Attach(::CreateWindowEx(0, - TOOLBARCLASSNAME, - NULL, 0 + toolBar.Attach(::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, 0 + | WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS - | WS_CHILD - | CCS_NOPARENTALIGN - | CCS_NORESIZE - | CCS_NODIVIDER + | TBSTYLE_WRAPABLE // | TBSTYLE_AUTOSIZE - // | CCS_ADJUSTABLE + // | CCS_NORESIZE + #ifdef UNDER_CE + | CCS_NODIVIDER + | CCS_NOPARENTALIGN + #endif ,0,0,0,0, parent, NULL, g_hInstance, NULL)); // TB_BUTTONSTRUCTSIZE message, which is required for @@ -149,8 +151,8 @@ static void CreateToolbar( toolBar.ButtonStructSize(); imageList.Create( - LargeButtons ? 48: 24, - LargeButtons ? 36: 24, + largeButtons ? 48: 24, + largeButtons ? 36: 24, ILC_MASK | ILC_COLOR32, 0, 0); toolBar.SetImageList(0, imageList); } @@ -162,7 +164,7 @@ struct CButtonInfo UINT Bitmap2ResID; UINT StringResID; UInt32 LangID; - UString GetText() const { return LangString(StringResID, LangID); }; + UString GetText() const { return LangString(StringResID, LangID); } }; static CButtonInfo g_StandardButtons[] = @@ -206,17 +208,13 @@ static void SetButtonText(int commandID, UString &s) static void AddButton( NControl::CImageList &imageList, NControl::CToolBar &toolBar, - CButtonInfo &butInfo, - bool showText, - bool large) + CButtonInfo &butInfo, bool showText, bool large) { TBBUTTON but; but.iBitmap = 0; but.idCommand = butInfo.CommandID; but.fsState = TBSTATE_ENABLED; - but.fsStyle = BTNS_BUTTON - // | BTNS_AUTOSIZE - ; + but.fsStyle = TBSTYLE_BUTTON; but.dwData = 0; UString s = butInfo.GetText(); @@ -241,110 +239,54 @@ static void AddButton( #endif } -static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar) -{ - SIZE size; - toolBar.GetMaxSize(&size); - - RECT rect; - toolBar.GetWindowRect(&rect); - - REBARBANDINFO rbBand; - rbBand.cbSize = sizeof(REBARBANDINFO); // Required - rbBand.fMask = RBBIM_STYLE - | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; - rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER; - rbBand.cxMinChild = size.cx; // rect.right - rect.left; - rbBand.cyMinChild = size.cy; // rect.bottom - rect.top; - rbBand.cyChild = rbBand.cyMinChild; - rbBand.cx = rbBand.cxMinChild; - rbBand.cxIdeal = rbBand.cxMinChild; - rbBand.hwndChild = toolBar; - reBar.InsertBand(-1, &rbBand); -} - void CApp::ReloadToolbars() { - if (!_rebar) - return; - HWND parent = _rebar; - - while (_rebar.GetBandCount() > 0) - _rebar.DeleteBand(0); - - _archiveToolBar.Destroy(); - _archiveButtonsImageList.Destroy(); + _buttonsImageList.Destroy(); + _toolBar.Destroy(); - _standardButtonsImageList.Destroy(); - _standardToolBar.Destroy(); - if (ShowArchiveToolbar) + if (ShowArchiveToolbar || ShowStandardToolbar) { - CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons); - for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) - AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i], - ShowButtonsLables, LargeButtons); - AddBand(_rebar, _archiveToolBar); - } - - if (ShowStandardToolbar) - { - CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons); - for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) - AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i], - ShowButtonsLables, LargeButtons); - AddBand(_rebar, _standardToolBar); + CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons); + int i; + if (ShowArchiveToolbar) + for (i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) + AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons); + if (ShowStandardToolbar) + for (i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) + AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons); + + _toolBar.AutoSize(); } } -void CApp::ReloadRebar(HWND hwnd) +void CApp::SaveToolbarChanges() { - _rebar.Destroy(); - if (!ShowArchiveToolbar && !ShowStandardToolbar) - return; - if (g_ComCtl32Version >= MAKELONG(71, 4)) - { - INITCOMMONCONTROLSEX icex; - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; - InitCommonControlsEx(&icex); - - _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW, - REBARCLASSNAME, - NULL, - WS_VISIBLE - | WS_BORDER - | WS_CHILD - | WS_CLIPCHILDREN - | WS_CLIPSIBLINGS - // | CCS_NODIVIDER - // | CCS_NOPARENTALIGN // it's bead for moveing of two bands - // | CCS_TOP - | RBS_VARHEIGHT - | RBS_BANDBORDERS - // | RBS_AUTOSIZE - ,0,0,0,0, hwnd, NULL, g_hInstance, NULL)); - } - if (_rebar == 0) - return; - REBARINFO rbi; - rbi.cbSize = sizeof(REBARINFO); // Required when using this struct. - rbi.fMask = 0; - rbi.himl = (HIMAGELIST)NULL; - _rebar.SetBarInfo(&rbi); + SaveToolbar(); ReloadToolbars(); + MoveSubWindows(); } +void MyLoadMenu(); + HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted) { + _window.Attach(hwnd); + #ifdef UNDER_CE + _commandBar.Create(g_hInstance, hwnd, 1); + #endif + MyLoadMenu(); + #ifdef UNDER_CE + _commandBar.AutoSize(); + #endif + ReadToolbar(); - ReloadRebar(hwnd); + ReloadToolbars(); int i; for (i = 0; i < kNumPanelsMax; i++) PanelsCreated[i] = false; - _window.Attach(hwnd); AppState.Read(); SetListSettings(); SetShowSystemMenu(); @@ -380,8 +322,6 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &ar return S_OK; } -extern void MoveSubWindows(HWND hWnd); - HRESULT CApp::SwitchOnOffOnePanel() { if (NumPanels == 1) @@ -398,7 +338,7 @@ HRESULT CApp::SwitchOnOffOnePanel() Panels[1 - LastFocusedPanel].Enable(false); Panels[1 - LastFocusedPanel].Show(SW_HIDE); } - MoveSubWindows(_window); + MoveSubWindows(); return S_OK; } @@ -647,14 +587,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) destPath = srcPanel._currentFolderPrefix + destPath; } + #ifndef UNDER_CE if (destPath.Length() > 0 && destPath[0] == '\\') if (destPath.Length() == 1 || destPath[1] != '\\') { srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } + #endif - if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind(WCHAR_PATH_SEPARATOR) == destPath.Length() - 1) || + if (indices.Size() > 1 || (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) || NFind::DoesDirExist(destPath)) { NDirectory::CreateComplexDirectory(destPath); @@ -831,26 +773,13 @@ int CApp::GetFocusedPanelIndex() const hwnd = GetParent(hwnd); } } - */ +*/ static UString g_ToolTipBuffer; static CSysString g_ToolTipBufferSys; void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh) { - if (pnmh->hwndFrom == _rebar) - { - switch(pnmh->code) - { - case RBN_HEIGHTCHANGE: - { - MoveSubWindows(g_HWND); - return; - } - } - return ; - } - else { if (pnmh->code == TTN_GETDISPINFO) { diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h index 1fc77138..d2ced9ba 100755 --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -3,10 +3,12 @@ #ifndef __APP_H #define __APP_H -#include "Panel.h" -#include "AppState.h" +#include "Windows/Control/CommandBar.h" #include "Windows/Control/ImageList.h" +#include "AppState.h" +#include "Panel.h" + class CApp; extern CApp g_App; @@ -14,8 +16,6 @@ extern HWND g_HWND; const int kNumPanelsMax = 2; -extern void MoveSubWindows(HWND hWnd); - enum { kAddCommand = kToolbarStartID, @@ -77,12 +77,10 @@ class CDropTarget: public: MY_UNKNOWN_IMP1_MT(IDropTarget) - STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, - POINTL pt, DWORD *effect); + STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect); STDMETHOD(DragLeave)(); - STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, - POINTL pt, DWORD *effect); + STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); CDropTarget(): TargetPanelIndex(-1), @@ -119,16 +117,18 @@ public: CPanel Panels[kNumPanelsMax]; bool PanelsCreated[kNumPanelsMax]; - NWindows::NControl::CImageList _archiveButtonsImageList; - NWindows::NControl::CImageList _standardButtonsImageList; + NWindows::NControl::CImageList _buttonsImageList; - NWindows::NControl::CReBar _rebar; - NWindows::NControl::CToolBar _archiveToolBar; - NWindows::NControl::CToolBar _standardToolBar; + #ifdef UNDER_CE + NWindows::NControl::CCommandBar _commandBar; + #endif + NWindows::NControl::CToolBar _toolBar; CDropTarget *_dropTargetSpec; CMyComPtr _dropTarget; + CApp(): _window(0), NumPanels(2), LastFocusedPanel(0) {} + void CreateDragTarget() { _dropTargetSpec = new CDropTarget(); @@ -165,94 +165,53 @@ public: void Save(); void Release(); - - /* - void SetFocus(int panelIndex) - { Panels[panelIndex].SetFocusToList(); } - */ - void SetFocusToLastItem() - { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); } - + // void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); } + void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); } int GetFocusedPanelIndex() const { return LastFocusedPanel; } - bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); } - - /* - void SetCurrentIndex() - { CurrentPanel = GetFocusedPanelIndex(); } - */ - - CApp(): NumPanels(2), LastFocusedPanel(0) {} - CPanel &GetFocusedPanel() - { return Panels[GetFocusedPanelIndex()]; } + CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; } // File Menu - void OpenItem() - { GetFocusedPanel().OpenSelectedItems(true); } - void OpenItemInside() - { GetFocusedPanel().OpenFocusedItemAsInternal(); } - void OpenItemOutside() - { GetFocusedPanel().OpenSelectedItems(false); } - void EditItem() - { GetFocusedPanel().EditItem(); } - void Rename() - { GetFocusedPanel().RenameFile(); } - void CopyTo() - { OnCopy(false, false, GetFocusedPanelIndex()); } - void MoveTo() - { OnCopy(true, false, GetFocusedPanelIndex()); } - void Delete(bool toRecycleBin) - { GetFocusedPanel().DeleteItems(toRecycleBin); } + void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); } + void OpenItemInside() { GetFocusedPanel().OpenFocusedItemAsInternal(); } + void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); } + void EditItem() { GetFocusedPanel().EditItem(); } + void Rename() { GetFocusedPanel().RenameFile(); } + void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); } + void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); } + void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); } void CalculateCrc(); void DiffFiles(); void Split(); void Combine(); - void Properties() - { GetFocusedPanel().Properties(); } - void Comment() - { GetFocusedPanel().ChangeComment(); } + void Properties() { GetFocusedPanel().Properties(); } + void Comment() { GetFocusedPanel().ChangeComment(); } - void CreateFolder() - { GetFocusedPanel().CreateFolder(); } - void CreateFile() - { GetFocusedPanel().CreateFile(); } + void CreateFolder() { GetFocusedPanel().CreateFolder(); } + void CreateFile() { GetFocusedPanel().CreateFile(); } // Edit - void EditCut() - { GetFocusedPanel().EditCut(); } - void EditCopy() - { GetFocusedPanel().EditCopy(); } - void EditPaste() - { GetFocusedPanel().EditPaste(); } - - void SelectAll(bool selectMode) - { GetFocusedPanel().SelectAll(selectMode); } - void InvertSelection() - { GetFocusedPanel().InvertSelection(); } - void SelectSpec(bool selectMode) - { GetFocusedPanel().SelectSpec(selectMode); } - void SelectByType(bool selectMode) - { GetFocusedPanel().SelectByType(selectMode); } - - void RefreshStatusBar() - { GetFocusedPanel().RefreshStatusBar(); } - - void SetListViewMode(UINT32 index) - { GetFocusedPanel().SetListViewMode(index); } - UINT32 GetListViewMode() - { return GetFocusedPanel().GetListViewMode(); } - - void SortItemsWithPropID(PROPID propID) - { GetFocusedPanel().SortItemsWithPropID(propID); } - - void OpenRootFolder() - { GetFocusedPanel().OpenDrivesFolder(); } - void OpenParentFolder() - { GetFocusedPanel().OpenParentFolder(); } - void FoldersHistory() - { GetFocusedPanel().FoldersHistory(); } - void RefreshView() - { GetFocusedPanel().OnReload(); } + void EditCut() { GetFocusedPanel().EditCut(); } + void EditCopy() { GetFocusedPanel().EditCopy(); } + void EditPaste() { GetFocusedPanel().EditPaste(); } + + void SelectAll(bool selectMode) { GetFocusedPanel().SelectAll(selectMode); } + void InvertSelection() { GetFocusedPanel().InvertSelection(); } + void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); } + void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); } + + void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); } + + void SetListViewMode(UINT32 index) { GetFocusedPanel().SetListViewMode(index); } + UINT32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); } + PROPID GetSortID() { return GetFocusedPanel().GetSortID(); } + + void SortItemsWithPropID(PROPID propID) { GetFocusedPanel().SortItemsWithPropID(propID); } + + void OpenRootFolder() { GetFocusedPanel().OpenDrivesFolder(); } + void OpenParentFolder() { GetFocusedPanel().OpenParentFolder(); } + void FoldersHistory() { GetFocusedPanel().FoldersHistory(); } + void RefreshView() { GetFocusedPanel().OnReload(); } void RefreshAllPanels() { for (int i = 0; i < NumPanels; i++) @@ -263,18 +222,29 @@ public: Panels[index].OnReload(); } } + + /* + void SysIconsWereChanged() + { + for (int i = 0; i < NumPanels; i++) + { + int index = i; + if (NumPanels == 1) + index = LastFocusedPanel; + Panels[index].SysIconsWereChanged(); + } + } + */ + void SetListSettings(); void SetShowSystemMenu(); HRESULT SwitchOnOffOnePanel(); bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); } void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); } - void OpenBookmark(int index) - { GetFocusedPanel().OpenBookmark(index); } - void SetBookmark(int index) - { GetFocusedPanel().SetBookmark(index); } + void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); } + void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); } - void ReloadRebar(HWND hwnd); void ReloadToolbars(); void ReadToolbar() { @@ -293,33 +263,28 @@ public: if (ShowArchiveToolbar) mask |= 8; SaveToolbarsMask(mask); } + + void SaveToolbarChanges(); + void SwitchStandardToolbar() { ShowStandardToolbar = !ShowStandardToolbar; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchArchiveToolbar() { ShowArchiveToolbar = !ShowArchiveToolbar; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchButtonsLables() { ShowButtonsLables = !ShowButtonsLables; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchLargeButtons() { LargeButtons = !LargeButtons; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void AddToArchive() { GetFocusedPanel().AddToArchive(); } @@ -332,6 +297,8 @@ public: void RefreshTitle(bool always = false); void RefreshTitleAlways() { RefreshTitle(true); } void RefreshTitle(int panelIndex, bool always = false); + + void MoveSubWindows(); }; #endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp new file mode 100755 index 00000000..602b12f3 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp @@ -0,0 +1,514 @@ +// BrowseDialog.cpp + +#include "StdAfx.h" + +#ifdef UNDER_CE + +#include "Common/IntToString.h" + +#include "Windows/PropVariantConversions.h" + +#include "BrowseDialog.h" +#include "LangUtils.h" +#include "PropertyNameRes.h" + +#ifndef _SFX +#include "RegistryUtils.h" +#endif + +using namespace NWindows; +using namespace NFile; +using namespace NFind; + +extern bool g_LVN_ITEMACTIVATE_Support; + +static const int kParentIndex = -1; + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 } +}; +#endif + +static bool GetParentPath(const UString &path2, UString &dest, UString &focused) +{ + UString path = path2; + dest.Empty(); + if (path.IsEmpty()) + return false; + if (path.Back() == WCHAR_PATH_SEPARATOR) + path.DeleteBack(); + if (path.IsEmpty()) + return false; + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos < 0 || path.Back() == WCHAR_PATH_SEPARATOR) + return false; + focused = path.Mid(pos + 1); + dest = path.Left(pos + 1); + return true; +} + +bool CBrowseDialog::OnInit() +{ + #ifdef LANG + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + #endif + if (!Title.IsEmpty()) + SetText(Title); + _list.Attach(GetItem(IDC_BROWSE_LIST)); + + #ifndef UNDER_CE + _list.SetUnicodeFormat(true); + #endif + + #ifndef _SFX + if (ReadSingleClick()) + _list.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT); + _showDots = ReadShowDots(); + #endif + + _list.SetImageList(GetSysImageList(true), LVSIL_SMALL); + _list.SetImageList(GetSysImageList(false), LVSIL_NORMAL); + + _list.InsertColumn(0, LangStringSpec(IDS_PROP_NAME, 0x02000204), 100); + _list.InsertColumn(1, LangStringSpec(IDS_PROP_MTIME, 0x0200020C), 100); + { + LV_COLUMNW column; + column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + column.fmt = LVCFMT_RIGHT; + column.iSubItem = 2; + UString s = LangStringSpec(IDS_PROP_SIZE, 0x02000207); + column.pszText = (wchar_t *)(const wchar_t *)s; + _list.InsertColumn(2, &column); + + // _list.InsertColumn(2, LangStringSpec(IDS_PROP_SIZE, 0x02000207), 100); + } + + _list.InsertItem(0, L"12345678901234567"); + _list.SetSubItem(0, 1, L"2009-09-09"); + _list.SetSubItem(0, 2, L"9999 MB"); + for (int i = 0; i < 3; i++) + _list.SetColumnWidthAuto(i); + _list.DeleteAllItems(); + + UString selectedName; + if (!FolderMode) + { + int pos = Path.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0 && Path.Back() != WCHAR_PATH_SEPARATOR) + { + selectedName = Path.Mid(pos + 1); + Path = Path.Left(pos + 1); + } + } + _ascending = true; + _sortIndex = 0; + + NormalizeSize(); + + while (Reload(Path, selectedName) != S_OK) + { + UString parent; + if (!GetParentPath(Path, parent, selectedName)) + break; + selectedName.Empty(); + Path = parent; + } + + return CModalDialog::OnInit(); +} + +bool CBrowseDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_PARENT, rect); + mx = rect.left; + my = rect.top; + } + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_PATH, rect); + MoveItem(IDC_BROWSE_PATH, rect.left, rect.top, xSize - mx - rect.left, RECT_SIZE_Y(rect)); + } + + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_LIST, rect); + _list.Move(rect.left, rect.top, xSize - mx - rect.left, y - my - rect.top); + } + return false; +} + +static UString ConvertSizeToStringShort(UInt64 value) +{ + wchar_t s[32]; + wchar_t c = L'\0', c2 = L'\0'; + if (value < (UInt64)10000) + { + c = L'\0'; + c2 = L'\0'; + } + else if (value < ((UInt64)10000 << 10)) + { + value >>= 10; + c = L'K'; + } + else if (value < ((UInt64)10000 << 20)) + { + value >>= 20; + c = L'M'; + } + else + { + value >>= 30; + c = L'G'; + } + ConvertUInt64ToString(value, s); + int p = MyStringLen(s); + if (c != 0) + s[p++] = L' '; + s[p++] = c; + s[p++] = c2; + s[p++] = L'\0'; + return s; +} + +int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) +{ + if (lParam1 == kParentIndex) return -1; + if (lParam2 == kParentIndex) return 1; + const CFileInfoW &f1 = _files[(int)lParam1]; + const CFileInfoW &f2 = _files[(int)lParam2]; + + bool isDir1 = f1.IsDir(); + bool isDir2 = f2.IsDir(); + + if (isDir1 && !isDir2) return -1; + if (isDir2 && !isDir1) return 1; + + int result = 0; + switch(_sortIndex) + { + case 0: result = f1.Name.CompareNoCase(f2.Name); break; + case 1: result = CompareFileTime(&f1.MTime, &f2.MTime); break; + case 2: result = MyCompare(f1.Size, f2.Size); break; + } + return _ascending ? result: (-result); +} + +static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) +{ + if (lpData == NULL) + return 0; + return ((CBrowseDialog*)lpData)->CompareItems(lParam1, lParam2); +} + +static HRESULT GetNormalizedError() +{ + HRESULT errorCode = GetLastError(); + return (errorCode == 0) ? 1 : errorCode; +} + +HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName) +{ + CEnumeratorW enumerator(pathPrefix + L'*'); + CObjectVector files; + for (;;) + { + bool found; + CFileInfoW fi; + if (!enumerator.Next(fi, found)) + return GetNormalizedError(); + if (!found) + break; + files.Add(fi); + } + + Path = pathPrefix; + + _files = files; + + SetItemText(IDC_BROWSE_PATH, Path); + _list.SetRedraw(false); + _list.DeleteAllItems(); + + if (!Path.IsEmpty() && Path.Back() != WCHAR_PATH_SEPARATOR) + Path += WCHAR_PATH_SEPARATOR; + + LVITEMW item; + + int index = 0; + int cursorIndex = -1; + + #ifndef _SFX + if (_showDots) + { + UString itemName = L".."; + item.iItem = index; + if (selectedName.IsEmpty()) + cursorIndex = item.iItem; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + int subItem = 0; + item.iSubItem = subItem++; + item.lParam = kParentIndex; + item.pszText = (wchar_t *)(const wchar_t *)itemName; + item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, Path); + if (item.iImage < 0) + item.iImage = 0; + _list.InsertItem(&item); + _list.SetSubItem(index, subItem++, L""); + _list.SetSubItem(index, subItem++, L""); + index++; + } + #endif + + for (int i = 0; i < _files.Size(); i++) + { + const CFileInfoW &fi = _files[i]; + item.iItem = index; + if (fi.Name.CompareNoCase(selectedName) == 0) + cursorIndex = item.iItem; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + int subItem = 0; + item.iSubItem = subItem++; + item.lParam = i; + item.pszText = (wchar_t *)(const wchar_t *)fi.Name; + item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + fi.Name); + if (item.iImage < 0) + item.iImage = 0; + _list.InsertItem(&item); + { + FILETIME ft; + UString s; + if (FileTimeToLocalFileTime(&fi.MTime, &ft)) + s = ConvertFileTimeToString(ft, false, false); + _list.SetSubItem(index, subItem++, s); + } + { + UString s; + if (!fi.IsDir()) + s = ConvertSizeToStringShort(fi.Size); + _list.SetSubItem(index, subItem++, s); + } + index++; + } + + if (_list.GetItemCount() > 0 && cursorIndex >= 0) + _list.SetItemState_FocusedSelected(cursorIndex); + _list.SortItems(CompareItems2, (LPARAM)this); + if (_list.GetItemCount() > 0 && cursorIndex < 0) + _list.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED); + _list.EnsureVisible(_list.GetFocusedItem(), false); + _list.SetRedraw(true); + return S_OK; +} + +HRESULT CBrowseDialog::Reload() +{ + UString selectedCur; + int index = _list.GetNextSelectedItem(-1); + if (index >= 0) + { + int fileIndex = GetRealItemIndex(index); + if (fileIndex != kParentIndex) + selectedCur = _files[fileIndex].Name; + } + return Reload(Path, selectedCur); +} + +void CBrowseDialog::OpenParentFolder() +{ + UString parent, selected; + if (GetParentPath(Path, parent, selected)) + Reload(parent, selected); +} + +extern UString HResultToMessage(HRESULT errorCode); + +bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header) +{ + if (header->hwndFrom != _list) + return false; + switch(header->code) + { + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnItemEnter(); + return true; + } + break; + case NM_DBLCLK: + case NM_RETURN: // probabably it's unused + if (!g_LVN_ITEMACTIVATE_Support) + { + OnItemEnter(); + return true; + } + break; + case LVN_COLUMNCLICK: + { + int index = LPNMLISTVIEW(header)->iSubItem; + if (index == _sortIndex) + _ascending = !_ascending; + else + { + _ascending = (index == 0); + _sortIndex = index; + } + Reload(); + return false; + } + case LVN_KEYDOWN: + { + LRESULT result; + bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result); + return boolResult; + } + } + return false; +} + +bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) +{ + bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + result = 0; + + switch(keyDownInfo->wVKey) + { + case VK_BACK: + OpenParentFolder(); + return true; + case 'R': + if (ctrl) + { + Reload(); + return true; + } + return false; + } + return false; +} + +bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDC_BROWSE_PARENT: + OpenParentFolder(); + return true; + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +void CBrowseDialog::ShowError(LPCWSTR s) { MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR); } + +void CBrowseDialog::ShowSelectError() +{ + ShowError(FolderMode ? + L"You must select some folder": + L"You must select some file"); +} + +void CBrowseDialog::FinishOnOK() +{ + int index = _list.GetNextSelectedItem(-1); + if (index < 0) + { + if (!FolderMode) + { + ShowSelectError(); + return; + } + } + else + { + int fileIndex = GetRealItemIndex(index); + if (fileIndex == kParentIndex) + { + OpenParentFolder(); + return; + } + const CFileInfoW &file = _files[fileIndex]; + if (file.IsDir() != FolderMode) + { + ShowSelectError(); + return; + } + Path += file.Name; + } + End(IDOK); +} + +void CBrowseDialog::OnItemEnter() +{ + int index = _list.GetNextSelectedItem(-1); + if (index < 0) + return; + int fileIndex = GetRealItemIndex(index); + if (fileIndex == kParentIndex) + OpenParentFolder(); + else + { + const CFileInfoW &file = _files[fileIndex]; + if (!file.IsDir()) + { + if (!FolderMode) + FinishOnOK(); + else + ShowSelectError(); + return; + } + HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L""); + if (res != S_OK) + ShowError(HResultToMessage(res)); + } +} + +void CBrowseDialog::OnOK() +{ + if (GetFocus() == _list) + { + OnItemEnter(); + return; + } + FinishOnOK(); +} + +static bool MyBrowse(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath, bool folderMode) +{ + CBrowseDialog dialog; + dialog.Title = title; + dialog.Path = initialFolder; + dialog.FolderMode = folderMode; + if (dialog.Create(owner) != IDOK) + return false; + resultPath = dialog.Path; + return true; +} + +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath) +{ + return MyBrowse(owner, title, initialFolder, resultPath, true); +} + +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR, UString &resultPath) +{ + return MyBrowse(owner, title, initialFolder, resultPath, false); +} + +#endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h new file mode 100755 index 00000000..41eb6b50 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.h @@ -0,0 +1,77 @@ +// BrowseDialog.h + +#ifndef __BROWSE_DIALOG_H +#define __BROWSE_DIALOG_H + +#ifdef UNDER_CE + +#include "Windows/FileFind.h" + +#include "Windows/Control/Dialog.h" +#include "Windows/Control/ListView.h" + +#include "BrowseDialogRes.h" +#include "SysIconUtils.h" + +class CBrowseDialog: public NWindows::NControl::CModalDialog +{ + NWindows::NControl::CListView _list; + CObjectVector _files; + CExtToIconMap _extToIconMap; + int _sortIndex; + bool _ascending; + bool _showDots; + + virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); + virtual bool OnNotify(UINT controlID, LPNMHDR header); + virtual void OnOK(); + + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); + + void FinishOnOK(); + HRESULT Reload(const UString &pathPrefix, const UString &selectedName); + HRESULT Reload(); + void OpenParentFolder(); + + void OnItemEnter(); + + int GetRealItemIndex(int indexInListView) const + { + LPARAM param; + if (!_list.GetItemParam(indexInListView, param)) + return (int)-1; + return (int)param; + } + + void ShowError(LPCWSTR s); + void ShowSelectError(); +public: + UString Title; + UString Path; + bool FolderMode; + + CBrowseDialog(): FolderMode(true), _showDots(false) {} + + INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_BROWSE, parent); } + int CompareItems(LPARAM lParam1, LPARAM lParam2); +}; + +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath); +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR s, UString &resultPath); + +#else + +#include "Windows/CommonDialog.h" +#include "Windows/Shell.h" + +#define MyBrowseForFolder(h, title, initialFolder, resultPath) \ + NShell::BrowseForFolder(h, title, initialFolder, resultPath) + +#define MyBrowseForFile(h, title, initialFolder, s, resultPath) \ + MyGetOpenFileName(h, title, initialFolder, s, resultPath) + +#endif + +#endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.rc b/CPP/7zip/UI/FileManager/BrowseDialog.rc new file mode 100755 index 00000000..4d7ec288 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.rc @@ -0,0 +1,17 @@ +#include "BrowseDialogRes.h" +#include "../../GuiCommon.rc" + +#define xc 180 +#define yc 160 + +IDD_DIALOG_BROWSE MY_RESIZE_DIALOG +CAPTION "7-Zip: Browse" +{ + LTEXT "", IDC_BROWSE_PATH, m + 20, m + 3, xc - 20, 8 + CONTROL "List1", IDC_BROWSE_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, + m, m + 16, xc, yc - bys - m - 16 + PUSHBUTTON "OK", IDOK, bx2, by, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + PUSHBUTTON "..", IDC_BROWSE_PARENT, m, m, 16, 14 +} diff --git a/CPP/7zip/UI/FileManager/BrowseDialogRes.h b/CPP/7zip/UI/FileManager/BrowseDialogRes.h new file mode 100755 index 00000000..79f0efdb --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialogRes.h @@ -0,0 +1,4 @@ +#define IDD_DIALOG_BROWSE 509 +#define IDC_BROWSE_LIST 1000 +#define IDC_BROWSE_PATH 1001 +#define IDC_BROWSE_PARENT 1002 diff --git a/CPP/7zip/UI/FileManager/ClassDefs.cpp b/CPP/7zip/UI/FileManager/ClassDefs.cpp index 5b4401a1..99405d9b 100755 --- a/CPP/7zip/UI/FileManager/ClassDefs.cpp +++ b/CPP/7zip/UI/FileManager/ClassDefs.cpp @@ -2,16 +2,10 @@ #include "StdAfx.h" -#include +#include "Common/MyInitGuid.h" -#include "IFolder.h" -#include "../../IPassword.h" #include "PluginInterface.h" -#include "ExtractCallback.h" -#include "../../ICoder.h" - #include "../Agent/Agent.h" -// {23170F69-40C1-278A-1000-000100020000} DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp index 807a5dd2..c3cc08e7 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.cpp +++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp @@ -43,9 +43,28 @@ bool CComboDialog::OnInit() _comboBox.SetText(Value); for(int i = 0; i < Strings.Size(); i++) _comboBox.AddString(Strings[i]); + NormalizeSize(); return CModalDialog::OnInit(); } +bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + InvalidateRect(NULL); + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + ChangeSubWindowSizeX(_comboBox, xSize - mx * 2); + return false; +} + void CComboDialog::OnOK() { _comboBox.GetText(Value); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.h b/CPP/7zip/UI/FileManager/ComboDialog.h index 0a1addc5..ff111b19 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.h +++ b/CPP/7zip/UI/FileManager/ComboDialog.h @@ -1,10 +1,11 @@ // ComboDialog.h -#ifndef __COMBODIALOG_H -#define __COMBODIALOG_H +#ifndef __COMBO_DIALOG_H +#define __COMBO_DIALOG_H -#include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" +#include "Windows/Control/Dialog.h" + #include "ComboDialogRes.h" class CComboDialog: public NWindows::NControl::CModalDialog @@ -12,6 +13,7 @@ class CComboDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _comboBox; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); public: // bool Sorted; UString Title; diff --git a/CPP/7zip/UI/FileManager/ComboDialog.rc b/CPP/7zip/UI/FileManager/ComboDialog.rc index 7005e09e..6789347a 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.rc +++ b/CPP/7zip/UI/FileManager/ComboDialog.rc @@ -1,24 +1,13 @@ #include "ComboDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 233 -#define ySize2 57 +#define xc 240 +#define yc 64 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_COMBO DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_COMBO MY_RESIZE_DIALOG CAPTION "Combo" -MY_FONT -BEGIN - LTEXT "", IDC_COMBO_STATIC, marg, marg, xSize2, 8 - COMBOBOX IDC_COMBO_COMBO, marg, 20, xSize2, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END +{ + LTEXT "", IDC_COMBO_STATIC, m, m, xc, 8 + COMBOBOX IDC_COMBO_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/ComboDialogRes.h b/CPP/7zip/UI/FileManager/ComboDialogRes.h index b5111ddf..7f37cb93 100755 --- a/CPP/7zip/UI/FileManager/ComboDialogRes.h +++ b/CPP/7zip/UI/FileManager/ComboDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_DIALOG_COMBO 200 +#define IDD_DIALOG_COMBO 505 #define IDC_COMBO_STATIC 1000 #define IDC_COMBO_COMBO 1001 diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp index 2bf60301..8cbaf41f 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -1,13 +1,13 @@ // CopyDialog.cpp #include "StdAfx.h" -#include "CopyDialog.h" -#include "Common/StringConvert.h" +#include "Windows/FileName.h" #include "Windows/Control/Static.h" -#include "Windows/Shell.h" -#include "Windows/FileName.h" + +#include "BrowseDialog.h" +#include "CopyDialog.h" #ifdef LANG #include "LangUtils.h" @@ -34,13 +34,53 @@ bool CCopyDialog::OnInit() NControl::CStatic staticContol; staticContol.Attach(GetItem(IDC_COPY_STATIC)); staticContol.SetText(Static); + #ifdef UNDER_CE + // we do it, since WinCE selects Value\something instead of Value !!!! + _path.AddString(Value); + #endif for (int i = 0; i < Strings.Size(); i++) _path.AddString(Strings[i]); _path.SetText(Value); SetItemText(IDC_COPY_INFO, Info); + NormalizeSize(true); return CModalDialog::OnInit(); } +bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_COPY_SET_PATH, rect); + int bx = rect.right - rect.left; + MoveItem(IDC_COPY_SET_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx); + } + + { + RECT rect; + GetClientRectOfItem(IDC_COPY_INFO, rect); + NControl::CStatic staticContol; + staticContol.Attach(GetItem(IDC_COPY_INFO)); + int yPos = rect.top; + staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos); + } + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + + return false; +} + bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) @@ -57,18 +97,10 @@ void CCopyDialog::OnButtonSetPath() UString currentPath; _path.GetText(currentPath); - /* - #ifdef LANG - UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881); - #else - UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER); - #endif - */ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); - // UString title = L"Specify a location for output folder"; UString resultPath; - if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _path.SetCurSel(-1); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h index 55872f1c..2c22d700 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -1,10 +1,11 @@ // CopyDialog.h -#ifndef __COPYDIALOG_H -#define __COPYDIALOG_H +#ifndef __COPY_DIALOG_H +#define __COPY_DIALOG_H -#include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" +#include "Windows/Control/Dialog.h" + #include "CopyDialogRes.h" const int kCopyDialog_NumInfoLines = 11; @@ -14,15 +15,15 @@ class CCopyDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _path; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); void OnButtonSetPath(); bool OnButtonClicked(int buttonID, HWND buttonHWND); public: UString Title; UString Static; UString Value; - UStringVector Strings; - UString Info; + UStringVector Strings; INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); } }; diff --git a/CPP/7zip/UI/FileManager/CopyDialog.rc b/CPP/7zip/UI/FileManager/CopyDialog.rc index 1686adda..922dddc4 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.rc +++ b/CPP/7zip/UI/FileManager/CopyDialog.rc @@ -1,32 +1,17 @@ #include "CopyDialogRes.h" #include "../../GuiCommon.rc" -#undef infoSize -#define infoSize 100 +#define xc 320 +#define yc 144 -#define xSize2 346 -#define ySize2 (infoSize + 50) +#define y 40 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - -IDD_DIALOG_COPY DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_COPY MY_RESIZE_DIALOG CAPTION "Copy" -MY_FONT -BEGIN - LTEXT "", IDC_COPY_STATIC, marg, marg, xSize2, 8 - COMBOBOX IDC_COPY_COMBO, marg, 20, xSize2 - bDotsSize - 12, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP - LTEXT "", IDC_COPY_INFO, marg, bYPos - (infoSize + 2), xSize2, infoSize, SS_NOPREFIX | SS_LEFTNOWORDWRAP - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_SET_FOLDER "Specify a location for output folder." -END +{ + LTEXT "", IDC_COPY_STATIC, m, m, xc, 8 + COMBOBOX IDC_COPY_COMBO, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "", IDC_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/CopyDialogRes.h b/CPP/7zip/UI/FileManager/CopyDialogRes.h index 900bf29f..4944de84 100755 --- a/CPP/7zip/UI/FileManager/CopyDialogRes.h +++ b/CPP/7zip/UI/FileManager/CopyDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_DIALOG_COPY 202 +#define IDD_DIALOG_COPY 506 #define IDC_COPY_STATIC 1000 #define IDC_COPY_COMBO 1001 diff --git a/CPP/7zip/UI/FileManager/DialogSize.h b/CPP/7zip/UI/FileManager/DialogSize.h new file mode 100755 index 00000000..f4dd1c32 --- /dev/null +++ b/CPP/7zip/UI/FileManager/DialogSize.h @@ -0,0 +1,16 @@ +// DialogSize.h + +#ifndef __DIALOG_SIZE_H +#define __DIALOG_SIZE_H + +#include "Windows/Control/Dialog.h" + +#ifdef UNDER_CE +#define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y); +#define SIZED_DIALOG(big) (isBig ? big : big ## _2) +#else +#define BIG_DIALOG_SIZE(x, y) +#define SIZED_DIALOG(big) big +#endif + +#endif diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp index 69261eb6..dbc580ff 100755 --- a/CPP/7zip/UI/FileManager/EditPage.cpp +++ b/CPP/7zip/UI/FileManager/EditPage.cpp @@ -1,20 +1,14 @@ // EditPage.cpp #include "StdAfx.h" -#include "EditPageRes.h" -#include "EditPage.h" -#include "Common/StringConvert.h" - -#include "Windows/Defs.h" -#include "Windows/CommonDialog.h" -// #include "Windows/FileFind.h" -// #include "Windows/FileDir.h" +#include "EditPage.h" +#include "EditPageRes.h" -#include "RegistryUtils.h" +#include "BrowseDialog.h" #include "HelpUtils.h" #include "LangUtils.h" -#include "ProgramLocation.h" +#include "RegistryUtils.h" using namespace NWindows; @@ -38,9 +32,6 @@ bool CEditPage::OnInit() LONG CEditPage::OnApply() { - // int selectedIndex = _langCombo.GetCurSel(); - // int pathIndex = _langCombo.GetItemData(selectedIndex); - // ReloadLang(); UString editorPath; _editorEdit.GetText(editorPath); SaveRegEditor(editorPath); @@ -49,33 +40,27 @@ LONG CEditPage::OnApply() void CEditPage::OnNotifyHelp() { - ShowHelpWindow(NULL, kEditTopic); // change it + ShowHelpWindow(NULL, kEditTopic); } -bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND) +bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(aButtonID) + switch (buttonID) { case IDC_EDIT_BUTTON_SET: { - OnSetEditorButton(); - // if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, aResultPath)) - // return; + UString editorPath; + _editorEdit.GetText(editorPath); + UString resPath; + if (MyBrowseForFile(HWND(*this), 0, editorPath, L"*.exe", resPath)) + { + _editorEdit.SetText(resPath); + // Changed(); + } return true; } } - return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND); -} - -void CEditPage::OnSetEditorButton() -{ - UString editorPath; - _editorEdit.GetText(editorPath); - UString resPath; - if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath)) - return; - _editorEdit.SetText(resPath); - // Changed(); + return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); } bool CEditPage::OnCommand(int code, int itemID, LPARAM param) @@ -87,5 +72,3 @@ bool CEditPage::OnCommand(int code, int itemID, LPARAM param) } return CPropertyPage::OnCommand(code, itemID, param); } - - diff --git a/CPP/7zip/UI/FileManager/EditPage.h b/CPP/7zip/UI/FileManager/EditPage.h index 26999dcf..cfc50658 100755 --- a/CPP/7zip/UI/FileManager/EditPage.h +++ b/CPP/7zip/UI/FileManager/EditPage.h @@ -1,7 +1,7 @@ // EditPage.h -#ifndef __EDITPAGE_H -#define __EDITPAGE_H +#ifndef __EDIT_PAGE_H +#define __EDIT_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/Edit.h" @@ -9,13 +9,12 @@ class CEditPage: public NWindows::NControl::CPropertyPage { NWindows::NControl::CEdit _editorEdit; - void OnSetEditorButton(); public: virtual bool OnInit(); virtual void OnNotifyHelp(); virtual bool OnCommand(int code, int itemID, LPARAM param); virtual LONG OnApply(); - virtual bool OnButtonClicked(int aButtonID, HWND aButtonHWND); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); }; #endif diff --git a/CPP/7zip/UI/FileManager/EditPage.rc b/CPP/7zip/UI/FileManager/EditPage.rc index ea261286..eb1e8599 100755 --- a/CPP/7zip/UI/FileManager/EditPage.rc +++ b/CPP/7zip/UI/FileManager/EditPage.rc @@ -1,16 +1,13 @@ #include "EditPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc SMALL_PAGE_SIZE_X +#define yc 60 -IDD_EDIT DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_EDIT MY_PAGE CAPTION "Editor" -MY_FONT -BEGIN - LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, marg, marg, xSize2, 8 - EDITTEXT IDC_EDIT_EDIT_EDITOR, marg, 20, xSize2 - 12 - bDotsSize, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, (xSize - marg - bDotsSize), 20, bDotsSize, bYSize -END +{ + LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, m, m, xc, 8 + EDITTEXT IDC_EDIT_EDIT_EDITOR, m, 20, xc - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, xs - m - bxsDots, 19, bxsDots, bys +} diff --git a/CPP/7zip/UI/FileManager/EditPageRes.h b/CPP/7zip/UI/FileManager/EditPageRes.h index a2de1970..33981ae0 100755 --- a/CPP/7zip/UI/FileManager/EditPageRes.h +++ b/CPP/7zip/UI/FileManager/EditPageRes.h @@ -1,4 +1,4 @@ -#define IDD_EDIT 903 +#define IDD_EDIT 542 #define IDC_EDIT_STATIC_EDITOR 1000 #define IDC_EDIT_EDIT_EDITOR 1002 #define IDC_EDIT_BUTTON_SET 1003 diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp index 9902e9a1..d27db23f 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -1,23 +1,17 @@ -// ExtractCallback.h +// ExtractCallback.cpp #include "StdAfx.h" -#include "Common/Wildcard.h" -#include "Common/StringConvert.h" - #include "Windows/Error.h" #include "Windows/FileDir.h" #include "Windows/FileFind.h" -#include "Windows/ResourceString.h" #include "../../Common/FilePathAutoRename.h" #include "../GUI/ExtractRes.h" -#include "../GUI/resource.h" #include "ExtractCallback.h" #include "FormatUtils.h" -#include "MessagesDialog.h" #include "OverwriteDialog.h" #ifndef _NO_CRYPTO #include "PasswordDialog.h" @@ -27,20 +21,12 @@ using namespace NWindows; using namespace NFile; using namespace NFind; -CExtractCallbackImp::~CExtractCallbackImp() -{ - if (ShowMessages && !Messages.IsEmpty()) - { - CMessagesDialog messagesDialog; - messagesDialog.Messages = &Messages; - messagesDialog.Create(ParentWindow); - } -} +CExtractCallbackImp::~CExtractCallbackImp() {} void CExtractCallbackImp::Init() { - Messages.Clear(); NumArchiveErrors = 0; + ThereAreMessageErrors = false; #ifndef _SFX NumFolders = NumFiles = 0; NeedAddFile = false; @@ -49,7 +35,8 @@ void CExtractCallbackImp::Init() void CExtractCallbackImp::AddErrorMessage(LPCWSTR message) { - Messages.Add(message); + ThereAreMessageErrors = true; + ProgressDialog->Sync.AddErrorMessage(message); } STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 @@ -59,40 +46,40 @@ STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 ) { #ifndef _SFX - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); #endif return S_OK; } STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) { - ProgressDialog.ProgressSynch.SetProgress(total, 0); + ProgressDialog->Sync.SetProgress(total, 0); return S_OK; } STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); if (value != NULL) - ProgressDialog.ProgressSynch.SetPos(*value); + ProgressDialog->Sync.SetPos(*value); return S_OK; } HRESULT CExtractCallbackImp::Open_CheckBreak() { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles); return S_OK; } HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); - // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); + // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesCur(*numFiles); return S_OK; } @@ -126,7 +113,7 @@ void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag() #ifndef _SFX STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.SetRatioInfo(inSize, outSize); return S_OK; } #endif @@ -134,14 +121,14 @@ STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt6 /* STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(total); + ProgressDialog->Sync.SetNumFilesTotal(total); return S_OK; } STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) { if (value != NULL) - ProgressDialog.ProgressSynch.SetNumFilesCur(*value); + ProgressDialog->Sync.SetNumFilesCur(*value); return S_OK; } */ @@ -153,30 +140,16 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( { COverwriteDialog dialog; - dialog.OldFileInfo.Time = *existTime; - dialog.OldFileInfo.SizeIsDefined = (existSize != NULL); - if (dialog.OldFileInfo.SizeIsDefined) - dialog.OldFileInfo.Size = *existSize; + dialog.OldFileInfo.SetTime(existTime); + dialog.OldFileInfo.SetSize(existSize); dialog.OldFileInfo.Name = existName; - if (newTime == 0) - dialog.NewFileInfo.TimeIsDefined = false; - else - { - dialog.NewFileInfo.TimeIsDefined = true; - dialog.NewFileInfo.Time = *newTime; - } - - dialog.NewFileInfo.SizeIsDefined = (newSize != NULL); - if (dialog.NewFileInfo.SizeIsDefined) - dialog.NewFileInfo.Size = *newSize; + dialog.NewFileInfo.SetTime(newTime); + dialog.NewFileInfo.SetSize(newSize); dialog.NewFileInfo.Name = newName; - /* - NOverwriteDialog::NResult::EEnum writeAnswer = - NOverwriteDialog::Execute(oldFileInfo, newFileInfo); - */ - INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z + ProgressDialog->WaitCreating(); + INT_PTR writeAnswer = dialog.Create(*ProgressDialog); switch(writeAnswer) { @@ -243,7 +216,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool } if (_needWriteArchivePath) { - AddErrorMessage(_currentArchivePath); + if (!_currentArchivePath.IsEmpty()) + AddErrorMessage(_currentArchivePath); _needWriteArchivePath = false; } AddErrorMessage( @@ -259,7 +233,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool NumFolders++; else NumFiles++; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(NumFiles); #endif return S_OK; } @@ -270,7 +244,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name) { #ifndef _SFX - ProgressDialog.ProgressSynch.SetTitleFileName(name); + ProgressDialog->Sync.SetTitleFileName(name); #endif _currentArchivePath = name; return S_OK; @@ -280,7 +254,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path) { _currentFilePath = path; #ifndef _SFX - ProgressDialog.ProgressSynch.SetCurrentFileName(path); + ProgressDialog->Sync.SetCurrentFileName(path); #endif return S_OK; } @@ -291,7 +265,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path) if (NeedAddFile) NumFiles++; NeedAddFile = true; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(NumFiles); #endif return SetCurrentFilePath2(path); } @@ -365,7 +339,8 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) if (!PasswordIsDefined) { CPasswordDialog dialog; - if (dialog.Create(ProgressDialog) == IDCANCEL) + ProgressDialog->WaitCreating(); + if (dialog.Create(*ProgressDialog) == IDCANCEL) return E_ABORT; Password = dialog.Password; PasswordIsDefined = true; diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h index ee46222a..b4e88fd5 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.h +++ b/CPP/7zip/UI/FileManager/ExtractCallback.h @@ -1,30 +1,27 @@ // ExtractCallback.h -#ifndef __EXTRACTCALLBACK_H -#define __EXTRACTCALLBACK_H +#ifndef __EXTRACT_CALLBACK_H +#define __EXTRACT_CALLBACK_H + +#include "Common/MyCom.h" + +#include "Windows/ResourceString.h" #include "../Agent/IFolderArchive.h" -#include "Common/MyString.h" #include "../Common/ArchiveOpenCallback.h" -#ifdef _SFX -#include "ProgressDialog.h" -#else -#include "ProgressDialog2.h" +#ifndef _NO_CRYPTO +#include "../../IPassword.h" #endif -#include "Windows/ResourceString.h" +#include "IFolder.h" + +#include "ProgressDialog2.h" #ifdef LANG #include "LangUtils.h" #endif -#ifndef _NO_CRYPTO -#include "../../IPassword.h" -#endif -#include "Common/MyCom.h" -#include "IFolder.h" - class CExtractCallbackImp: public IExtractCallbackUI, public IOpenCallbackUI, @@ -99,32 +96,23 @@ public: #endif private: - // bool _extractMode; UString _currentArchivePath; bool _needWriteArchivePath; UString _currentFilePath; bool _isFolder; - // void CreateComplexDirectory(const UStringVector &aDirPathParts); - HRESULT SetCurrentFilePath2(const wchar_t *filePath); void AddErrorMessage(LPCWSTR message); public: - CProgressDialog ProgressDialog; - UStringVector Messages; - bool ShowMessages; + CProgressDialog *ProgressDialog; #ifndef _SFX UInt64 NumFolders; UInt64 NumFiles; bool NeedAddFile; #endif - HWND ParentWindow; - INT_PTR StartProgressDialog(const UString &title) - { - return ProgressDialog.Create(title, ParentWindow); - } UInt32 NumArchiveErrors; + bool ThereAreMessageErrors; NExtract::NOverwriteMode::EEnum OverwriteMode; #ifndef _NO_CRYPTO @@ -138,13 +126,13 @@ public: PasswordIsDefined(false), PasswordWasAsked(false), #endif - OverwriteMode(NExtract::NOverwriteMode::kAskBefore), - ParentWindow(0), - ShowMessages(true) + OverwriteMode(NExtract::NOverwriteMode::kAskBefore) {} ~CExtractCallbackImp(); void Init(); + + bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; } }; #endif diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp index e4bcc998..033e266d 100755 --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -6,7 +6,11 @@ #include "Windows/Error.h" #include "Windows/MemoryLock.h" +#include "Windows/NtCheck.h" + +#ifndef UNDER_CE #include "Windows/Security.h" +#endif #include "../GUI/ExtractRes.h" @@ -29,13 +33,21 @@ using namespace NFind; #define MENU_HEIGHT 26 -#ifndef _UNICODE -bool g_IsNT = false; -#endif HINSTANCE g_hInstance; HWND g_HWND; bool g_OpenArchive = false; static UString g_MainPath; +static bool g_Maximized = false; + +#ifndef UNDER_CE +DWORD g_ComCtl32Version; +#endif + +bool g_LVN_ITEMACTIVATE_Support = true; +// LVN_ITEMACTIVATE replaces both NM_DBLCLK & NM_RETURN +// Windows 2000 +// NT/98 + IE 3 (g_ComCtl32Version >= 4.70) + const int kNumDefaultPanels = 1; @@ -45,21 +57,6 @@ int kPanelSizeMin = 120; // bool OnMenuCommand(HWND hWnd, int id); -static UString GetProgramPath() -{ - UString s; - NDLL::MyGetModuleFileName(g_hInstance, s); - return s; -} - -UString GetProgramFolderPrefix() -{ - UString path = GetProgramPath(); - int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); - return path.Left(pos + 1); -} - - class CSplitterPos { int _ratio; // 10000 is max @@ -123,22 +120,18 @@ static int g_StartCaptureSplitterPos; CApp g_App; -void MoveSubWindows(HWND hWnd); -void OnSize(HWND hWnd); - LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); const wchar_t *kWindowClass = L"FM"; -#ifndef _UNICODE -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} +#ifdef UNDER_CE +#define WS_OVERLAPPEDWINDOW ( \ + WS_OVERLAPPED | \ + WS_CAPTION | \ + WS_SYSMENU | \ + WS_THICKFRAME | \ + WS_MINIMIZEBOX | \ + WS_MAXIMIZEBOX) #endif // FUNCTION: InitInstance(HANDLE, int) @@ -173,14 +166,21 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM)); + wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); // wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU); + wc.lpszMenuName = + #ifdef UNDER_CE + 0 + #else + MAKEINTRESOURCEW(IDM_MENU) + #endif + ; + wc.lpszClassName = kWindowClass; MyRegisterClass(&wc); @@ -225,29 +225,37 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) if (!wnd.Create(kWindowClass, title, style, x, y, xSize, ySize, NULL, NULL, hInstance, NULL)) return FALSE; - g_HWND = (HWND)wnd; + if (nCmdShow == SW_SHOWNORMAL || + nCmdShow == SW_SHOW + #ifndef UNDER_CE + || nCmdShow == SW_SHOWDEFAULT + #endif + ) + { + if (maximized) + nCmdShow = SW_SHOWMAXIMIZED; + else + nCmdShow = SW_SHOWNORMAL; + } + + if (nCmdShow == SW_SHOWMAXIMIZED) + g_Maximized = true; + + #ifndef UNDER_CE WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (wnd.GetPlacement(&placement)) { - if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || - nCmdShow == SW_SHOWDEFAULT) - { - if (maximized) - placement.showCmd = SW_SHOWMAXIMIZED; - else - placement.showCmd = SW_SHOWNORMAL; - } - else - placement.showCmd = nCmdShow; if (windowPosIsRead) placement.rcNormalPosition = rect; + placement.showCmd = nCmdShow; wnd.SetPlacement(&placement); - // window.Show(nCmdShow); } else + #endif wnd.Show(nCmdShow); + return TRUE; } @@ -277,22 +285,23 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands) } */ -DWORD GetDllVersion(LPCTSTR lpszDllName) +#ifndef UNDER_CE +static DWORD GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hinstDll; DWORD dwVersion = 0; hinstDll = LoadLibrary(lpszDllName); - if(hinstDll) + if (hinstDll) { DLLGETVERSIONPROC pDllGetVersion; - pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion"); + pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); /*Because some DLLs might not implement this function, you must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ - if(pDllGetVersion) + if (pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; @@ -302,7 +311,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName) hr = (*pDllGetVersion)(&dvi); - if(SUCCEEDED(hr)) + if (SUCCEEDED(hr)) { dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); } @@ -311,8 +320,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName) } return dwVersion; } - -DWORD g_ComCtl32Version; +#endif /* #ifndef _WIN64 @@ -354,6 +362,7 @@ bool IsLargePageSupported() #endif } +#ifndef UNDER_CE static void SetMemoryLock() { if (!IsLargePageSupported()) @@ -364,6 +373,7 @@ static void SetMemoryLock() if (ReadLockMemoryEnable()) NSecurity::EnableLockMemoryPrivilege(); } +#endif /* static const int kNumSwitches = 1; @@ -378,34 +388,52 @@ enum Enum static const CSwitchForm kSwitchForms[kNumSwitches] = { - { L"SOA", NSwitchType::kSimple, false }, + { L"SOA", NSwitchType::kSimple, false }, }; */ // int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */); -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow) -{ - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif +#define NT_CHECK_FAIL_ACTION MessageBoxW(0, L"Unsupported Windows version", L"7-zip", MB_ICONERROR); return 1; +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + /* lpCmdLine */, int nCmdShow) +{ #ifdef _WIN32 + + NT_CHECK SetLargePageSize(); + #endif InitCommonControls(); + #ifndef UNDER_CE g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll")); + g_LVN_ITEMACTIVATE_Support = (g_ComCtl32Version >= MAKELONG(71, 4)); + #endif // OleInitialize is required for drag and drop. + #ifndef UNDER_CE OleInitialize(NULL); + #endif // Maybe needs CoInitializeEx also ? // NCOM::CComInitializer comInitializer; - UString programString, commandsString; + UString commandsString; // MessageBoxW(0, GetCommandLineW(), L"", 0); + + #ifdef UNDER_CE + commandsString = GetCommandLineW(); + #else + UString programString; SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString); + #endif commandsString.Trim(); UString paramString, tailString; @@ -427,7 +455,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* { parser.ParseStrings(kSwitchForms, commandStrings); const UStringVector &nonSwitchStrings = parser.NonSwitchStrings; - if(nonSwitchStrings.Size() > 1) + if (nonSwitchStrings.Size() > 1) { g_MainPath = nonSwitchStrings[1]; // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs; @@ -443,14 +471,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* */ + #ifndef UNDER_CE SetMemoryLock(); + #endif MSG msg; if (!InitInstance (hInstance, nCmdShow)) return FALSE; - MyLoadMenu(g_HWND); - #ifndef _UNICODE if (g_IsNT) { @@ -481,40 +509,39 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* } g_HWND = 0; + #ifndef UNDER_CE OleUninitialize(); + #endif return (int)msg.wParam; } static void SaveWindowInfo(HWND aWnd) { - /* + #ifdef UNDER_CE RECT rect; if (!::GetWindowRect(aWnd, &rect)) return; - */ + SaveWindowSize(rect, g_Maximized); + #else WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (!::GetWindowPlacement(aWnd, &placement)) return; - SaveWindowSize(placement.rcNormalPosition, - BOOLToBool(::IsZoomed(aWnd))); - SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, - g_Splitter.GetPos()); + SaveWindowSize(placement.rcNormalPosition, BOOLToBool(::IsZoomed(aWnd))); + #endif + SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, g_Splitter.GetPos()); } -void ExecuteCommand(UINT commandID) +static void ExecuteCommand(UINT commandID) { + CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]); + CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]); + switch (commandID) { - case kAddCommand: - g_App.AddToArchive(); - break; - case kExtractCommand: - g_App.ExtractArchives(); - break; - case kTestCommand: - g_App.TestArchives(); - break; + case kAddCommand: g_App.AddToArchive(); break; + case kExtractCommand: g_App.ExtractArchives(); break; + case kTestCommand: g_App.TestArchives(); break; } } @@ -554,7 +581,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CREATE: { - + g_HWND = hWnd; /* INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); @@ -679,7 +706,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos + (short)LOWORD(lParam) - g_StartCaptureMousePos); - MoveSubWindows(hWnd); + g_App.MoveSubWindows(); } break; } @@ -693,8 +720,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) g_Splitter.SetPos(hWnd, g_SplitterPos ); g_CanChangeSplitter = true; } + + g_Maximized = (wParam == SIZE_MAXIMIZED) || (wParam == SIZE_MAXSHOW); - OnSize(hWnd); + g_App.MoveSubWindows(); /* int xSize = LOWORD(lParam); int ySize = HIWORD(lParam); @@ -729,7 +758,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) */ /* case kLangWasChangedMessage: - MyLoadMenu(g_HWND); + MyLoadMenu(); return 0; */ @@ -749,71 +778,71 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0 ; } */ - } - #ifndef _UNICODE - if (g_IsNT) - return DefWindowProcW(hWnd, message, wParam, lParam); - else - #endif - return DefWindowProc(hWnd, message, wParam, lParam); - -} - -void OnSize(HWND hWnd) -{ - /* - if (g_App._rebar) - { - RECT rect; - ::GetClientRect(hWnd, &rect); - int xSize = rect.right; - int ySize = rect.bottom; - // rect.bottom = 0; - // g_App._rebar.SizeToRect(&rect); - // g_App._rebar.Move(0, 0, xSize, ySize); } - */ - MoveSubWindows(hWnd); + #ifndef _UNICODE + if (g_IsNT) + return DefWindowProcW(hWnd, message, wParam, lParam); + else + #endif + return DefWindowProc(hWnd, message, wParam, lParam); + } -int Window_GetRealHeight(NWindows::CWindow &w) +static int Window_GetRealHeight(NWindows::CWindow &w) { RECT rect; - WINDOWPLACEMENT placement; w.GetWindowRect(&rect); int res = rect.bottom - rect.top; + #ifndef UNDER_CE + WINDOWPLACEMENT placement; if (w.GetPlacement(&placement)) res += placement.rcNormalPosition.top; + #endif return res; } -void MoveSubWindows(HWND hWnd) +void CApp::MoveSubWindows() { + HWND hWnd = _window; RECT rect; + if (hWnd == 0) + return; ::GetClientRect(hWnd, &rect); int xSize = rect.right; + if (xSize == 0) + return; int headerSize = 0; - if (g_App._rebar) - headerSize = Window_GetRealHeight(g_App._rebar); + #ifdef UNDER_CE + _commandBar.AutoSize(); + { + _commandBar.Show(true); // maybe we need it for + headerSize += _commandBar.Height(); + } + #endif + if (_toolBar) + { + _toolBar.AutoSize(); + #ifdef UNDER_CE + int h2 = Window_GetRealHeight(_toolBar); + _toolBar.Move(0, headerSize, xSize, h2); + #endif + headerSize += Window_GetRealHeight(_toolBar); + } int ySize = MyMax((int)(rect.bottom - headerSize), 0); - // It's for such case: Minimize / Close: - if (xSize == 0 && ySize == 0) - return; - - if (g_App.NumPanels > 1) + if (NumPanels > 1) { - g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize); + Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize); int xWidth1 = g_Splitter.GetPos() + kSplitterWidth; - g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize); + Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize); } else { /* - int otherPanel = 1 - g_App.LastFocusedPanel; - if (g_App.PanelsCreated[otherPanel]) - g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize); + int otherPanel = 1 - LastFocusedPanel; + if (PanelsCreated[otherPanel]) + Panels[otherPanel].Move(0, headerSize, 0, ySize); */ - g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize); + Panels[LastFocusedPanel].Move(0, headerSize, xSize, ySize); } } diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp index 2c3ab6c8..615043b5 100755 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -403,26 +403,22 @@ SOURCE=.\PanelSplitFile.cpp # PROP Default_Filter "" # Begin Group "Options" -# PROP Default_Filter "" -# Begin Group "Settings" - # PROP Default_Filter "" # Begin Source File -SOURCE=.\SettingsPage.cpp +SOURCE=.\EditPage.cpp # End Source File # Begin Source File -SOURCE=.\SettingsPage.h +SOURCE=.\EditPage.h # End Source File -# End Group # Begin Source File -SOURCE=.\EditPage.cpp +SOURCE=.\FoldersPage.cpp # End Source File # Begin Source File -SOURCE=.\EditPage.h +SOURCE=.\FoldersPage.h # End Source File # Begin Source File @@ -434,48 +430,41 @@ SOURCE=.\LangPage.h # End Source File # Begin Source File -SOURCE=.\PluginsPage.cpp +SOURCE=.\MenuPage.cpp # End Source File # Begin Source File -SOURCE=.\PluginsPage.h +SOURCE=.\MenuPage.h # End Source File # Begin Source File -SOURCE=.\SystemPage.cpp +SOURCE=.\OptionsDialog.cpp # End Source File # Begin Source File -SOURCE=.\SystemPage.h +SOURCE=.\PluginsPage.cpp # End Source File -# End Group -# Begin Group "Password" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\PasswordDialog.cpp +SOURCE=.\PluginsPage.h # End Source File # Begin Source File -SOURCE=.\PasswordDialog.h +SOURCE=.\SettingsPage.cpp # End Source File -# End Group -# Begin Group "Progress" +# Begin Source File -# PROP Default_Filter "" +SOURCE=.\SettingsPage.h +# End Source File # Begin Source File -SOURCE=.\ProgressDialog2.cpp +SOURCE=.\SystemPage.cpp # End Source File # Begin Source File -SOURCE=.\ProgressDialog2.h +SOURCE=.\SystemPage.h # End Source File # End Group -# Begin Group "About" - -# PROP Default_Filter "" # Begin Source File SOURCE=.\AboutDialog.cpp @@ -484,19 +473,14 @@ SOURCE=.\AboutDialog.cpp SOURCE=.\AboutDialog.h # End Source File -# End Group -# Begin Group "Split" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\SplitDialog.cpp +SOURCE=.\BrowseDialog.cpp # End Source File # Begin Source File -SOURCE=.\SplitDialog.h +SOURCE=.\BrowseDialog.h # End Source File -# End Group # Begin Source File SOURCE=.\ComboDialog.cpp @@ -515,6 +499,10 @@ SOURCE=CopyDialog.h # End Source File # Begin Source File +SOURCE=.\DialogSize.h +# End Source File +# Begin Source File + SOURCE=.\ListViewDialog.cpp # End Source File # Begin Source File @@ -537,6 +525,30 @@ SOURCE=OverwriteDialog.cpp SOURCE=OverwriteDialog.h # End Source File +# Begin Source File + +SOURCE=.\PasswordDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\PasswordDialog.h +# End Source File +# Begin Source File + +SOURCE=.\ProgressDialog2.cpp +# End Source File +# Begin Source File + +SOURCE=.\ProgressDialog2.h +# End Source File +# Begin Source File + +SOURCE=.\SplitDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\SplitDialog.h +# End Source File # End Group # Begin Group "FM Common" @@ -855,6 +867,10 @@ SOURCE=..\..\..\Windows\FileIO.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\FileMapping.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\FileName.cpp # End Source File # Begin Source File @@ -907,6 +923,10 @@ SOURCE=..\..\..\Windows\Net.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\Process.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\Process.h # End Source File # Begin Source File @@ -1190,10 +1210,6 @@ SOURCE=..\Common\ExtractMode.h # End Source File # Begin Source File -SOURCE=..\Common\HandlerLoader.h -# End Source File -# Begin Source File - SOURCE=..\Common\IFileExtractCallback.h # End Source File # Begin Source File @@ -1333,6 +1349,26 @@ SOURCE=..\Agent\UpdateCallbackAgent.cpp SOURCE=..\Agent\UpdateCallbackAgent.h # End Source File # End Group +# Begin Group "Explorer" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\Explorer\ContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\Explorer\ContextMenu.h +# End Source File +# Begin Source File + +SOURCE=..\Explorer\RegistryContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\Explorer\RegistryContextMenu.h +# End Source File +# End Group # End Group # Begin Group "Compress" @@ -1436,10 +1472,6 @@ SOURCE=.\OpenCallback.h # End Source File # Begin Source File -SOURCE=.\OptionsDialog.cpp -# End Source File -# Begin Source File - SOURCE=.\PluginInterface.h # End Source File # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index 5951fc09..1b3837cf 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -14,7 +14,11 @@ #include "FSDrives.h" #include "FSFolder.h" + +#ifndef UNDER_CE #include "NetFolder.h" +#endif + #include "SysIconUtils.h" namespace NWindows { @@ -61,8 +65,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) { DWORD lastError = GetLastError(); CFindFile findFile; - CFileInfoW fileInfo; - if (!findFile.FindFirst(_path + UString(L"*"), fileInfo)) + CFileInfoW fi; + if (!findFile.FindFirst(_path + UString(L"*"), fi)) return lastError; } return S_OK; @@ -73,13 +77,13 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, RINOK(progress->SetCompleted(NULL)); numFiles = numFolders = size = 0; CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*")); - CFileInfoW fileInfo; - while (enumerator.Next(fileInfo)) + CFileInfoW fi; + while (enumerator.Next(fi)) { - if (fileInfo.IsDir()) + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -88,7 +92,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -98,21 +102,23 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) { { CEnumeratorW enumerator(path + L"*"); - CDirItem fileInfo; - while (enumerator.Next(fileInfo)) + CDirItem fi; + while (enumerator.Next(fi)) { - fileInfo.CompressedSizeIsDefined = false; + #ifndef UNDER_CE + fi.CompressedSizeIsDefined = false; /* - if (!GetCompressedFileSize(_path + fileInfo.Name, - fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + if (!GetCompressedFileSize(_path + fi.Name, + fi.CompressedSize)) + fi.CompressedSize = fi.Size; */ - if (fileInfo.IsDir()) + #endif + if (fi.IsDir()) { - // fileInfo.Size = GetFolderSize(_path + fileInfo.Name); - fileInfo.Size = 0; + // fi.Size = GetFolderSize(_path + fi.Name); + fi.Size = 0; } - dirItem.Files.Add(fileInfo); + dirItem.Files.Add(fi); } } if (!_flatMode) @@ -237,7 +243,8 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders) } */ -bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) +#ifndef UNDER_CE +static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) { DWORD highPart; DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart); @@ -256,46 +263,49 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) size = (UInt64(highPart) << 32) | lowPart; return true; } +#endif STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { NCOM::CPropVariant prop; if (itemIndex >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[itemIndex]; + CDirItem &fi = *_refs[itemIndex]; switch(propID) { - case kpidIsDir: prop = fileInfo.IsDir(); break; - case kpidName: prop = fileInfo.Name; break; - case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break; + case kpidIsDir: prop = fi.IsDir(); break; + case kpidName: prop = fi.Name; break; + case kpidSize: if (!fi.IsDir()) prop = fi.Size; break; case kpidPackSize: - if (!fileInfo.CompressedSizeIsDefined) + #ifdef UNDER_CE + prop = fi.Size; + #else + if (!fi.CompressedSizeIsDefined) { - fileInfo.CompressedSizeIsDefined = true; - if (fileInfo.IsDir () || - !MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + fi.CompressedSizeIsDefined = true; + if (fi.IsDir () || + !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize)) + fi.CompressedSize = fi.Size; } - prop = fileInfo.CompressedSize; + prop = fi.CompressedSize; + #endif break; - case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break; - case kpidCTime: prop = fileInfo.CTime; break; - case kpidATime: prop = fileInfo.ATime; break; - case kpidMTime: prop = fileInfo.MTime; break; + case kpidAttrib: prop = (UInt32)fi.Attrib; break; + case kpidCTime: prop = fi.CTime; break; + case kpidATime: prop = fi.ATime; break; + case kpidMTime: prop = fi.MTime; break; case kpidComment: { LoadComments(); UString comment; - if (_comments.GetValue(GetRelPath(fileInfo), comment)) + if (_comments.GetValue(GetRelPath(fi), comment)) prop = comment; break; } case kpidPrefix: { if (_flatMode) - { - prop = GetPrefix(fileInfo); - } + prop = GetPrefix(fi); break; } } @@ -333,10 +343,10 @@ UString CFSFolder::GetRelPath(const CDirItem &item) const STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { *resultFolder = 0; - const CDirItem &fileInfo = *_refs[index]; - if (!fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (!fi.IsDir()) return E_INVALIDARG; - return BindToFolderSpec(GetRelPath(fileInfo), resultFolder); + return BindToFolderSpec(GetRelPath(fi), resultFolder); } STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) @@ -362,15 +372,19 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) { - parentPath.Empty(); + #ifdef UNDER_CE + *resultFolder = 0; + #else CFSDrives *drivesFolderSpec = new CFSDrives; CMyComPtr drivesFolder = drivesFolderSpec; drivesFolderSpec->Init(); *resultFolder = drivesFolder.Detach(); + #endif return S_OK; } UString parentPathReduced = parentPath.Left(pos); parentPath = parentPath.Left(pos + 1); + #ifndef UNDER_CE pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos == 1) { @@ -382,6 +396,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) *resultFolder = netFolder.Detach(); return S_OK; } + #endif CFSFolder *parentFolderSpec = new CFSFolder; CMyComPtr parentFolder = parentFolderSpec; RINOK(parentFolderSpec->Init(parentPath, 0)); @@ -457,11 +472,11 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, int index = indices[i]; if (index >= _refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -470,7 +485,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -478,8 +493,8 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) { - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { /* CMyComPtr subFolder; @@ -499,9 +514,9 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) } */ UInt64 numFolders, numFiles; - return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress); + return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress); } - size = fileInfo.Size; + size = fi.Size; return S_OK; } @@ -560,9 +575,9 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) { - const CDirItem &fileInfo = *_refs[index]; - const UString fullPrefix = _path + GetPrefix(fileInfo); - if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName)) + const CDirItem &fi = *_refs[index]; + const UString fullPrefix = _path + GetPrefix(fi); + if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName)) return GetLastError(); return S_OK; } @@ -572,10 +587,10 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress RINOK(progress->SetTotal(numItems)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fileInfo = *_refs[indices[i]]; - const UString fullPath = _path + GetRelPath(fileInfo); + const CDirItem &fi = *_refs[indices[i]]; + const UString fullPath = _path + GetRelPath(fi); bool result; - if (fileInfo.IsDir()) + if (fi.IsDir()) result = NDirectory::RemoveDirectoryWithSubItems(fullPath); else result = NDirectory::DeleteFileAlways(fullPath); @@ -592,14 +607,14 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[index]; - if (fileInfo.Parent->Parent != 0) + CDirItem &fi = *_refs[index]; + if (fi.Parent->Parent != 0) return E_NOTIMPL; switch(propID) { case kpidComment: { - UString filename = fileInfo.Name; + UString filename = fi.Name; filename.Trim(); if (value->vt == VT_EMPTY) _comments.DeletePair(filename); @@ -630,10 +645,10 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; + const CDirItem &fi = *_refs[index]; *iconIndex = 0; int iconIndexTemp; - if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0) + if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attrib, iconIndexTemp) != 0) { *iconIndex = iconIndexTemp; return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h index 95f40bb3..42e33242 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.h +++ b/CPP/7zip/UI/FileManager/FSFolder.h @@ -3,7 +3,6 @@ #ifndef __FSFOLDER_H #define __FSFOLDER_H -#include "Common/MyString.h" #include "Common/MyCom.h" #include "Windows/FileFind.h" @@ -17,8 +16,10 @@ class CFSFolder; struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW { + #ifndef UNDER_CE bool CompressedSizeIsDefined; UInt64 CompressedSize; + #endif }; struct CDirItem; @@ -98,6 +99,9 @@ private: void AddRefs(CDirItem &dirItem); public: HRESULT Init(const UString &path, IFolderFolder *parentFolder); + #ifdef UNDER_CE + HRESULT InitToRoot() { return Init(L"\\", NULL); } + #endif CFSFolder() : _flatMode(false) {} diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp index 9711616c..b6ffd574 100755 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -6,8 +6,9 @@ #include "Common/StringConvert.h" -#include "Windows/FileDir.h" +#include "Windows/DLL.h" #include "Windows/Error.h" +#include "Windows/FileDir.h" #include "../../Common/FilePathAutoRename.h" @@ -41,6 +42,29 @@ struct CProgressInfo IProgress *Progress; }; +#ifndef PROGRESS_CONTINUE + +#define PROGRESS_CONTINUE 0 +#define PROGRESS_CANCEL 1 + +#define COPY_FILE_FAIL_IF_EXISTS 0x00000001 + +typedef +DWORD +(WINAPI* LPPROGRESS_ROUTINE)( + LARGE_INTEGER TotalFileSize, + LARGE_INTEGER TotalBytesTransferred, + LARGE_INTEGER StreamSize, + LARGE_INTEGER StreamBytesTransferred, + DWORD dwStreamNumber, + DWORD dwCallbackReason, + HANDLE hSourceFile, + HANDLE hDestinationFile, + LPVOID lpData + ); + +#endif + static DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER /* TotalFileSize */, // file size LARGE_INTEGER TotalBytesTransferred, // bytes transferred @@ -94,11 +118,17 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres if (g_IsNT) #endif { + const wchar_t *k_DllName = + #ifdef UNDER_CE + L"coredll.dll" + #else + L"kernel32.dll" + #endif + ; CopyFileExPointerW copyFunctionW = (CopyFileExPointerW) - ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), - "CopyFileExW"); + My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW"); if (copyFunctionW == 0) - return false; + return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE)); if (copyFunctionW(existingFile, newFile, CopyProgressRoutine, &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) return true; @@ -141,6 +171,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)( static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize) { + #ifndef UNDER_CE // if (IsItWindows2000orHigher()) // { CProgressInfo progressInfo; @@ -148,7 +179,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres progressInfo.StartPos = completedSize; MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer) - ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), + My_GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "MoveFileWithProgressW"); if (moveFunction != 0) { @@ -172,6 +203,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres } // } // else + #endif return NDirectory::MyMoveFile(existingFile, newFile); } diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp index 992fbd8c..310b890c 100755 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp @@ -30,9 +30,12 @@ struct CThreadArchiveOpen void Process() { - OpenCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback); - OpenCallbackSpec->ProgressDialog.MyClose(); + try + { + CProgressCloser closer(OpenCallbackSpec->ProgressDialog); + Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback); + } + catch(...) { Result = E_FAIL; } } static THREAD_FUNC_DECL MyThreadFunction(void *param) @@ -42,14 +45,15 @@ struct CThreadArchiveOpen } }; -static int FindPlugin(const CObjectVector &plugins, - const UString &pluginName) +/* +static int FindPlugin(const CObjectVector &plugins, const UString &pluginName) { for (int i = 0; i < plugins.Size(); i++) if (plugins[i].Name.CompareNoCase(pluginName) == 0) return i; return -1; } +*/ HRESULT OpenFileFolderPlugin( IInStream *inStream, @@ -77,6 +81,7 @@ HRESULT OpenFileFolderPlugin( NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension); + /* if (!extension.IsEmpty()) { CExtInfo extInfo; @@ -94,6 +99,7 @@ HRESULT OpenFileFolderPlugin( } } } + */ for (int i = 0; i < plugins.Size(); i++) { @@ -127,11 +133,13 @@ HRESULT OpenFileFolderPlugin( t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow; t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + t.OpenCallbackSpec->ProgressDialog.WaitMode = true; - NWindows::CThread thread; - if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK) - throw 271824; - t.OpenCallbackSpec->StartProgressDialog(progressTitle); + { + NWindows::CThread thread; + RINOK(thread.Create(CThreadArchiveOpen::MyThreadFunction, &t)); + t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread); + } if (t.Result == E_ABORT) return t.Result; diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp index 173eeffa..22993383 100755 --- a/CPP/7zip/UI/FileManager/FilePlugins.cpp +++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp @@ -2,14 +2,13 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" #include "Common/MyCom.h" -#include "IFolder.h" +#include "../Agent/Agent.h" + #include "FilePlugins.h" -#include "StringUtils.h" #include "PluginLoader.h" -#include "../Agent/Agent.h" +#include "StringUtils.h" using namespace NRegistryAssociations; @@ -31,9 +30,12 @@ int CExtDatabase::FindPlugin(const UString &plugin) void CExtDatabase::Read() { + /* CObjectVector extItems; ReadInternalAssociations(extItems); + */ ReadFileFolderPluginInfoList(Plugins); + /* for (int i = 0; i < extItems.Size(); i++) { const CExtInfo &extInfo = extItems[i]; @@ -48,6 +50,7 @@ void CExtDatabase::Read() } ExtBigItems.Add(extInfoBig); } + */ for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++) { const CPluginInfo &pluginInfo = Plugins[pluginIndex]; @@ -69,6 +72,10 @@ void CExtDatabase::Read() for (int i = 0; i < exts.Size(); i++) { const UString &ext = exts[i]; + #ifdef UNDER_CE + if (ext == L"cab") + continue; + #endif int index = FindExtInfoBig(ext); if (index < 0) { @@ -91,6 +98,7 @@ void CExtDatabase::Read() void CExtDatabase::Save() { + /* CObjectVector extItems; for (int i = 0; i < ExtBigItems.Size(); i++) { @@ -107,6 +115,5 @@ void CExtDatabase::Save() extItems.Add(extInfo); } WriteInternalAssociations(extItems); + */ } - - diff --git a/CPP/7zip/UI/FileManager/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp new file mode 100755 index 00000000..068b9d47 --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp @@ -0,0 +1,151 @@ +// FoldersPage.cpp + +#include "StdAfx.h" + +#include "FoldersPageRes.h" +#include "FoldersPage.h" + +#include "../FileManager/BrowseDialog.h" +#include "../FileManager/HelpUtils.h" +#include "../FileManager/LangUtils.h" + +using namespace NWindows; + +static CIDLangPair kIDLangPairs[] = +{ + { IDC_FOLDERS_STATIC_WORKING_FOLDER, 0x01000210 }, + { IDC_FOLDERS_WORK_RADIO_SYSTEM, 0x01000211 }, + { IDC_FOLDERS_WORK_RADIO_CURRENT, 0x01000212 }, + { IDC_FOLDERS_WORK_RADIO_SPECIFIED, 0x01000213 }, + { IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, 0x01000214 } +}; + +static const int kWorkModeButtons[] = +{ + IDC_FOLDERS_WORK_RADIO_SYSTEM, + IDC_FOLDERS_WORK_RADIO_CURRENT, + IDC_FOLDERS_WORK_RADIO_SPECIFIED +}; + +static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkModeButtons[0]); + +bool CFoldersPage::OnInit() +{ + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + m_WorkDirInfo.Load(); + + CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly); + + CheckRadioButton(kWorkModeButtons[0], kWorkModeButtons[kNumWorkModeButtons - 1], + kWorkModeButtons[m_WorkDirInfo.Mode]); + + m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH); + m_ButtonSetWorkPath.Init(*this, IDC_FOLDERS_WORK_BUTTON_PATH); + + m_WorkPath.SetText(m_WorkDirInfo.Path); + + MyEnableControls(); + + return CPropertyPage::OnInit(); +} + +int CFoldersPage::GetWorkMode() const +{ + for (int i = 0; i < kNumWorkModeButtons; i++) + if(IsButtonCheckedBool(kWorkModeButtons[i])) + return i; + throw 0; +} + +void CFoldersPage::MyEnableControls() +{ + bool enablePath = (GetWorkMode() == NWorkDir::NMode::kSpecified); + m_WorkPath.Enable(enablePath); + m_ButtonSetWorkPath.Enable(enablePath); +} + +void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo) +{ + m_WorkPath.GetText(workDirInfo.Path); + workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE); + workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode()); +} + +/* +bool CFoldersPage::WasChanged() +{ + NWorkDir::CInfo workDirInfo; + GetWorkDir(workDirInfo); + return (workDirInfo.Mode != m_WorkDirInfo.Mode || + workDirInfo.ForRemovableOnly != m_WorkDirInfo.ForRemovableOnly || + workDirInfo.Path.Compare(m_WorkDirInfo.Path) != 0); +} +*/ + +void CFoldersPage::ModifiedEvent() +{ + Changed(); + /* + if (WasChanged()) + Changed(); + else + UnChanged(); + */ +} + +bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + for (int i = 0; i < kNumWorkModeButtons; i++) + if (buttonID == kWorkModeButtons[i]) + { + MyEnableControls(); + ModifiedEvent(); + return true; + } + switch(buttonID) + { + case IDC_FOLDERS_WORK_BUTTON_PATH: + OnFoldersWorkButtonPath(); + break; + case IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE: + break; + default: + return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); + } + ModifiedEvent(); + return true; +} + +bool CFoldersPage::OnCommand(int code, int itemID, LPARAM lParam) +{ + if (code == EN_CHANGE && itemID == IDC_FOLDERS_WORK_EDIT_PATH) + { + ModifiedEvent(); + return true; + } + return CPropertyPage::OnCommand(code, itemID, lParam); +} + +void CFoldersPage::OnFoldersWorkButtonPath() +{ + UString currentPath; + m_WorkPath.GetText(currentPath); + UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281); + UString resultPath; + if (MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) + m_WorkPath.SetText(resultPath); +} + +LONG CFoldersPage::OnApply() +{ + GetWorkDir(m_WorkDirInfo); + m_WorkDirInfo.Save(); + return PSNRET_NOERROR; +} + +static LPCWSTR kFoldersTopic = L"fm/plugins/7-zip/options.htm#folders"; + +void CFoldersPage::OnNotifyHelp() +{ + ShowHelpWindow(NULL, kFoldersTopic); +} diff --git a/CPP/7zip/UI/FileManager/FoldersPage.h b/CPP/7zip/UI/FileManager/FoldersPage.h new file mode 100755 index 00000000..d8456a40 --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage.h @@ -0,0 +1,29 @@ +// FoldersPage.h + +#ifndef __FOLDERS_PAGE_H +#define __FOLDERS_PAGE_H + +#include "Windows/Control/PropertyPage.h" + +#include "../Common/ZipRegistry.h" + +class CFoldersPage : public NWindows::NControl::CPropertyPage +{ + NWorkDir::CInfo m_WorkDirInfo; + + void MyEnableControls(); + void ModifiedEvent(); + NWindows::NControl::CDialogChildControl m_WorkPath; + NWindows::NControl::CDialogChildControl m_ButtonSetWorkPath; + void OnFoldersWorkButtonPath(); + int GetWorkMode() const; + void GetWorkDir(NWorkDir::CInfo &workDirInfo); + // bool WasChanged(); + virtual bool OnInit(); + virtual bool OnCommand(int code, int itemID, LPARAM lParam); + virtual void OnNotifyHelp(); + virtual LONG OnApply(); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); +}; + +#endif diff --git a/CPP/7zip/UI/FileManager/FoldersPage.rc b/CPP/7zip/UI/FileManager/FoldersPage.rc new file mode 100755 index 00000000..fb48ee6e --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage.rc @@ -0,0 +1,23 @@ +#include "FoldersPageRes.h" +#include "../../GuiCommon.rc" + +#define xc 196 +#define yc 100 + +IDD_FOLDERS MY_PAGE +#include "FoldersPage2.rc" + +#ifdef UNDER_CE + +#undef xc +#define xc SMALL_PAGE_SIZE_X + +IDD_FOLDERS_2 MY_PAGE +#include "FoldersPage2.rc" + +#endif + +STRINGTABLE +BEGIN + IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files." +END diff --git a/CPP/7zip/UI/FileManager/FoldersPage2.rc b/CPP/7zip/UI/FileManager/FoldersPage2.rc new file mode 100755 index 00000000..0b73ec9f --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage2.rc @@ -0,0 +1,16 @@ +CAPTION "Folders" +BEGIN + // GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 98 + + LTEXT "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 8 + CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP, + m, 20, xc, 10 + CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON, + m, 34, xc, 10 + CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON, + m, 48, xc, 10 + EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xs - m - bxsDots, 61, bxsDots, bys + CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, MY_CHECKBOX, + m, 86, xc, 10 +END diff --git a/CPP/7zip/UI/FileManager/FoldersPageRes.h b/CPP/7zip/UI/FileManager/FoldersPageRes.h new file mode 100755 index 00000000..896f197a --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPageRes.h @@ -0,0 +1,13 @@ +#define IDD_FOLDERS 571 +#define IDD_FOLDERS_2 671 + +#define IDS_FOLDERS_SET_WORK_PATH_TITLE 877 + +#define IDC_FOLDERS_STATIC_WORKING_FOLDER 1001 + +#define IDC_FOLDERS_WORK_RADIO_SYSTEM 1011 +#define IDC_FOLDERS_WORK_RADIO_CURRENT 1012 +#define IDC_FOLDERS_WORK_RADIO_SPECIFIED 1013 +#define IDC_FOLDERS_WORK_EDIT_PATH 1014 +#define IDC_FOLDERS_WORK_BUTTON_PATH 1015 +#define IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE 1017 diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp index c2bf49a5..a1c17399 100755 --- a/CPP/7zip/UI/FileManager/HelpUtils.cpp +++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp @@ -10,6 +10,11 @@ static LPCWSTR kHelpFileName = L"7-zip.chm::/"; +#ifdef UNDER_CE +void ShowHelpWindow(HWND, LPCWSTR) +{ +} +#else void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile) { UString path; @@ -19,5 +24,4 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile) path += topicFile; HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL); } - - +#endif diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp index 264872f6..85829368 100755 --- a/CPP/7zip/UI/FileManager/LangPage.cpp +++ b/CPP/7zip/UI/FileManager/LangPage.cpp @@ -1,16 +1,16 @@ // LangPage.cpp #include "StdAfx.h" -#include "LangPageRes.h" -#include "LangPage.h" #include "Common/StringConvert.h" #include "Windows/ResourceString.h" -#include "RegistryUtils.h" #include "HelpUtils.h" +#include "LangPage.h" +#include "LangPageRes.h" #include "LangUtils.h" +#include "RegistryUtils.h" static CIDLangPair kIDLangPairs[] = { @@ -19,17 +19,19 @@ static CIDLangPair kIDLangPairs[] = static LPCWSTR kLangTopic = L"fm/options.htm#language"; +static UString NativeLangString(const UString &s) +{ + return L" (" + s + L')'; +} + bool CLangPage::OnInit() { - _langWasChanged = false; LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); - UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH); - s += L" ("; - s += NWindows::MyLoadStringW(IDS_LANG_NATIVE); - s += L")"; + UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) + + NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE)); int index = (int)_langCombo.AddString(s); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(L"-"); @@ -40,21 +42,12 @@ bool CLangPage::OnInit() for (int i = 0; i < langs.Size(); i++) { const CLangEx &lang = langs[i]; - UString name; - UString englishName, nationalName; - if (lang.Lang.GetMessage(0x00000000, englishName)) - name = englishName; - else + UString name, nationalName; + if (!lang.Lang.GetMessage(0, name)) name = lang.ShortName; - if (lang.Lang.GetMessage(0x00000001, nationalName)) - { - if (!nationalName.IsEmpty()) - { - name += L" ("; - name += nationalName; - name += L")"; - } - } + if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty()) + name += NativeLangString(nationalName); + index = (int)_langCombo.AddString(name); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(lang.ShortName); @@ -70,13 +63,13 @@ LONG CLangPage::OnApply() int pathIndex = (int)_langCombo.GetItemData(selectedIndex); SaveRegLang(_paths[pathIndex]); ReloadLang(); - _langWasChanged = true; + LangWasChanged = true; return PSNRET_NOERROR; } void CLangPage::OnNotifyHelp() { - ShowHelpWindow(NULL, kLangTopic); // change it + ShowHelpWindow(NULL, kLangTopic); } bool CLangPage::OnCommand(int code, int itemID, LPARAM param) diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h index 64825b8e..e58f5098 100755 --- a/CPP/7zip/UI/FileManager/LangPage.h +++ b/CPP/7zip/UI/FileManager/LangPage.h @@ -1,7 +1,7 @@ // LangPage.h -#ifndef __LANGPAGE_H -#define __LANGPAGE_H +#ifndef __LANG_PAGE_H +#define __LANG_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/ComboBox.h" @@ -11,7 +11,8 @@ class CLangPage: public NWindows::NControl::CPropertyPage NWindows::NControl::CComboBox _langCombo; UStringVector _paths; public: - bool _langWasChanged; + bool LangWasChanged; + CLangPage() { LangWasChanged = false; } virtual bool OnInit(); virtual void OnNotifyHelp(); virtual bool OnCommand(int code, int itemID, LPARAM param); diff --git a/CPP/7zip/UI/FileManager/LangPage.rc b/CPP/7zip/UI/FileManager/LangPage.rc index bd4d83d8..327b33e2 100755 --- a/CPP/7zip/UI/FileManager/LangPage.rc +++ b/CPP/7zip/UI/FileManager/LangPage.rc @@ -1,18 +1,34 @@ #include "LangPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 148 +#define yc 100 -IDD_LANG DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_LANG MY_PAGE CAPTION "Language" -MY_FONT -BEGIN - LTEXT "Language:", IDC_LANG_STATIC_LANG, marg, marg, xSize2, 8 - COMBOBOX IDC_LANG_COMBO_LANG, marg, 20, 146, ySize2 - 12, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP -END +{ + LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED +} + + +#ifdef UNDER_CE + +#undef m +#undef xc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +IDD_LANG_2 MY_PAGE +CAPTION "Language" +{ + LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED +} + +#endif + STRINGTABLE BEGIN diff --git a/CPP/7zip/UI/FileManager/LangPageRes.h b/CPP/7zip/UI/FileManager/LangPageRes.h index 39571e53..eb704dbf 100755 --- a/CPP/7zip/UI/FileManager/LangPageRes.h +++ b/CPP/7zip/UI/FileManager/LangPageRes.h @@ -1,4 +1,6 @@ -#define IDD_LANG 900 +#define IDD_LANG 544 +#define IDD_LANG_2 644 + #define IDS_LANG_ENGLISH 995 #define IDS_LANG_NATIVE 996 diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp index e8001cf6..bec08e0d 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp +++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp @@ -1,7 +1,9 @@ // ListViewDialog.cpp #include "StdAfx.h" + #include "ListViewDialog.h" +#include "RegistryUtils.h" #ifdef LANG #include "LangUtils.h" @@ -18,13 +20,17 @@ bool CListViewDialog::OnInit() LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _listView.Attach(GetItem(IDC_LISTVIEW_LIST)); + + if (ReadSingleClick()) + _listView.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT); + SetText(Title); LVCOLUMN columnInfo; columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM; columnInfo.fmt = LVCFMT_LEFT; columnInfo.iSubItem = 0; - columnInfo.cx = 1000; + columnInfo.cx = 200; _listView.InsertColumn(0, &columnInfo); @@ -32,20 +38,67 @@ bool CListViewDialog::OnInit() _listView.InsertItem(i, Strings[i]); if (Strings.Size() > 0) - _listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(0); + + _listView.SetColumnWidthAuto(0); StringsWereChanged = false; + + NormalizeSize(); return CModalDialog::OnInit(); } +bool CListViewDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + /* + RECT rect; + GetClientRect(&rect); + rect.top = y - my; + InvalidateRect(&rect); + */ + InvalidateRect(NULL); + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + /* + if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE) + mx = 0; + */ + _listView.Move(mx, my, xSize - mx * 2, y - my * 2); + return false; +} + +extern bool g_LVN_ITEMACTIVATE_Support; + bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) { if (header->hwndFrom != _listView) return false; switch(header->code) { + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnOK(); + return true; + } + break; case NM_DBLCLK: - OnOK(); - return true; + case NM_RETURN: // probabably it's unused + if (!g_LVN_ITEMACTIVATE_Support) + { + OnOK(); + return true; + } + break; + case LVN_KEYDOWN: { LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header); @@ -55,9 +108,6 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) { if (!DeleteIsAllowed) return false; - int focusedIndex = _listView.GetFocusedItem(); - if (focusedIndex < 0) - focusedIndex = 0; for (;;) { int index = _listView.GetNextSelectedItem(-1); @@ -67,10 +117,10 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) _listView.DeleteItem(index); Strings.Delete(index); } - if (focusedIndex >= _listView.GetItemCount()) - focusedIndex = _listView.GetItemCount() - 1; + int focusedIndex = _listView.GetFocusedItem(); if (focusedIndex >= 0) - _listView.SetItemState(focusedIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(focusedIndex); + _listView.SetColumnWidthAuto(0); return true; } case 'A': diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.h b/CPP/7zip/UI/FileManager/ListViewDialog.h index 57375c8b..6be51c7e 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.h +++ b/CPP/7zip/UI/FileManager/ListViewDialog.h @@ -1,10 +1,11 @@ // ListViewDialog.h -#ifndef __LISTVIEWDIALOG_H -#define __LISTVIEWDIALOG_H +#ifndef __LISTVIEW_DIALOG_H +#define __LISTVIEW_DIALOG_H #include "Windows/Control/Dialog.h" #include "Windows/Control/ListView.h" + #include "ListViewDialogRes.h" class CListViewDialog: public NWindows::NControl::CModalDialog @@ -12,19 +13,18 @@ class CListViewDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CListView _listView; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual bool OnNotify(UINT controlID, LPNMHDR header); - public: UString Title; bool DeleteIsAllowed; - UStringVector Strings; bool StringsWereChanged; + UStringVector Strings; int FocusedItemIndex; INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); } CListViewDialog(): DeleteIsAllowed(false) {} - }; #endif diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.rc b/CPP/7zip/UI/FileManager/ListViewDialog.rc index cb456534..8f963bf1 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.rc +++ b/CPP/7zip/UI/FileManager/ListViewDialog.rc @@ -1,26 +1,14 @@ #include "ListViewDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 342 -#define ySize2 220 +#define xc 320 +#define yc 240 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_LISTVIEW DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_LISTVIEW MY_RESIZE_DIALOG CAPTION "ListView" -MY_FONT -BEGIN +{ CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, - marg, marg, xSize2, ySize2 - bYSize - 10 - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - - + m, m, xc, yc - bys - m + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/ListViewDialogRes.h b/CPP/7zip/UI/FileManager/ListViewDialogRes.h index 440d14b0..aaa6521f 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialogRes.h +++ b/CPP/7zip/UI/FileManager/ListViewDialogRes.h @@ -1,3 +1,2 @@ -#define IDD_DIALOG_LISTVIEW 201 - -#define IDC_LISTVIEW_LIST 1000 +#define IDD_DIALOG_LISTVIEW 508 +#define IDC_LISTVIEW_LIST 1000 diff --git a/CPP/7zip/UI/FileManager/MenuPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp new file mode 100755 index 00000000..719c86ad --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage.cpp @@ -0,0 +1,200 @@ +// MenuPage.cpp + +#include "StdAfx.h" + +#include "../Common/ZipRegistry.h" + +#include "../Explorer/ContextMenuFlags.h" +#include "../Explorer/RegistryContextMenu.h" +#include "../Explorer/resource.h" + +#include "HelpUtils.h" +#include "LangUtils.h" +#include "MenuPage.h" +#include "MenuPageRes.h" +#include "FormatUtils.h" + +using namespace NContextMenuFlags; + +static CIDLangPair kIDLangPairs[] = +{ + { IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, 0x01000301}, + { IDC_SYSTEM_CASCADED_MENU, 0x01000302}, + { IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, 0x01000310} +}; + +static LPCWSTR kSystemTopic = L"fm/plugins/7-zip/options.htm#system"; + +struct CContextMenuItem +{ + int ControlID; + UInt32 LangID; + UInt32 Flag; +}; + +static CContextMenuItem kMenuItems[] = +{ + { IDS_CONTEXT_OPEN, 0x02000103, kOpen}, + { IDS_CONTEXT_EXTRACT, 0x02000105, kExtract}, + { IDS_CONTEXT_EXTRACT_HERE, 0x0200010B, kExtractHere }, + { IDS_CONTEXT_EXTRACT_TO, 0x0200010D, kExtractTo }, + + { IDS_CONTEXT_TEST, 0x02000109, kTest}, + + { IDS_CONTEXT_COMPRESS, 0x02000107, kCompress }, + { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z }, + { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip } + + #ifndef UNDER_CE + , + { IDS_CONTEXT_COMPRESS_EMAIL, 0x02000111, kCompressEmail }, + { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail }, + { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail } + #endif +}; + +const int kNumMenuItems = sizeof(kMenuItems) / sizeof(kMenuItems[0]); + +bool CMenuPage::OnInit() +{ + _initMode = true; + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + + #ifdef UNDER_CE + EnableItem(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, false); + #else + CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NZipRootRegistry::CheckContextMenuHandler()); + #endif + + CContextMenuInfo ci; + ci.Load(); + + CheckButton(IDC_SYSTEM_CASCADED_MENU, ci.Cascaded); + + _listView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST)); + + UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT; + _listView.SetExtendedListViewStyle(newFlags, newFlags); + + _listView.InsertColumn(0, L"", 100); + + for (int i = 0; i < kNumMenuItems; i++) + { + CContextMenuItem &menuItem = kMenuItems[i]; + + UString s = LangString(menuItem.ControlID, menuItem.LangID); + + switch(menuItem.ControlID) + { + case IDS_CONTEXT_EXTRACT_TO: + { + s = MyFormatNew(s, LangString(IDS_CONTEXT_FOLDER, 0x02000140)); + break; + } + case IDS_CONTEXT_COMPRESS_TO: + case IDS_CONTEXT_COMPRESS_TO_EMAIL: + { + UString s2 = LangString(IDS_CONTEXT_ARCHIVE, 0x02000141); + switch(menuItem.Flag) + { + case kCompressTo7z: + case kCompressTo7zEmail: + s2 += L".7z"; + break; + case kCompressToZip: + case kCompressToZipEmail: + s2 += L".zip"; + break; + } + s = MyFormatNew(s, s2); + break; + } + } + + int itemIndex = _listView.InsertItem(i, s); + _listView.SetCheckState(itemIndex, ((ci.Flags & menuItem.Flag) != 0)); + } + + _listView.SetColumnWidthAuto(0); + _initMode = false; + return CPropertyPage::OnInit(); +} + +#ifndef UNDER_CE +STDAPI DllRegisterServer(void); +STDAPI DllUnregisterServer(void); +HWND g_MenuPageHWND = 0; +#endif + +LONG CMenuPage::OnApply() +{ + #ifndef UNDER_CE + g_MenuPageHWND = *this; + if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU)) + { + DllRegisterServer(); + NZipRootRegistry::AddContextMenuHandler(); + } + else + { + DllUnregisterServer(); + NZipRootRegistry::DeleteContextMenuHandler(); + } + #endif + + CContextMenuInfo ci; + ci.Cascaded = IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU); + ci.Flags = 0; + for (int i = 0; i < kNumMenuItems; i++) + if (_listView.GetCheckState(i)) + ci.Flags |= kMenuItems[i].Flag; + ci.Save(); + + return PSNRET_NOERROR; +} + +void CMenuPage::OnNotifyHelp() +{ + ShowHelpWindow(NULL, kSystemTopic); +} + +bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDC_SYSTEM_CASCADED_MENU: + case IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU: + Changed(); + return true; + } + return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); + +} + +bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam) +{ + if (lParam->hwndFrom == HWND(_listView)) + { + switch(lParam->code) + { + case (LVN_ITEMCHANGED): + return OnItemChanged((const NMLISTVIEW *)lParam); + } + } + return CPropertyPage::OnNotify(controlID, lParam); +} + + +bool CMenuPage::OnItemChanged(const NMLISTVIEW *info) +{ + if (_initMode) + return true; + if ((info->uChanged & LVIF_STATE) != 0) + { + UINT oldState = info->uOldState & LVIS_STATEIMAGEMASK; + UINT newState = info->uNewState & LVIS_STATEIMAGEMASK; + if (oldState != newState) + Changed(); + } + return true; +} diff --git a/CPP/7zip/UI/FileManager/MenuPage.h b/CPP/7zip/UI/FileManager/MenuPage.h new file mode 100755 index 00000000..5005ea9c --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage.h @@ -0,0 +1,25 @@ +// MenuPage.h + +#ifndef __MENU_PAGE_H +#define __MENU_PAGE_H + +#include "Windows/Control/PropertyPage.h" +#include "Windows/Control/ListView.h" + +#include "../Common/LoadCodecs.h" + +class CMenuPage: public NWindows::NControl::CPropertyPage +{ + bool _initMode; + NWindows::NControl::CListView _listView; + + virtual bool OnInit(); + virtual void OnNotifyHelp(); + virtual bool OnNotify(UINT controlID, LPNMHDR lParam); + virtual bool OnItemChanged(const NMLISTVIEW *info); + virtual LONG OnApply(); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); +public: +}; + +#endif diff --git a/CPP/7zip/UI/FileManager/MenuPage.rc b/CPP/7zip/UI/FileManager/MenuPage.rc new file mode 100755 index 00000000..bb4281d8 --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage.rc @@ -0,0 +1,24 @@ +#include "MenuPageRes.h" +#include "../../GuiCommon.rc" + +#define xc 196 +#define yc 164 + +IDD_MENU MY_PAGE +#include "MenuPage2.rc" + +#ifdef UNDER_CE + +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +#define yc 112 + +IDD_MENU_2 MY_PAGE +#include "MenuPage2.rc" + +#endif diff --git a/CPP/7zip/UI/FileManager/MenuPage2.rc b/CPP/7zip/UI/FileManager/MenuPage2.rc new file mode 100755 index 00000000..1862aa06 --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage2.rc @@ -0,0 +1,14 @@ +#define y 40 + +CAPTION "7-Zip" +BEGIN + CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, + MY_CHECKBOX, m, m, xc, 10 + CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU, + MY_CHECKBOX, m, m + 14, xc, 10 + LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, + m, m + 28, xc, 8 + CONTROL "List", IDC_SYSTEM_OPTIONS_LIST, "SysListView32", + LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, + m, m + y, xc, yc - y +END diff --git a/CPP/7zip/UI/FileManager/MenuPageRes.h b/CPP/7zip/UI/FileManager/MenuPageRes.h new file mode 100755 index 00000000..f1220bfd --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPageRes.h @@ -0,0 +1,7 @@ +#define IDD_MENU 570 +#define IDD_MENU_2 670 + +#define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 +#define IDC_SYSTEM_CASCADED_MENU 1011 +#define IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS 1020 +#define IDC_SYSTEM_OPTIONS_LIST 1022 diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp index 201c0bae..3d73ade1 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp +++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp @@ -1,11 +1,13 @@ // MessagesDialog.cpp #include "StdAfx.h" -#include "MessagesDialog.h" -#include "Common/StringConvert.h" + #include "Common/IntToString.h" + #include "Windows/ResourceString.h" +#include "MessagesDialog.h" + #ifdef LANG #include "LangUtils.h" #endif @@ -49,9 +51,12 @@ bool CMessagesDialog::OnInit() LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _messageList.Attach(GetItem(IDC_MESSAGE_LIST)); + + #ifndef UNDER_CE _messageList.SetUnicodeFormat(true); + #endif - _messageList.InsertColumn(0, L"#", 30); + _messageList.InsertColumn(0, L"", 30); const UString s = #ifdef LANG @@ -62,15 +67,27 @@ bool CMessagesDialog::OnInit() _messageList.InsertColumn(1, s, 600); - for(int i = 0; i < Messages->Size(); i++) + for (int i = 0; i < Messages->Size(); i++) AddMessage((*Messages)[i]); - /* - if(_messageList.GetItemCount() > 0) - { - UINT aState = LVIS_SELECTED | LVIS_FOCUSED; - _messageList.SetItemState(0, aState, aState); - } - */ + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + NormalizeSize(); return CModalDialog::OnInit(); } + +bool CMessagesDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx, by; + GetItemSizes(IDOK, bx, by); + int y = ySize - my - by; + int x = xSize - mx - bx; + + InvalidateRect(NULL); + + MoveItem(IDOK, x, y, bx, by); + _messageList.Move(mx, my, xSize - mx * 2, y - my * 2); + return false; +} diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.h b/CPP/7zip/UI/FileManager/MessagesDialog.h index 6df0d46c..1304d516 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.h +++ b/CPP/7zip/UI/FileManager/MessagesDialog.h @@ -1,19 +1,20 @@ // MessagesDialog.h -#ifndef __MESSAGESDIALOG_H -#define __MESSAGESDIALOG_H - -#include "MessagesDialogRes.h" +#ifndef __MESSAGES_DIALOG_H +#define __MESSAGES_DIALOG_H #include "Windows/Control/Dialog.h" #include "Windows/Control/ListView.h" +#include "MessagesDialogRes.h" + class CMessagesDialog: public NWindows::NControl::CModalDialog { NWindows::NControl::CListView _messageList; void AddMessageDirect(LPCWSTR message); void AddMessage(LPCWSTR message); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); public: const UStringVector *Messages; INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); } diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.rc b/CPP/7zip/UI/FileManager/MessagesDialog.rc index bf1c56b0..fb2f0f7d 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.rc +++ b/CPP/7zip/UI/FileManager/MessagesDialog.rc @@ -1,25 +1,14 @@ #include "MessagesDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 430 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) -#define bXPos (xSize - marg - bXSize) -#define bYPos (ySize - marg - bYSize) +#define xc 440 +#define yc 160 - -IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_MESSAGES MY_RESIZE_DIALOG CAPTION "7-Zip: Diagnostic messages" -MY_FONT -BEGIN - DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize - CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32", +{ + DEFPUSHBUTTON "&Close", IDOK, bx, by, bxs, bys + CONTROL "List1", IDC_MESSAGE_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - marg, marg, xSize2, ySize2 - bYSize - 6 -END - -STRINGTABLE -BEGIN - IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message" -END + m, m, xc, yc - bys - m +} diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp index f98325a0..ebd41fd9 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -3,6 +3,7 @@ #include "StdAfx.h" #include "Windows/Menu.h" +#include "Windows/Control/Dialog.h" #include "../../PropID.h" @@ -16,6 +17,8 @@ #include "resource.h" +using namespace NWindows; + static const UINT kOpenBookmarkMenuID = 730; static const UINT kSetBookmarkMenuID = 740; @@ -25,44 +28,28 @@ static LPCWSTR kFMHelpTopic = L"FM/index.htm"; extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance); -using namespace NWindows; - -static const int kFileMenuIndex = 0; -static const int kEditMenuIndex = 1; -static const int kViewMenuIndex = 2; -static const int kBookmarksMenuIndex = kViewMenuIndex + 1; - -struct CStringLangPair +enum { - wchar_t *String; - UINT32 LangID; + kMenuIndex_File = 0, + kMenuIndex_Edit, + kMenuIndex_View, + kMenuIndex_Bookmarks }; -static CStringLangPair kStringLangPairs[] = +static const UInt32 kTopMenuLangIDs[] = { - { L"&File", 0x03000102 }, - { L"&Edit", 0x03000103 }, - { L"&View", 0x03000104 }, - { L"&Bookmarks", 0x03000107 }, - { L"&Tools", 0x03000105 }, - { L"&Help", 0x03000106 }, + 0x03000102, + 0x03000103, + 0x03000104, + 0x03000107, + 0x03000105, + 0x03000106 }; -UINT32 kAddToFavoritesLangID = 0x03000710; -UINT32 kToolbarsLangID = 0x03000451; +static const UInt32 kAddToFavoritesLangID = 0x03000710; +static const UInt32 kToolbarsLangID = 0x03000451; -/* -static int FindStringLangItem(const UString &anItem) -{ - for (int i = 0; i < sizeof(kStringLangPairs) / - sizeof(kStringLangPairs[0]); i++) - if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0) - return i; - return -1; -} -*/ - -static CIDLangPair kIDLangPairs[] = +static const CIDLangPair kIDLangPairs[] = { // File { IDM_FILE_OPEN, 0x03000210 }, @@ -136,6 +123,18 @@ static int FindLangItem(int ControlID) return -1; } +static int GetSortControlID(PROPID propID) +{ + switch(propID) + { + case kpidName: return IDM_VIEW_ARANGE_BY_NAME; + case kpidExtension: return IDM_VIEW_ARANGE_BY_TYPE; + case kpidMTime: return IDM_VIEW_ARANGE_BY_DATE; + case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE; + case kpidNoProperty: return IDM_VIEW_ARANGE_NO_SORT; + } + return -1; +} /* static bool g_IsNew_fMask = true; @@ -177,50 +176,38 @@ static UINT Get_fMaskForFTypeAndString() } */ -static UINT Get_fMaskForString() -{ - return MIIM_TYPE; -} - -static UINT Get_fMaskForFTypeAndString() -{ - return MIIM_TYPE; -} - - +static inline UINT Get_fMaskForString() { return MIIM_TYPE; } +static inline UINT Get_fMaskForFTypeAndString() { return MIIM_TYPE; } static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) { CMenu menu; menu.Attach(menuLoc); - for (int i = 0; i < menu.GetItemCount(); i++) + for (int i = 0;; i++) { CMenuItem item; item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID; item.fType = MFT_STRING; - if (menu.GetItem(i, true, item)) + if (!menu.GetItem(i, true, item)) + break; { UString newString; if (item.hSubMenu) { - if (level == 1 && menuIndex == kBookmarksMenuIndex) - newString = LangString(kAddToFavoritesLangID); + UInt32 langID = 0; + if (level == 1 && menuIndex == kMenuIndex_Bookmarks) + langID = kAddToFavoritesLangID; else { MyChangeMenu(item.hSubMenu, level + 1, i); - if (level == 1 && menuIndex == kViewMenuIndex) - { - newString = LangString(kToolbarsLangID); - } + if (level == 1 && menuIndex == kMenuIndex_View) + langID = kToolbarsLangID; + else if (level == 0 && i < sizeof(kTopMenuLangIDs) / sizeof(kTopMenuLangIDs[0])) + langID = kTopMenuLangIDs[i]; else - { - if (level == 0 && i < sizeof(kStringLangPairs) / - sizeof(kStringLangPairs[0])) - newString = LangString(kStringLangPairs[i].LangID); - else - continue; - } + continue; } + newString = LangString(langID); if (newString.IsEmpty()) continue; } @@ -247,41 +234,14 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) } } -CMenu g_FileMenu; +static CMenu g_FileMenu; -class CFileMenuDestroyer +struct CFileMenuDestroyer { -public: - ~CFileMenuDestroyer() - { - if ((HMENU)g_FileMenu != 0) - g_FileMenu.Destroy(); - } + ~CFileMenuDestroyer() { if ((HMENU)g_FileMenu != 0) g_FileMenu.Destroy(); } } g_FileMenuDestroyer; -void MyLoadMenu(HWND hWnd) -{ - if ((HMENU)g_FileMenu != 0) - g_FileMenu.Destroy(); - HMENU oldMenu = ::GetMenu(hWnd); - HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU)); - ::SetMenu(hWnd, baseMenu); - ::DestroyMenu(oldMenu); - if (!g_LangID.IsEmpty()) - { - HMENU menuOld = ::GetMenu(hWnd); - MyChangeMenu(menuOld, 0, 0); - } - ::DrawMenuBar(hWnd); -} - -extern HWND g_HWND; -void MyLoadMenu() -{ - MyLoadMenu(g_HWND); -} - static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) { CMenu srcMenu; @@ -289,39 +249,74 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) CMenu destMenu; destMenu.Attach(destMenuSpec); int startPos = 0; - for (int i = 0; i < srcMenu.GetItemCount(); i++) + for (int i = 0;; i++) { CMenuItem item; item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; if (srcMenu.GetItem(i, true, item)) + { if (destMenu.InsertItem(startPos, true, item)) startPos++; + } + else + break; } } +void MyLoadMenu() +{ + HMENU baseMenu; + + #ifdef UNDER_CE + + HMENU oldMenu = g_App._commandBar.GetMenu(0); + if (oldMenu) + ::DestroyMenu(oldMenu); + BOOL b = g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0); + baseMenu = g_App._commandBar.GetMenu(0); + if (!g_LangID.IsEmpty()) + MyChangeMenu(baseMenu, 0, 0); + g_App._commandBar.DrawMenuBar(0); + + #else + + HWND hWnd = g_HWND; + HMENU oldMenu = ::GetMenu(hWnd); + ::SetMenu(hWnd, ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU))); + ::DestroyMenu(oldMenu); + baseMenu = ::GetMenu(hWnd); + if (!g_LangID.IsEmpty()) + MyChangeMenu(baseMenu, 0, 0); + ::DrawMenuBar(hWnd); + + #endif + + if ((HMENU)g_FileMenu != 0) + g_FileMenu.Destroy(); + g_FileMenu.CreatePopup(); + CopyMenu(::GetSubMenu(baseMenu, 0), g_FileMenu); +} + void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) { - if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu) + HMENU mainMenu = + #ifdef UNDER_CE + g_App._commandBar.GetMenu(0); + #else + ::GetMenu(g_HWND) + #endif + ; + if (::GetSubMenu(mainMenu, position) != hMenu) return; - if (position == kFileMenuIndex) + if (position == kMenuIndex_File) { - if ((HMENU)g_FileMenu == 0) - { - g_FileMenu.CreatePopup(); - CopyMenu(hMenu, g_FileMenu); - } CMenu menu; menu.Attach(hMenu); - while (menu.GetItemCount() > 0) - { - if (!menu.RemoveItem(0, MF_BYPOSITION)) - break; - } - // CopyMenu(g_FileMenu, hMenu); + menu.RemoveAllItems(); g_App.GetFocusedPanel().CreateFileMenu(hMenu); } - else if (position == kEditMenuIndex) + else if (position == kMenuIndex_Edit) { /* CMenu menu; @@ -331,35 +326,32 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED); */ } - else if (position == kViewMenuIndex) + else if (position == kMenuIndex_View) { // View; CMenu menu; menu.Attach(hMenu); menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND); - menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND | - ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND | - ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND | - (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND | - (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND | - (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND | - (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED)); + + menu.CheckRadioItem(IDM_VIEW_ARANGE_BY_NAME, IDM_VIEW_ARANGE_NO_SORT, + GetSortControlID(g_App.GetSortID()), MF_BYCOMMAND); + + menu.CheckItemByID(IDM_VIEW_TWO_PANELS, g_App.NumPanels == 2); + menu.CheckItemByID(IDM_VIEW_FLAT_VIEW, g_App.GetFlatMode()); + menu.CheckItemByID(IDM_VIEW_ARCHIVE_TOOLBAR, g_App.ShowArchiveToolbar); + menu.CheckItemByID(IDM_VIEW_STANDARD_TOOLBAR, g_App.ShowStandardToolbar); + menu.CheckItemByID(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, g_App.LargeButtons); + menu.CheckItemByID(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, g_App.ShowButtonsLables); } - else if (position == kBookmarksMenuIndex) + else if (position == kMenuIndex_Bookmarks) { CMenu menu; menu.Attach(hMenu); CMenu subMenu; subMenu.Attach(menu.GetSubMenu(0)); - while (subMenu.GetItemCount() > 0) - subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION); + subMenu.RemoveAllItems(); int i; for (i = 0; i < 10; i++) { @@ -372,8 +364,7 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s); } - while (menu.GetItemCount() > 2) - menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION); + menu.RemoveAllItemsFrom(2); for (i = 0; i < 10; i++) { @@ -401,84 +392,51 @@ void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id) { if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu) return; - // g_App.GetFocusedPanel()._contextMenu.Release(); -} - -void OnMenuUnActivating(HWND hWnd) -{ } */ - void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, bool isFsFolder, int numItems, bool allAreFiles) { - { - CMenu srcMenu; - srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0)); - if ((HMENU)g_FileMenu == 0) - { - g_FileMenu.CreatePopup(); - CopyMenu(srcMenu, g_FileMenu); - } - } - CMenu destMenu; destMenu.Attach(hMenu); UString diffPath; ReadRegDiff(diffPath); - for (int i = 0; i < g_FileMenu.GetItemCount(); i++) + int numRealItems = startPos; + for (int i = 0;; i++) { CMenuItem item; item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; - if (g_FileMenu.GetItem(i, true, item)) + if (!g_FileMenu.GetItem(i, true, item)) + break; { - if (!programMenu) - if (item.wID == IDCLOSE) - continue; + if (!programMenu && item.wID == IDCLOSE) + continue; if (item.wID == IDM_FILE_DIFF && diffPath.IsEmpty()) continue; bool isOneFsFile = (isFsFolder && numItems == 1 && allAreFiles); - if ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile) - item.fState |= MFS_DISABLED; + bool disable = ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile); - /* - bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE); - if (forFileMode) - { - if (createItem) - continue; - } - else - { - if (!createItem) - continue; - } - */ + bool isBigScreen = NControl::IsDialogSizeOK(40, 200); + + if (!isBigScreen && (disable || item.IsSeparator())) + continue; if (destMenu.InsertItem(startPos, true, item)) startPos++; + if (disable) + destMenu.EnableItem(startPos - 1, MF_BYPOSITION | MF_GRAYED); + + if (!item.IsSeparator()) + numRealItems = startPos; } } - while (destMenu.GetItemCount() > 0) - { - CMenuItem item; - item.fMask = MIIM_TYPE; - item.fType = 0; - // item.dwTypeData = 0; - int lastIndex = destMenu.GetItemCount() - 1; - if (!destMenu.GetItem(lastIndex, true, item)) - break; - if(item.fType != MFT_SEPARATOR) - break; - if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION)) - break; - } + destMenu.RemoveAllItemsFrom(numRealItems); } bool ExecuteFileCommand(int id) @@ -618,7 +576,7 @@ bool OnMenuCommand(HWND hWnd, int id) g_App.SetListViewMode(index); /* CMenu menu; - menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex)); + menu.Attach(::GetSubMenu(::GetMenu(hWnd), kMenuIndex_View)); menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, id, MF_BYCOMMAND); */ @@ -688,8 +646,12 @@ bool OnMenuCommand(HWND hWnd, int id) break; case IDM_BENCHMARK: + { + CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]); + CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]); Benchmark(); break; + } // Help case IDM_HELP_CONTENTS: ShowHelpWindow(NULL, kFMHelpTopic); @@ -717,4 +679,3 @@ bool OnMenuCommand(HWND hWnd, int id) } return true; } - diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h index 83c1d24f..53e9d0ef 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.h +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.h @@ -1,13 +1,12 @@ // MyLoadMenu.h -#ifndef __MYLOADMENU_H -#define __MYLOADMENU_H +#ifndef __MY_LOAD_MENU_H +#define __MY_LOAD_MENU_H void OnMenuActivating(HWND hWnd, HMENU hMenu, int position); // void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id); // void OnMenuUnActivating(HWND hWnd); -void MyLoadMenu(HWND hWnd); bool OnMenuCommand(HWND hWnd, int id); void MyLoadMenu(); void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp index a275f89b..72245ac4 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.cpp +++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp @@ -15,43 +15,43 @@ using namespace NWindows; STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); { NSynchronization::CCriticalSectionLock lock(_criticalSection); if (numFiles != NULL) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); - ProgressDialog.ProgressSynch.SetBytesProgressMode(false); + ProgressDialog.Sync.SetNumFilesTotal(*numFiles); + ProgressDialog.Sync.SetBytesProgressMode(false); } if (numBytes != NULL) - ProgressDialog.ProgressSynch.SetNumBytesTotal(*numBytes); + ProgressDialog.Sync.SetNumBytesTotal(*numBytes); } return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); NSynchronization::CCriticalSectionLock lock(_criticalSection); if (numFiles != NULL) - ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + ProgressDialog.Sync.SetNumFilesCur(*numFiles); if (numBytes != NULL) - ProgressDialog.ProgressSynch.SetPos(*numBytes); + ProgressDialog.Sync.SetPos(*numBytes); return S_OK; } STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); - ProgressDialog.ProgressSynch.SetNumBytesTotal(total); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); + ProgressDialog.Sync.SetNumBytesTotal(total); return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); if (completed != NULL) - ProgressDialog.ProgressSynch.SetPos(*completed); + ProgressDialog.Sync.SetPos(*completed); return S_OK; } @@ -112,6 +112,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) { CPasswordDialog dialog; + ProgressDialog.WaitCreating(); if (dialog.Create(ProgressDialog) == IDCANCEL) return E_ABORT; diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h index 5f0fbefc..559eb8fc 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.h +++ b/CPP/7zip/UI/FileManager/OpenCallback.h @@ -75,7 +75,7 @@ public: _subArchiveMode = false; } */ - void LoadFileInfo(const UString &folderPrefix, const UString &fileName) + void LoadFileInfo(const UString &folderPrefix, const UString &fileName) { _folderPrefix = folderPrefix; if (!_fileInfo.Find(_folderPrefix + fileName)) @@ -83,9 +83,9 @@ public: } void ShowMessage(const UInt64 *completed); - INT_PTR StartProgressDialog(const UString &title) + INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread) { - return ProgressDialog.Create(title, ParentWindow); + return ProgressDialog.Create(title, thread, ParentWindow); } }; diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp index 09d74705..1b44461f 100755 --- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp +++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp @@ -2,42 +2,114 @@ #include "StdAfx.h" -#include "resource.h" - -#include "Common/StringConvert.h" - +#include "Windows/Control/Dialog.h" #include "Windows/Control/PropertyPage.h" -#include "Windows/Error.h" -#include "LangPage.h" -#include "LangPageRes.h" -#include "PluginsPage.h" -#include "PluginsPageRes.h" -#include "SystemPage.h" -#include "SystemPageRes.h" +#include "DialogSize.h" #include "EditPage.h" #include "EditPageRes.h" +#include "FoldersPage.h" +#include "FoldersPageRes.h" +#include "LangPage.h" +#include "LangPageRes.h" +#include "MenuPage.h" +#include "MenuPageRes.h" +// #include "PluginsPage.h" +// #include "PluginsPageRes.h" #include "SettingsPage.h" #include "SettingsPageRes.h" +#include "SystemPage.h" +#include "SystemPageRes.h" +#include "App.h" #include "LangUtils.h" #include "MyLoadMenu.h" -#include "App.h" +#include "ProgramLocation.h" + +#include "resource.h" using namespace NWindows; +#ifndef UNDER_CE +typedef UINT32 (WINAPI * DllRegisterServerPtr)(); + +extern HWND g_MenuPageHWND; + +static void ShowMenuErrorMessage(const wchar_t *m) +{ + MessageBoxW(g_MenuPageHWND, m, L"7-Zip", MB_ICONERROR); +} + +static int DllRegisterServer2(const char *name) +{ + NWindows::NDLL::CLibrary lib; + + UString prefix; + GetProgramFolderPath(prefix); + if (!lib.Load(prefix + L"7-zip.dll")) + { + ShowMenuErrorMessage(L"7-Zip cannot load 7-zip.dll"); + return E_FAIL; + } + DllRegisterServerPtr f = (DllRegisterServerPtr)lib.GetProc(name); + if (f == NULL) + { + ShowMenuErrorMessage(L"Incorrect plugin"); + return E_FAIL; + } + HRESULT res = f(); + if (res != S_OK) + ShowMenuErrorMessage(HResultToMessage(res)); + return (int)res; +} + +STDAPI DllRegisterServer(void) +{ + #ifdef UNDER_CE + return S_OK; + #else + return DllRegisterServer2("DllRegisterServer"); + #endif +} + +STDAPI DllUnregisterServer(void) +{ + #ifdef UNDER_CE + return S_OK; + #else + return DllRegisterServer2("DllUnregisterServer"); + #endif +} + +#endif + void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) { CSystemPage systemPage; - CPluginsPage pluginsPage; + // CPluginsPage pluginsPage; CEditPage editPage; CSettingsPage settingsPage; CLangPage langPage; + CMenuPage menuPage; + CFoldersPage foldersPage; CObjectVector pages; - UINT32 langIDs[] = { 0x03010300, 0x03010100, 0x03010200, 0x03010400, 0x01000400}; - UINT pageIDs[] = { IDD_SYSTEM, IDD_PLUGINS, IDD_EDIT, IDD_SETTINGS, IDD_LANG}; - NControl::CPropertyPage *pagePinters[] = { &systemPage, &pluginsPage, &editPage, &settingsPage, &langPage }; + UINT32 langIDs[] = { 0x03010300, + // 0x03010100, + 0xFFFFFFFF, + 0x01000200, 0x03010200, 0x03010400, 0x01000400}; + + BIG_DIALOG_SIZE(200, 200); + + UINT pageIDs[] = { + SIZED_DIALOG(IDD_SYSTEM), + // IDD_PLUGINS, + SIZED_DIALOG(IDD_MENU), + SIZED_DIALOG(IDD_FOLDERS), + IDD_EDIT, + SIZED_DIALOG(IDD_SETTINGS), + SIZED_DIALOG(IDD_LANG) }; + NControl::CPropertyPage *pagePinters[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage }; const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]); for (int i = 0; i < kNumPages; i++) { @@ -51,15 +123,23 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000)); if (res != -1 && res != 0) { - if (langPage._langWasChanged) + if (langPage.LangWasChanged) { g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); MyLoadMenu(); + g_App.ReloadToolbars(); + g_App.MoveSubWindows(); + } + /* + if (systemPage.WasChanged) + { + // probably it doesn't work, since image list is locked? + g_App.SysIconsWereChanged(); } + */ g_App.SetListSettings(); g_App.SetShowSystemMenu(); g_App.RefreshAllPanels(); - g_App.ReloadToolbars(); // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0); } } diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp index 42c63266..5f072daf 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -2,9 +2,8 @@ #include "StdAfx.h" -#include "OverwriteDialog.h" - #include "Common/StringConvert.h" + #include "Windows/FileName.h" #include "Windows/Defs.h" #include "Windows/ResourceString.h" @@ -12,6 +11,7 @@ #include "Windows/PropVariantConversions.h" #include "FormatUtils.h" +#include "OverwriteDialog.h" // #include "../resource.h" @@ -36,6 +36,16 @@ static CIDLangPair kIDLangPairs[] = }; #endif +static const int kCurrentFileNameSizeLimit = 82; +static const int kCurrentFileNameSizeLimit2 = 30; + +void COverwriteDialog::ReduceString(UString &s) +{ + int size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2; + if (s.Length() > size) + s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); +} + void COverwriteDialog::SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo) { @@ -47,19 +57,23 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, #endif NumberToString(fileInfo.Size)); - UString reducedName; - const int kLineSize = 88; - for (int i = 0; i < fileInfo.Name.Length();) + const UString &fileName = fileInfo.Name; + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); + UString s1, s2; + if (slashPos >= 0) { - reducedName += fileInfo.Name.Mid(i, kLineSize); - reducedName += L" "; - i += kLineSize; + s1 = fileName.Left(slashPos + 1); + s2 = fileName.Mid(slashPos + 1); } - - UString fullString = reducedName; - fullString += L"\n"; + else + s2 = fileName; + ReduceString(s1); + ReduceString(s2); + + UString fullString = s1 + L'\n' + s2; + fullString += L'\n'; fullString += sizeString; - fullString += L"\n"; + fullString += L'\n'; if (fileInfo.TimeIsDefined) { @@ -101,10 +115,9 @@ bool COverwriteDialog::OnInit() LangSetWindowText(HWND(*this), 0x02000900); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif - SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); - SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + NormalizePosition(); return CModalDialog::OnInit(); } diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h index d206fb01..f760611e 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h @@ -1,31 +1,68 @@ // OverwriteDialog.h -#ifndef __OVERWRITEDIALOG_H -#define __OVERWRITEDIALOG_H +#ifndef __OVERWRITE_DIALOG_H +#define __OVERWRITE_DIALOG_H + +#include "Common/Types.h" -#include "OverwriteDialogRes.h" #include "Windows/Control/Dialog.h" +#include "DialogSize.h" +#include "OverwriteDialogRes.h" + namespace NOverwriteDialog { struct CFileInfo { bool SizeIsDefined; - UINT64 Size; bool TimeIsDefined; + UInt64 Size; FILETIME Time; UString Name; + + void SetTime(const FILETIME *t) + { + if (t == 0) + TimeIsDefined = false; + else + { + TimeIsDefined = true; + Time = *t; + } + } + void SetSize(const UInt64 *size) + { + if (size == 0) + SizeIsDefined = false; + else + { + SizeIsDefined = true; + Size = *size; + } + } }; } class COverwriteDialog: public NWindows::NControl::CModalDialog { - void SetFileInfoControl(int textID, int iconID, - const NOverwriteDialog::CFileInfo &fileInfo); + bool _isBig; + + void SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo); virtual bool OnInit(); bool OnButtonClicked(int buttonID, HWND buttonHWND); + void ReduceString(UString &s); + public: - INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); } + INT_PTR Create(HWND parent = 0) + { + BIG_DIALOG_SIZE(280, 200); + #ifdef UNDER_CE + _isBig = isBig; + #else + _isBig = true; + #endif + return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_OVERWRITE), parent); + } NOverwriteDialog::CFileInfo OldFileInfo; NOverwriteDialog::CFileInfo NewFileInfo; diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.rc b/CPP/7zip/UI/FileManager/OverwriteDialog.rc index 1cce0876..8961d28b 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.rc +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.rc @@ -1,44 +1,89 @@ #include "OverwriteDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 357 -#define ySize2 204 - -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 280 +#define yc 200 #undef iconSize -#define iconSize 20 +#define iconSize 24 + +#undef x +#undef fx +#undef fy +#define x (m + iconSize + m) +#define fx (xc - iconSize - m) +#define fy 50 + +#define bSizeBig 104 +#undef bx1 +#define bx1 (xs - m - bSizeBig) + +IDD_DIALOG_OVERWRITE MY_DIALOG +CAPTION "Confirm File Replace" +BEGIN + LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, m, 7, xc, 8 + LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, 28, xc, 8 + + ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 44, iconSize, iconSize + LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 44, fx, fy, SS_NOPREFIX + + LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 98, xc, 8 + + ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 114, iconSize, iconSize + LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 114, fx, fy, SS_NOPREFIX + + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bSizeBig, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, xs - m - bxs, by1, bxs, bys +END -#undef fiXPos -#undef fiXSize -#undef fiYSize -#define fiXPos (iconSize + 12) -#define fiXSize (xSize2 - fiXPos) -#define fiYSize 50 -#define b1YPos (ySize - marg - bYSize) -#define b2YPos (b1YPos - bYSize - 10) +#ifdef UNDER_CE -IDD_DIALOG_OVERWRITE DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc 152 +#define yc 144 + +#undef fy +#define fy 40 + +#undef bxs +#define bxs 48 + +#undef bx1 + +#define bx1 (xs - m - bxs) + +IDD_DIALOG_OVERWRITE_2 MY_DIALOG CAPTION "Confirm File Replace" -MY_FONT BEGIN - LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8 - LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8 - ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize - LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize, SS_NOPREFIX - LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8 - ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize - LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize, SS_NOPREFIX - PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize - PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize - PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize - PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, 300, b2YPos, bXSize, bYSize - PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, 181, b1YPos, 109, bYSize - PUSHBUTTON "&Cancel", IDCANCEL, 300, b1YPos, bXSize, bYSize + LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, m, xc, 8 + + ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 20, iconSize, iconSize + LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 20, fx, fy, SS_NOPREFIX + + LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 60, xc, 8 + + ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 72, iconSize, iconSize + LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 72, fx, fy, SS_NOPREFIX + + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bxs, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, bx1, by1, bxs, bys END +#endif + STRINGTABLE BEGIN diff --git a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h index 66710f84..3bc6900d 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h @@ -1,8 +1,9 @@ +#define IDD_DIALOG_OVERWRITE 502 +#define IDD_DIALOG_OVERWRITE_2 602 + #define IDS_FILE_MODIFIED 600 #define IDS_FILE_SIZE 601 -#define IDD_DIALOG_OVERWRITE 502 - #define IDC_STATIC_OVERWRITE_HEADER 1000 #define IDC_STATIC_OVERWRITE_QUESTION_BEGIN 1001 diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index 9255b117..3988f1f3 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -118,6 +118,9 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) case kRefreshStatusBar: OnRefreshStatusBar(); return 0; + case kRefreshHeaderComboBox: + LoadFullPathAndShow(); + return 0; case WM_TIMER: OnTimer(); return 0; @@ -184,6 +187,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; switch(wParam) { + /* case VK_RETURN: { if (shift && !alt && !ctrl) @@ -193,6 +197,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) } break; } + */ case VK_NEXT: { if (ctrl && !alt && !shift) @@ -210,6 +215,17 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) } } } + #ifdef UNDER_CE + else if (message == WM_KEYUP) + { + if (wParam == VK_F2) // it's VK_TSOFT2 + { + // Activate Menu + ::PostMessage(g_HWND, WM_SYSCOMMAND, SC_KEYMENU, 0); + return 0; + } + } + #endif else if (message == WM_SETFOCUS) { _panel->_lastFocusedIsList = true; @@ -310,15 +326,6 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); } -static HIMAGELIST GetSysImageList(bool smallIcons) -{ - SHFILEINFO shellInfo; - return (HIMAGELIST)SHGetFileInfo(TEXT(""), - FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY, - &shellInfo, sizeof(shellInfo), - SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON)); -} - bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) { // _virtualMode = false; @@ -356,7 +363,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL)) return false; + #ifndef UNDER_CE _listView.SetUnicodeFormat(true); + #endif _listView.SetUserDataLongPtr(LONG_PTR(&_listView)); _listView._panel = this; @@ -398,7 +407,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0}, }; + #ifndef UNDER_CE if (g_ComCtl32Version >= MAKELONG(71, 4)) + #endif { icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; @@ -409,7 +420,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER - | CCS_NOPARENTALIGN + // | CCS_NOPARENTALIGN | CCS_TOP | RBS_VARHEIGHT | RBS_BANDBORDERS @@ -437,17 +448,27 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), 0, 0, 0, 0, sizeof (TBBUTTON))); + #ifndef UNDER_CE + // Load ComboBoxEx class icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_USEREX_CLASSES; InitCommonControlsEx(&icex); + #endif - _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL, + _headerComboBox.CreateEx(0, + #ifdef UNDER_CE + WC_COMBOBOXW + #else + WC_COMBOBOXEXW + #endif + , NULL, WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, 0, 0, 100, 520, ((_headerReBar == 0) ? HWND(*this) : _headerToolBar), (HMENU)(UINT_PTR)(_comboBoxID), g_hInstance, NULL); - _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0); + #ifndef UNDER_CE + _headerComboBox.SetUnicodeFormat(true); _headerComboBox.SetImageList(GetSysImageList(true)); @@ -475,6 +496,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _comboBoxEdit._origWindowProc = (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc)); + #endif + if (_headerReBar) { REBARINFO rbi; @@ -491,7 +514,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) REBARBANDINFO rbBand; rbBand.cbSize = sizeof(REBARBANDINFO); // Required - rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; + rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; rbBand.fStyle = RBBS_NOGRIPPER; rbBand.cxMinChild = size.cx; rbBand.cyMinChild = size.cy; @@ -540,6 +563,8 @@ void CPanel::OnDestroy() void CPanel::ChangeWindowSize(int xSize, int ySize) { + if ((HWND)*this == 0) + return; int kHeaderSize; int kStatusBarSize; // int kStatusBar2Size; @@ -577,6 +602,8 @@ void CPanel::ChangeWindowSize(int xSize, int ySize) bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize) { + if ((HWND)*this == 0) + return true; if (_headerReBar) _headerReBar.Move(0, 0, xSize, 0); ChangeWindowSize(xSize, ySize); @@ -611,7 +638,7 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result) return OnNotifyList(header, result); else if (::GetParent(header->hwndFrom) == _listView && header->code == NM_RCLICK) - return OnRightClick((LPNMITEMACTIVATE)header, result); + return OnRightClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header, result); return false; } @@ -647,15 +674,11 @@ void CPanel::MessageBox(LPCWSTR message) { MessageBox(message, L"7-Zip"); } void CPanel::MessageBoxMyError(LPCWSTR message) { MessageBox(message, L"Error"); } + + void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) { - UString message; - if (errorCode == E_OUTOFMEMORY) - message = LangString(IDS_MEM_ERROR, 0x0200060B); - else - if (!NError::MyFormatMessage(errorCode, message)) - message = L"Error"; - MessageBox(message, caption); + MessageBox(HResultToMessage(errorCode), caption); } void CPanel::MessageBoxError(HRESULT errorCode) @@ -791,26 +814,19 @@ void CPanel::AddToArchive() UString destCurDirPrefix = _currentFolderPrefix; if (IsFSDrivesFolder()) { - destCurDirPrefix = L"C:\\"; + destCurDirPrefix = ROOT_FS_FOLDER; if (!IsDeviceDrivesPrefix()) curPrefix.Empty(); } for (int i = 0; i < indices.Size(); i++) - { - int index = indices[i]; - names.Add(curPrefix + GetItemRelPath(index)); - } - const UString archiveName = CreateArchiveName( - names.Front(), (names.Size() > 1), false); - + names.Add(curPrefix + GetItemRelPath(indices[i])); + const UString archiveName = CreateArchiveName(names.Front(), (names.Size() > 1), false); HRESULT res = CompressFiles(destCurDirPrefix, archiveName, L"", names, false, true, false); if (res != S_OK) { - if (_currentFolderPrefix.Length() >= MAX_PATH) + if (destCurDirPrefix.Length() >= MAX_PATH) MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01); - else - MessageBoxError(res); } // KillSelection(); } @@ -866,40 +882,45 @@ void CPanel::ExtractArchives() ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true); } -struct CThreadTest +static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { + wchar_t sz[32]; + s += LangString(resourceID, langID); + s += L' '; + ConvertUInt64ToString(value, sz); + s += sz; + s += L'\n'; +} + +class CThreadTest: public CProgressThreadVirt +{ + HRESULT ProcessVirt(); +public: CRecordVector Indices; CExtractCallbackImp *ExtractCallbackSpec; CMyComPtr ExtractCallback; CMyComPtr ArchiveFolder; - HRESULT Result; +}; - void Test() - { - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(), - NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, - NULL, BoolToInt(true), ExtractCallback); - ExtractCallbackSpec->ProgressDialog.MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) +HRESULT CThreadTest::ProcessVirt() +{ + RINOK(ArchiveFolder->Extract(&Indices[0], Indices.Size(), + NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, + NULL, BoolToInt(true), ExtractCallback)); + if (ExtractCallbackSpec->IsOK()) { - ((CThreadTest*)param)->Test(); - return 0; + UString s; + AddValuePair(IDS_FOLDERS_COLON, 0x02000321, ExtractCallbackSpec->NumFolders, s); + AddValuePair(IDS_FILES_COLON, 0x02000320, ExtractCallbackSpec->NumFiles, s); + // AddSizePair(IDS_SIZE_COLON, 0x02000322, Stat.UnpackSize, s); + // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, Stat.PackSize, s); + s += L'\n'; + s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); + OkMessage = s; } + return S_OK; }; -static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) -{ - wchar_t sz[32]; - s += LangString(resourceID, langID); - s += L" "; - ConvertUInt64ToString(value, sz); - s += sz; - s += L"\n"; -} - /* static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { @@ -912,7 +933,7 @@ static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s s += L" ("; s += sz; s += L" MB)"; - s += L"\n"; + s += L'\n'; } */ @@ -930,8 +951,7 @@ void CPanel::TestArchives() extracter.ArchiveFolder = archiveFolder; extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; - extracter.ExtractCallbackSpec->ParentWindow = GetParent(); - extracter.ExtractCallbackSpec->ShowMessages = true; + extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; if (indices.IsEmpty()) return; @@ -941,35 +961,17 @@ void CPanel::TestArchives() UString title = LangString(IDS_PROGRESS_TESTING, 0x02000F90); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; - extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); - extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.CompressingMode = false; + extracter.ProgressDialog.MainWindow = GetParent(); + extracter.ProgressDialog.MainTitle = progressWindowTitle; + extracter.ProgressDialog.MainAddTitle = title + L" "; extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); - NWindows::CThread extractThread; - if (extractThread.Create(CThreadTest::MyThreadFunction, &extracter) != S_OK) + if (extracter.Create(title, GetParent()) != S_OK) return; - extracter.ExtractCallbackSpec->StartProgressDialog(title); - if (extracter.ExtractCallbackSpec->Messages.IsEmpty() && extracter.Result == S_OK) - { - UString s; - AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.ExtractCallbackSpec->NumFolders, s); - AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.ExtractCallbackSpec->NumFiles, s); - // AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s); - // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s); - s += L"\n"; - s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); - MessageBoxInfo(s, LangString(IDS_PROGRESS_TESTING, 0x02000F90)); - } - else - { - if (extracter.Result != S_OK && extracter.Result != E_ABORT) - MessageBoxError(extracter.Result, L"Testing Error"); - } } RefreshTitleAlways(); return; @@ -986,4 +988,3 @@ void CPanel::TestArchives() return; ::TestArchives(paths); } - diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index ed157634..ead12d2e 100755 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -3,6 +3,8 @@ #ifndef __PANEL_H #define __PANEL_H +#include "../../../../C/Alloc.h" + #include "Common/MyCom.h" #include "Windows/DLL.h" @@ -23,6 +25,7 @@ #include "AppState.h" #include "IFolder.h" #include "MyCom2.h" +#include "ProgressDialog2.h" #include "SysIconUtils.h" const int kParentFolderID = 100; @@ -31,6 +34,12 @@ const int kToolbarStartID = 2000; const int kParentIndex = -1; +#ifdef UNDER_CE +#define ROOT_FS_FOLDER L"\\" +#else +#define ROOT_FS_FOLDER L"C:\\\\" +#endif + struct CPanelCallback { virtual void OnTab() = 0; @@ -118,11 +127,12 @@ struct CFolderLink: public CTempFileInfo enum MyMessages { - kShiftSelectMessage = WM_USER + 1, + kShiftSelectMessage = WM_USER + 1, kReLoadMessage, kSetFocusToListView, kOpenItemChanged, - kRefreshStatusBar + kRefreshStatusBar, + kRefreshHeaderComboBox }; UString GetFolderPath(IFolderFolder * folder); @@ -163,6 +173,12 @@ struct CSelectedState CSelectedState(): FocusedItem(-1), SelectFocused(false) {} }; +#ifdef UNDER_CE +#define MY_NMLISTVIEW_NMITEMACTIVATE NMLISTVIEW +#else +#define MY_NMLISTVIEW_NMITEMACTIVATE NMITEMACTIVATE +#endif + class CPanel: public NWindows::NControl::CWindow2 { CExtToIconMap _extToIconMap; @@ -183,14 +199,20 @@ class CPanel: public NWindows::NControl::CWindow2 bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result); + #ifndef UNDER_CE + LRESULT OnNotifyComboBoxEnter(const UString &s); bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result); #ifndef _UNICODE bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result); #endif + + #endif + bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result); bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result); void OnItemChanged(NMLISTVIEW *item); + void OnNotifyActivateItems(); bool OnNotifyList(LPNMHDR lParam, LRESULT &result); void OnDrag(LPNMLISTVIEW nmListView); bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); @@ -203,6 +225,8 @@ public: HWND _mainWindow; CPanelCallback *_panelCallback; + void SysIconsWereChanged() { _extToIconMap.Clear(); } + void DeleteItems(bool toRecycleBin); void DeleteItemsInternal(CRecordVector &indices); void CreateFolder(); @@ -242,7 +266,13 @@ private: public: NWindows::NControl::CReBar _headerReBar; NWindows::NControl::CToolBar _headerToolBar; - NWindows::NControl::CComboBoxEx _headerComboBox; + NWindows::NControl:: + #ifdef UNDER_CE + CComboBox + #else + CComboBoxEx + #endif + _headerComboBox; UStringVector ComboBoxPaths; // CMyComboBox _headerComboBox; CMyComboBoxEdit _comboBoxEdit; @@ -383,8 +413,9 @@ public: void Release(); ~CPanel(); - void OnLeftClick(LPNMITEMACTIVATE itemActivate); - bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result); + void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate); + bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result); + void ShowColumnsContextMenu(int x, int y); void OnTimer(); void OnReload(); @@ -494,6 +525,8 @@ public: void MessageBoxLastError(LPCWSTR caption); void MessageBoxLastError(); + void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID); + void MessageBoxErrorLang(UINT resourceID, UInt32 langID); void OpenFocusedItemAsInternal(); @@ -522,10 +555,11 @@ public: void ChangeComment(); void SetListViewMode(UInt32 index); - UInt32 GetListViewMode() const { return _ListViewMode; }; + UInt32 GetListViewMode() const { return _ListViewMode; } + PROPID GetSortID() const { return _sortID; } void ChangeFlatMode(); - bool GetFlatMode() const { return _flatMode; }; + bool GetFlatMode() const { return _flatMode; } void RefreshStatusBar(); void OnRefreshStatusBar(); @@ -572,4 +606,20 @@ public: UString GetItemsInfoString(const CRecordVector &indices); }; +class CMyBuffer +{ + void *_data; +public: + CMyBuffer(): _data(0) {} + operator void *() { return _data; } + bool Allocate(size_t size) + { + if (_data != 0) + return false; + _data = ::MidAlloc(size); + return _data != 0; + } + ~CMyBuffer() { ::MidFree(_data); } +}; + #endif diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp index 8ad3d4c9..8c27ef2f 100755 --- a/CPP/7zip/UI/FileManager/PanelCopy.cpp +++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp @@ -13,8 +13,10 @@ using namespace NWindows; -struct CThreadExtractInArchive2 +class CPanelCopyThread: public CProgressThreadVirt { + HRESULT ProcessVirt(); +public: CMyComPtr FolderOperations; CRecordVector Indices; UString DestPath; @@ -23,26 +25,17 @@ struct CThreadExtractInArchive2 HRESULT Result; bool MoveMode; - CThreadExtractInArchive2(): MoveMode(false) {} - - DWORD Extract() - { - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - if (MoveMode) - Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), - DestPath, ExtractCallback); - else - Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), - DestPath, ExtractCallback); - ExtractCallbackSpec->ProgressDialog.MyClose(); - return 0; - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadExtractInArchive2 *)param)->Extract(); - } + CPanelCopyThread(): MoveMode(false), Result(E_FAIL) {} }; + +HRESULT CPanelCopyThread::ProcessVirt() +{ + if (MoveMode) + Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + else + Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + return Result; +} HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &folder, bool moveMode, bool showErrorMessages, UStringVector *messages, @@ -61,22 +54,22 @@ HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &fold HRESULT res; { - CThreadExtractInArchive2 extracter; + CPanelCopyThread extracter; + extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; - extracter.ExtractCallbackSpec->ParentWindow = GetParent(); - extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages; - extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; + extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; + extracter.ProgressDialog.CompressingMode = false; UString title = moveMode ? LangString(IDS_MOVING, 0x03020206): LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); - extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.MainWindow = GetParent(); + extracter.ProgressDialog.MainTitle = progressWindowTitle; + extracter.ProgressDialog.MainAddTitle = title + L" "; extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); @@ -88,15 +81,13 @@ HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &fold extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword; extracter.ExtractCallbackSpec->Password = password; - NWindows::CThread extractThread; - RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter)); - extracter.ExtractCallbackSpec->StartProgressDialog(title); + RINOK(extracter.Create(title, GetParent())); if (messages != 0) - *messages = extracter.ExtractCallbackSpec->Messages; + *messages = extracter.ProgressDialog.Sync.Messages; res = extracter.Result; - if (res == S_OK && extracter.ExtractCallbackSpec->Messages.IsEmpty()) + if (res == S_OK && extracter.ExtractCallbackSpec->IsOK()) { usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined; password = extracter.ExtractCallbackSpec->Password; @@ -113,57 +104,55 @@ struct CThreadUpdate UString FolderPrefix; UStringVector FileNames; CRecordVector FileNamePointers; + CProgressDialog ProgressDialog; CMyComPtr UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; HRESULT Result; - DWORD Process() + void Process() { - UpdateCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderOperations->CopyFrom( + try + { + CProgressCloser closer(ProgressDialog); + Result = FolderOperations->CopyFrom( FolderPrefix, &FileNamePointers.Front(), FileNamePointers.Size(), UpdateCallback); - UpdateCallbackSpec->ProgressDialog.MyClose(); - return 0; + } + catch(...) { Result = E_FAIL; } } - static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadUpdate *)param)->Process(); + ((CThreadUpdate *)param)->Process(); + return 0; } }; - HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages) { CMyComPtr folderOperations; - if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) - { - UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - if (showErrorMessages) - MessageBox(errorMessage); - else if (messages != 0) - messages->Add(errorMessage); - return E_FAIL; - } - + _folder.QueryInterface(IID_IFolderOperations, &folderOperations); HRESULT res; + if (!folderOperations) + res = E_NOINTERFACE; + else { CThreadUpdate updater; updater.UpdateCallbackSpec = new CUpdateCallback100Imp; updater.UpdateCallback = updater.UpdateCallbackSpec; + updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog; + UString title = LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent(); - updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - updater.UpdateCallbackSpec->ProgressDialog.MainAddTitle = title + UString(L" "); + updater.ProgressDialog.MainWindow = GetParent(); + updater.ProgressDialog.MainTitle = progressWindowTitle; + updater.ProgressDialog.MainAddTitle = title + UString(L" "); - updater.UpdateCallbackSpec->Init((HWND)*this, false, L""); + updater.UpdateCallbackSpec->Init(false, L""); updater.FolderOperations = folderOperations; updater.FolderPrefix = folderPrefix; updater.FileNames.Reserve(filePaths.Size()); @@ -176,13 +165,24 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP NWindows::CThread thread; RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater)); - updater.UpdateCallbackSpec->StartProgressDialog(title); + updater.ProgressDialog.Create(title, thread, GetParent()); if (messages != 0) - *messages = updater.UpdateCallbackSpec->Messages; + *messages = updater.ProgressDialog.Sync.Messages; res = updater.Result; } + + if (res == E_NOINTERFACE) + { + UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + if (showErrorMessages) + MessageBox(errorMessage); + else if (messages != 0) + messages->Add(errorMessage); + return E_ABORT; + } + RefreshTitleAlways(); return res; } @@ -219,10 +219,9 @@ void CPanel::CopyFromAsk(const UStringVector &filePaths) message += L"\n\'"; message += _currentFolderPrefix; message += L"\' ?"; - int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL); + int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION); if (res != IDYES) return; CopyFromNoAsk(filePaths); } - diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp index aaa645cf..6b00a9b5 100755 --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -3,19 +3,15 @@ #include "StdAfx.h" #include "../../../../C/7zCrc.h" -#include "../../../../C/Alloc.h" #include "../../../../C/Sha256.h" #include "Common/IntToString.h" -#include "Windows/Error.h" #include "Windows/FileFind.h" #include "Windows/FileIO.h" #include "Windows/FileName.h" -#include "Windows/Thread.h" #include "OverwriteDialogRes.h" -#include "ProgressDialog2.h" #include "App.h" #include "FormatUtils.h" @@ -27,7 +23,6 @@ using namespace NWindows; using namespace NFile; -using namespace NName; static const UInt32 kBufSize = (1 << 15); @@ -40,7 +35,7 @@ struct CDirEnumerator CObjectVector Enumerators; UStringVector Prefixes; int Index; - bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode); + HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath); void Init(); CDirEnumerator(): FlatMode(false) {}; @@ -53,7 +48,13 @@ void CDirEnumerator::Init() Index = 0; } -bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode) +static HRESULT GetNormalizedError() +{ + HRESULT errorCode = GetLastError(); + return (errorCode == 0) ? E_FAIL : errorCode; +} + +HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath) { filled = false; for (;;) @@ -61,7 +62,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr if (Enumerators.IsEmpty()) { if (Index >= FileNames.Size()) - return true; + return S_OK; const UString &path = FileNames[Index]; int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); resPath.Empty(); @@ -80,9 +81,9 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr #endif if (!fileInfo.Find(BasePrefix + path)) { - errorCode = ::GetLastError(); + WRes errorCode = GetNormalizedError(); resPath = path; - return false; + return errorCode; } Index++; break; @@ -90,9 +91,9 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr bool found; if (!Enumerators.Back().Next(fileInfo, found)) { - errorCode = ::GetLastError(); + HRESULT errorCode = GetNormalizedError(); resPath = Prefixes.Back(); - return false; + return errorCode; } if (found) { @@ -105,36 +106,26 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr resPath += fileInfo.Name; if (!FlatMode && fileInfo.IsDir()) { - UString prefix = resPath + (UString)(wchar_t)kDirDelimiter; - Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard)); + UString prefix = resPath + WCHAR_PATH_SEPARATOR; + Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard)); Prefixes.Add(prefix); } filled = true; - return true; + return S_OK; } -struct CThreadCrc +static void ConvertByteToHex(unsigned value, wchar_t *s) { - class CMyBuffer + for (int i = 0; i < 2; i++) { - void *_data; - public: - CMyBuffer(): _data(0) {} - operator void *() { return _data; } - bool Allocate(size_t size) - { - if (_data != 0) - return false; - _data = ::MidAlloc(size); - return _data != 0; - } - ~CMyBuffer() { ::MidFree(_data); } - }; - - CProgressDialog *ProgressDialog; + unsigned t = value & 0xF; + value >>= 4; + s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); + } +} - CDirEnumerator DirEnumerator; - +class CThreadCrc: public CProgressThreadVirt +{ UInt64 NumFilesScan; UInt64 NumFiles; UInt64 NumFolders; @@ -143,155 +134,176 @@ struct CThreadCrc Byte Sha256Sum[SHA256_DIGEST_SIZE]; UInt32 DataNameCrcSum; - HRESULT Result; - DWORD ErrorCode; - UString ErrorPath; - UString Error; - bool ThereIsError; + UString GetResultMessage() const; + HRESULT ProcessVirt(); +public: + CDirEnumerator Enumerator; + +}; + +UString CThreadCrc::GetResultMessage() const +{ + UString s; + wchar_t sz[32]; + + s += LangString(IDS_FILES_COLON, 0x02000320); + s += L' '; + ConvertUInt64ToString(NumFiles, sz); + s += sz; + s += L'\n'; + + s += LangString(IDS_FOLDERS_COLON, 0x02000321); + s += L' '; + ConvertUInt64ToString(NumFolders, sz); + s += sz; + s += L'\n'; - void Process2() + s += LangString(IDS_SIZE_COLON, 0x02000322); + s += L' '; + ConvertUInt64ToString(DataSize, sz); + s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz); + s += L'\n'; + + s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721); + s += L' '; + ConvertUInt32ToHex(DataCrcSum, sz); + s += sz; + s += L'\n'; + + s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722); + s += L' '; + ConvertUInt32ToHex(DataNameCrcSum, sz); + s += sz; + s += L'\n'; + + if (NumFiles == 1 && NumFilesScan == 1) { - DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0; - memset(Sha256Sum, 0, SHA256_DIGEST_SIZE); - ProgressDialog->WaitCreating(); - - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) + s += L"SHA-256: "; + for (int i = 0; i < SHA256_DIGEST_SIZE; i++) { - Error = L"Can not allocate memory"; - ThereIsError = true; - return; + wchar_t s2[4]; + ConvertByteToHex(Sha256Sum[i], s2); + s2[2] = 0; + s += s2; } - Byte *buffer = (Byte *)(void *)bufferObject; - - UInt64 totalSize = 0; - - DirEnumerator.Init(); + } + return s; +} - UString scanningStr = LangString(IDS_SCANNING, 0x03020800); - scanningStr += L" "; +HRESULT CThreadCrc::ProcessVirt() +{ + DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0; + memset(Sha256Sum, 0, SHA256_DIGEST_SIZE); + // ProgressDialog.WaitCreating(); + + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + + UInt64 totalSize = 0; + + Enumerator.Init(); + + UString scanningStr = LangString(IDS_SCANNING, 0x03020800); + scanningStr += L' '; + + CProgressSync &sync = ProgressDialog.Sync; - for (;;) + for (;;) + { + NFind::CFileInfoW fileInfo; + bool filled; + UString resPath; + HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); + if (errorCode != 0) { - NFile::NFind::CFileInfoW fileInfo; - bool filled; - UString resPath; - if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode)) - { - ThereIsError = true; - ErrorPath = resPath; - return; - } - if (!filled) - break; - if (!fileInfo.IsDir()) - { - totalSize += fileInfo.Size; - NumFilesScan++; - } - ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath); - ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0); - if (Result != S_OK) - return; + ErrorPath1 = resPath; + return errorCode; } - ProgressDialog->ProgressSynch.SetNumFilesTotal(NumFilesScan); - ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); - - DirEnumerator.Init(); - - for (;;) + if (!filled) + break; + if (!fileInfo.IsDir()) + { + totalSize += fileInfo.Size; + NumFilesScan++; + } + sync.SetCurrentFileName(scanningStr + resPath); + sync.SetProgress(totalSize, 0); + RINOK(sync.SetPosAndCheckPaused(0)); + } + sync.SetNumFilesTotal(NumFilesScan); + sync.SetProgress(totalSize, 0); + + Enumerator.Init(); + + for (;;) + { + NFind::CFileInfoW fileInfo; + bool filled; + UString resPath; + HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); + if (errorCode != 0) { - NFile::NFind::CFileInfoW fileInfo; - bool filled; - UString resPath; - if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode)) + ErrorPath1 = resPath; + return errorCode; + } + if (!filled) + break; + + UInt32 crc = CRC_INIT_VAL; + CSha256 sha256; + Sha256_Init(&sha256); + + if (fileInfo.IsDir()) + NumFolders++; + else + { + NIO::CInFile inFile; + if (!inFile.Open(Enumerator.BasePrefix + resPath)) { - ThereIsError = true; - ErrorPath = resPath; - return; + errorCode = GetNormalizedError(); + ErrorPath1 = resPath; + return errorCode; } - if (!filled) - break; - - UInt32 crc = CRC_INIT_VAL; - CSha256 sha256; - Sha256_Init(&sha256); - - if (fileInfo.IsDir()) - NumFolders++; - else + sync.SetCurrentFileName(resPath); + sync.SetNumFilesCur(NumFiles); + NumFiles++; + for (;;) { - NFile::NIO::CInFile inFile; - if (!inFile.Open(DirEnumerator.BasePrefix + resPath)) + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) { - ErrorCode = ::GetLastError(); - ThereIsError = true; - ErrorPath = resPath; - return; + errorCode = GetNormalizedError(); + ErrorPath1 = resPath; + return errorCode; } - ProgressDialog->ProgressSynch.SetCurrentFileName(resPath); - ProgressDialog->ProgressSynch.SetNumFilesCur(NumFiles); - NumFiles++; - for (;;) - { - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) - { - ErrorCode = ::GetLastError(); - ThereIsError = true; - ErrorPath = resPath; - return; - } - if (processedSize == 0) - break; - crc = CrcUpdate(crc, buffer, processedSize); - if (NumFilesScan == 1) - Sha256_Update(&sha256, buffer, processedSize); - - DataSize += processedSize; - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); - if (Result != S_OK) - return; - } - DataCrcSum += CRC_GET_DIGEST(crc); + if (processedSize == 0) + break; + crc = CrcUpdate(crc, buffer, processedSize); if (NumFilesScan == 1) - Sha256_Final(&sha256, Sha256Sum); - } - for (int i = 0; i < resPath.Length(); i++) - { - wchar_t c = resPath[i]; - crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF))); - crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF))); + Sha256_Update(&sha256, buffer, processedSize); + + DataSize += processedSize; + RINOK(sync.SetPosAndCheckPaused(DataSize)); } - DataNameCrcSum += CRC_GET_DIGEST(crc); - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); - if (Result != S_OK) - return; + DataCrcSum += CRC_GET_DIGEST(crc); + if (NumFilesScan == 1) + Sha256_Final(&sha256, Sha256Sum); } + for (int i = 0; i < resPath.Length(); i++) + { + wchar_t c = resPath[i]; + crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF))); + crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF))); + } + DataNameCrcSum += CRC_GET_DIGEST(crc); + RINOK(sync.SetPosAndCheckPaused(DataSize)); } - DWORD Process() - { - try { Process2(); } - catch(...) { Error = L"Error"; ThereIsError = true;} - ProgressDialog->MyClose(); - return 0; - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadCrc *)param)->Process(); - } -}; - -static void ConvertByteToHex(unsigned value, wchar_t *s) -{ - for (int i = 0; i < 2; i++) - { - unsigned t = value & 0xF; - value >>= 4; - s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); - } + sync.SetNumFilesCur(NumFiles); + OkMessage = GetResultMessage(); + OkMessageTitle = LangString(IDS_CHECKSUM_INFORMATION, 0x03020720); + return S_OK; } void CApp::CalculateCrc() @@ -308,98 +320,23 @@ void CApp::CalculateCrc() if (indices.IsEmpty()) return; - CThreadCrc combiner; + { + CThreadCrc t; for (int i = 0; i < indices.Size(); i++) - combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i])); - combiner.DirEnumerator.BasePrefix = srcPanel.GetFsPath(); - combiner.DirEnumerator.FlatMode = GetFlatMode(); + t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i])); + t.Enumerator.BasePrefix = srcPanel.GetFsPath(); + t.Enumerator.FlatMode = GetFlatMode(); - { - CProgressDialog progressDialog; - combiner.ProgressDialog = &progressDialog; - combiner.ErrorCode = 0; - combiner.Result = S_OK; - combiner.ThereIsError = false; + t.ProgressDialog.ShowCompressionInfo = false; - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710); - progressDialog.MainWindow = _window; - progressDialog.MainTitle = progressWindowTitle; - progressDialog.MainAddTitle = title + UString(L" "); + t.ProgressDialog.MainWindow = _window; + t.ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + t.ProgressDialog.MainAddTitle = title + UString(L' '); - NWindows::CThread thread; - if (thread.Create(CThreadCrc::MyThreadFunction, &combiner) != S_OK) + if (t.Create(title, _window) != S_OK) return; - progressDialog.Create(title, _window); - - if (combiner.Result != S_OK) - { - if (combiner.Result != E_ABORT) - srcPanel.MessageBoxError(combiner.Result); - } - else if (combiner.ThereIsError) - { - if (combiner.Error.IsEmpty()) - { - UString message = combiner.DirEnumerator.BasePrefix + combiner.ErrorPath; - message += L"\n"; - message += NError::MyFormatMessageW(combiner.ErrorCode); - srcPanel.MessageBoxMyError(message); - } - else - srcPanel.MessageBoxMyError(combiner.Error); - } - else - { - UString s; - { - wchar_t sz[32]; - - s += LangString(IDS_FILES_COLON, 0x02000320); - s += L" "; - ConvertUInt64ToString(combiner.NumFiles, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_FOLDERS_COLON, 0x02000321); - s += L" "; - ConvertUInt64ToString(combiner.NumFolders, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_SIZE_COLON, 0x02000322); - s += L" "; - ConvertUInt64ToString(combiner.DataSize, sz); - s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);; - s += L"\n"; - - s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721); - s += L" "; - ConvertUInt32ToHex(combiner.DataCrcSum, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722); - s += L" "; - ConvertUInt32ToHex(combiner.DataNameCrcSum, sz); - s += sz; - s += L"\n"; - - if (combiner.NumFiles == 1 && combiner.NumFilesScan == 1) - { - s += L"SHA-256: "; - for (int i = 0; i < SHA256_DIGEST_SIZE; i++) - { - wchar_t s2[4]; - ConvertByteToHex(combiner.Sha256Sum[i], s2); - s2[2] = 0; - s += s2; - } - } - } - srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720)); - } } RefreshTitleAlways(); } diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp index 6d1c9a29..eb5ad871 100755 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -2,6 +2,10 @@ #include "StdAfx.h" +#ifdef UNDER_CE +#include +#endif + #include "Common/StringConvert.h" #include "Windows/Memory.h" @@ -413,6 +417,10 @@ void CDropTarget::RemoveSelection() m_SelectionIndex = -1; } +#ifdef UNDER_CE +#define ChildWindowFromPointEx(hwndParent, pt, uFlags) ChildWindowFromPoint(hwndParent, pt) +#endif + void CDropTarget::PositionCursor(POINTL ptl) { m_SubFolderIndex = -1; @@ -767,8 +775,6 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo { if (fileNames.Size() == 0) return; - const UString archiveName = CreateArchiveName(fileNames.Front(), - (fileNames.Size() > 1), false); bool createNewArchive = true; if (!IsFSFolder()) createNewArchive = !DoesItSupportOperations(); @@ -780,8 +786,9 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo { NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2); if (IsFolderInTemp(folderPath2)) - folderPath2 = L"C:\\"; // fix it + folderPath2 = ROOT_FS_FOLDER; } + const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false); CompressFiles(folderPath2, archiveName, L"", fileNames, false, // email true, // showDialog diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index e6336f31..41ffe9da 100755 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -9,7 +9,11 @@ #include "../../PropID.h" +#ifdef UNDER_CE +#include "FSFolder.h" +#else #include "FSDrives.h" +#endif #include "LangUtils.h" #include "ListViewDialog.h" #include "Panel.h" @@ -193,6 +197,8 @@ void CPanel::LoadFullPathAndShow() _appState->FolderHistory.AddString(_currentFolderPrefix); _headerComboBox.SetText(_currentFolderPrefix); + + #ifndef UNDER_CE COMBOBOXEXITEM item; item.mask = 0; @@ -220,10 +226,12 @@ void CPanel::LoadFullPathAndShow() } item.iItem = -1; _headerComboBox.SetItem(&item); + #endif RefreshTitle(); } +#ifndef UNDER_CE LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s) { if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK) @@ -262,6 +270,7 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result) } return false; } +#endif #ifndef _UNICODE bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result) @@ -295,6 +304,16 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result) void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList) { + #ifdef UNDER_CE + + UString s; + iconIndex = iconIndex; + for (int i = 0; i < indent; i++) + s += L" "; + _headerComboBox.AddString(s + name); + + #else + COMBOBOXEXITEMW item; item.mask = CBEIF_TEXT | CBEIF_INDENT; item.iSelectedImage = item.iImage = iconIndex; @@ -304,6 +323,9 @@ void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, boo item.iIndent = indent; item.pszText = (LPWSTR)(LPCWSTR)name; _headerComboBox.InsertItem(&item); + + #endif + if (addToList) ComboBoxPaths.Add(name); } @@ -322,32 +344,30 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) ComboBoxPaths.Clear(); _headerComboBox.ResetContent(); - int iconIndex; - UString name; - int i; UStringVector pathParts; SplitPathToParts(_currentFolderPrefix, pathParts); UString sumPass; + if (!pathParts.IsEmpty()) + pathParts.DeleteBack(); for (i = 0; i < pathParts.Size(); i++) { UString name = pathParts[i]; - if (name.IsEmpty()) - continue; sumPass += name; - UString curName = sumPass; - if (i == 0) - curName += WCHAR_PATH_SEPARATOR; + sumPass += WCHAR_PATH_SEPARATOR; CFileInfoW info; DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; if (info.Find(sumPass)) attrib = info.Attrib; - sumPass += WCHAR_PATH_SEPARATOR; - AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false); + AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false); ComboBoxPaths.Add(sumPass); } + #ifndef UNDER_CE + + int iconIndex; + UString name; name = RootFolder_GetName_Documents(iconIndex); AddComboBoxItem(name, iconIndex, 0, true); @@ -369,7 +389,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) name = RootFolder_GetName_Network(iconIndex); AddComboBoxItem(name, iconIndex, 0, true); - // UStringVector strings; _appState->FolderHistory.GetList(strings); + #endif return false; } @@ -382,10 +402,14 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) { UString pass = ComboBoxPaths[index]; _headerComboBox.SetCurSel(-1); - _headerComboBox.SetText(pass); // it's fix for seclecting by mouse. + // _headerComboBox.SetText(pass); // it's fix for seclecting by mouse. if (BindToPathAndRefresh(pass) == S_OK) { PostMessage(kSetFocusToListView); + #ifdef UNDER_CE + PostMessage(kRefreshHeaderComboBox); + #endif + return true; } } @@ -410,6 +434,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) { + #ifndef UNDER_CE switch(header->code) { case CBEN_BEGINEDIT: @@ -429,6 +454,7 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result); } } + #endif return false; } @@ -463,16 +489,17 @@ void CPanel::OpenParentFolder() { LoadFullPath(); // Maybe we don't need it ?? UString focucedName; - if (!_currentFolderPrefix.IsEmpty()) + if (!_currentFolderPrefix.IsEmpty() && + _currentFolderPrefix.Back() == WCHAR_PATH_SEPARATOR) { - UString string = _currentFolderPrefix; - string.Delete(string.Length() - 1); - int pos = string.ReverseFind(WCHAR_PATH_SEPARATOR); - if (pos < 0) - pos = 0; - else - pos++; - focucedName = string.Mid(pos); + focucedName = _currentFolderPrefix; + focucedName.DeleteBack(); + if (focucedName != L"\\\\.") + { + int pos = focucedName.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0) + focucedName = focucedName.Mid(pos + 1); + } } CDisableTimerProcessing disableTimerProcessing1(*this); @@ -553,9 +580,15 @@ void CPanel::OpenRootFolder() void CPanel::OpenDrivesFolder() { CloseOpenFolders(); - CFSDrives *fsFolderSpec = new CFSDrives; - _folder = fsFolderSpec; - fsFolderSpec->Init(); + #ifdef UNDER_CE + NFsFolder::CFSFolder *folderSpec = new NFsFolder::CFSFolder; + _folder = folderSpec; + folderSpec->InitToRoot(); + #else + CFSDrives *folderSpec = new CFSDrives; + _folder = folderSpec; + folderSpec->Init(); + #endif RefreshListCtrl(); } diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 2aab2aae..2deea0af 100755 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -8,22 +8,19 @@ #include "Windows/Error.h" #include "Windows/FileDir.h" #include "Windows/FileFind.h" -#include "Windows/Synchronization.h" +#include "Windows/Process.h" #include "Windows/Thread.h" -#include "ExtractCallback.h" +#include "../Common/ExtractingFilePath.h" + +#include "App.h" + #include "FileFolderPluginOpen.h" #include "FormatUtils.h" -#include "IFolder.h" #include "LangUtils.h" -#include "Panel.h" #include "RegistryUtils.h" #include "UpdateCallback100.h" -#include "App.h" - -#include "../Common/ExtractingFilePath.h" - #include "resource.h" using namespace NWindows; @@ -31,7 +28,6 @@ using namespace NSynchronization; using namespace NFile; using namespace NDirectory; -extern HWND g_HWND; #ifndef _UNICODE extern bool g_IsNT; #endif @@ -167,6 +163,9 @@ HRESULT CPanel::OpenParentArchiveFolder() static const wchar_t *kStartExtensions[] = { + #ifdef UNDER_CE + L"cab", + #endif L"exe", L"bat", L"com", L"chm", L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb", @@ -175,7 +174,9 @@ static const wchar_t *kStartExtensions[] = L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn", L"dwf", - + + L"flv", L"swf", + L"odt", L"ods", L"wb3", L"pdf" @@ -194,81 +195,31 @@ static bool DoItemAlwaysStart(const UString &name) return false; } -static HRESULT MyCreateProcess(const UString &command, HANDLE *hProcess) +static UString GetQuotedString(const UString &s) { - PROCESS_INFORMATION processInformation; - BOOL result; - #ifndef _UNICODE - if (!g_IsNT) - { - STARTUPINFOA startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command), - NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); - } - else - #endif - { - STARTUPINFOW startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command, - NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); - } - - if (result == 0) - return ::GetLastError(); - - ::CloseHandle(processInformation.hThread); - *hProcess = processInformation.hProcess; - return S_OK; + return UString(L'\"') + s + UString(L'\"'); } -static HRESULT MyCreateProcess(const UString &command) -{ - HANDLE hProcess; - HRESULT res = MyCreateProcess(command, &hProcess); - if (res == SZ_OK) - ::CloseHandle(hProcess); - return res; -} - -static HANDLE StartEditApplication(const UString &path, HWND window) +static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &process) { UString command; ReadRegEditor(command); if (command.IsEmpty()) { + #ifdef UNDER_CE + command = L"\\Windows\\"; + #else if (!MyGetWindowsDirectory(command)) return 0; NFile::NName::NormalizeDirPathPrefix(command); + #endif command += L"notepad.exe"; } - command = UString(L"\"") + command + UString(L"\""); - command += L" \""; - command += path; - command += L"\""; - HANDLE hProcess; - HRESULT res = MyCreateProcess(command, &hProcess); - if (res == SZ_OK) - return hProcess; - ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), - L"7-Zip", MB_OK | MB_ICONSTOP); - return 0; + HRESULT res = process.Create(command, GetQuotedString(path), NULL); + if (res != SZ_OK) + ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); + return res; } void CApp::DiffFiles() @@ -304,16 +255,9 @@ void CApp::DiffFiles() if (command.IsEmpty()) return; - command = UString(L"\"") + command + UString(L"\""); - command += L" \""; - command += path1; - command += L"\""; - - command += L" \""; - command += path2; - command += L"\""; + UString param = GetQuotedString(path1) + L' ' + GetQuotedString(path2); - HRESULT res = MyCreateProcess(command); + HRESULT res = MyCreateProcess(command, param); if (res == SZ_OK) return; ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); @@ -323,10 +267,9 @@ void CApp::DiffFiles() typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo); #endif -static HANDLE StartApplication(const UString &dir, const UString &path, HWND window) +static HRESULT StartApplication(const UString &dir, const UString &path, HWND window, CProcess &process) { UINT32 result; - HANDLE hProcess; #ifndef _UNICODE if (g_IsNT) { @@ -346,28 +289,38 @@ static HANDLE StartApplication(const UString &dir, const UString &path, HWND win return 0; shellExecuteExW(&execInfo); result = (UINT32)(UINT_PTR)execInfo.hInstApp; - hProcess = execInfo.hProcess; + process.Attach(execInfo.hProcess); } else #endif { SHELLEXECUTEINFO execInfo; execInfo.cbSize = sizeof(execInfo); - execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; + execInfo.fMask = SEE_MASK_NOCLOSEPROCESS + #ifndef UNDER_CE + | SEE_MASK_FLAG_DDEWAIT + #endif + ; execInfo.hwnd = NULL; execInfo.lpVerb = NULL; const CSysString sysPath = GetSystemString(path); const CSysString sysDir = GetSystemString(dir); execInfo.lpFile = sysPath; execInfo.lpParameters = NULL; - execInfo.lpDirectory = sysDir.IsEmpty() ? NULL : (LPCTSTR)sysDir; + execInfo.lpDirectory = + #ifdef UNDER_CE + NULL + #else + sysDir.IsEmpty() ? NULL : (LPCTSTR)sysDir + #endif + ; execInfo.nShow = SW_SHOWNORMAL; execInfo.hProcess = 0; ::ShellExecuteEx(&execInfo); result = (UINT32)(UINT_PTR)execInfo.hInstApp; - hProcess = execInfo.hProcess; + process.Attach(execInfo.hProcess); } - if(result <= 32) + if (result <= 32) { switch(result) { @@ -378,7 +331,13 @@ static HANDLE StartApplication(const UString &dir, const UString &path, HWND win L"7-Zip", MB_OK | MB_ICONSTOP); } } - return hProcess; + return S_OK; +} + +static void StartApplicationDontWait(const UString &dir, const UString &path, HWND window) +{ + CProcess process; + StartApplication(dir, path, window, process); } void CPanel::EditItem(int index) @@ -388,18 +347,29 @@ void CPanel::EditItem(int index) OpenItemInArchive(index, false, true, true); return; } - HANDLE hProcess = StartEditApplication(GetItemFullPath(index), (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + CProcess process; + StartEditApplication(GetItemFullPath(index), (HWND)*this, process); } void CPanel::OpenFolderExternal(int index) { UString fsPrefix = GetFsPath(); - HANDLE hProcess = StartApplication(fsPrefix, - fsPrefix + GetItemRelPath(index) + WCHAR_PATH_SEPARATOR, (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + UString name; + if (index == kParentIndex) + { + int pos = fsPrefix.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0 && pos == fsPrefix.Length() - 1) + { + UString s = fsPrefix.Left(pos); + pos = s.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0) + fsPrefix = s.Left(pos + 1); + } + name = fsPrefix; + } + else + name = fsPrefix + GetItemRelPath(index) + WCHAR_PATH_SEPARATOR; + StartApplicationDontWait(fsPrefix, name, (HWND)*this); } void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) @@ -416,7 +386,8 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) MessageBoxErrorLang(IDS_VIRUS, 0x03020284); return; } - UString fullPath = _currentFolderPrefix + name; + UString prefix = GetFsPath(); + UString fullPath = prefix + name; if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) { @@ -432,12 +403,31 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) if (tryExternal) { // SetCurrentDirectory opens HANDLE to folder!!! - // NDirectory::MySetCurrentDirectory(_currentFolderPrefix); - HANDLE hProcess = StartApplication(_currentFolderPrefix, fullPath, (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + // NDirectory::MySetCurrentDirectory(prefix); + StartApplicationDontWait(prefix, fullPath, (HWND)*this); } } + +class CThreadCopyFrom: public CProgressThreadVirt +{ + HRESULT ProcessVirt(); +public: + UString PathPrefix; + UString Name; + + CMyComPtr FolderOperations; + CMyComPtr UpdateCallback; + CUpdateCallback100Imp *UpdateCallbackSpec; +}; + +HRESULT CThreadCopyFrom::ProcessVirt() +{ + UStringVector fileNames; + CRecordVector fileNamePointers; + fileNames.Add(Name); + fileNamePointers.Add(fileNames[0]); + return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback); +}; HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password) @@ -448,19 +438,18 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return E_FAIL; } - UStringVector fileNames; - CRecordVector fileNamePointers; - fileNames.Add(itemName); - fileNamePointers.Add(fileNames[0]); - - UString pathPrefix = folderPath; - NName::NormalizeDirPathPrefix(pathPrefix); - - CUpdateCallback100Imp *callbackSpec = new CUpdateCallback100Imp; - CMyComPtr callback = callbackSpec; - callbackSpec->Init((HWND)*this, usePassword, password); - return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), callback); + CThreadCopyFrom t; + t.UpdateCallbackSpec = new CUpdateCallback100Imp; + t.UpdateCallback = t.UpdateCallbackSpec; + t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog; + t.Name = itemName; + t.PathPrefix = folderPath; + NName::NormalizeDirPathPrefix(t.PathPrefix); + t.FolderOperations = folderOperations; + t.UpdateCallbackSpec->Init(usePassword, password); + RINOK(t.Create(itemName, (HWND)*this)); + return t.Result; } LRESULT CPanel::OnOpenItemChanged(LPARAM lParam) @@ -658,19 +647,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (!tryExternal) return; - HANDLE hProcess; + CProcess process; + HRESULT res; if (editMode) - hProcess = StartEditApplication(tempFilePath, (HWND)*this); + res = StartEditApplication(tempFilePath, (HWND)*this, process); else - hProcess = StartApplication(tempDirNorm, tempFilePath, (HWND)*this); + res = StartApplication(tempDirNorm, tempFilePath, (HWND)*this, process); - if (hProcess == 0) + if ((HANDLE)process == 0) return; tmpProcessInfo->Window = (HWND)(*this); tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix; tmpProcessInfo->ItemName = name; - tmpProcessInfo->ProcessHandle = hProcess; + tmpProcessInfo->ProcessHandle = process.Detach(); NWindows::CThread thread; if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK) diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp index 7ea9585a..626d4309 100755 --- a/CPP/7zip/UI/FileManager/PanelItems.cpp +++ b/CPP/7zip/UI/FileManager/PanelItems.cpp @@ -716,13 +716,20 @@ void CPanel::SaveListViewInfo() } } -bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) + +bool CPanel::OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActiveate, LRESULT &result) { if(itemActiveate->hdr.hwndFrom == HWND(_listView)) return false; - POINT point; ::GetCursorPos(&point); + ShowColumnsContextMenu(point.x, point.y); + result = TRUE; + return true; +} + +void CPanel::ShowColumnsContextMenu(int x, int y) +{ CMenu menu; CMenuDestroyer menuDestroyer(menu); @@ -740,8 +747,7 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) flags |= MF_GRAYED; menu.AppendItem(flags, kCommandStart + i, prop.Name); } - int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, - point.x, point.y, _listView); + int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView); if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size()) { int index = menuResult - kCommandStart; @@ -775,8 +781,6 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) _listView.DeleteColumn(visibleIndex); } } - result = TRUE; - return true; } void CPanel::OnReload() diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp index aee4759e..43d7981b 100755 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -180,7 +180,9 @@ LRESULT CPanel::SetItemText(LVITEMW &item) return 0; } +#ifndef UNDER_CE extern DWORD g_ComCtl32Version; +#endif void CPanel::OnItemChanged(NMLISTVIEW *item) { @@ -194,11 +196,23 @@ void CPanel::OnItemChanged(NMLISTVIEW *item) _selectedStatusVector[index] = newSelected; } +extern bool g_LVN_ITEMACTIVATE_Support; + +void CPanel::OnNotifyActivateItems() +{ + // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; + // bool rightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; + bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; + bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + if (!shift && alt && !ctrl) + Properties(); + else + OpenSelectedItems(!shift || alt || ctrl); +} + bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) { - // bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; switch(header->code) { case LVN_ITEMCHANGED: @@ -240,33 +254,23 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) case LVN_COLUMNCLICK: OnColumnClick(LPNMLISTVIEW(header)); return false; - /* - case LVN_ITEMACTIVATE: - RefreshStatusBar(); - if (!alt && !ctrl && !shift) - OpenSelectedItems(true); - return false; - */ + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnNotifyActivateItems(); + return false; + } + break; case NM_DBLCLK: - RefreshStatusBar(); - OpenSelectedItems(true); - return false; case NM_RETURN: - { - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; - // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; - if (!shift && alt && !ctrl) + if (!g_LVN_ITEMACTIVATE_Support) { - Properties(); + OnNotifyActivateItems(); return false; } - OpenSelectedItems(true); - return false; - } + break; + case NM_RCLICK: RefreshStatusBar(); break; @@ -298,8 +302,10 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) SetFocusToList(); RefreshStatusBar(); if (_mySelectMode) + #ifndef UNDER_CE if (g_ComCtl32Version >= MAKELONG(71, 4)) - OnLeftClick((LPNMITEMACTIVATE)header); + #endif + OnLeftClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header); return false; } case LVN_BEGINLABELEDITW: diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp index 2672f694..093f02f0 100755 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -8,8 +8,9 @@ #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" -#include "../Common/PropIDUtils.h" #include "../../PropID.h" +#include "../Common/PropIDUtils.h" +#include "../Explorer/ContextMenu.h" #include "App.h" #include "LangUtils.h" @@ -22,9 +23,12 @@ using namespace NWindows; +LONG g_DllRefCount = 0; +/* // {23170F69-40C1-278A-1000-000100020000} DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); +*/ static const UINT kSevenZipStartMenuID = kPluginMenuStartID ; static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; @@ -50,7 +54,7 @@ void CPanel::InvokeSystemCommand(const char *command) contextMenu->InvokeCommand(&ci); } -static const wchar_t *kSeparator = L"--------------------------------------\n"; +static const wchar_t *kSeparator = L"----------------------------\n"; static const wchar_t *kPropValueSeparator = L": "; extern UString ConvertSizeToString(UInt64 value); @@ -442,7 +446,8 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec, bool sevenZipMenuCreated = false; CMyComPtr contextMenu; - if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK) + contextMenu = new CZipContextMenu; + // if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK) { CMyComPtr initContextMenu; if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK) @@ -489,8 +494,10 @@ void CPanel::CreateFileMenu(HMENU menuSpec, if (g_App.ShowSystemMenu) CreateSystemMenu(menu, operatedIndices, systemContextMenu); + /* if (menu.GetItemCount() > 0) menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0); + */ int i; for (i = 0; i < operatedIndices.Size(); i++) @@ -516,18 +523,28 @@ bool CPanel::InvokePluginCommand(int id, else offset = id - kSevenZipStartMenuID; - CMINVOKECOMMANDINFOEX commandInfo; + #ifdef UNDER_CE + CMINVOKECOMMANDINFO + #else + CMINVOKECOMMANDINFOEX + #endif + commandInfo; commandInfo.cbSize = sizeof(commandInfo); - commandInfo.fMask = CMIC_MASK_UNICODE; + commandInfo.fMask = 0 + #ifndef UNDER_CE + | CMIC_MASK_UNICODE + #endif + ; commandInfo.hwnd = GetParent(); commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset)); commandInfo.lpParameters = NULL; CSysString currentFolderSys = GetSystemString(_currentFolderPrefix); commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys); commandInfo.nShow = SW_SHOW; + commandInfo.lpParameters = NULL; + #ifndef UNDER_CE commandInfo.lpTitle = ""; commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset)); - commandInfo.lpParameters = NULL; UString currentFolderUnicode = _currentFolderPrefix; commandInfo.lpDirectoryW = currentFolderUnicode; commandInfo.lpTitleW = L""; @@ -535,6 +552,7 @@ bool CPanel::InvokePluginCommand(int id, // commandInfo.ptInvoke.y = yPos; commandInfo.ptInvoke.x = 0; commandInfo.ptInvoke.y = 0; + #endif HRESULT result; if (isSystemMenu) result = systemContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo)); @@ -550,6 +568,12 @@ bool CPanel::InvokePluginCommand(int id, bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) { + if (::GetParent((HWND)windowHandle) == _listView) + { + ShowColumnsContextMenu(xPos, yPos); + return true; + } + if (windowHandle != _listView) return false; /* @@ -599,7 +623,11 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) CMyComPtr systemContextMenu; CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false); - int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, + int result = menu.Track(TPM_LEFTALIGN + #ifndef UNDER_CE + | TPM_RIGHTBUTTON + #endif + | TPM_RETURNCMD | TPM_NONOTIFY, xPos, yPos, _listView); if (result == 0) diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp index 9a60fb1a..579208d2 100755 --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -35,8 +35,10 @@ enum EFolderOpType FOLDER_TYPE_RENAME = 2 }; -struct CThreadFolderOperations +class CThreadFolderOperations: public CProgressThreadVirt { + HRESULT ProcessVirt(); +public: EFolderOpType OpType; UString Name; UInt32 Index; @@ -45,45 +47,43 @@ struct CThreadFolderOperations CMyComPtr FolderOperations; CMyComPtr UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; - HRESULT Result; - - CThreadFolderOperations(EFolderOpType opType); - void Process() - { - NCOM::CComInitializer comInitializer; - UpdateCallbackSpec->ProgressDialog.WaitCreating(); + HRESULT Result; - switch(OpType) - { - case FOLDER_TYPE_CREATE_FOLDER: - Result = FolderOperations->CreateFolder(Name, UpdateCallback); - break; - case FOLDER_TYPE_DELETE: - Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); - break; - case FOLDER_TYPE_RENAME: - Result = FolderOperations->Rename(Index, Name, UpdateCallback); - break; - default: - Result = E_FAIL; - } - UpdateCallbackSpec->ProgressDialog.MyClose(); - } + CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {}; + HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError); +}; - static THREAD_FUNC_DECL MyThreadFunction(void *param) +HRESULT CThreadFolderOperations::ProcessVirt() +{ + NCOM::CComInitializer comInitializer; + switch(OpType) { - ((CThreadFolderOperations *)param)->Process(); - return 0; + case FOLDER_TYPE_CREATE_FOLDER: + Result = FolderOperations->CreateFolder(Name, UpdateCallback); + break; + case FOLDER_TYPE_DELETE: + Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); + break; + case FOLDER_TYPE_RENAME: + Result = FolderOperations->Rename(Index, Name, UpdateCallback); + break; + default: + Result = E_FAIL; } + return Result; }; -CThreadFolderOperations::CThreadFolderOperations(EFolderOpType opType): OpType(opType) {}; -static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UString &progressTitle) +HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError) { - op.UpdateCallbackSpec = new CUpdateCallback100Imp; - op.UpdateCallback = op.UpdateCallbackSpec; + UpdateCallbackSpec = new CUpdateCallback100Imp; + UpdateCallback = UpdateCallbackSpec; + UpdateCallbackSpec->ProgressDialog = &ProgressDialog; + + ProgressDialog.WaitMode = true; + ProgressDialog.Sync.SetErrorMessageTitle(titleError); + Result = S_OK; bool usePassword = false; UString password; @@ -94,21 +94,14 @@ static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UStrin password = fl.Password; } - op.UpdateCallbackSpec->Init(panel.GetParent(), usePassword, password); - - op.UpdateCallbackSpec->ProgressDialog.MainWindow = panel._mainWindow; - op.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - op.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + UpdateCallbackSpec->Init(usePassword, password); - // op.FolderOperations = folderOperations; - // op.Index = realIndex; - // op.Name = newName; - // HRESULT result = folderOperations->Rename(realIndex, newName, 0); + ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent() + ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + ProgressDialog.MainAddTitle = progressTitle + UString(L" "); - NWindows::CThread thread; - if (thread.Create(CThreadFolderOperations::MyThreadFunction, &op) != S_OK) - throw 271824; - op.UpdateCallbackSpec->StartProgressDialog(progressTitle); + RINOK(Create(progressTitle, ProgressDialog.MainWindow)); + return Result; } #ifndef _UNICODE @@ -124,6 +117,9 @@ void CPanel::DeleteItems(bool toRecycleBin) return; CSelectedState state; SaveSelectedState(state); + + #ifndef UNDER_CE + // WM6 / SHFileOperationW doesn't ask user! So we use internal delete bool useInternalDelete = false; if (IsFSFolder() && toRecycleBin) { @@ -218,16 +214,25 @@ void CPanel::DeleteItems(bool toRecycleBin) else useInternalDelete = true; if (useInternalDelete) + #endif DeleteItemsInternal(indices); RefreshListCtrl(state); } +void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID) +{ + if (errorCode == E_NOINTERFACE) + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + else + MessageBoxError(errorCode, LangString(resourceID, langID)); +} + void CPanel::DeleteItemsInternal(CRecordVector &indices) { CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING, 0x03020217); return; } @@ -261,9 +266,9 @@ void CPanel::DeleteItemsInternal(CRecordVector &indices) CThreadFolderOperations op(FOLDER_TYPE_DELETE); op.FolderOperations = folderOperations; op.Indices = indices; - DoOperation(op, *this, LangString(IDS_DELETING, 0x03020216)); - if (op.Result != S_OK) - MessageBoxError(op.Result, LangString(IDS_ERROR_DELETING, 0x03020217)); + op.DoOperation(*this, + LangString(IDS_DELETING, 0x03020216), + LangString(IDS_ERROR_DELETING, 0x03020217)); } RefreshTitleAlways(); } @@ -286,7 +291,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING, 0x03020221); return FALSE; } const UString newName = lpnmh->item.pszText; @@ -305,12 +310,11 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) op.FolderOperations = folderOperations; op.Index = realIndex; op.Name = newName; - DoOperation(op, *this, LangString(IDS_RENAMING, 0x03020220)); - if (op.Result != S_OK) - { - MessageBoxError(op.Result, LangString(IDS_ERROR_RENAMING, 0x03020221)); + HRESULT res = op.DoOperation(*this, + LangString(IDS_RENAMING, 0x03020220), + LangString(IDS_ERROR_RENAMING, 0x03020221)); + if (res != S_OK) return FALSE; - } } // Can't use RefreshListCtrl here. @@ -335,7 +339,7 @@ void CPanel::CreateFolder() CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR, 0x03020233); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -354,13 +358,11 @@ void CPanel::CreateFolder() CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER); op.FolderOperations = folderOperations; op.Name = newName; - DoOperation(op, *this, LangString(IDS_CREATE_FOLDER, 0x03020230)); - - if (op.Result != S_OK) - { - MessageBoxError(op.Result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + HRESULT res = op.DoOperation(*this, + LangString(IDS_CREATE_FOLDER, 0x03020230), + LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + if (res != S_OK) return; - } } int pos = newName.Find(WCHAR_PATH_SEPARATOR); if (pos >= 0) @@ -378,7 +380,7 @@ void CPanel::CreateFile() CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR, 0x03020243); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -394,7 +396,7 @@ void CPanel::CreateFile() HRESULT result = folderOperations->CreateFile(newName, 0); if (result != S_OK) { - MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243)); + MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR, 0x03020243); return; } int pos = newName.Find(WCHAR_PATH_SEPARATOR); @@ -454,8 +456,10 @@ void CPanel::ChangeComment() HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL); if (result != S_OK) { - MessageBoxError(result, L"Set Comment Error"); + if (result == E_NOINTERFACE) + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + else + MessageBoxError(result, L"Set Comment Error"); } RefreshListCtrl(state); } - diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp index bbd4a187..64cef433 100755 --- a/CPP/7zip/UI/FileManager/PanelSelect.cpp +++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp @@ -97,8 +97,7 @@ void CPanel::OnInsert() int nextIndex = focusedItem + 1; if (nextIndex < _listView.GetItemCount()) { - _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED, - LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(nextIndex); _listView.EnsureVisible(nextIndex, false); } } @@ -250,14 +249,15 @@ void CPanel::KillSelection() } } -void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) +void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate) { - if(itemActivate->hdr.hwndFrom != HWND(_listView)) + if (itemActivate->hdr.hwndFrom != HWND(_listView)) return; // It will be work only for Version 4.71 (IE 4); int indexInList = itemActivate->iItem; if (indexInList < 0) return; + #ifndef UNDER_CE if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0) { // int focusedIndex = _listView.GetFocusedItem(); @@ -280,8 +280,10 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) } } else + #endif { _startGroupSelect = indexInList; + #ifndef UNDER_CE if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0) { int realIndex = GetRealItemIndex(indexInList); @@ -291,6 +293,7 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) _listView.RedrawItem(indexInList); } } + #endif } return; } diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp index d1531957..150c71b1 100755 --- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp +++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp @@ -2,13 +2,11 @@ #include "StdAfx.h" -#include "../../../../C/Alloc.h" - #include "Common/IntToString.h" +#include "Windows/Error.h" #include "Windows/FileIO.h" #include "Windows/FileFind.h" -#include "Windows/Thread.h" #include "../GUI/ExtractRes.h" @@ -18,27 +16,12 @@ #include "CopyDialog.h" #include "FormatUtils.h" #include "LangUtils.h" -#include "ProgressDialog2.h" #include "SplitDialog.h" #include "SplitUtils.h" using namespace NWindows; -class CMyBuffer -{ - void *_data; -public: - CMyBuffer(): _data(0) {} - operator void *() { return _data; } - bool Allocate(size_t size) - { - if (_data != 0) - return false; - _data = ::MidAlloc(size); - return _data != 0; - } - ~CMyBuffer() { ::MidFree(_data); } -}; +static const wchar_t *g_Message_FileWriteError = L"File write error"; struct CVolSeqName { @@ -92,95 +75,85 @@ struct CVolSeqName static const UInt32 kBufSize = (1 << 20); -struct CThreadSplit +class CThreadSplit: public CProgressThreadVirt { - // HRESULT Result; - // CPanel *Panel; - CProgressDialog *ProgressDialog; + HRESULT ProcessVirt(); +public: UString FilePath; UString VolBasePath; CRecordVector VolumeSizes; - UString Error; +}; + +HRESULT CThreadSplit::ProcessVirt() +{ + NFile::NIO::CInFile inFile; + if (!inFile.Open(FilePath)) + return GetLastError(); + NFile::NIO::COutFile outFile; + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + UInt64 curVolSize = 0; + CVolSeqName seqName; + UInt64 length; + if (!inFile.GetLength(length)) + return GetLastError(); + + CProgressSync &sync = ProgressDialog.Sync; + sync.SetProgress(length, 0); + UInt64 pos = 0; + + UInt64 numFiles = 0; + int volIndex = 0; - void Process2() + for (;;) { - // NCOM::CComInitializer comInitializer; - ProgressDialog->WaitCreating(); - NFile::NIO::CInFile inFile; - if (!inFile.Open(FilePath)) - throw L"Can not open file"; - NFile::NIO::COutFile outFile; - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) - throw L"Can not allocate buffer"; - Byte *buffer = (Byte *)(void *)bufferObject; - UInt64 curVolSize = 0; - CVolSeqName seqName; - UInt64 length; - if (!inFile.GetLength(length)) - throw "error"; - - ProgressDialog->ProgressSynch.SetProgress(length, 0); - UInt64 pos = 0; - - int volIndex = 0; - - for (;;) + UInt64 volSize; + if (volIndex < VolumeSizes.Size()) + volSize = VolumeSizes[volIndex]; + else + volSize = VolumeSizes.Back(); + + UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize)); + UInt32 processedSize; + if (!inFile.Read(buffer, needSize, processedSize)) + return GetLastError(); + if (processedSize == 0) + break; + needSize = processedSize; + if (curVolSize == 0) { - UInt64 volSize; - if (volIndex < VolumeSizes.Size()) - volSize = VolumeSizes[volIndex]; - else - volSize = VolumeSizes.Back(); - - UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize)); - UInt32 processedSize; - if (!inFile.Read(buffer, needSize, processedSize)) - throw L"Can not read input file"; - if (processedSize == 0) - break; - needSize = processedSize; - if (curVolSize == 0) - { - UString name = VolBasePath; - name += L"."; - name += seqName.GetNextName(); - if (!outFile.Create(name, false)) - throw L"Can not create output file"; - ProgressDialog->ProgressSynch.SetCurrentFileName(name); - } - if (!outFile.Write(buffer, needSize, processedSize)) - throw L"Can not write output file"; - if (needSize != processedSize) - throw L"Can not write output file"; - curVolSize += processedSize; - if (curVolSize == volSize) + UString name = VolBasePath; + name += L'.'; + name += seqName.GetNextName(); + sync.SetCurrentFileName(name); + sync.SetNumFilesCur(numFiles++); + if (!outFile.Create(name, false)) { - outFile.Close(); - if (volIndex < VolumeSizes.Size()) - volIndex++; - curVolSize = 0; + HRESULT res = GetLastError(); + ErrorPath1 = name; + return res; } - pos += processedSize; - HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); - if (res != S_OK) - return; } + if (!outFile.Write(buffer, needSize, processedSize)) + return GetLastError(); + if (needSize != processedSize) + throw g_Message_FileWriteError; + curVolSize += processedSize; + if (curVolSize == volSize) + { + outFile.Close(); + if (volIndex < VolumeSizes.Size()) + volIndex++; + curVolSize = 0; + } + pos += processedSize; + RINOK(sync.SetPosAndCheckPaused(pos)); } - void Process() - { - try { Process2(); } - catch(const wchar_t *s) { Error = s; } - catch(...) { Error = L"Error"; } - ProgressDialog->MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - ((CThreadSplit *)param)->Process(); - return 0; - } -}; + sync.SetNumFilesCur(numFiles); + return S_OK; +} void CApp::Split() { @@ -239,7 +212,7 @@ void CApp::Split() ConvertUInt64ToString(numVolumes, s); if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), - MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) + MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; } @@ -251,20 +224,20 @@ void CApp::Split() return; } + { CThreadSplit spliter; - // spliter.Panel = this; - { - CProgressDialog progressDialog; - spliter.ProgressDialog = &progressDialog; + CProgressDialog &progressDialog = spliter.ProgressDialog; UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_SPLITTING, 0x03020510); + progressDialog.ShowCompressionInfo = false; + progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; progressDialog.MainAddTitle = title + UString(L" "); - progressDialog.ProgressSynch.SetTitleFileName(itemName); + progressDialog.Sync.SetTitleFileName(itemName); spliter.FilePath = srcPath + itemName; @@ -276,16 +249,12 @@ void CApp::Split() // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); - NWindows::CThread thread; - if (thread.Create(CThreadSplit::MyThreadFunction, &spliter) != S_OK) - throw 271824; - progressDialog.Create(title, _window); + if (spliter.Create(title, _window) != 0) + return; } RefreshTitleAlways(); - if (!spliter.Error.IsEmpty()) - srcPanel.MessageBoxMyError(spliter.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); @@ -293,78 +262,71 @@ void CApp::Split() } -struct CThreadCombine +class CThreadCombine: public CProgressThreadVirt { - CProgressDialog *ProgressDialog; - + HRESULT ProcessVirt(); +public: UString InputDirPrefix; UStringVector Names; UString OutputPath; UInt64 TotalSize; +}; - UString Error; - HRESULT Res; +HRESULT CThreadCombine::ProcessVirt() +{ + NFile::NIO::COutFile outFile; + if (!outFile.Create(OutputPath, false)) + { + HRESULT res = GetLastError(); + ErrorPath1 = OutputPath; + return res; + } + + CProgressSync &sync = ProgressDialog.Sync; + sync.SetProgress(TotalSize, 0); - void Process2() + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + UInt64 pos = 0; + for (int i = 0; i < Names.Size(); i++) { - NFile::NIO::COutFile outFile; - if (!outFile.Create(OutputPath, false)) + NFile::NIO::CInFile inFile; + const UString nextName = InputDirPrefix + Names[i]; + if (!inFile.Open(nextName)) { - Error = L"Can create open output file:\n" + OutputPath; - return; + HRESULT res = GetLastError(); + ErrorPath1 = nextName; + return res; } - - ProgressDialog->ProgressSynch.SetProgress(TotalSize, 0); - - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) - throw L"Can not allocate buffer"; - Byte *buffer = (Byte *)(void *)bufferObject; - UInt64 pos = 0; - for (int i = 0; i < Names.Size(); i++) + sync.SetCurrentFileName(nextName); + for (;;) { - NFile::NIO::CInFile inFile; - const UString nextName = InputDirPrefix + Names[i]; - if (!inFile.Open(nextName)) + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) { - Error = L"Can not open input file:\n" + nextName; - return; + HRESULT res = GetLastError(); + ErrorPath1 = nextName; + return res; } - ProgressDialog->ProgressSynch.SetCurrentFileName(nextName); - for (;;) + if (processedSize == 0) + break; + UInt32 needSize = processedSize; + if (!outFile.Write(buffer, needSize, processedSize)) { - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) - throw L"Can not read input file"; - if (processedSize == 0) - break; - UInt32 needSize = processedSize; - if (!outFile.Write(buffer, needSize, processedSize) || needSize != processedSize) - throw L"Can not write output file"; - pos += processedSize; - Res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); - if (Res != S_OK) - return; + HRESULT res = GetLastError(); + ErrorPath1 = OutputPath; + return res; } + if (needSize != processedSize) + throw g_Message_FileWriteError; + pos += processedSize; + RINOK(sync.SetPosAndCheckPaused(pos)); } } - - void Process() - { - Res = S_OK; - ProgressDialog->WaitCreating(); - try { Process2(); } - catch(const wchar_t *s) { Error = s; } - catch(...) { Error = L"Error";} - ProgressDialog->MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - ((CThreadCombine *)param)->Process(); - return 0; - } -}; + return S_OK; +} extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s); @@ -410,6 +372,7 @@ void CApp::Combine() return; } + { CThreadCombine combiner; UString nextName = itemName; @@ -491,10 +454,9 @@ void CApp::Combine() return; } - { - CProgressDialog progressDialog; - combiner.ProgressDialog = &progressDialog; - + CProgressDialog &progressDialog = combiner.ProgressDialog; + progressDialog.ShowCompressionInfo = false; + UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_COMBINING, 0x03020610); @@ -507,15 +469,11 @@ void CApp::Combine() // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); - NWindows::CThread thread; - if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) - throw 271824; - progressDialog.Create(title, _window); + if (combiner.Create(title, _window) != 0) + return; } RefreshTitleAlways(); - if (!combiner.Error.IsEmpty()) - srcPanel.MessageBoxMyError(combiner.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp index 94e8219d..eaf90a24 100755 --- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp +++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp @@ -1,6 +1,7 @@ // PasswordDialog.cpp #include "StdAfx.h" + #include "PasswordDialog.h" #ifdef LANG @@ -12,7 +13,8 @@ static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 }, { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 }, - + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 } }; #endif @@ -33,8 +35,7 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { if (buttonID == IDC_CHECK_PASSWORD_SHOW) { - _passwordControl.SetPasswordChar((IsButtonChecked( - IDC_CHECK_PASSWORD_SHOW) == BST_CHECKED) ? 0: TEXT('*')); + _passwordControl.SetPasswordChar(IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW) ? 0: TEXT('*')); UString password; _passwordControl.GetText(password); _passwordControl.SetText(password); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.rc b/CPP/7zip/UI/FileManager/PasswordDialog.rc index 64381aff..2328ac56 100755 --- a/CPP/7zip/UI/FileManager/PasswordDialog.rc +++ b/CPP/7zip/UI/FileManager/PasswordDialog.rc @@ -1,26 +1,14 @@ #include "PasswordDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 172 -#define ySize2 68 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 140 +#define yc 72 -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_PASSWORD DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_PASSWORD MY_DIALOG CAPTION "Enter password" -MY_FONT BEGIN - LTEXT "&Enter password:", IDC_STATIC_PASSWORD_HEADER, marg, marg, xSize2, 8 - EDITTEXT IDC_EDIT_PASSWORD, marg , 19, xSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL - - CONTROL "&Show password", IDC_CHECK_PASSWORD_SHOW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 41, xSize2, 10 - - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize + LTEXT "&Enter password:", IDC_STATIC_PASSWORD_HEADER, m, m, xc, 8 + EDITTEXT IDC_EDIT_PASSWORD, m, 20, xc, 14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Show password", IDC_CHECK_PASSWORD_SHOW, MY_CHECKBOX, m, 42, xc, 10 + OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h index f48c9e97..3cf15aa5 100755 --- a/CPP/7zip/UI/FileManager/PluginLoader.h +++ b/CPP/7zip/UI/FileManager/PluginLoader.h @@ -1,22 +1,18 @@ // PluginLoader.h -#ifndef __PLUGINLOADER_H -#define __PLUGINLOADER_H +#ifndef __PLUGIN_LOADER_H +#define __PLUGIN_LOADER_H #include "Windows/DLL.h" -typedef UINT32 (WINAPI * CreateObjectPointer)( - const GUID *clsID, - const GUID *interfaceID, - void **outObject); +typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); class CPluginLibrary: public NWindows::NDLL::CLibrary { public: HRESULT CreateManager(REFGUID clsID, IFolderManager **manager) { - CreateObjectPointer createObject = (CreateObjectPointer) - GetProcAddress("CreateObject"); + CreateObjectPointer createObject = (CreateObjectPointer)GetProc("CreateObject"); if (createObject == NULL) return GetLastError(); return createObject(&clsID, &IID_IFolderManager, (void **)manager); diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp index d79e78d8..0eeec9d6 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.cpp +++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp @@ -1,22 +1,16 @@ // PluginsPage.cpp #include "StdAfx.h" -#include "PluginsPageRes.h" -#include "PluginsPage.h" -#include "Common/StringConvert.h" #include "Common/MyCom.h" -#include "Windows/Defs.h" #include "Windows/DLL.h" -#include "Windows/Control/ListView.h" -#include "Windows/FileFind.h" -#include "RegistryUtils.h" #include "HelpUtils.h" #include "LangUtils.h" +#include "PluginsPage.h" +#include "PluginsPageRes.h" #include "ProgramLocation.h" - #include "PluginInterface.h" static CIDLangPair kIDLangPairs[] = @@ -33,16 +27,16 @@ bool CPluginsPage::OnInit() _listView.Attach(GetItem(IDC_PLUGINS_LIST)); - UINT32 newFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; + UINT32 newFlags = /* LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); - _listView.InsertColumn(0, L"Plugins", 160); + _listView.InsertColumn(0, L"Plugins", 50); ReadFileFolderPluginInfoList(_plugins); _listView.SetRedraw(false); // _listView.DeleteAllItems(); - for(int i = 0; i < _plugins.Size(); i++) + for (int i = 0; i < _plugins.Size(); i++) { const CPluginInfo &p = _plugins[i]; if (!p.OptionsClassIDDefined) @@ -59,11 +53,12 @@ bool CPluginsPage::OnInit() _listView.SetCheckState(i, true); } _listView.SetRedraw(true); - if(_listView.GetItemCount() > 0) + if (_listView.GetItemCount() > 0) { UINT state = LVIS_SELECTED | LVIS_FOCUSED; _listView.SetItemState(0, state, state); } + _listView.SetColumnWidthAuto(0); return CPropertyPage::OnInit(); } @@ -156,17 +151,15 @@ void CPluginsPage::OnButtonOptions() MessageBoxW(HWND(*this), L"There are no options", L"7-Zip", 0); return; } - NWindows::NDLL::CLibrary library; + NWindows::NDLL::CLibrary lib; CMyComPtr pluginOptions; - if (!library.Load(pluginInfo.FilePath)) + if (!lib.Load(pluginInfo.FilePath)) { MessageBoxW(HWND(*this), L"Can't load plugin", L"7-Zip", 0); return; } - typedef UINT32 (WINAPI * CreateObjectPointer)( - const GUID *clsID, const GUID *interfaceID, void **outObject); - CreateObjectPointer createObject = (CreateObjectPointer) - library.GetProcAddress("CreateObject"); + typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); + CreateObjectPointer createObject = (CreateObjectPointer)lib.GetProc("CreateObject"); if (createObject == NULL) { MessageBoxW(HWND(*this), L"Incorrect plugin", L"7-Zip", 0); @@ -211,4 +204,4 @@ bool CPluginsPage::OnCommand(int code, int itemID, LPARAM lParam) return CPropertyPage::OnCommand(code, itemID, lParam); } -*/ \ No newline at end of file +*/ diff --git a/CPP/7zip/UI/FileManager/PluginsPage.rc b/CPP/7zip/UI/FileManager/PluginsPage.rc index b4868aa3..18e5dfc8 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.rc +++ b/CPP/7zip/UI/FileManager/PluginsPage.rc @@ -1,19 +1,15 @@ #include "PluginsPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 96 +#define yc 80 - -IDD_PLUGINS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_PLUGINS MY_PAGE CAPTION "Plugins" -MY_FONT BEGIN - LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, marg, marg, xSize2, 8 - CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | - LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - marg, 20, xSize2 - bXSize - 12, ySize2 - 12 - PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, (xSize - marg - bXSize), 20, bXSize, bYSize + LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, m, m, xc, 8 + CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, 20, xc, 40 + PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, m, by, bxs, bys END diff --git a/CPP/7zip/UI/FileManager/PluginsPageRes.h b/CPP/7zip/UI/FileManager/PluginsPageRes.h index 8fc923ee..ca07ca5c 100755 --- a/CPP/7zip/UI/FileManager/PluginsPageRes.h +++ b/CPP/7zip/UI/FileManager/PluginsPageRes.h @@ -1,4 +1,4 @@ -#define IDD_PLUGINS 901 +#define IDD_PLUGINS 541 #define IDC_PLUGINS_STATIC_PLUGINS 1000 #define IDC_PLUGINS_LIST 1001 #define IDC_PLUGINS_BUTTON_OPTIONS 1002 diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp index fc7b40db..04c2c98c 100755 --- a/CPP/7zip/UI/FileManager/ProgramLocation.cpp +++ b/CPP/7zip/UI/FileManager/ProgramLocation.cpp @@ -1,10 +1,9 @@ -// ProgramLocation.h +// ProgramLocation.cpp #include "StdAfx.h" #include "ProgramLocation.h" -#include "Windows/FileName.h" #include "Windows/DLL.h" using namespace NWindows; diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h index 38317b45..55c56144 100755 --- a/CPP/7zip/UI/FileManager/ProgramLocation.h +++ b/CPP/7zip/UI/FileManager/ProgramLocation.h @@ -1,7 +1,7 @@ // ProgramLocation.h -#ifndef __PROGRAMLOCATION_H -#define __PROGRAMLOCATION_H +#ifndef __PROGRAM_LOCATION_H +#define __PROGRAM_LOCATION_H #include "Common/MyString.h" diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp index 5be77a8f..cdb8399e 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp @@ -1,15 +1,19 @@ // ProgressDialog.cpp #include "StdAfx.h" + +#include "Common/IntToString.h" + #include "resource.h" + #include "ProgressDialog.h" -#include "Common/IntToString.h" -#include "Common/IntToString.h" using namespace NWindows; +extern HINSTANCE g_hInstance; + static const UINT_PTR kTimerID = 3; -static const UINT kTimerElapse = 50; +static const UINT kTimerElapse = 100; #ifdef LANG #include "LangUtils.h" @@ -22,7 +26,7 @@ static CIDLangPair kIDLangPairs[] = }; #endif -HRESULT CProgressSynch::ProcessStopAndPause() +HRESULT CProgressSync::ProcessStopAndPause() { for (;;) { @@ -48,30 +52,37 @@ void CProgressDialog::AddToTitle(LPCWSTR s) #endif - bool CProgressDialog::OnInit() { - _range = UINT64(-1); + _range = (UInt64)-1; _prevPercentValue = -1; + _wasCreated = true; + _dialogCreatedEvent.Set(); + #ifdef LANG // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); + + if (IconID >= 0) + { + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID)); + SetIcon(ICON_BIG, icon); + } + _timer = SetTimer(kTimerID, kTimerElapse); - _dialogCreatedEvent.Set(); SetText(_title); + CheckNeedClose(); return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() -{ - ProgressSynch.SetStopped(true); -} +void CProgressDialog::OnCancel() { Sync.SetStopped(true); } +void CProgressDialog::OnOK() { } -void CProgressDialog::SetRange(UINT64 range) +void CProgressDialog::SetRange(UInt64 range) { _range = range; _peviousPos = (UInt64)(Int64)-1; @@ -79,16 +90,16 @@ void CProgressDialog::SetRange(UINT64 range) m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100% } -void CProgressDialog::SetPos(UINT64 pos) +void CProgressDialog::SetPos(UInt64 pos) { bool redraw = true; if (pos < _range && pos > _peviousPos) { - UINT64 posDelta = pos - _peviousPos; + UInt64 posDelta = pos - _peviousPos; if (posDelta < (_range >> 10)) redraw = false; } - if(redraw) + if (redraw) { m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% _peviousPos = pos; @@ -97,10 +108,13 @@ void CProgressDialog::SetPos(UINT64 pos) bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { - if (ProgressSynch.GetPaused()) + if (Sync.GetPaused()) return true; - UINT64 total, completed; - ProgressSynch.GetProgress(total, completed); + + CheckNeedClose(); + + UInt64 total, completed; + Sync.GetProgress(total, completed); if (total != _range) SetRange(total); SetPos(completed); @@ -124,29 +138,6 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) return true; } - -//////////////////// -// CU64ToI32Converter - -static const UINT64 kMaxIntValue = 0x7FFFFFFF; - -void CU64ToI32Converter::Init(UINT64 range) -{ - _numShiftBits = 0; - while(range > kMaxIntValue) - { - range >>= 1; - _numShiftBits++; - } -} - -int CU64ToI32Converter::Count(UINT64 aValue) -{ - return int(aValue >> _numShiftBits); -} - -const UINT CProgressDialog::kCloseMessage = WM_USER + 1; - bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) @@ -155,14 +146,20 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { KillTimer(_timer); _timer = 0; - End(0); - return true; + if (_inCancelMessageBox) + { + _externalCloseMessageWasReceived = true; + break; + } + return OnExternalCloseMessage(); } + /* case WM_SETTEXT: { if (_timer == 0) return true; } + */ } return CModalDialog::OnMessage(message, wParam, lParam); } @@ -173,16 +170,35 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { case IDCANCEL: { - bool paused = ProgressSynch.GetPaused();; - ProgressSynch.SetPaused(true); - int res = ::MessageBoxW(HWND(*this), - L"Are you sure you want to cancel?", - _title, MB_YESNOCANCEL); - ProgressSynch.SetPaused(paused); + bool paused = Sync.GetPaused(); + Sync.SetPaused(true); + _inCancelMessageBox = true; + int res = ::MessageBoxW(HWND(*this), L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL); + _inCancelMessageBox = false; + Sync.SetPaused(paused); if (res == IDCANCEL || res == IDNO) + { + if (_externalCloseMessageWasReceived) + OnExternalCloseMessage(); return true; + } break; } } return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + +void CProgressDialog::CheckNeedClose() +{ + if (_needClose) + { + PostMessage(kCloseMessage); + _needClose = false; + } +} + +bool CProgressDialog::OnExternalCloseMessage() +{ + End(0); + return true; +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h index 201aead7..429ed740 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog.h @@ -1,59 +1,61 @@ // ProgressDialog.h -#ifndef __PROGRESSDIALOG_H -#define __PROGRESSDIALOG_H +#ifndef __PROGRESS_DIALOG_H +#define __PROGRESS_DIALOG_H -#include "ProgressDialogRes.h" +#include "Windows/Synchronization.h" +#include "Windows/Thread.h" #include "Windows/Control/Dialog.h" #include "Windows/Control/ProgressBar.h" -#include "Windows/Synchronization.h" -class CProgressSynch +#include "ProgressDialogRes.h" + +class CProgressSync { - NWindows::NSynchronization::CCriticalSection _criticalSection; + NWindows::NSynchronization::CCriticalSection _cs; bool _stopped; bool _paused; - UINT64 _total; - UINT64 _completed; + UInt64 _total; + UInt64 _completed; public: - CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {} + CProgressSync(): _stopped(false), _paused(false), _total(1), _completed(0) {} HRESULT ProcessStopAndPause(); bool GetStopped() { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); return _stopped; } void SetStopped(bool value) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _stopped = value; } bool GetPaused() { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); return _paused; } void SetPaused(bool value) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _paused = value; } - void SetProgress(UINT64 total, UINT64 completed) + void SetProgress(UInt64 total, UInt64 completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _total = total; _completed = completed; } - void SetPos(UINT64 completed) + void SetPos(UInt64 completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _completed = completed; } - void GetProgress(UINT64 &total, UINT64 &completed) + void GetProgress(UInt64 &total, UInt64 &completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); total = _total; completed = _completed; } @@ -61,14 +63,17 @@ public: class CU64ToI32Converter { - UINT64 _numShiftBits; + UInt64 _numShiftBits; public: - void Init(UINT64 _range); - int Count(UINT64 aValue); + void Init(UInt64 range) + { + // Windows CE doesn't like big number here. + for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++) + range >>= 1; + } + int Count(UInt64 value) { return int(value >> _numShiftBits); } }; -// class CProgressDialog: public NWindows::NControl::CModelessDialog - class CProgressDialog: public NWindows::NControl::CModalDialog { private: @@ -76,24 +81,35 @@ private: UString _title; CU64ToI32Converter _converter; - UINT64 _peviousPos; - UINT64 _range; + UInt64 _peviousPos; + UInt64 _range; NWindows::NControl::CProgressBar m_ProgressBar; int _prevPercentValue; + bool _wasCreated; + bool _needClose; + bool _inCancelMessageBox; + bool _externalCloseMessageWasReceived; + bool OnTimer(WPARAM timerID, LPARAM callback); - void SetRange(UINT64 range); - void SetPos(UINT64 pos); + void SetRange(UInt64 range); + void SetPos(UInt64 pos); virtual bool OnInit(); virtual void OnCancel(); + virtual void OnOK(); NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; #ifndef _SFX void AddToTitle(LPCWSTR string); #endif bool OnButtonClicked(int buttonID, HWND buttonHWND); + + void WaitCreating() { _dialogCreatedEvent.Lock(); } + void CheckNeedClose(); + bool OnExternalCloseMessage(); public: - CProgressSynch ProgressSynch; + CProgressSync Sync; + int IconID; #ifndef _SFX HWND MainWindow; @@ -107,27 +123,48 @@ public: ,MainWindow(0) #endif { + IconID = -1; + _wasCreated = false; + _needClose = false; + _inCancelMessageBox = false; + _externalCloseMessageWasReceived = false; + if (_dialogCreatedEvent.Create() != S_OK) throw 1334987; } - void WaitCreating() { _dialogCreatedEvent.Lock(); } - - - INT_PTR Create(const UString &title, HWND wndParent = 0) + INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0) { _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + INT_PTR res = CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + thread.Wait(); + return res; } - static const UINT kCloseMessage; + enum + { + kCloseMessage = WM_USER + 1 + }; virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); - void MyClose() + void ProcessWasFinished() { - PostMessage(kCloseMessage); + WaitCreating(); + if (_wasCreated) + PostMessage(kCloseMessage); + else + _needClose = true; }; }; + +class CProgressCloser +{ + CProgressDialog *_p; +public: + CProgressCloser(CProgressDialog &p) : _p(&p) {} + ~CProgressCloser() { _p->ProcessWasFinished(); } +}; + #endif diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.rc b/CPP/7zip/UI/FileManager/ProgressDialog.rc index e5cdd7e8..3a65338f 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog.rc @@ -1,20 +1,12 @@ #include "ProgressDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 172 -#define ySize2 42 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 172 +#define yc 44 -#define bYPos (ySize - marg - bYSize) -#define bXPos (xSize - marg - bXSize) - - -IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_PROGRESS MY_DIALOG CAPTION "Progress" -MY_FONT BEGIN - PUSHBUTTON "Cancel", IDCANCEL, bXPos, bYPos , bXSize, bYSize - CONTROL "Progress1", IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER, - marg,marg, xSize2, 14 + PUSHBUTTON "Cancel", IDCANCEL, bx, by, bxs, bys + CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, m, xc, 14 END diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp index 87a1521d..2c9996ab 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp @@ -3,17 +3,35 @@ #include "StdAfx.h" #include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/Control/Static.h" +#include "Windows/Error.h" #include "ProgressDialog2.h" +#include "DialogSize.h" + +#include "ProgressDialog2Res.h" + +#include "../GUI/ExtractRes.h" using namespace NWindows; +extern HINSTANCE g_hInstance; + static const UINT_PTR kTimerID = 3; -static const UINT kTimerElapse = 100; -#ifdef LANG +static const UINT kCloseMessage = WM_USER + 1; + +static const UINT kTimerElapse = + #ifdef UNDER_CE + 500 + #else + 100 + #endif + ; + #include "LangUtils.h" -#endif #ifdef LANG static CIDLangPair kIDLangPairs[] = @@ -34,7 +52,7 @@ static CIDLangPair kIDLangPairs[] = }; #endif -HRESULT CProgressSynch::ProcessStopAndPause() +HRESULT CProgressSync::ProcessStopAndPause() { for (;;) { @@ -47,13 +65,38 @@ HRESULT CProgressSynch::ProcessStopAndPause() return S_OK; } -HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed) +HRESULT CProgressSync::SetPosAndCheckPaused(UInt64 completed) { RINOK(ProcessStopAndPause()); SetPos(completed); return S_OK; } + +CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true) + #ifndef _SFX + , MainWindow(0) + #endif + { + IconID = -1; + MessagesDisplayed = false; + _wasCreated = false; + _needClose = false; + _inCancelMessageBox = false; + _externalCloseMessageWasReceived = false; + + _numPostedMessages = 0; + _errorsWereDisplayed = false; + _waitCloseByCancelButton = false; + _cancelWasPressed = false; + ShowCompressionInfo = true; + WaitMode = false; + if (_dialogCreatedEvent.Create() != S_OK) + throw 1334987; + if (_createDialogEvent.Create() != S_OK) + throw 1334987; + } + #ifndef _SFX CProgressDialog::~CProgressDialog() { @@ -68,7 +111,9 @@ void CProgressDialog::AddToTitle(LPCWSTR s) } } -static const int kTitleFileNameSizeLimit = 40; +#endif + +static const int kTitleFileNameSizeLimit = 36; static const int kCurrentFileNameSizeLimit = 82; static void ReduceString(UString &s, int size) @@ -76,22 +121,34 @@ static void ReduceString(UString &s, int size) if (s.Length() > size) s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); } -#endif + +void CProgressDialog::EnableErrorsControls(bool enable) +{ + int cmdShow = enable ? SW_SHOW : SW_HIDE; + ShowItem(IDC_PROGRESS_ERRORS, cmdShow); + ShowItem(IDC_PROGRESS_ERRORS_VALUE, cmdShow); + ShowItem(IDC_PROGRESS_LIST, cmdShow); +} bool CProgressDialog::OnInit() { - _range = (UInt64)(Int64)(-1); - _prevPercentValue = UInt32(-1); - _prevElapsedSec = UInt32(-1); - _prevRemainingSec = UInt32(-1); - _prevSpeed = UInt32(-1); + _range = (UInt64)(Int64)-1; + _prevPercentValue = (UInt32)-1; + _prevElapsedSec = (UInt32)-1; + _prevRemainingSec = (UInt32)-1; + _prevSpeed = (UInt32)-1; _prevMode = kSpeedBytes; _prevTime = ::GetTickCount(); _elapsedTime = 0; _foreground = true; + m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); + _messageList.Attach(GetItem(IDC_PROGRESS_LIST)); + + _wasCreated = true; + _dialogCreatedEvent.Set(); + #ifdef LANG - // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif @@ -104,24 +161,197 @@ bool CProgressDialog::OnInit() window = GetItem(IDC_BUTTON_PAUSE); window.GetText(pauseString); - foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11); - continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13); - pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20); + foregroundString = LangStringSpec(IDS_PROGRESS_FOREGROUND, 0x02000C11); + continueString = LangStringSpec(IDS_PROGRESS_CONTINUE, 0x02000C13); + pausedString = LangStringSpec(IDS_PROGRESS_PAUSED, 0x02000C20); - m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); - _timer = SetTimer(kTimerID, kTimerElapse); - _dialogCreatedEvent.Set(); SetText(_title); SetPauseText(); SetPriorityText(); + + + #ifndef UNDER_CE + _messageList.SetUnicodeFormat(true); + #endif + + _messageList.InsertColumn(0, L"", 30); + + const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); + + _messageList.InsertColumn(1, s, 600); + + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + + + EnableErrorsControls(false); + + GetItemSizes(IDCANCEL, buttonSizeX, buttonSizeY); + _numReduceSymbols = kCurrentFileNameSizeLimit; + NormalizeSize(true); + + if (!ShowCompressionInfo) + { + HideItem(IDC_PROGRESS_PACKED); + HideItem(IDC_PROGRESS_PACKED_VALUE); + HideItem(IDC_PROGRESS_RATIO); + HideItem(IDC_PROGRESS_RATIO_VALUE); + } + + if (IconID >= 0) + { + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID)); + // SetIcon(ICON_SMALL, icon); + SetIcon(ICON_BIG, icon); + } + _timer = SetTimer(kTimerID, kTimerElapse); + #ifdef UNDER_CE + Foreground(); + #endif + + CheckNeedClose(); + return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() +bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) { - ProgressSynch.SetStopped(true); + int sY; + int sStep; + int mx, my; + { + RECT rect; + GetClientRectOfItem(IDC_PROGRESS_ELAPSED, rect); + mx = rect.left; + my = rect.top; + sY = rect.bottom - rect.top; + GetClientRectOfItem(IDC_PROGRESS_REMAINING, rect); + sStep = rect.top - my; + } + + + InvalidateRect(NULL); + + int xSizeClient = xSize - mx * 2; + + { + int i; + for (i = 800; i > 40; i = i * 9 / 10) + if (Units_To_Pixels_X(i) <= xSizeClient) + break; + _numReduceSymbols = i / 4; + } + + int yPos = ySize - my - buttonSizeY; + + ChangeSubWindowSizeX(GetItem(IDC_PROGRESS_FILE_NAME), xSize - mx * 2); + ChangeSubWindowSizeX(GetItem(IDC_PROGRESS1), xSize - mx * 2); + + int bSizeX = buttonSizeX; + int mx2 = mx; + for (;; mx2--) + { + int bSize2 = bSizeX * 3 + mx2 * 2; + if (bSize2 <= xSizeClient) + break; + if (mx2 < 5) + { + bSizeX = (xSizeClient - mx2 * 2) / 3; + break; + } + } + if (bSizeX < 2) + bSizeX = 2; + + { + RECT rect; + GetClientRectOfItem(IDC_PROGRESS_LIST, rect); + int y = rect.top; + int ySize2 = yPos - my - y; + const int kMinYSize = buttonSizeY + buttonSizeY * 3 / 4; + int xx = xSize - mx * 2; + if (ySize2 < kMinYSize) + { + ySize2 = kMinYSize; + if (xx > bSizeX * 2) + xx -= bSizeX; + } + + _messageList.Move(mx, y, xx, ySize2); + } + + { + int xPos = xSize - mx; + xPos -= bSizeX; + MoveItem(IDCANCEL, xPos, yPos, bSizeX, buttonSizeY); + xPos -= (mx2 + bSizeX); + MoveItem(IDC_BUTTON_PAUSE, xPos, yPos, bSizeX, buttonSizeY); + xPos -= (mx2 + bSizeX); + MoveItem(IDC_BUTTON_PROGRESS_PRIORITY, xPos, yPos, bSizeX, buttonSizeY); + } + + int valueSize; + int labelSize; + int padSize; + + labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN); + valueSize = Units_To_Pixels_X(MY_PROGRESS_VALUE_UNITS); + padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS); + int requiredSize = (labelSize + valueSize) * 2 + padSize; + + int gSize; + { + if (requiredSize < xSizeClient) + { + int incr = (xSizeClient - requiredSize) / 3; + labelSize += incr; + } + else + labelSize = (xSizeClient - valueSize * 2 - padSize) / 2; + if (labelSize < 0) + labelSize = 0; + + gSize = labelSize + valueSize; + padSize = xSizeClient - gSize * 2; + } + + labelSize = gSize - valueSize; + + UINT IDs[] = + { + IDC_PROGRESS_ELAPSED, IDC_PROGRESS_ELAPSED_VALUE, + IDC_PROGRESS_REMAINING, IDC_PROGRESS_REMAINING_VALUE, + IDC_PROGRESS_FILES, IDC_PROGRESS_FILES_VALUE, + IDC_PROGRESS_RATIO, IDC_PROGRESS_RATIO_VALUE, + IDC_PROGRESS_ERRORS, IDC_PROGRESS_ERRORS_VALUE, + + IDC_PROGRESS_TOTAL, IDC_PROGRESS_TOTAL_VALUE, + IDC_PROGRESS_SPEED, IDC_PROGRESS_SPEED_VALUE, + IDC_PROGRESS_UNPACKED, IDC_PROGRESS_UNPACKED_VALUE, + IDC_PROGRESS_PACKED, IDC_PROGRESS_PACKED_VALUE + }; + + yPos = my; + for (int i = 0; i < sizeof(IDs) / sizeof(IDs[0]); i += 2) + { + int x = mx; + const int kNumColumn1Items = 5 * 2; + if (i >= kNumColumn1Items) + { + if (i == kNumColumn1Items) + yPos = my; + x = mx + gSize + padSize; + } + MoveItem(IDs[i], x, yPos, labelSize, sY); + MoveItem(IDs[i + 1], x + labelSize, yPos, valueSize, sY); + yPos += sStep; + } + return false; } +void CProgressDialog::OnCancel() { Sync.SetStopped(true); } +void CProgressDialog::OnOK() { } + static void ConvertSizeToString(UInt64 value, wchar_t *s) { const wchar_t *kModif = L" KM"; @@ -144,7 +374,7 @@ void CProgressDialog::SetRange(UInt64 range) _range = range; _previousPos = (UInt64)(Int64)-1; _converter.Init(range); - m_ProgressBar.SetRange32(0, _converter.Count(range)); // Test it for 100% + m_ProgressBar.SetRange32(0, _converter.Count(range)); } void CProgressDialog::SetPos(UInt64 pos) @@ -157,7 +387,7 @@ void CProgressDialog::SetPos(UInt64 pos) } if(redraw) { - m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% + m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% _previousPos = pos; } } @@ -179,13 +409,11 @@ void CProgressDialog::ShowSize(int id, UInt64 value) SetItemText(id, s); } -bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) +void CProgressDialog::UpdateStatInfo(bool showAll) { - if (ProgressSynch.GetPaused()) - return true; UInt64 total, completed, totalFiles, completedFiles, inSize, outSize; bool bytesProgressMode; - ProgressSynch.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode); + Sync.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode); UInt32 curTime = ::GetTickCount(); @@ -222,8 +450,29 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) elapsedChanged = true; } - if (elapsedChanged) + if (elapsedChanged || showAll) { + { + UInt64 numErrors; + + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + numErrors = Sync.Messages.Size(); + } + if (numErrors > 0) + { + UpdateMessagesDialog(); + TCHAR s[40]; + ConvertUInt64ToString(numErrors, s); + SetItemText(IDC_PROGRESS_ERRORS_VALUE, s); + if (!_errorsWereDisplayed) + { + _errorsWereDisplayed = true; + EnableErrorsControls(true); + } + } + } + if (completed != 0) { @@ -245,7 +494,6 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) _prevRemainingSec = remainingSec; } } - // if (elapsedChanged) { UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; UInt64 speedB = (completed * 1000) / elapsedTime; @@ -296,7 +544,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) total = 1; UInt32 percentValue = (UInt32)(completed * 100 / total); UString titleName; - ProgressSynch.GetTitleFileName(titleName); + Sync.GetTitleFileName(titleName); if (percentValue != _prevPercentValue || _prevTitleName != titleName) { _prevPercentValue = percentValue; @@ -339,7 +587,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) UString fileName; - ProgressSynch.GetCurrentFileName(fileName); + Sync.GetCurrentFileName(fileName); if (_prevFileName != fileName) { int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); @@ -351,38 +599,127 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) } else s2 = fileName; - ReduceString(s1, kCurrentFileNameSizeLimit); - ReduceString(s2, kCurrentFileNameSizeLimit); + ReduceString(s1, _numReduceSymbols); + ReduceString(s2, _numReduceSymbols); UString s = s1 + L"\n" + s2; SetItemText(IDC_PROGRESS_FILE_NAME, s); _prevFileName == fileName; } - - return true; } +bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) +{ + if (Sync.GetPaused()) + return true; -//////////////////// -// CU64ToI32Converter + CheckNeedClose(); -static const UInt64 kMaxIntValue = 0x7FFFFFFF; + UpdateStatInfo(false); + return true; +} -void CU64ToI32Converter::Init(UInt64 range) +struct CWaitCursor { - _numShiftBits = 0; - while(range > kMaxIntValue) + HCURSOR _waitCursor; + HCURSOR _oldCursor; + CWaitCursor() { - range >>= 1; - _numShiftBits++; + _waitCursor = LoadCursor(NULL, IDC_WAIT); + if (_waitCursor != NULL) + _oldCursor = SetCursor(_waitCursor); } -} + ~CWaitCursor() + { + if (_waitCursor != NULL) + SetCursor(_oldCursor); + } +}; -int CU64ToI32Converter::Count(UInt64 aValue) +INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread, HWND wndParent) { - return int(aValue >> _numShiftBits); + INT_PTR res = 0; + try + { + if (WaitMode) + { + CWaitCursor waitCursor; + HANDLE h[] = { thread, _createDialogEvent }; + + WRes res = WaitForMultipleObjects(sizeof(h) / sizeof(h[0]), h, FALSE, + #ifdef UNDER_CE + 2500 + #else + 1000 + #endif + ); + if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage()) + return 0; + } + _title = title; + BIG_DIALOG_SIZE(360, 192); + res = CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_PROGRESS), wndParent); + } + catch(...) + { + _wasCreated = true; + _dialogCreatedEvent.Set(); + res = res; + } + thread.Wait(); + if (!MessagesDisplayed) + MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR | MB_OK); + return res; } -const UINT CProgressDialog::kCloseMessage = WM_USER + 1; +bool CProgressDialog::OnExternalCloseMessage() +{ + UpdateStatInfo(true); + + HideItem(IDC_BUTTON_PROGRESS_PRIORITY); + HideItem(IDC_BUTTON_PAUSE); + SetItemText(IDCANCEL, LangStringSpec(IDS_CLOSE, 0x02000713)); + + bool thereAreMessages; + UString okMessage; + UString okMessageTitle; + UString errorMessage; + UString errorMessageTitle; + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + errorMessage = Sync.ErrorMessage; + errorMessageTitle = Sync.ErrorMessageTitle; + okMessage = Sync.OkMessage; + okMessageTitle = Sync.OkMessageTitle; + thereAreMessages = !Sync.Messages.IsEmpty(); + } + if (!errorMessage.IsEmpty()) + { + MessagesDisplayed = true; + if (errorMessageTitle.IsEmpty()) + errorMessageTitle = L"7-Zip"; + MessageBoxW(*this, errorMessage, errorMessageTitle, MB_ICONERROR | MB_OK); + } + else if (!thereAreMessages) + { + MessagesDisplayed = true; + if (!okMessage.IsEmpty()) + { + if (okMessageTitle.IsEmpty()) + okMessageTitle = L"7-Zip"; + MessageBoxW(*this, okMessage, okMessageTitle, MB_OK); + } + } + + if (thereAreMessages && !_cancelWasPressed) + { + _waitCloseByCancelButton = true; + UpdateMessagesDialog(); + return true; + } + + End(0); + return true; +} bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { @@ -392,14 +729,21 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { KillTimer(_timer); _timer = 0; - End(0); - return true; + if (_inCancelMessageBox) + { + _externalCloseMessageWasReceived = true; + break; + } + return OnExternalCloseMessage(); } + /* case WM_SETTEXT: { if (_timer == 0) return true; + break; } + */ } return CModalDialog::OnMessage(message, wParam, lParam); } @@ -407,31 +751,31 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) void CProgressDialog::SetTitleText() { UString title; - if (ProgressSynch.GetPaused()) + if (Sync.GetPaused()) { title = pausedString; - title += L" "; + title += L' '; } - if (_prevPercentValue != UInt32(-1)) + if (_prevPercentValue != (UInt32)-1) { wchar_t s[64]; ConvertUInt64ToString(_prevPercentValue, s); title += s; - title += L"%"; + title += L'%'; } if (!_foreground) { - title += L" "; + title += L' '; title += backgroundedString; } - title += L" "; + title += L' '; UString totalTitle = title + _title; UString fileName; - ProgressSynch.GetTitleFileName(fileName); + Sync.GetTitleFileName(fileName); if (!fileName.IsEmpty()) { ReduceString(fileName, kTitleFileNameSizeLimit); - totalTitle += L" "; + totalTitle += L' '; totalTitle += fileName; } SetText(totalTitle); @@ -442,15 +786,15 @@ void CProgressDialog::SetTitleText() void CProgressDialog::SetPauseText() { - SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ? + SetItemText(IDC_BUTTON_PAUSE, Sync.GetPaused() ? continueString : pauseString); SetTitleText(); } void CProgressDialog::OnPauseButton() { - bool paused = !ProgressSynch.GetPaused(); - ProgressSynch.SetPaused(paused); + bool paused = !Sync.GetPaused(); + Sync.SetPaused(paused); UInt32 curTime = ::GetTickCount(); if (paused) _elapsedTime += (curTime - _prevTime); @@ -469,39 +813,188 @@ void CProgressDialog::SetPriorityText() void CProgressDialog::OnPriorityButton() { _foreground = !_foreground; + #ifndef UNDER_CE SetPriorityClass(GetCurrentProcess(), _foreground ? NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS); + #endif SetPriorityText(); } +void CProgressDialog::AddMessageDirect(LPCWSTR message) +{ + int itemIndex = _messageList.GetItemCount(); + wchar_t sz[32]; + ConvertInt64ToString(itemIndex, sz); + _messageList.InsertItem(itemIndex, sz); + _messageList.SetSubItem(itemIndex, 1, message); +} + +void CProgressDialog::AddMessage(LPCWSTR message) +{ + UString s = message; + while (!s.IsEmpty()) + { + int pos = s.Find(L'\n'); + if (pos < 0) + break; + AddMessageDirect(s.Left(pos)); + s.Delete(0, pos + 1); + } + AddMessageDirect(s); +} + +void CProgressDialog::UpdateMessagesDialog() +{ + int numMessages; + UStringVector messages; + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + numMessages = _numPostedMessages; + for (int i = _numPostedMessages; i < Sync.Messages.Size(); i++) + messages.Add(Sync.Messages[i]); + _numPostedMessages = Sync.Messages.Size(); + } + if (!messages.IsEmpty()) + { + for (int i = 0; i < messages.Size(); i++) + AddMessage(messages[i]); + if (numMessages < 128) + { + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + } + } +} + + bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { + // case IDOK: // if IDCANCEL is not DEFPUSHBUTTON case IDCANCEL: { - bool paused = ProgressSynch.GetPaused();; - // ProgressSynch.SetPaused(true); + if (_waitCloseByCancelButton) + { + MessagesDisplayed = true; + End(IDCLOSE); + break; + } + + bool paused = Sync.GetPaused(); if (!paused) OnPauseButton(); + _inCancelMessageBox = true; int res = ::MessageBoxW(HWND(*this), - LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), + LangStringSpec(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), _title, MB_YESNOCANCEL); - // ProgressSynch.SetPaused(paused); + _inCancelMessageBox = false; if (!paused) OnPauseButton(); if (res == IDCANCEL || res == IDNO) + { + if (_externalCloseMessageWasReceived) + OnExternalCloseMessage(); return true; + } + + _cancelWasPressed = true; + MessagesDisplayed = true; break; } + case IDC_BUTTON_PAUSE: OnPauseButton(); return true; case IDC_BUTTON_PROGRESS_PRIORITY: - { OnPriorityButton(); return true; - } } return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + +void CProgressDialog::CheckNeedClose() +{ + if (_needClose) + { + PostMessage(kCloseMessage); + _needClose = false; + } +} + +void CProgressDialog::ProcessWasFinished() +{ + // Set Window title here. + if (!WaitMode) + WaitCreating(); + + if (_wasCreated) + PostMessage(kCloseMessage); + else + _needClose = true; +}; + + +HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow) +{ + NWindows::CThread thread; + RINOK(thread.Create(MyThreadFunction, this)); + ProgressDialog.Create(title, thread, parentWindow); + return S_OK; +} + +UString HResultToMessage(HRESULT errorCode) +{ + UString message; + if (errorCode == E_OUTOFMEMORY) + message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B); + else if (!NError::MyFormatMessage(errorCode, message)) + message.Empty(); + if (message.IsEmpty()) + message = L"Error"; + return message; +} + +static void AddMessageToString(UString &dest, const UString &src) +{ + if (!src.IsEmpty()) + { + if (!dest.IsEmpty()) + dest += L'\n'; + dest += src; + } +} + +void CProgressThreadVirt::Process() +{ + CProgressCloser closer(ProgressDialog); + UString m; + try { Result = ProcessVirt(); } + catch(const wchar_t *s) { m = s; } + catch(const UString &s) { m = s; } + catch(const char *s) { m = GetUnicodeString(s); } + catch(...) { m = L"Error"; } + if (Result != E_ABORT) + { + if (m.IsEmpty() && Result != S_OK) + m = HResultToMessage(Result); + } + AddMessageToString(m, ErrorMessage); + AddMessageToString(m, ErrorPath1); + AddMessageToString(m, ErrorPath2); + + if (m.IsEmpty()) + { + if (!OkMessage.IsEmpty()) + { + ProgressDialog.Sync.SetOkMessageTitle(OkMessageTitle); + ProgressDialog.Sync.SetOkMessage(OkMessage); + } + } + else + { + ProgressDialog.Sync.SetErrorMessage(m); + if (Result == S_OK) + Result = E_FAIL; + } +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h index 3ab9f4c0..bbdc5afa 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h @@ -3,17 +3,15 @@ #ifndef __PROGRESS_DIALOG2_H #define __PROGRESS_DIALOG2_H -#include "Common/Types.h" +#include "Windows/Synchronization.h" +#include "Windows/Thread.h" #include "Windows/Control/Dialog.h" +#include "Windows/Control/ListView.h" #include "Windows/Control/ProgressBar.h" -#include "Windows/Synchronization.h" - -#include "ProgressDialog2Res.h" -class CProgressSynch +class CProgressSync { - NWindows::NSynchronization::CCriticalSection _cs; bool _stopped; bool _paused; bool _bytesProgressMode; @@ -25,11 +23,20 @@ class CProgressSynch UInt64 _inSize; UInt64 _outSize; - UString TitleFileName; - UString CurrentFileName; + UString _titleFileName; + UString _currentFileName; public: - CProgressSynch(): + UStringVector Messages; + UString ErrorMessage; + UString ErrorMessageTitle; + + UString OkMessage; + UString OkMessageTitle; + + NWindows::NSynchronization::CCriticalSection _cs; + + CProgressSync(): _stopped(false), _paused(false), _totalBytes((UInt64)(Int64)-1), _curBytes(0), _totalFiles((UInt64)(Int64)-1), _curFiles(0), @@ -116,22 +123,57 @@ public: void SetTitleFileName(const UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - TitleFileName = fileName; + _titleFileName = fileName; } void GetTitleFileName(UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = TitleFileName; + fileName = _titleFileName; } void SetCurrentFileName(const UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - CurrentFileName = fileName; + _currentFileName = fileName; } void GetCurrentFileName(UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = CurrentFileName; + fileName = _currentFileName; + } + + void AddErrorMessage(LPCWSTR message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + Messages.Add(message); + } + + void SetErrorMessage(const UString &message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + ErrorMessage = message; + } + + void SetOkMessage(const UString &message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + OkMessage = message; + } + + void SetOkMessageTitle(const UString &title) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + OkMessageTitle = title; + } + + void SetErrorMessageTitle(const UString &title) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + ErrorMessageTitle = title; + } + + bool ThereIsMessage() const + { + return !Messages.IsEmpty() || !ErrorMessage.IsEmpty() || !OkMessage.IsEmpty(); } }; @@ -139,12 +181,15 @@ class CU64ToI32Converter { UInt64 _numShiftBits; public: - void Init(UInt64 _range); - int Count(UInt64 aValue); + void Init(UInt64 range) + { + // Windows CE doesn't like big number here. + for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++) + range >>= 1; + } + int Count(UInt64 value) { return int(value >> _numShiftBits); } }; -// class CProgressDialog: public NWindows::NControl::CModelessDialog - enum ESpeedMode { kSpeedBytes, @@ -164,7 +209,8 @@ private: UString continueString; UString pausedString; - + int buttonSizeX; + int buttonSizeY; UINT_PTR _timer; @@ -173,6 +219,7 @@ private: UInt64 _previousPos; UInt64 _range; NWindows::NControl::CProgressBar m_ProgressBar; + NWindows::NControl::CListView _messageList; UInt32 _prevPercentValue; UInt32 _prevTime; @@ -184,11 +231,30 @@ private: bool _foreground; + int _numReduceSymbols; + + bool _wasCreated; + bool _needClose; + + UInt32 _numPostedMessages; + + bool _errorsWereDisplayed; + + bool _waitCloseByCancelButton; + bool _cancelWasPressed; + + bool _inCancelMessageBox; + bool _externalCloseMessageWasReceived; + + void UpdateStatInfo(bool showAll); bool OnTimer(WPARAM timerID, LPARAM callback); void SetRange(UInt64 range); void SetPos(UInt64 pos); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual void OnCancel(); + virtual void OnOK(); + NWindows::NSynchronization::CManualResetEvent _createDialogEvent; NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; #ifndef _SFX void AddToTitle(LPCWSTR string); @@ -203,10 +269,25 @@ private: void SetTitleText(); void ShowSize(int id, UInt64 value); + void UpdateMessagesDialog(); + + void AddMessageDirect(LPCWSTR message); + void AddMessage(LPCWSTR message); + + bool OnExternalCloseMessage(); + void EnableErrorsControls(bool enable); + + void ShowAfterMessages(HWND wndParent); + + void CheckNeedClose(); public: - CProgressSynch ProgressSynch; + CProgressSync Sync; bool CompressingMode; - + bool WaitMode; + bool ShowCompressionInfo; + bool MessagesDisplayed; // = true if user pressed OK on all messages or there are no messages. + int IconID; + #ifndef _SFX HWND MainWindow; UString MainTitle; @@ -214,29 +295,64 @@ public: ~CProgressDialog(); #endif - CProgressDialog(): _timer(0), CompressingMode(true) - #ifndef _SFX - ,MainWindow(0) - #endif + CProgressDialog(); + void WaitCreating() { - if (_dialogCreatedEvent.Create() != S_OK) - throw 1334987; + _createDialogEvent.Set(); + _dialogCreatedEvent.Lock(); } - void WaitCreating() { _dialogCreatedEvent.Lock(); } + INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0); - INT_PTR Create(const UString &title, HWND wndParent = 0) - { - _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); - } - - static const UINT kCloseMessage; virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); - void MyClose() { PostMessage(kCloseMessage); }; + void ProcessWasFinished(); +}; + + +class CProgressCloser +{ + CProgressDialog *_p; +public: + CProgressCloser(CProgressDialog &p) : _p(&p) {} + ~CProgressCloser() { _p->ProcessWasFinished(); } +}; + +class CProgressThreadVirt +{ +protected: + UString ErrorMessage; + UString ErrorPath1; + UString ErrorPath2; + UString OkMessage; + UString OkMessageTitle; + + // error if any of HRESULT, ErrorMessage, ErrorPath + virtual HRESULT ProcessVirt() = 0; + void Process(); +public: + HRESULT Result; + bool ThreadFinishedOK; // if there is no fatal exception + CProgressDialog ProgressDialog; + + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + CProgressThreadVirt *p = (CProgressThreadVirt *)param; + try + { + p->Process(); + p->ThreadFinishedOK = true; + } + catch (...) { p->Result = E_FAIL; } + return 0; + } + + HRESULT Create(const UString &title, HWND parentWindow = 0); + CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {} }; +UString HResultToMessage(HRESULT errorCode); + #endif diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc index 2b707451..703dbb1f 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc @@ -1,77 +1,41 @@ #include "ProgressDialog2Res.h" #include "../../GuiCommon.rc" -#define xSize2 350 -#define ySize2 110 +#undef DIALOG_ID +#define DIALOG_ID IDD_DIALOG_PROGRESS +#define xc 360 +#define k 11 +#define z1s 16 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#include "ProgressDialog2a.rc" -#define bYPos (ySize - marg - bYSize) - -#undef bXSize -#define bXSize 80 - -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) -#define bXPos3 (bXPos2 - 10 - bXSize) - -#define x0Size 90 -#define x1 (marg + x0Size) -#define x1Size 70 - -#define x3Size 60 -#define x3 (xSize - marg - x3Size) - -#define x2Size 90 -#define x2 (x3 - x2Size) - -#undef y0 -#undef y1 -#undef y2 -#undef y3 -#define y0 marg -#define y1 (y0 + 11) -#define y2 (y1 + 11) -#define y3 (y2 + 11) +#ifdef UNDER_CE +#include "../../GuiCommon.rc" -IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX -CAPTION "Progress" -MY_FONT -BEGIN - PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize - PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize - LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, y0, x0Size, 8 - LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, y1, x0Size, 8 - LTEXT "Files:", IDC_PROGRESS_FILES, marg, y2, x0Size, 8 - LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, marg, y3, x0Size, 8 - LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2Size, 8 - LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2Size, 8 - LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2Size, 8 - LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2Size, 8 +#undef DIALOG_ID +#undef m +#undef k +#undef z1s - RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1Size, 8 - RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1Size, 8 - RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1Size, 8 - RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1Size, 8 +#define DIALOG_ID IDD_DIALOG_PROGRESS_2 +#define m 4 +#define k 8 +#define z1s 12 - RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3Size, 8 - RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3Size, 8 - RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8 - RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8 +#define xc 280 - LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 42, xSize2, 21, SS_NOPREFIX | SS_LEFTNOWORDWRAP - CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13 -END +#include "ProgressDialog2a.rc" +#endif STRINGTABLE DISCARDABLE -BEGIN +{ IDS_PROGRESS_PAUSED "Paused" IDS_PROGRESS_FOREGROUND "&Foreground" IDS_PROGRESS_CONTINUE "&Continue" IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?" -END + IDS_CLOSE "&Close" + IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message" +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h index 16bf2634..21ac03c2 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h @@ -1,10 +1,16 @@ -#define IDC_BUTTON_PAUSE 3 -#define IDC_BUTTON_PROGRESS_PRIORITY 4 #define IDD_DIALOG_PROGRESS 500 +#define IDD_DIALOG_PROGRESS_2 600 + +#define IDC_BUTTON_PAUSE 50 +#define IDC_BUTTON_PROGRESS_PRIORITY 51 + #define IDS_PROGRESS_PAUSED 700 #define IDS_PROGRESS_FOREGROUND 701 #define IDS_PROGRESS_CONTINUE 702 #define IDS_PROGRESS_ASK_CANCEL 703 +#define IDS_CLOSE 704 +#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503 + #define IDC_PROGRESS1 1000 #define IDC_PROGRESS_ELAPSED 1002 #define IDC_PROGRESS_ELAPSED_VALUE 1003 @@ -24,3 +30,12 @@ #define IDC_PROGRESS_PACKED_VALUE 1017 #define IDC_PROGRESS_UNPACKED 1018 #define IDC_PROGRESS_UNPACKED_VALUE 1019 + +#define IDC_PROGRESS_ERRORS 1030 +#define IDC_PROGRESS_ERRORS_VALUE 1031 +#define IDC_PROGRESS_LIST 1032 + +#define MY_PROGRESS_VALUE_UNITS 44 +#define MY_PROGRESS_LABEL_UNITS_MIN 60 +#define MY_PROGRESS_LABEL_UNITS_START 90 +#define MY_PROGRESS_PAD_UNITS 4 diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2a.rc b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc new file mode 100755 index 00000000..8eba4148 --- /dev/null +++ b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc @@ -0,0 +1,78 @@ +#undef bxs +#define bxs 80 + +#define x0s MY_PROGRESS_LABEL_UNITS_START +#define x1s MY_PROGRESS_VALUE_UNITS +#define x2s MY_PROGRESS_LABEL_UNITS_START +#define x3s MY_PROGRESS_VALUE_UNITS + +#define x1 (m + x0s) +#define x3 (xs - m - x3s) +#define x2 (x3 - x2s) + +#undef y0 +#undef y1 +#undef y2 +#undef y3 +#undef y4 + +#undef z0 +#undef z0z +#undef z1 +#undef z2 +#undef z2 + +#define y0 m +#define y1 (y0 + k) +#define y2 (y1 + k) +#define y3 (y2 + k) +#define y4 (y3 + k) + +#define z2 (y4 + k + 1) +#define z2s 24 + +#define z1 (z2 + z2s) + +#define z0 (z1 + z1s + m) +#define z0s 48 + +#define yc (z0 + z0s + bys) + + +DIALOG_ID MY_RESIZE_DIALOG +CAPTION "Progress" +{ + PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bx3, by, bxs, bys + PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bx2, by, bxs, bys + DEFPUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + + LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, m, y0, x0s, 8 + LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, m, y1, x0s, 8 + LTEXT "Files:", IDC_PROGRESS_FILES, m, y2, x0s, 8 + LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, m, y3, x0s, 8 + LTEXT "Errors:", IDC_PROGRESS_ERRORS, m, y4, x0s, 8 + + LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2s, 8 + LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2s, 8 + LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2s, 8 + LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2s, 8 + + RTEXT "", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1s, 8 + RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1s, 8 + RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1s, 8 + RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1s, 8 + RTEXT "", IDC_PROGRESS_ERRORS_VALUE, x1, y4, x1s, 8 + + RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3s, 8 + RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3s, 8 + RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3s, 8 + RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3s, 8 + + LTEXT "", IDC_PROGRESS_FILE_NAME, m, z2, xc, z2s, SS_NOPREFIX | SS_LEFTNOWORDWRAP + CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, z1, xc, z1s + + + CONTROL "List1", IDC_PROGRESS_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, z0, xc, z0s +} diff --git a/CPP/7zip/UI/FileManager/PropertyName.cpp b/CPP/7zip/UI/FileManager/PropertyName.cpp index 48090d38..79b09300 100755 --- a/CPP/7zip/UI/FileManager/PropertyName.cpp +++ b/CPP/7zip/UI/FileManager/PropertyName.cpp @@ -26,7 +26,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidPath, IDS_PROP_PATH, 0x02000203 }, { kpidName, IDS_PROP_NAME, 0x02000204 }, { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 }, - { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206}, + { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206}, { kpidSize, IDS_PROP_SIZE, 0x02000207}, { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 }, { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 }, @@ -40,7 +40,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 }, { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 }, { kpidCRC, IDS_PROP_CRC, 0x02000213 }, - { kpidType, IDS_PROP_FILE_TYPE, 0x02000214}, + { kpidType, IDS_PROP_FILE_TYPE, 0x02000214}, { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 }, { kpidMethod, IDS_PROP_METHOD, 0x02000216 }, { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 }, diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp index d4fbfe13..f7edbb4b 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp @@ -20,7 +20,9 @@ namespace NRegistryAssociations { static NSynchronization::CCriticalSection g_CriticalSection; -#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") +#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") + +/* static const TCHAR *kCUKeyPath = REG_PATH_FM; static const WCHAR *kExtPlugins = L"Plugins"; @@ -64,10 +66,8 @@ void ReadInternalAssociations(CObjectVector &items) UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); SplitString(pluginsString, extInfo.Plugins); - /* - if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) - extInfo.Enabled = false; - */ + // if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) + // extInfo.Enabled = false; items.Add(extInfo); } } @@ -89,6 +89,7 @@ void WriteInternalAssociations(const CObjectVector &items) // key.SetValue(kExtEnabled, extInfo.Enabled); } } +*/ /////////////////////////////////// // External @@ -100,6 +101,7 @@ static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon"); static const TCHAR *kShellKeyName = TEXT("shell"); static const TCHAR *kOpenKeyName = TEXT("open"); static const TCHAR *kCommandKeyName = TEXT("command"); +static const TCHAR *k7zipPrefix = TEXT("7-Zip."); static CSysString GetExtensionKeyName(const CSysString &extension) { @@ -108,10 +110,11 @@ static CSysString GetExtensionKeyName(const CSysString &extension) static CSysString GetExtProgramKeyName(const CSysString &extension) { - return CSysString(TEXT("7-Zip.")) + extension; + return CSysString(k7zipPrefix) + extension; } -static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconPath, int &iconIndex) +static bool CheckShellExtensionInfo2(const CSysString &extension, + CSysString programKeyName, UString &iconPath, int &iconIndex) { iconIndex = -1; iconPath.Empty(); @@ -119,15 +122,13 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP CKey extKey; if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS) return false; - CSysString programNameValue; - if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS) + if (extKey.QueryValue(NULL, programKeyName) != ERROR_SUCCESS) return false; - CSysString extProgramKeyName = GetExtProgramKeyName(extension); - UString programNameValueU = GetUnicodeString(programNameValue); - if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0) + UString s = GetUnicodeString(k7zipPrefix); + if (s.CompareNoCase(GetUnicodeString(programKeyName.Left(s.Length()))) != 0) return false; CKey iconKey; - if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) + if (extKey.Open(HKEY_CLASSES_ROOT, programKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) return false; UString value; if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS) @@ -151,10 +152,11 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); - if (!CheckShellExtensionInfo2(extension, iconPath, iconIndex)) + CSysString programKeyName; + if (!CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex)) return false; CKey extProgKey; - return (extProgKey.Open(HKEY_CLASSES_ROOT, GetExtProgramKeyName(extension), KEY_READ) == ERROR_SUCCESS); + return (extProgKey.Open(HKEY_CLASSES_ROOT, programKeyName, KEY_READ) == ERROR_SUCCESS); } static void DeleteShellExtensionKey(const CSysString &extension) @@ -177,9 +179,10 @@ static void DeleteShellExtensionProgramKey(const CSysString &extension) void DeleteShellExtensionInfo(const CSysString &extension) { + CSysString programKeyName; UString iconPath; int iconIndex; - if (CheckShellExtensionInfo2(extension, iconPath, iconIndex)) + if (CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex)) DeleteShellExtensionKey(extension); DeleteShellExtensionProgramKey(extension); } @@ -193,7 +196,13 @@ void AddShellExtensionInfo(const CSysString &extension, DeleteShellExtensionKey(extension); DeleteShellExtensionProgramKey(extension); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); - CSysString programKeyName = GetExtProgramKeyName(extension); + CSysString programKeyName; + { + CSysString ext = extension; + if (iconIndex < 0) + ext = TEXT("*"); + programKeyName = GetExtProgramKeyName(ext); + } { CKey extKey; extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension)); @@ -212,7 +221,9 @@ void AddShellExtensionInfo(const CSysString &extension, CKey iconKey; iconKey.Create(programKey, kDefaultIconKeyName); UString iconPathFull = iconPath; - if (iconIndex >= 0) + if (iconIndex < 0) + iconIndex = 0; + // if (iconIndex >= 0) { iconPathFull += L","; wchar_t s[16]; @@ -240,7 +251,7 @@ void AddShellExtensionInfo(const CSysString &extension, // ContextMenu /* -static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP"); +static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip"); static const TCHAR *kContextMenuHandlerCLASSIDValue = TEXT("{23170F69-40C1-278A-1000-000100020000}"); static const TCHAR *kRootKeyNameForFile = TEXT("*"); diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h index 2516fd2b..5390b9db 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.h +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h @@ -7,6 +7,7 @@ namespace NRegistryAssociations { + /* struct CExtInfo { UString Ext; @@ -16,6 +17,7 @@ namespace NRegistryAssociations { bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo); void ReadInternalAssociations(CObjectVector &items); void WriteInternalAssociations(const CObjectVector &items); + */ bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex); diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp index 61cceb5f..d49eaa6e 100755 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp @@ -2,21 +2,16 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" -// #include "Windows/Registry.h" -// #include "Windows/Synchronization.h" - #include "Windows/DLL.h" #include "Windows/PropVariant.h" #include "Windows/FileFind.h" +#include "ProgramLocation.h" #include "RegistryPlugins.h" #include "IFolder.h" using namespace NWindows; using namespace NFile; -// using namespace NRegistry; -// using namespace NCOM; /* static const TCHAR *kLMBasePath = TEXT("Software\\7-Zip\\FM"); @@ -32,66 +27,65 @@ static CSysString GetFileFolderPluginsKeyName() CSysString(kPluginsKeyName); } -static NSynchronization::CCriticalSection g_CriticalSection; */ -typedef UINT32 (WINAPI * GetPluginPropertyFunc)( - PROPID propID, PROPVARIANT *value); -static bool ReadPluginInfo(CPluginInfo &pluginInfo) +typedef UINT32 (WINAPI * GetPluginPropertyFunc)(PROPID propID, PROPVARIANT *value); + +static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll) { + if (needCheckDll) { - NDLL::CLibrary library; - if (!library.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE)) + NDLL::CLibrary lib; + if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE)) return false; } - NDLL::CLibrary library; - if (!library.Load(pluginInfo.FilePath)) + NDLL::CLibrary lib; + if (!lib.Load(pluginInfo.FilePath)) return false; - GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc) - library.GetProcAddress("GetPluginProperty"); + GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty"); if (getPluginProperty == NULL) return false; - NCOM::CPropVariant propVariant; - if (getPluginProperty(NPlugin::kName, &propVariant) != S_OK) + NCOM::CPropVariant prop; + if (getPluginProperty(NPlugin::kName, &prop) != S_OK) return false; - if (propVariant.vt != VT_BSTR) + if (prop.vt != VT_BSTR) return false; - pluginInfo.Name = propVariant.bstrVal; - propVariant.Clear(); + pluginInfo.Name = prop.bstrVal; + prop.Clear(); - if (getPluginProperty(NPlugin::kClassID, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.ClassIDDefined = false; - else if (propVariant.vt != VT_BSTR) + else if (prop.vt != VT_BSTR) return false; else { pluginInfo.ClassIDDefined = true; - pluginInfo.ClassID = *(const GUID *)propVariant.bstrVal; + pluginInfo.ClassID = *(const GUID *)prop.bstrVal; } - propVariant.Clear(); + prop.Clear(); - if (getPluginProperty(NPlugin::kOptionsClassID, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.OptionsClassIDDefined = false; - else if (propVariant.vt != VT_BSTR) + else if (prop.vt != VT_BSTR) return false; else { pluginInfo.OptionsClassIDDefined = true; - pluginInfo.OptionsClassID = *(const GUID *)propVariant.bstrVal; + pluginInfo.OptionsClassID = *(const GUID *)prop.bstrVal; } - propVariant.Clear(); + prop.Clear(); - if (getPluginProperty(NPlugin::kType, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kType, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.Type = kPluginTypeFF; - else if (propVariant.vt == VT_UI4) - pluginInfo.Type = (EPluginType)propVariant.ulVal; + else if (prop.vt == VT_UI4) + pluginInfo.Type = (EPluginType)prop.ulVal; else return false; return true; @@ -103,11 +97,12 @@ void ReadPluginInfoList(CObjectVector &plugins) { plugins.Clear(); - UString baseFolderPrefix = GetProgramFolderPrefix(); + UString baseFolderPrefix; + GetProgramFolderPath(baseFolderPrefix); { CPluginInfo pluginInfo; pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll"; - if (::ReadPluginInfo(pluginInfo)) + if (::ReadPluginInfo(pluginInfo, false)) plugins.Add(pluginInfo); } UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR; @@ -119,7 +114,7 @@ void ReadPluginInfoList(CObjectVector &plugins) continue; CPluginInfo pluginInfo; pluginInfo.FilePath = folderPath + fileInfo.Name; - if (::ReadPluginInfo(pluginInfo)) + if (::ReadPluginInfo(pluginInfo, true)) plugins.Add(pluginInfo); } } diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp index bd1248a2..6697169b 100755 --- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp +++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp @@ -11,7 +11,7 @@ using namespace NWindows; using namespace NRegistry; -#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") +#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") static const TCHAR *kCUBasePath = REG_PATH_7Z; static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM"); @@ -29,7 +29,7 @@ static const TCHAR *kShowGrid = TEXT("ShowGrid"); static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection"); // static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd"); static const TCHAR *kLargePagesEnable = TEXT("LargePages"); -// static const TCHAR *kSingleClick = TEXT("SingleClick"); +static const TCHAR *kSingleClick = TEXT("SingleClick"); // static const TCHAR *kUnderline = TEXT("Underline"); static const TCHAR *kFlatViewName = TEXT("FlatViewArc"); @@ -135,10 +135,10 @@ bool ReadShowGrid(){ return ReadOption(kShowGrid, false); } void SaveAlternativeSelection(bool enable) { SaveOption(kAlternativeSelection, enable); } bool ReadAlternativeSelection(){ return ReadOption(kAlternativeSelection, false); } -/* void SaveSingleClick(bool enable) { SaveOption(kSingleClick, enable); } bool ReadSingleClick(){ return ReadOption(kSingleClick, false); } +/* void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); } bool ReadUnderline(){ return ReadOption(kUnderline, false); } */ diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.h b/CPP/7zip/UI/FileManager/RegistryUtils.h index 5469f401..3bf06617 100755 --- a/CPP/7zip/UI/FileManager/RegistryUtils.h +++ b/CPP/7zip/UI/FileManager/RegistryUtils.h @@ -4,6 +4,7 @@ #define __REGISTRY_UTILS_H #include "Common/MyString.h" +#include "Common/Types.h" void SaveRegLang(const UString &path); void ReadRegLang(UString &path); @@ -38,10 +39,10 @@ bool ReadAlternativeSelection(); bool ReadLockMemoryEnable(); void SaveLockMemoryEnable(bool enable); -/* void SaveSingleClick(bool enable); bool ReadSingleClick(); +/* void SaveUnderline(bool enable); bool ReadUnderline(); */ diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp index ea6f5080..1f4886d2 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.cpp +++ b/CPP/7zip/UI/FileManager/RootFolder.cpp @@ -4,14 +4,17 @@ #include "Common/StringConvert.h" +#include "Windows/DLL.h" #include "Windows/PropVariant.h" #include "../../PropID.h" -#include "FSDrives.h" #include "FSFolder.h" #include "LangUtils.h" +#ifndef UNDER_CE #include "NetFolder.h" +#include "FSDrives.h" +#endif #include "RootFolder.h" #include "SysIconUtils.h" @@ -26,7 +29,11 @@ static const STATPROPSTG kProps[] = UString RootFolder_GetName_Computer(int &iconIndex) { + #ifdef UNDER_CE + GetRealIconIndex(L"\\", FILE_ATTRIBUTE_DIRECTORY, iconIndex); + #else iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES); + #endif return LangString(IDS_COMPUTER, 0x03020300); } @@ -42,20 +49,29 @@ UString RootFolder_GetName_Documents(int &iconIndex) return LangString(IDS_DOCUMENTS, 0x03020302); ; } -const int ROOT_INDEX_COMPUTER = 0; -const int ROOT_INDEX_DOCUMENTS = 1; -const int ROOT_INDEX_NETWORK = 2; -const int ROOT_INDEX_VOLUMES = 3; +enum +{ + ROOT_INDEX_COMPUTER = 0 + #ifndef UNDER_CE + , ROOT_INDEX_DOCUMENTS + , ROOT_INDEX_NETWORK + , ROOT_INDEX_VOLUMES + #endif +}; -static const wchar_t *kVolPrefix = L"\\\\.\\"; +#ifndef UNDER_CE +static const wchar_t *kVolPrefix = L"\\\\."; +#endif void CRootFolder::Init() { _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]); + #ifndef UNDER_CE _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]); _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]); _names[ROOT_INDEX_VOLUMES] = kVolPrefix; _iconIndices[ROOT_INDEX_VOLUMES] = GetIconIndexForCSIDL(CSIDL_DRIVES); + #endif }; STDMETHODIMP CRootFolder::LoadItems() @@ -90,7 +106,11 @@ UString GetMyDocsPath() UString us; WCHAR s[MAX_PATH + 1]; SHGetSpecialFolderPathWp getW = (SHGetSpecialFolderPathWp) - ::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathW"); + #ifdef UNDER_CE + My_GetProcAddress(GetModuleHandle(TEXT("coredll.dll")), "SHGetSpecialFolderPath"); + #else + My_GetProcAddress(GetModuleHandle(TEXT("shell32.dll")), "SHGetSpecialFolderPathW"); + #endif if (getW && getW(0, s, CSIDL_PERSONAL, FALSE)) us = s; #ifndef _UNICODE @@ -112,6 +132,14 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde { *resultFolder = NULL; CMyComPtr subFolder; + #ifdef UNDER_CE + if (index == ROOT_INDEX_COMPUTER) + { + NFsFolder::CFSFolder *fsFolder = new NFsFolder::CFSFolder; + subFolder = fsFolder; + fsFolder->InitToRoot(); + } + #else if (index == ROOT_INDEX_COMPUTER || index == ROOT_INDEX_VOLUMES) { CFSDrives *fsDrivesSpec = new CFSDrives; @@ -134,6 +162,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde RINOK(fsFolderSpec->Init(s, NULL)); } } + #endif else return E_INVALIDARG; *resultFolder = subFolder.Detach(); @@ -161,9 +190,14 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu for (int i = 0; i < kNumRootFolderItems; i++) if (AreEqualNames(name2, _names[i])) return BindToFolder((UInt32)i, resultFolder); + #ifdef UNDER_CE + if (name2 == L"\\") + return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); + #else if (AreEqualNames(name2, L"My Documents") || AreEqualNames(name2, L"Documents")) return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder); + #endif if (AreEqualNames(name2, L"My Computer") || AreEqualNames(name2, L"Computer")) return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); @@ -179,6 +213,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu CMyComPtr subFolder; + #ifndef UNDER_CE if (name2.Left(4) == kVolPrefix) { CFSDrives *folderSpec = new CFSDrives; @@ -186,6 +221,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu folderSpec->Init(true); } else + #endif { if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR) name2 += WCHAR_PATH_SEPARATOR; @@ -193,6 +229,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu subFolder = fsFolderSpec; if (fsFolderSpec->Init(name2, 0) != S_OK) { + #ifndef UNDER_CE if (name2[0] == WCHAR_PATH_SEPARATOR) { CNetFolder *netFolderSpec = new CNetFolder; @@ -200,6 +237,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu netFolderSpec->Init(name2); } else + #endif return E_INVALIDARG; } } diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h index 9f08e601..21d74db8 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.h +++ b/CPP/7zip/UI/FileManager/RootFolder.h @@ -7,7 +7,13 @@ #include "IFolder.h" -const int kNumRootFolderItems = 4; +const int kNumRootFolderItems = + #ifdef UNDER_CE + 1 + #else + 4 + #endif + ; class CRootFolder: public IFolderFolder, diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp index 8b2eb836..f6694c56 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.cpp +++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp @@ -1,18 +1,20 @@ // SettingsPage.cpp #include "StdAfx.h" -#include "SettingsPageRes.h" -#include "SettingsPage.h" #include "Common/StringConvert.h" -#include "Windows/Defs.h" +#ifndef UNDER_CE #include "Windows/MemoryLock.h" +#endif -#include "RegistryUtils.h" #include "HelpUtils.h" #include "LangUtils.h" #include "ProgramLocation.h" +#include "RegistryUtils.h" +#include "SettingsPage.h" + +#include "SettingsPageRes.h" using namespace NWindows; @@ -48,7 +50,7 @@ bool CSettingsPage::OnInit() CheckButton(IDC_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable()); else EnableItem(IDC_SETTINGS_LARGE_PAGES, false); - // CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick()); + CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick()); // CheckButton(IDC_SETTINGS_UNDERLINE, ReadUnderline()); // EnableSubItems(); @@ -72,14 +74,16 @@ LONG CSettingsPage::OnApply() SaveFullRow(IsButtonCheckedBool(IDC_SETTINGS_FULL_ROW)); SaveShowGrid(IsButtonCheckedBool(IDC_SETTINGS_SHOW_GRID)); SaveAlternativeSelection(IsButtonCheckedBool(IDC_SETTINGS_ALTERNATIVE_SELECTION)); + #ifndef UNDER_CE if (IsLargePageSupported()) { bool enable = IsButtonCheckedBool(IDC_SETTINGS_LARGE_PAGES); NSecurity::EnableLockMemoryPrivilege(enable); SaveLockMemoryEnable(enable); } + #endif - // SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); + SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); // SaveUnderline(IsButtonCheckedBool(IDC_SETTINGS_UNDERLINE)); return PSNRET_NOERROR; @@ -94,8 +98,8 @@ bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - /* case IDC_SETTINGS_SINGLE_CLICK: + /* EnableSubItems(); break; */ diff --git a/CPP/7zip/UI/FileManager/SettingsPage.rc b/CPP/7zip/UI/FileManager/SettingsPage.rc index 1d0e709b..3e4a611e 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.rc +++ b/CPP/7zip/UI/FileManager/SettingsPage.rc @@ -1,35 +1,22 @@ #include "SettingsPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - - -IDD_SETTINGS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE -CAPTION "Settings" -MY_FONT -BEGIN - CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, marg, xSize2, 10 - CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 21, xSize2, 10 - CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 35, xSize2, 10 - CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 63, xSize2, 10 - CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 77, xSize2, 10 - CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, - marg, 91, xSize2, 10 - CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, - marg + 12, 105, xSize2 - 12, 10 - - CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 122, xSize2, 10 - - CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 142, xSize2, 10 - -END +#define xc 200 +#define yc 120 + +IDD_SETTINGS MY_PAGE +#include "SettingsPage2.rc" + + +#ifdef UNDER_CE + +#undef m +#undef xc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +IDD_SETTINGS_2 MY_PAGE +#include "SettingsPage2.rc" + +#endif diff --git a/CPP/7zip/UI/FileManager/SettingsPage2.rc b/CPP/7zip/UI/FileManager/SettingsPage2.rc new file mode 100755 index 00000000..c920120e --- /dev/null +++ b/CPP/7zip/UI/FileManager/SettingsPage2.rc @@ -0,0 +1,24 @@ +CAPTION "Settings" +BEGIN + CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, MY_CHECKBOX, + m, 8, xc, 10 + CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, MY_CHECKBOX, + m, 22, xc, 10 + CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, MY_CHECKBOX, + m, 36, xc, 10 + CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, MY_CHECKBOX, + m, 50, xc, 10 + CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, MY_CHECKBOX, + m, 64, xc, 10 + CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, MY_CHECKBOX, + m, 78, xc, 10 + /* + CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, + m + 12, 92, xc - 12, 10 + */ + + CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, MY_CHECKBOX, + m, 92, xc, 10 + CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, MY_CHECKBOX, + m, 106, xc, 10 +END diff --git a/CPP/7zip/UI/FileManager/SettingsPageRes.h b/CPP/7zip/UI/FileManager/SettingsPageRes.h index 8932dc0e..b6c7f5cc 100755 --- a/CPP/7zip/UI/FileManager/SettingsPageRes.h +++ b/CPP/7zip/UI/FileManager/SettingsPageRes.h @@ -1,4 +1,6 @@ -#define IDD_SETTINGS 904 +#define IDD_SETTINGS 543 +#define IDD_SETTINGS_2 643 + #define IDC_SETTINGS_SHOW_DOTS 1000 #define IDC_SETTINGS_SHOW_REAL_FILE_ICONS 1001 diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp index bab319d1..5dca8e48 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.cpp +++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp @@ -1,18 +1,18 @@ // SplitDialog.cpp #include "StdAfx.h" -#include "SplitDialog.h" -#include "Common/StringToInt.h" -#include "Windows/Shell.h" #include "Windows/FileName.h" -#include "SplitUtils.h" #ifdef LANG #include "LangUtils.h" #endif +#include "BrowseDialog.h" #include "CopyDialogRes.h" +#include "SplitDialog.h" +#include "SplitUtils.h" +#include "resourceGui.h" using namespace NWindows; @@ -45,9 +45,36 @@ bool CSplitDialog::OnInit() _pathCombo.SetText(Path); AddVolumeItems(_volumeCombo); _volumeCombo.SetCurSel(0); + NormalizeSize(); return CModalDialog::OnInit(); } +bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int yPos = ySize - my - by; + int xPos = xSize - mx - bx1; + + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_BUTTON_SPLIT_PATH, rect); + int bx = rect.right - rect.left; + MoveItem(IDC_BUTTON_SPLIT_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + ChangeSubWindowSizeX(_pathCombo, xSize - mx - mx - bx - mx); + } + + MoveItem(IDCANCEL, xPos, yPos, bx1, by); + MoveItem(IDOK, xPos - mx - bx2, yPos, bx2, by); + + return false; +} + bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) @@ -67,7 +94,7 @@ void CSplitDialog::OnButtonSetPath() UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); UString resultPath; - if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _pathCombo.SetCurSel(-1); @@ -82,7 +109,7 @@ void CSplitDialog::OnOK() volumeString.Trim(); if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0) { - ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); + ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); return; } CModalDialog::OnOK(); diff --git a/CPP/7zip/UI/FileManager/SplitDialog.h b/CPP/7zip/UI/FileManager/SplitDialog.h index 607a3daf..33fb64e7 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.h +++ b/CPP/7zip/UI/FileManager/SplitDialog.h @@ -1,11 +1,11 @@ // SplitDialog.h -#ifndef __SPLITDIALOG_H -#define __SPLITDIALOG_H +#ifndef __SPLIT_DIALOG_H +#define __SPLIT_DIALOG_H -#include "Common/Types.h" #include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" + #include "SplitDialogRes.h" class CSplitDialog: public NWindows::NControl::CModalDialog @@ -14,6 +14,7 @@ class CSplitDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _volumeCombo; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); void OnButtonSetPath(); public: diff --git a/CPP/7zip/UI/FileManager/SplitDialog.rc b/CPP/7zip/UI/FileManager/SplitDialog.rc index 7e78daaf..e977d651 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.rc +++ b/CPP/7zip/UI/FileManager/SplitDialog.rc @@ -1,32 +1,16 @@ #include "SplitDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 223 -#define ySize2 89 +#define xc 288 +#define yc 96 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - - -IDD_DIALOG_SPLIT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_SPLIT MY_RESIZE_DIALOG CAPTION "Split File" -MY_FONT -BEGIN - LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, marg, marg, xSize2, 8 - COMBOBOX IDC_COMBO_SPLIT_PATH, marg, 18, xSize2 - bDotsSize - 12, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xSize - marg - bDotsSize, 17, bDotsSize, bYSize, WS_GROUP - LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, marg, 38, xSize2, 8 - COMBOBOX IDC_COMBO_SPLIT_VOLUME, marg, 50, 120, 52, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - -STRINGTABLE BEGIN - IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, m, m, xc, 8 + COMBOBOX IDC_COMBO_SPLIT_PATH, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, m, 44, xc, 8 + COMBOBOX IDC_COMBO_SPLIT_VOLUME, m, 56, 96, 52, MY_COMBO_WITH_EDIT + OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/SplitDialogRes.h b/CPP/7zip/UI/FileManager/SplitDialogRes.h index 019b7029..a6f06d1c 100755 --- a/CPP/7zip/UI/FileManager/SplitDialogRes.h +++ b/CPP/7zip/UI/FileManager/SplitDialogRes.h @@ -5,4 +5,3 @@ #define IDC_STATIC_SPLIT_VOLUME 1010 #define IDC_COMBO_SPLIT_VOLUME 1011 -#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95 diff --git a/CPP/7zip/UI/FileManager/SplitUtils.cpp b/CPP/7zip/UI/FileManager/SplitUtils.cpp index 3a7635fa..8bae0573 100755 --- a/CPP/7zip/UI/FileManager/SplitUtils.cpp +++ b/CPP/7zip/UI/FileManager/SplitUtils.cpp @@ -59,10 +59,11 @@ bool ParseVolumeSizes(const UString &s, CRecordVector &values) void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo) { - volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy")); + volumeCombo.AddString(TEXT("10M")); volumeCombo.AddString(TEXT("650M - CD")); volumeCombo.AddString(TEXT("700M - CD")); volumeCombo.AddString(TEXT("4480M - DVD")); + volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy")); } UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector &volSizes) diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp index 3e5de7aa..e359ed2b 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp +++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp @@ -1,12 +1,13 @@ -// SysIconUtils.h +// SysIconUtils.cpp #include "StdAfx.h" -#include "SysIconUtils.h" #ifndef _UNICODE #include "Common/StringConvert.h" #endif +#include "SysIconUtils.h" + #ifndef _UNICODE extern bool g_IsNT; #endif @@ -18,7 +19,7 @@ int GetIconIndexForCSIDL(int csidl) if (pidl) { SHFILEINFO shellInfo; - SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL, + SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL, &shellInfo, sizeof(shellInfo), SHGFI_PIDL | SHGFI_SYSICONINDEX); IMalloc *pMalloc; @@ -33,10 +34,10 @@ int GetIconIndexForCSIDL(int csidl) return 0; } -DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex) +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex) { SHFILEINFO shellInfo; - DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; @@ -44,7 +45,7 @@ DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex) #ifndef _UNICODE -typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); +typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); struct CSHGetFileInfoInit { @@ -57,36 +58,36 @@ struct CSHGetFileInfoInit } g_SHGetFileInfoInit; #endif -DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) +static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) { #ifdef _UNICODE - return SHGetFileInfoW( + return SHGetFileInfo( #else if (g_SHGetFileInfoInit.shGetFileInfoW == 0) return 0; return g_SHGetFileInfoInit.shGetFileInfoW( #endif - pszPath, dwFileAttributes, psfi, cbFileInfo, uFlags); + pszPath, attrib, psfi, cbFileInfo, uFlags); } #ifndef _UNICODE // static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } -DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex) +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex) { if(g_IsNT) { SHFILEINFOW shellInfo; - DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; } else - return GetRealIconIndex(UnicodeStringToMultiByte(path), attributes, iconIndex); + return GetRealIconIndex(UnicodeStringToMultiByte(path), attrib, iconIndex); } #endif -DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, +DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString &typeName) { #ifndef _UNICODE @@ -94,9 +95,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, { SHFILEINFO shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX - | SHGFI_TYPENAME); + DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = GetUnicodeString(shellInfo.szTypeName); iconIndex = shellInfo.iIcon; return res; @@ -106,49 +106,54 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, { SHFILEINFOW shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX - | SHGFI_TYPENAME); + DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = shellInfo.szTypeName; iconIndex = shellInfo.iIcon; return res; } } -int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileNameSpec, UString &typeName) +int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName) { - UString fileName = fileNameSpec; - if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + int dotPos = fileName.ReverseFind(L'.'); + if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0) { - fileName = L"__Fldr__"; - if (_dirIconIndex < 0) - GetRealIconIndex(fileName, attributes, _dirIconIndex, _dirTypeName); - typeName = _dirTypeName; - return _dirIconIndex; + CAttribIconPair pair; + pair.Attrib = attrib; + int index = _attribMap.FindInSorted(pair); + if (index >= 0) + { + typeName = _attribMap[index].TypeName; + return _attribMap[index].IconIndex; + } + GetRealIconIndex( + #ifdef UNDER_CE + L"\\" + #endif + L"__File__" + , attrib, pair.IconIndex, pair.TypeName); + _attribMap.AddToSorted(pair); + typeName = pair.TypeName; + return pair.IconIndex; } - int dotPos = fileName.ReverseFind('.'); - if (dotPos < 0) + + CExtIconPair pair; + pair.Ext = fileName.Mid(dotPos + 1); + int index = _extMap.FindInSorted(pair); + if (index >= 0) { - fileName = L"__File__"; - if (_noExtIconIndex < 0) - GetRealIconIndex(fileName, attributes, _noExtIconIndex, _noExtTypeName); - typeName = _noExtTypeName; - return _noExtIconIndex; + typeName = _extMap[index].TypeName; + return _extMap[index].IconIndex; } - CExtIconPair extIconPair; - extIconPair.Ext = fileName.Mid(dotPos + 1); - int anIndex = _map.FindInSorted(extIconPair); - if (anIndex >= 0) - return _map[anIndex].IconIndex; - fileName = fileName.Mid(dotPos); - GetRealIconIndex(fileName, attributes, extIconPair.IconIndex, extIconPair.TypeName); - _map.AddToSorted(extIconPair); - typeName = extIconPair.TypeName; - return extIconPair.IconIndex; + GetRealIconIndex(fileName.Mid(dotPos), attrib, pair.IconIndex, pair.TypeName); + _extMap.AddToSorted(pair); + typeName = pair.TypeName; + return pair.IconIndex; } -int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileName) +int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName) { UString typeName; - return GetIconIndex(attributes, fileName, typeName); + return GetIconIndex(attrib, fileName, typeName); } diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h index a90d28bc..5ba9c57f 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.h +++ b/CPP/7zip/UI/FileManager/SysIconUtils.h @@ -1,7 +1,7 @@ // SysIconUtils.h -#ifndef __SYSICONUTILS_H -#define __SYSICONUTILS_H +#ifndef __SYS_ICON_UTILS_H +#define __SYS_ICON_UTILS_H #include "Common/MyString.h" @@ -10,42 +10,48 @@ struct CExtIconPair UString Ext; int IconIndex; UString TypeName; - }; -inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) +struct CAttribIconPair { - return (a1.Ext == a2.Ext); -} + DWORD Attrib; + int IconIndex; + UString TypeName; +}; -inline bool operator<(const CExtIconPair &a1, const CExtIconPair &a2) -{ - return (a1.Ext < a2.Ext); -} +inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext == a2.Ext; } +inline bool operator< (const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext < a2.Ext; } + +inline bool operator==(const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib == a2.Attrib; } +inline bool operator< (const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib < a2.Attrib; } class CExtToIconMap { - int _dirIconIndex; - UString _dirTypeName; - int _noExtIconIndex; - UString _noExtTypeName; - CObjectVector _map; + CObjectVector _extMap; + CObjectVector _attribMap; public: - CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {} void Clear() { - _dirIconIndex = -1; - _noExtIconIndex = -1; - _map.Clear(); + _extMap.Clear(); + _attribMap.Clear(); } - int GetIconIndex(UINT32 attributes, const UString &fileName, UString &typeName); - int GetIconIndex(UINT32 attributes, const UString &fileName); + int GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName); + int GetIconIndex(DWORD attrib, const UString &fileName); }; -DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex); #ifndef _UNICODE -DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex); #endif int GetIconIndexForCSIDL(int csidl); +inline HIMAGELIST GetSysImageList(bool smallIcons) +{ + SHFILEINFO shellInfo; + return (HIMAGELIST)SHGetFileInfo(TEXT(""), + FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY, + &shellInfo, sizeof(shellInfo), + SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON)); +} + #endif diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp index 1cd7ce15..3681992d 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.cpp +++ b/CPP/7zip/UI/FileManager/SystemPage.cpp @@ -52,11 +52,11 @@ bool CSystemPage::OnInit() _listViewExt.SetExtendedListViewStyle(newFlags, newFlags); _listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags); - _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 70); + _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 40); const UString s = LangString(IDS_PLUGIN, 0x03010310); - _listViewExt.InsertColumn(1, s, 70); + _listViewExt.InsertColumn(1, s, 40); - _listViewPlugins.InsertColumn(0, s, 70); + _listViewPlugins.InsertColumn(0, s, 40); _extDatabase.Read(); @@ -77,11 +77,8 @@ bool CSystemPage::OnInit() } // _listViewExt.SortItems(); - if(_listViewExt.GetItemCount() > 0) - { - UINT state = LVIS_SELECTED | LVIS_FOCUSED; - _listViewExt.SetItemState(0, state, state); - } + if (_listViewExt.GetItemCount() > 0) + _listViewExt.SetItemState_FocusedSelected(0); RefreshPluginsList(-1); _initMode = false; @@ -166,7 +163,10 @@ LONG CSystemPage::OnApply() else NRegistryAssociations::DeleteContextMenuHandler(); */ + #ifndef UNDER_CE SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); + WasChanged = true; + #endif return PSNRET_NOERROR; } @@ -370,12 +370,11 @@ void CSystemPage::RefreshPluginsList(int selectIndex) int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name); _listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled); } - if(_listViewPlugins.GetItemCount() > 0) + if (_listViewPlugins.GetItemCount() > 0) { if (selectIndex < 0) selectIndex = 0; - UINT state = LVIS_SELECTED | LVIS_FOCUSED; - _listViewPlugins.SetItemState(selectIndex, state, state); + _listViewPlugins.SetItemState_FocusedSelected(selectIndex); } _initMode = false; } diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h index 1b5891f6..967731fd 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.h +++ b/CPP/7zip/UI/FileManager/SystemPage.h @@ -1,7 +1,7 @@ // SystemPage.h -#ifndef __SYSTEMPAGE_H -#define __SYSTEMPAGE_H +#ifndef __SYSTEM_PAGE_H +#define __SYSTEM_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/ListView.h" @@ -13,7 +13,6 @@ class CSystemPage: public NWindows::NControl::CPropertyPage bool _initMode; CExtDatabase _extDatabase; - // CObjectVector m_Archivers; NWindows::NControl::CListView _listViewExt; NWindows::NControl::CListView _listViewPlugins; @@ -26,6 +25,8 @@ class CSystemPage: public NWindows::NControl::CPropertyPage void SelectAll(); public: + bool WasChanged; + CSystemPage(): WasChanged(false) {} virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); virtual bool OnInit(); virtual void OnNotifyHelp(); diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc index 9b4e808d..52e60d19 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.rc +++ b/CPP/7zip/UI/FileManager/SystemPage.rc @@ -1,26 +1,42 @@ #include "SystemPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 200 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) -#define g0Size xSize2 -#define gYSize (ySize2 - 20 - bYSize) +#define xc 200 +#define yc 200 - -IDD_SYSTEM DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_SYSTEM MY_PAGE CAPTION "System" -MY_FONT BEGIN - LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, marg, marg, xSize2, 8 - CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", + LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 + CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP, - marg, 20, g0Size, gYSize - PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, marg, (ySize - marg - bYSize), 90, bYSize + m, m + 12, xc, (yc - m - 12 - 1 - bys) + PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys), 90, bys +END + +#ifdef UNDER_CE + +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) +#define yc (128 + 8) +IDD_SYSTEM_2 MY_PAGE +CAPTION "System" +BEGIN + LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 + CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", + LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP, + m, m + 12, xc, (yc - m - 12 - 1 - bys - 8) + PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys - 8), 90, bys END +#endif + + STRINGTABLE BEGIN IDS_PLUGIN "Plugin" diff --git a/CPP/7zip/UI/FileManager/SystemPageRes.h b/CPP/7zip/UI/FileManager/SystemPageRes.h index 8dce778b..b60b4533 100755 --- a/CPP/7zip/UI/FileManager/SystemPageRes.h +++ b/CPP/7zip/UI/FileManager/SystemPageRes.h @@ -1,4 +1,5 @@ -#define IDD_SYSTEM 902 +#define IDD_SYSTEM 540 +#define IDD_SYSTEM_2 640 #define IDS_PLUGIN 990 // #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 #define IDC_SYSTEM_STATIC_ASSOCIATE 1020 diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp index 3701d2bb..43dfa4dc 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp @@ -2,73 +2,56 @@ #include "StdAfx.h" -#include "MessagesDialog.h" #include "PasswordDialog.h" #include "UpdateCallback100.h" -CUpdateCallback100Imp::~CUpdateCallback100Imp() -{ - if (ShowMessages && !Messages.IsEmpty()) - { - CMessagesDialog messagesDialog; - messagesDialog.Messages = &Messages; - messagesDialog.Create(_parentWindow); - } -} - -void CUpdateCallback100Imp::AddErrorMessage(LPCWSTR message) -{ - Messages.Add(message); -} - STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) { - ProgressDialog.ProgressSynch.SetProgress(size, 0); + ProgressDialog->Sync.SetProgress(size, 0); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); if (completeValue != NULL) - ProgressDialog.ProgressSynch.SetPos(*completeValue); + ProgressDialog->Sync.SetPos(*completeValue); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.SetRatioInfo(inSize, outSize); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */) { - NumFiles++; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(++_numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message) { - AddErrorMessage(message); + ProgressDialog->Sync.AddErrorMessage(message); return S_OK; } @@ -88,7 +71,7 @@ STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const U STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) @@ -97,7 +80,8 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) if (!_passwordIsDefined) { CPasswordDialog dialog; - if (dialog.Create(_parentWindow) == IDCANCEL) + ProgressDialog->WaitCreating(); + if (dialog.Create(*ProgressDialog) == IDCANCEL) return E_ABORT; _password = dialog.Password; _passwordIsDefined = true; diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h index 5ae194a2..aa13320f 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.h +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h @@ -4,15 +4,12 @@ #define __UPDATE_CALLBACK100_H #include "Common/MyCom.h" -#include "Common/MyString.h" -#include "../Agent/IFolderArchive.h" -#include "ProgressDialog2.h" #include "../../IPassword.h" -#ifdef LANG -#include "LangUtils.h" -#endif +#include "../Agent/IFolderArchive.h" + +#include "ProgressDialog2.h" class CUpdateCallback100Imp: public IFolderArchiveUpdateCallback, @@ -22,7 +19,14 @@ class CUpdateCallback100Imp: public ICompressProgressInfo, public CMyUnknownImp { + bool _passwordIsDefined; + UString _password; + UInt64 _numFiles; public: + CProgressDialog *ProgressDialog; + + CUpdateCallback100Imp(): ProgressDialog(0) {} + MY_UNKNOWN_IMP5( IFolderArchiveUpdateCallback, ICryptoGetTextPassword2, @@ -38,35 +42,13 @@ public: STDMETHOD(CryptoGetTextPassword)(BSTR *password); STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); -private: - bool _passwordIsDefined; - UString _password; - void AddErrorMessage(LPCWSTR message); - bool ShowMessages; - -public: - CUpdateCallback100Imp(): ShowMessages(true) {} - ~CUpdateCallback100Imp(); - CProgressDialog ProgressDialog; - HWND _parentWindow; - UStringVector Messages; - UInt64 NumFolders; - UInt64 NumFiles; - - void Init(HWND parentWindow, - bool passwordIsDefined, const UString &password) + void Init(bool passwordIsDefined, const UString &password) { _passwordIsDefined = passwordIsDefined; _password = password; - _parentWindow = parentWindow; - NumFolders = NumFiles = 0; - } - void StartProgressDialog(const UString &title) - { - ProgressDialog.Create(title, _parentWindow); + _numFiles = 0; } - }; #endif diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp index 0f98c217..6ec53787 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -12,7 +12,7 @@ using namespace NWindows; using namespace NRegistry; -#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") +#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") static const TCHAR *kCUBasePath = REG_PATH_FM; static const TCHAR *kCulumnsKeyName = REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) TEXT("Columns"); @@ -48,7 +48,7 @@ static const UInt32 kColumnHeaderSize = 12; static const UInt32 kColumnInfoVersion = 1; -static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection; +static NSynchronization::CCriticalSection g_CS; class CTempOutBufferSpec { @@ -126,7 +126,7 @@ void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo) buffer.WriteUInt32(column.Width); } { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; key.Create(HKEY_CURRENT_USER, kCulumnsKeyName); key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize); @@ -140,9 +140,9 @@ void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo) CByteBuffer buffer; UInt32 size; { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - if(key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) return; if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS) return; @@ -197,8 +197,8 @@ struct CPanelsInfo void SaveWindowSize(const RECT &rect, bool maximized) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, keyName); // CWindowPosition position; CTempOutBufferSpec buffer; @@ -214,9 +214,9 @@ void SaveWindowSize(const RECT &rect, bool maximized) bool ReadWindowSize(RECT &rect, bool &maximized) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) return false; CByteBuffer buffer; UInt32 size; @@ -239,8 +239,8 @@ bool ReadWindowSize(RECT &rect, bool &maximized) void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, keyName); CTempOutBufferSpec buffer; @@ -254,9 +254,9 @@ void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos) bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) return false; CByteBuffer buffer; UInt32 size; @@ -286,7 +286,7 @@ static const UInt32 kDefaultToolbarMask = 8 | 4 | 1; UInt32 ReadToolbarsMask() { CKey key; - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return kDefaultToolbarMask; UInt32 mask; if (key.QueryValue(kToolbars, mask) != ERROR_SUCCESS) @@ -305,17 +305,17 @@ static UString GetPanelPathName(UInt32 panelIndex) void SavePanelPath(UInt32 panel, const UString &path) { + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, kCUBasePath); key.SetValue(GetPanelPathName(panel), path); } bool ReadPanelPath(UInt32 panel, UString &path) { + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return false; return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS); } @@ -334,7 +334,7 @@ void ReadListMode(CListMode &listMode) { CKey key; listMode.Init(); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return; UInt32 t; if (key.QueryValue(kListMode, t) != ERROR_SUCCESS) @@ -347,53 +347,21 @@ void ReadListMode(CListMode &listMode) } -void SaveStringList(LPCTSTR valueName, const UStringVector &folders) +static void SaveStringList(LPCTSTR valueName, const UStringVector &folders) { - UInt32 sizeInChars = 0; - int i; - for (i = 0; i < folders.Size(); i++) - sizeInChars += folders[i].Length() + 1; - CBuffer buffer; - buffer.SetCapacity(sizeInChars); - int pos = 0; - for (i = 0; i < folders.Size(); i++) - { - MyStringCopy((wchar_t *)buffer + pos, (const wchar_t *)folders[i]); - pos += folders[i].Length() + 1; - } + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, kCUBasePath); - key.SetValue(valueName, buffer, sizeInChars * sizeof(wchar_t)); + key.SetValue_Strings(valueName, folders); } -void ReadStringList(LPCTSTR valueName, UStringVector &folders) +static void ReadStringList(LPCTSTR valueName, UStringVector &folders) { folders.Clear(); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) - return; - CByteBuffer buffer; - UInt32 dataSize; - if (key.QueryValue(valueName, buffer, dataSize) != ERROR_SUCCESS) - return; - if (dataSize % sizeof(wchar_t) != 0) - return; - const wchar_t *data = (const wchar_t *)(const Byte *)buffer; - int sizeInChars = dataSize / sizeof(wchar_t); - UString string; - for (int i = 0; i < sizeInChars; i++) - { - wchar_t c = data[i]; - if (c == L'\0') - { - folders.Add(string); - string.Empty(); - } - else - string += c; - } + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS) + key.GetValue_Strings(valueName, folders); } void SaveFolderHistory(const UStringVector &folders) @@ -411,14 +379,12 @@ void SaveCopyHistory(const UStringVector &folders) void ReadCopyHistory(UStringVector &folders) { ReadStringList(kCopyHistoryValueName, folders); } -void AddUniqueStringToHeadOfList(UStringVector &list, - const UString &string) +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s) { - for(int i = 0; i < list.Size();) - if (string.CompareNoCase(list[i]) == 0) + for (int i = 0; i < list.Size();) + if (s.CompareNoCase(list[i]) == 0) list.Delete(i); else i++; - list.Insert(0, string); + list.Insert(0, s); } - diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h index 2500ce7b..b0510813 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.h +++ b/CPP/7zip/UI/FileManager/ViewSettings.h @@ -1,9 +1,10 @@ // ViewSettings.h -#ifndef __VIEWSETTINGS_H -#define __VIEWSETTINGS_H +#ifndef __VIEW_SETTINGS_H +#define __VIEW_SETTINGS_H #include "Common/MyString.h" +#include "Common/Types.h" struct CColumnInfo { @@ -44,15 +45,15 @@ struct CListViewInfo return -1; } - bool IsEqual(const CListViewInfo &aNewInfo) const + bool IsEqual(const CListViewInfo &info) const { - if (Columns.Size() != aNewInfo.Columns.Size() || - // SortIndex != aNewInfo.SortIndex || - SortID != aNewInfo.SortID || - Ascending != aNewInfo.Ascending) + if (Columns.Size() != info.Columns.Size() || + // SortIndex != info.SortIndex || + SortID != info.SortID || + Ascending != info.Ascending) return false; for (int i = 0; i < Columns.Size(); i++) - if (Columns[i] != aNewInfo.Columns[i]) + if (Columns[i] != info.Columns[i]) return false; return true; } @@ -92,7 +93,6 @@ void ReadFastFolders(UStringVector &folders); void SaveCopyHistory(const UStringVector &folders); void ReadCopyHistory(UStringVector &folders); -void AddUniqueStringToHeadOfList(UStringVector &list, - const UString &string); +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s); #endif diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile index fea2d39a..d26aa04b 100755 --- a/CPP/7zip/UI/FileManager/makefile +++ b/CPP/7zip/UI/FileManager/makefile @@ -1,28 +1,33 @@ PROG = 7zFM.exe -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib shell32.lib ole32.lib comctl32.lib htmlhelp.lib Mpr.lib Gdi32.lib comdlg32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DLANG \ - -DWIN_LONG_PATH \ -DNEW_FOLDER_INTERFACE \ -DEXTERNAL_CODECS \ - -DSUPPORT_DEVICE_FILE \ + +!IFDEF UNDER_CE +LIBS = $(LIBS) ceshell.lib Commctrl.lib +!ELSE +LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE +!ENDIF FM_OBJS = \ $O\App.obj \ + $O\BrowseDialog.obj \ $O\ClassDefs.obj \ $O\EnumFormatEtc.obj \ $O\ExtractCallback.obj \ $O\FileFolderPluginOpen.obj \ $O\FilePlugins.obj \ $O\FM.obj \ + $O\FoldersPage.obj \ $O\FormatUtils.obj \ - $O\FSDrives.obj \ $O\FSFolder.obj \ $O\FSFolderCopy.obj \ $O\HelpUtils.obj \ $O\LangUtils.obj \ + $O\MenuPage.obj \ $O\MyLoadMenu.obj \ - $O\NetFolder.obj \ $O\OpenCallback.obj \ $O\OptionsDialog.obj \ $O\Panel.obj \ @@ -89,21 +94,33 @@ WIN_OBJS = \ $O\FileFind.obj \ $O\FileIO.obj \ $O\FileName.obj \ - $O\FileSystem.obj \ $O\Memory.obj \ $O\MemoryLock.obj \ $O\Menu.obj \ - $O\Net.obj \ + $O\Process.obj \ $O\PropVariant.obj \ $O\PropVariantConversions.obj \ $O\Registry.obj \ $O\ResourceString.obj \ - $O\Security.obj \ $O\Shell.obj \ $O\Synchronization.obj \ $O\Time.obj \ $O\Window.obj \ +!IFNDEF UNDER_CE + +FM_OBJS = $(FM_OBJS) \ + $O\FSDrives.obj \ + $O\NetFolder.obj \ + +WIN_OBJS = $(WIN_OBJS) \ + $O\FileSystem.obj \ + $O\Net.obj \ + $O\Security.obj \ + +!ENDIF + + WIN_CTRL_OBJS = \ $O\ComboBox.obj \ $O\Dialog.obj \ @@ -118,6 +135,9 @@ WIN_CTRL_OBJS = \ $O\StreamObjects.obj \ $O\StreamUtils.obj \ +AR_COMMON_OBJS = \ + $O\OutStreamWithCRC.obj \ + UI_COMMON_OBJS = \ $O\ArchiveExtractCallback.obj \ $O\ArchiveName.obj \ @@ -137,8 +157,9 @@ UI_COMMON_OBJS = \ $O\WorkDir.obj \ $O\ZipRegistry.obj \ -AR_COMMON_OBJS = \ - $O\OutStreamWithCRC.obj \ +EXPLORER_OBJS = \ + $O\ContextMenu.obj \ + $O\RegistryContextMenu.obj \ AGENT_OBJS = \ $O\Agent.obj \ @@ -164,8 +185,9 @@ OBJS = \ $(WIN_OBJS) \ $(WIN_CTRL_OBJS) \ $(7ZIP_COMMON_OBJS) \ - $(UI_COMMON_OBJS) \ $(AR_COMMON_OBJS) \ + $(UI_COMMON_OBJS) \ + $(EXPLORER_OBJS) \ $(AGENT_OBJS) \ $O\CopyCoder.obj \ $(CRC_OBJS) \ @@ -184,12 +206,14 @@ $(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp $(COMPL) $(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp $(COMPL) -$(UI_COMMON_OBJS): ../Common/$(*B).cpp - $(COMPL) $(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp $(COMPL) +$(UI_COMMON_OBJS): ../Common/$(*B).cpp + $(COMPL) $(AGENT_OBJS): ../Agent/$(*B).cpp $(COMPL) +$(EXPLORER_OBJS): ../Explorer/$(*B).cpp + $(COMPL) $O\CopyCoder.obj: ../../Compress/$(*B).cpp $(COMPL) diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h index 72121c89..13c8e0e7 100755 --- a/CPP/7zip/UI/FileManager/resource.h +++ b/CPP/7zip/UI/FileManager/resource.h @@ -1,5 +1,5 @@ -#define IDI_FAM 101 -#define IDI_FM 101 +#include "resourceGui.h" + #define IDR_MENUBAR1 103 #define IDM_MENU 103 #define IDR_ACCELERATOR1 209 @@ -109,9 +109,6 @@ #define IDS_SELECT_MASK 2252 #define IDS_FOLDERS_HISTORY 2260 #define IDS_N_SELECTED_ITEMS 2270 -#define IDS_FILES_COLON 2274 -#define IDS_FOLDERS_COLON 2275 -#define IDS_SIZE_COLON 2276 #define IDS_TOO_MANY_ITEMS 2279 #define IDS_WANT_UPDATE_MODIFIED_FILE 2280 @@ -160,9 +157,6 @@ #define IDS_SCANNING 4050 #define IDS_PROPERTIES 4060 -#define IDS_PROGRESS_TESTING 4100 -#define IDS_MESSAGE_NO_ERRORS 4200 - #define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301 #define IDS_SELECT_ONE_FILE 4302 #define IDS_SELECT_FILES 4303 diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc index cdfed0b6..833cb374 100755 --- a/CPP/7zip/UI/FileManager/resource.rc +++ b/CPP/7zip/UI/FileManager/resource.rc @@ -32,7 +32,7 @@ BEGIN MENUITEM "Com&bine files...", IDM_FILE_COMBINE MENUITEM SEPARATOR MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES - MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT + MENUITEM "Comme&nt...\tCtrl+Z", IDM_FILE_COMMENT MENUITEM "Calculate checksum", IDM_FILE_CRC MENUITEM "Di&ff", IDM_FILE_DIFF MENUITEM SEPARATOR @@ -78,11 +78,9 @@ BEGIN MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT END - MENUITEM SEPARATOR MENUITEM "Open Root Folder\t\\", IDM_OPEN_ROOT_FOLDER MENUITEM "Up One Level\tBackspace", IDM_OPEN_PARENT_FOLDER MENUITEM "Folders History...\tAlt+F12", IDM_FOLDERS_HISTORY - MENUITEM SEPARATOR MENUITEM "&Refresh\tCtrl+R", IDM_VIEW_REFRESH END POPUP "F&avorites" @@ -97,34 +95,38 @@ BEGIN BEGIN MENUITEM "&Options...", IDM_OPTIONS MENUITEM "&Benchmark", IDM_BENCHMARK + #ifndef UNDER_CE END POPUP "&Help" BEGIN MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS + #endif MENUITEM SEPARATOR - MENUITEM "&About 7-Zip...", IDM_ABOUT + MENUITEM "&About 7-Zip...", IDM_ABOUT END END -IDI_FM ICON "FM.ico" +IDI_ICON ICON "../../UI/FileManager/FM.ico" -1 24 MOVEABLE PURE "7zFM.exe.manifest" +#ifndef UNDER_CE +1 24 MOVEABLE PURE "../../UI/FileManager/7zFM.exe.manifest" +#endif -IDB_ADD BITMAP "Add.bmp" -IDB_EXTRACT BITMAP "Extract.bmp" -IDB_TEST BITMAP "Test.bmp" -IDB_COPY BITMAP "Copy.bmp" -IDB_MOVE BITMAP "Move.bmp" -IDB_DELETE BITMAP "Delete.bmp" -IDB_INFO BITMAP "Info.bmp" -IDB_ADD2 BITMAP "Add2.bmp" -IDB_EXTRACT2 BITMAP "Extract2.bmp" -IDB_TEST2 BITMAP "Test2.bmp" -IDB_COPY2 BITMAP "Copy2.bmp" -IDB_MOVE2 BITMAP "Move2.bmp" -IDB_DELETE2 BITMAP "Delete2.bmp" -IDB_INFO2 BITMAP "Info2.bmp" +IDB_ADD BITMAP "../../UI/FileManager/Add.bmp" +IDB_EXTRACT BITMAP "../../UI/FileManager/Extract.bmp" +IDB_TEST BITMAP "../../UI/FileManager/Test.bmp" +IDB_COPY BITMAP "../../UI/FileManager/Copy.bmp" +IDB_MOVE BITMAP "../../UI/FileManager/Move.bmp" +IDB_DELETE BITMAP "../../UI/FileManager/Delete.bmp" +IDB_INFO BITMAP "../../UI/FileManager/Info.bmp" +IDB_ADD2 BITMAP "../../UI/FileManager/Add2.bmp" +IDB_EXTRACT2 BITMAP "../../UI/FileManager/Extract2.bmp" +IDB_TEST2 BITMAP "../../UI/FileManager/Test2.bmp" +IDB_COPY2 BITMAP "../../UI/FileManager/Copy2.bmp" +IDB_MOVE2 BITMAP "../../UI/FileManager/Move2.bmp" +IDB_DELETE2 BITMAP "../../UI/FileManager/Delete2.bmp" +IDB_INFO2 BITMAP "../../UI/FileManager/Info2.bmp" STRINGTABLE @@ -187,9 +189,6 @@ BEGIN IDS_SELECT_MASK "Mask:" IDS_FOLDERS_HISTORY "Folders History" IDS_N_SELECTED_ITEMS "{0} object(s) selected" - IDS_FILES_COLON "Files:" - IDS_FOLDERS_COLON "Folders:" - IDS_SIZE_COLON "Size:" IDS_PROP_TOTAL_SIZE "Total Size" IDS_PROP_FREE_SPACE "Free Space" @@ -219,8 +218,6 @@ BEGIN IDS_NETWORK "Network" IDS_DOCUMENTS "Documents" - IDS_PROGRESS_TESTING "Testing" - IDS_MESSAGE_NO_ERRORS "There are no errors" IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." IDS_SELECT_ONE_FILE "You must select one file" IDS_SELECT_FILES "You must select one or more files" @@ -228,20 +225,24 @@ BEGIN END +#include "AboutDialog.rc" +#include "BrowseDialog.rc" #include "ComboDialog.rc" #include "CopyDialog.rc" +#include "EditPage.rc" +#include "FoldersPage.rc" +#include "LangPage.rc" #include "ListViewDialog.rc" -#include "PropertyName.rc" +#include "MenuPage.rc" #include "MessagesDialog.rc" #include "OverwriteDialog.rc" #include "PasswordDialog.rc" -#include "SplitDialog.rc" -#include "ProgressDialog2.rc" -#include "AboutDialog.rc" -#include "LangPage.rc" #include "PluginsPage.rc" -#include "SystemPage.rc" -#include "EditPage.rc" +#include "ProgressDialog2.rc" +#include "PropertyName.rc" #include "SettingsPage.rc" -#include "../GUI/ExtractDialog.rc" +#include "SplitDialog.rc" +#include "SystemPage.rc" #include "../GUI/Extract.rc" +#include "../Explorer/resource2.rc" +#include "resourceGui.rc" diff --git a/CPP/7zip/UI/FileManager/resourceGui.h b/CPP/7zip/UI/FileManager/resourceGui.h new file mode 100755 index 00000000..14cedda5 --- /dev/null +++ b/CPP/7zip/UI/FileManager/resourceGui.h @@ -0,0 +1,10 @@ +#define IDI_ICON 1 + +#define IDS_INCORRECT_VOLUME_SIZE 95 + +#define IDS_FILES_COLON 2274 +#define IDS_FOLDERS_COLON 2275 +#define IDS_SIZE_COLON 2276 + +#define IDS_PROGRESS_TESTING 4100 +#define IDS_MESSAGE_NO_ERRORS 4200 diff --git a/CPP/7zip/UI/FileManager/resourceGui.rc b/CPP/7zip/UI/FileManager/resourceGui.rc new file mode 100755 index 00000000..2e706ea2 --- /dev/null +++ b/CPP/7zip/UI/FileManager/resourceGui.rc @@ -0,0 +1,13 @@ +#include "resourceGui.h" + +STRINGTABLE +BEGIN + IDS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + + IDS_FILES_COLON "Files:" + IDS_FOLDERS_COLON "Folders:" + IDS_SIZE_COLON "Size:" + + IDS_PROGRESS_TESTING "Testing" + IDS_MESSAGE_NO_ERRORS "There are no errors" +END -- cgit v1.2.3