diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index d5ad92a7d20..54c1e0c7093 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -267,23 +267,8 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) HRESULT DesktopWindow::OnDefaultCommand(LPIDA pIDList) { - HRESULT ret = E_NOTIMPL; - int cnt = pIDList->cidl; + if (MainFrame::OpenShellFolders(pIDList)) + return S_OK; - for(int i=0; ++i<=cnt; ) { - /* We know, the parent folder is the desktop, so we do not need to look at pIDList->aoffset[0] - UINT folderOffset = pIDList->aoffset[0]; - LPITEMIDLIST pidlFolder = (LPITEMIDLIST)((LPBYTE)pIDList+folderOffset); - */ - LPCITEMIDLIST pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]); - - SFGAOF attribs = SFGAO_FOLDER; - HRESULT hr = Desktop()->GetAttributesOf(1, &pidl, &attribs); - - if (SUCCEEDED(hr) && (attribs&SFGAO_FOLDER)) - if (MainFrame::Create(pidl, FALSE)) - ret = S_OK; - } - - return ret; + return E_NOTIMPL; } diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index 8bedeb831b8..233daac366e 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -211,6 +211,32 @@ ChildWindow* MainFrame::CreateChild(LPCITEMIDLIST pidl, int mode) } +int MainFrame::OpenShellFolders(LPIDA pIDList) +{ + int cnt = 0; + + LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pIDList+pIDList->aoffset[0]); + ShellFolder folder(parent_pidl); + + for(int i=pIDList->cidl; i>0; --i) { + LPCITEMIDLIST pidl = (LPCITEMIDLIST)((LPBYTE)pIDList+pIDList->aoffset[i]); + + SFGAOF attribs = SFGAO_FOLDER; + HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs); + + if (SUCCEEDED(hr) && (attribs&SFGAO_FOLDER)) + try { + if (MainFrame::Create(ShellPath(pidl).create_absolute_pidl(parent_pidl), FALSE)) + ++cnt; + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } + } + + return cnt; +} + + LRESULT MainFrame::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) { switch(nmsg) { diff --git a/reactos/subsys/system/explorer/shell/mainframe.h b/reactos/subsys/system/explorer/shell/mainframe.h index 8f91a4073f6..932bc66755b 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.h +++ b/reactos/subsys/system/explorer/shell/mainframe.h @@ -40,6 +40,7 @@ struct MainFrame : public PreTranslateWindow static HWND Create(); static HWND Create(LPCTSTR path, int mode=OWM_EXPLORE|OWM_DETAILS); static HWND Create(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL); + static int OpenShellFolders(LPIDA pIDList); ChildWindow* CreateChild(LPCTSTR path=NULL, int mode=OWM_EXPLORE|OWM_DETAILS); ChildWindow* CreateChild(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL); diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index b83fee369bc..abba514b6a1 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -283,7 +283,7 @@ void ShellBrowserChild::OnTreeGetDispInfo(int idCtrl, LPNMHDR pnmh) } if (lpdi->item.mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE)) { - ShellPath pidl_abs = entry->create_absolute_pidl(_hwnd); // Caching of absolute PIDLs could enhance performance. + ShellPath pidl_abs = entry->create_absolute_pidl(); // Caching of absolute PIDLs could enhance performance. LPCITEMIDLIST pidl = pidl_abs; SHFILEINFO sfi; @@ -385,6 +385,8 @@ void ShellBrowserChild::UpdateFolderView(IShellFolder* folder) FOLDERSETTINGS fs; IShellView* pLastShellView = _pShellView; + _folder = folder; + if (pLastShellView) pLastShellView->GetCurrentInfo(&fs); else { @@ -445,27 +447,31 @@ int ShellBrowserChild::Notify(int id, NMHDR* pnmh) HRESULT ShellBrowserChild::OnDefaultCommand(LPIDA pIDList) { - if (pIDList->cidl>=1 && _last_sel) { - ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel); + if (pIDList->cidl>=1) { + if (_left_hwnd) { // explorer mode + if (_last_sel) { + ShellDirectory* parent = (ShellDirectory*)TreeView_GetItemData(_left_hwnd, _last_sel); - if (parent) { - try { - parent->smart_scan(); - } catch(COMException& e) { - return e.Error(); + if (parent) { + try { + parent->smart_scan(); + } catch(COMException& e) { + return e.Error(); + } + + UINT firstOffset = pIDList->aoffset[1]; + LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pIDList+firstOffset); + + Entry* entry = parent->find_entry(pidl); + + if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) + if (expand_folder(static_cast(entry))) + return S_OK; + } } - - //UINT folderOffset = pIDList->aoffset[0]; - //LPITEMIDLIST pidlFolder = (LPITEMIDLIST)((LPBYTE)pIDList+folderOffset); - - UINT firstOffset = pIDList->aoffset[1]; - LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pIDList+firstOffset); - - Entry* entry = parent->find_entry(pidl); - - if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) - if (expand_folder(static_cast(entry))) - return S_OK; + } else { // no tree control + if (MainFrame::OpenShellFolders(pIDList)) + return S_OK; } } diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.h b/reactos/subsys/system/explorer/shell/shellbrowser.h index e379e58fef8..2be3f0f862d 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.h +++ b/reactos/subsys/system/explorer/shell/shellbrowser.h @@ -105,6 +105,7 @@ protected: WindowHandle _hWndFrame; ShellChildWndInfo _create_info; + ShellFolder _folder; IShellView* _pShellView; // current hosted shellview HIMAGELIST _himlSmall; // list diff --git a/reactos/subsys/system/explorer/shell/shellfs.cpp b/reactos/subsys/system/explorer/shell/shellfs.cpp index fda2fd26951..13c89ab7533 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.cpp +++ b/reactos/subsys/system/explorer/shell/shellfs.cpp @@ -102,13 +102,13 @@ bool ShellDirectory::fill_w32fdata_shell(LPCITEMIDLIST pidl, SFGAOF attribs, WIN } -ShellPath ShellEntry::create_absolute_pidl(HWND hwnd) +ShellPath ShellEntry::create_absolute_pidl() { if (_up/* && _up->_etype==ET_SHELL*/) { ShellDirectory* dir = static_cast(_up); if (dir->_pidl->mkid.cb) // Caching of absolute PIDLs could enhance performance. - return _pidl.create_absolute_pidl(dir->create_absolute_pidl(hwnd), hwnd); + return _pidl.create_absolute_pidl(dir->create_absolute_pidl()); } return _pidl; @@ -142,10 +142,6 @@ void ShellDirectory::get_path(PTSTR path) const BOOL ShellEntry::launch_entry(HWND hwnd, UINT nCmdShow) { - BOOL ret = TRUE; - - ShellPath shell_path = create_absolute_pidl(hwnd); - SHELLEXECUTEINFO shexinfo; shexinfo.cbSize = sizeof(SHELLEXECUTEINFO); @@ -156,8 +152,12 @@ BOOL ShellEntry::launch_entry(HWND hwnd, UINT nCmdShow) shexinfo.lpParameters = NULL; shexinfo.lpDirectory = NULL; shexinfo.nShow = nCmdShow; + + ShellPath shell_path = create_absolute_pidl(); shexinfo.lpIDList = &*shell_path; + BOOL ret = TRUE; + if (!ShellExecuteEx(&shexinfo)) { display_error(hwnd, GetLastError()); ret = FALSE; diff --git a/reactos/subsys/system/explorer/shell/shellfs.h b/reactos/subsys/system/explorer/shell/shellfs.h index 9a5d4939dd6..2f2e466a4c2 100644 --- a/reactos/subsys/system/explorer/shell/shellfs.h +++ b/reactos/subsys/system/explorer/shell/shellfs.h @@ -35,7 +35,7 @@ struct ShellEntry : public Entry virtual BOOL launch_entry(HWND hwnd, UINT nCmdShow=SW_SHOWNORMAL); IShellFolder* get_parent_folder() const; - ShellPath create_absolute_pidl(HWND hwnd); + ShellPath create_absolute_pidl(); ShellPath _pidl; // parent relative PIDL diff --git a/reactos/subsys/system/explorer/taskbar/startmenu.cpp b/reactos/subsys/system/explorer/taskbar/startmenu.cpp index 722afc489b7..5eb487344a5 100644 --- a/reactos/subsys/system/explorer/taskbar/startmenu.cpp +++ b/reactos/subsys/system/explorer/taskbar/startmenu.cpp @@ -454,7 +454,7 @@ void StartMenu::ActivateEntry(int id, const ShellEntrySet& entries) ShellEntry* entry = const_cast(*it); if (entry->_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - new_folders.push_back(entry->create_absolute_pidl(_hwnd)); + new_folders.push_back(entry->create_absolute_pidl()); else { // If the entry is no subdirectory, there can only be one shell entry. assert(entries.size()==1); diff --git a/reactos/subsys/system/explorer/utility/shellclasses.cpp b/reactos/subsys/system/explorer/utility/shellclasses.cpp index 8fb5ec87367..372e8aa5c0d 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.cpp +++ b/reactos/subsys/system/explorer/utility/shellclasses.cpp @@ -315,7 +315,7 @@ void ShellPath::GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd, ShellFolde #ifndef __MINGW32__ // ILCombine() is currently missing in MinGW. // convert an item id list from relative to absolute (=relative to the desktop) format -ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const +ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const { return ILCombine(parent_pidl, _p); @@ -335,7 +335,7 @@ ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) #else -ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const +ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const { static DynamicFct ILCombine(_T("SHELL32"), 25); diff --git a/reactos/subsys/system/explorer/utility/shellclasses.h b/reactos/subsys/system/explorer/utility/shellclasses.h index 25146121470..b543e7cd262 100644 --- a/reactos/subsys/system/explorer/utility/shellclasses.h +++ b/reactos/subsys/system/explorer/utility/shellclasses.h @@ -605,7 +605,7 @@ struct ShellPath : public SShellPtr } // convert an item id list from relative to absolute (=relative to the desktop) format - ShellPath create_absolute_pidl(LPCITEMIDLIST parent_pidl, HWND hwnd) const; + ShellPath create_absolute_pidl(LPCITEMIDLIST parent_pidl) const; };