open subfolders in cabinet windows
authorMartin Fuchs <fuchs.martin@gmail.com>
Sun, 28 Sep 2003 20:59:30 +0000 (20:59 +0000)
committerMartin Fuchs <fuchs.martin@gmail.com>
Sun, 28 Sep 2003 20:59:30 +0000 (20:59 +0000)
svn path=/trunk/; revision=6188

reactos/subsys/system/explorer/desktop/desktop.cpp
reactos/subsys/system/explorer/shell/mainframe.cpp
reactos/subsys/system/explorer/shell/mainframe.h
reactos/subsys/system/explorer/shell/shellbrowser.cpp
reactos/subsys/system/explorer/shell/shellbrowser.h
reactos/subsys/system/explorer/shell/shellfs.cpp
reactos/subsys/system/explorer/shell/shellfs.h
reactos/subsys/system/explorer/taskbar/startmenu.cpp
reactos/subsys/system/explorer/utility/shellclasses.cpp
reactos/subsys/system/explorer/utility/shellclasses.h

index d5ad92a..54c1e0c 100644 (file)
@@ -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;
-
-       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;
-       }
+       if (MainFrame::OpenShellFolders(pIDList))
+               return S_OK;
 
-       return ret;
+       return E_NOTIMPL;
 }
index 8bedeb8..233daac 100644 (file)
@@ -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) {
index 8f91a40..932bc66 100644 (file)
@@ -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);
index b83fee3..abba514 100644 (file)
@@ -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 (parent) {
-                       try {
-                               parent->smart_scan();
-                       } catch(COMException& e) {
-                               return e.Error();
-                       }
-
-                       //UINT folderOffset = pIDList->aoffset[0];
-                       //LPITEMIDLIST pidlFolder = (LPITEMIDLIST)((LPBYTE)pIDList+folderOffset);
+       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();
+                                       }
 
-                       UINT firstOffset = pIDList->aoffset[1];
-                       LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pIDList+firstOffset);
+                                       UINT firstOffset = pIDList->aoffset[1];
+                                       LPITEMIDLIST pidl = (LPITEMIDLIST)((LPBYTE)pIDList+firstOffset);
 
-                       Entry* entry = parent->find_entry(pidl);
+                                       Entry* entry = parent->find_entry(pidl);
 
-                       if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
-                               if (expand_folder(static_cast<ShellDirectory*>(entry)))
-                                       return S_OK;
+                                       if (entry && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
+                                               if (expand_folder(static_cast<ShellDirectory*>(entry)))
+                                                       return S_OK;
+                               }
+                       }
+               } else { // no tree control
+                       if (MainFrame::OpenShellFolders(pIDList))
+                               return S_OK;
                }
        }
 
index e379e58..2be3f0f 100644 (file)
@@ -105,6 +105,7 @@ protected:
 
        WindowHandle _hWndFrame;
        ShellChildWndInfo _create_info;
+       ShellFolder     _folder;
 
        IShellView*     _pShellView;    // current hosted shellview
        HIMAGELIST      _himlSmall;             // list
index fda2fd2..13c89ab 100644 (file)
@@ -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<ShellDirectory*>(_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;
index 9a5d493..2f2e466 100644 (file)
@@ -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
 
index 722afc4..5eb4873 100644 (file)
@@ -454,7 +454,7 @@ void StartMenu::ActivateEntry(int id, const ShellEntrySet& entries)
                ShellEntry* entry = const_cast<ShellEntry*>(*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);
index 8fb5ec8..372e8aa 100644 (file)
@@ -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<LPITEMIDLIST(WINAPI*)(LPCITEMIDLIST, LPCITEMIDLIST)> ILCombine(_T("SHELL32"), 25);
 
index 2514612..b543e7c 100644 (file)
@@ -605,7 +605,7 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
        }
 
         // 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;
 };