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;
}
}
+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) {
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);
}
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;
FOLDERSETTINGS fs;
IShellView* pLastShellView = _pShellView;
+ _folder = folder;
+
if (pLastShellView)
pLastShellView->GetCurrentInfo(&fs);
else {
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;
}
}
WindowHandle _hWndFrame;
ShellChildWndInfo _create_info;
+ ShellFolder _folder;
IShellView* _pShellView; // current hosted shellview
HIMAGELIST _himlSmall; // list
}
-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;
BOOL ShellEntry::launch_entry(HWND hwnd, UINT nCmdShow)
{
- BOOL ret = TRUE;
-
- ShellPath shell_path = create_absolute_pidl(hwnd);
-
SHELLEXECUTEINFO shexinfo;
shexinfo.cbSize = sizeof(SHELLEXECUTEINFO);
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;
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
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);
#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);
#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);
}
// 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;
};