mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
open subfolders in cabinet windows
svn path=/trunk/; revision=6188
This commit is contained in:
parent
a7de09c7ea
commit
febcdf59e3
10 changed files with 68 additions and 49 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<ShellDirectory*>(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<ShellDirectory*>(entry)))
|
||||
return S_OK;
|
||||
} else { // no tree control
|
||||
if (MainFrame::OpenShellFolders(pIDList))
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ protected:
|
|||
|
||||
WindowHandle _hWndFrame;
|
||||
ShellChildWndInfo _create_info;
|
||||
ShellFolder _folder;
|
||||
|
||||
IShellView* _pShellView; // current hosted shellview
|
||||
HIMAGELIST _himlSmall; // list
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue