From be7a6c466b7d0deede58ca6cb390e312946f349f Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Fri, 18 Jun 2004 16:36:00 +0000 Subject: [PATCH] re-enable DesktopWindow::OnDefaultCommand to open explorer windows on desktop double clicks svn path=/trunk/; revision=9706 --- .../system/explorer/desktop/desktop.cpp | 4 +- .../system/explorer/shell/mainframe.cpp | 131 ++++++++++-------- .../subsys/system/explorer/shell/mainframe.h | 3 +- .../system/explorer/shell/shellbrowser.cpp | 2 +- .../system/explorer/utility/xmlstorage.h | 2 +- 5 files changed, 83 insertions(+), 59 deletions(-) diff --git a/reactos/subsys/system/explorer/desktop/desktop.cpp b/reactos/subsys/system/explorer/desktop/desktop.cpp index 0a11cfd30cc..094d8c33e38 100644 --- a/reactos/subsys/system/explorer/desktop/desktop.cpp +++ b/reactos/subsys/system/explorer/desktop/desktop.cpp @@ -481,9 +481,9 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) HRESULT DesktopWindow::OnDefaultCommand(LPIDA pida) { -/*@@ if (SDIMainFrame::OpenShellFolders(pida, 0)) + if (MainFrameBase::OpenShellFolders(pida, 0)) return S_OK; -*/ + return E_NOTIMPL; } diff --git a/reactos/subsys/system/explorer/shell/mainframe.cpp b/reactos/subsys/system/explorer/shell/mainframe.cpp index a4c245f161a..88a13817dc0 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.cpp +++ b/reactos/subsys/system/explorer/shell/mainframe.cpp @@ -86,6 +86,67 @@ HWND MainFrameBase::Create(LPCTSTR path, bool mdi, UINT cmdshow) } +int MainFrameBase::OpenShellFolders(LPIDA pida, HWND hFrameWnd, bool mdi) +{ + int cnt = 0; + + LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); + ShellFolder folder(parent_pidl); + + for(int i=pida->cidl; i>0; --i) { + LPCITEMIDLIST pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]); + + SFGAOF attribs = SFGAO_FOLDER; + HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs); + + if (SUCCEEDED(hr)) + if (attribs & SFGAO_FOLDER) { + try { + ShellPath pidl_abs = ShellPath(pidl).create_absolute_pidl(parent_pidl); + + if (hFrameWnd) { + if (SendMessage(hFrameWnd, PM_OPEN_WINDOW, OWM_PIDL, (LPARAM)(LPCITEMIDLIST)pidl_abs)) + ++cnt; + } else { + HWND hwnd; +#ifndef _NO_MDI + if (mdi) + hwnd = MDIMainFrame::Create(pidl_abs, 0); + else +#endif + hwnd = SDIMainFrame::Create(pidl_abs, 0); + + if (hwnd) + ++cnt; + } + } catch(COMException& e) { + HandleException(e, g_Globals._hMainWnd); + } + }/*TEST + else { // !(attribs & SFGAO_FOLDER)) + SHELLEXECUTEINFOA shexinfo; + + shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA); + shexinfo.fMask = SEE_MASK_INVOKEIDLIST; + shexinfo.hwnd = NULL; + shexinfo.lpVerb = NULL; + shexinfo.lpFile = NULL; + shexinfo.lpParameters = NULL; + shexinfo.lpDirectory = NULL; + shexinfo.nShow = SW_NORMAL; + shexinfo.lpIDList = ILCombine(parent_pidl, pidl); + + if (ShellExecuteExA(&shexinfo)) + ++cnt; + + ILFree((LPITEMIDLIST)shexinfo.lpIDList); + }*/ + } + + return cnt; +} + + MainFrameBase::MainFrameBase(HWND hwnd) : super(hwnd), _himl(ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK|ILC_COLOR24, 2, 0)) @@ -815,60 +876,6 @@ ChildWindow* MDIMainFrame::CreateChild(LPCITEMIDLIST pidl, int mode) } -int MDIMainFrame::OpenShellFolders(LPIDA pida, HWND hFrameWnd) -{ - int cnt = 0; - - LPCITEMIDLIST parent_pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]); - ShellFolder folder(parent_pidl); - - for(int i=pida->cidl; i>0; --i) { - LPCITEMIDLIST pidl = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[i]); - - SFGAOF attribs = SFGAO_FOLDER; - HRESULT hr = folder->GetAttributesOf(1, &pidl, &attribs); - - if (SUCCEEDED(hr)) - if (attribs & SFGAO_FOLDER) { - try { - ShellPath pidl_abs = ShellPath(pidl).create_absolute_pidl(parent_pidl); - - if (hFrameWnd) { - if (SendMessage(hFrameWnd, PM_OPEN_WINDOW, OWM_PIDL, (LPARAM)(LPCITEMIDLIST)pidl_abs)) - ++cnt; - } else { - if (MDIMainFrame::Create(pidl_abs, 0)) - ++cnt; - } - } catch(COMException& e) { - HandleException(e, g_Globals._hMainWnd); - } - }/*TEST - else { // !(attribs & SFGAO_FOLDER)) - SHELLEXECUTEINFOA shexinfo; - - shexinfo.cbSize = sizeof(SHELLEXECUTEINFOA); - shexinfo.fMask = SEE_MASK_INVOKEIDLIST; - shexinfo.hwnd = NULL; - shexinfo.lpVerb = NULL; - shexinfo.lpFile = NULL; - shexinfo.lpParameters = NULL; - shexinfo.lpDirectory = NULL; - shexinfo.nShow = SW_NORMAL; - shexinfo.lpIDList = ILCombine(parent_pidl, pidl); - - if (ShellExecuteExA(&shexinfo)) - ++cnt; - - ILFree((LPITEMIDLIST)shexinfo.lpIDList); - }*/ - } - - return cnt; -} - - - BOOL MDIMainFrame::TranslateMsg(MSG* pmsg) { if (_hmdiclient && TranslateMDISysAccel(_hmdiclient, pmsg)) @@ -1284,6 +1291,22 @@ HWND SDIMainFrame::Create() 0/*hwndDesktop*/, hMenuFrame); } +HWND SDIMainFrame::Create(LPCITEMIDLIST pidl, int mode) +{ + HWND hFrame = Create(); + if (!hFrame) + return 0; + + ShowWindow(hFrame, SW_SHOW); + + SDIMainFrame* pFrame = GET_WINDOW(SDIMainFrame, hFrame); + + if (pFrame) + pFrame->jump_to(pidl, mode); + + return hFrame; +} + LRESULT SDIMainFrame::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 4c96cc916e9..0b06023066b 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.h +++ b/reactos/subsys/system/explorer/shell/mainframe.h @@ -39,6 +39,7 @@ struct MainFrameBase : public PreTranslateWindow ~MainFrameBase(); static HWND Create(LPCTSTR path, bool mdi=true, UINT cmdshow=SW_SHOWNORMAL); + static int OpenShellFolders(LPIDA pida, HWND hFrameWnd, bool mdi=true); WindowHandle _hwndrebar; @@ -93,7 +94,6 @@ struct MDIMainFrame : public MainFrameBase 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 pida, HWND hFrameWnd); ChildWindow* CreateChild(LPCTSTR path=NULL, int mode=OWM_EXPLORE|OWM_DETAILS); ChildWindow* CreateChild(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL); @@ -131,6 +131,7 @@ struct SDIMainFrame : public ShellBrowserChildT SDIMainFrame(HWND hwnd); static HWND Create(); + static HWND Create(LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL); protected: ShellPathInfo _shellpath_info; diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index c674a8c681b..adaf4ede54e 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -421,7 +421,7 @@ HRESULT ShellBrowser::OnDefaultCommand(LPIDA pida) } } } else { // no tree control - if (MDIMainFrame::OpenShellFolders(pida, _hWndFrame)) + if (MainFrameBase::OpenShellFolders(pida, _hWndFrame)) return S_OK; /* create new Frame Window diff --git a/reactos/subsys/system/explorer/utility/xmlstorage.h b/reactos/subsys/system/explorer/utility/xmlstorage.h index 5fed7e82fc6..1ec305c2ef3 100644 --- a/reactos/subsys/system/explorer/utility/xmlstorage.h +++ b/reactos/subsys/system/explorer/utility/xmlstorage.h @@ -1395,7 +1395,7 @@ struct XMLDoc : public XMLNode return status != XML_STATUS_ERROR; } - bool read(XMLReaderBase& reader, const string& display_path) + bool read(XMLReaderBase& reader, const std::string& display_path) { XML_Status status = reader.read();