mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 17:14:32 +00:00
[BROWSEUI][SDK] Implement IAddressEditBox::SetCurrentDir (#7814)
JIRA issue: CORE-19704 - Rename and retype pidlLastParsed as CComHeapPtr <ITEMIDLIST_ABSOLUTE> m_pidlLastParsed. - Implement CAddressEditBox::SetCurrentDir method. - Simplify CAddressEditBox::ParseNow method. - Modify IAddressEditBox interface.
This commit is contained in:
parent
776c660542
commit
367e4877f1
3 changed files with 45 additions and 83 deletions
|
@ -1,28 +1,11 @@
|
|||
/*
|
||||
* ReactOS Explorer
|
||||
*
|
||||
* Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||
* Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* PROJECT: ReactOS Explorer
|
||||
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||
* PURPOSE: The combo box of the address band
|
||||
* COPYRIGHT: Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||
* Copyright 2023-2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
This class handles the combo box of the address band.
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
/*
|
||||
|
@ -34,15 +17,12 @@ TODO:
|
|||
CAddressEditBox::CAddressEditBox() :
|
||||
fCombobox(WC_COMBOBOXEXW, this),
|
||||
fEditWindow(WC_EDITW, this),
|
||||
fSite(NULL),
|
||||
pidlLastParsed(NULL)
|
||||
fSite(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CAddressEditBox::~CAddressEditBox()
|
||||
{
|
||||
if (pidlLastParsed)
|
||||
ILFree(pidlLastParsed);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *pOwner)
|
||||
|
@ -90,9 +70,11 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Init(HWND comboboxEx, HWND editContro
|
|||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::SetCurrentDir(long paramC)
|
||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::SetCurrentDir(PCWSTR pszPath)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
m_pidlLastParsed.Free();
|
||||
m_pidlLastParsed.Attach(ILCreateFromPathW(pszPath));
|
||||
return m_pidlLastParsed ? S_OK : E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
BOOL CAddressEditBox::GetComboBoxText(CComHeapPtr<WCHAR>& pszText)
|
||||
|
@ -196,19 +178,20 @@ BOOL CAddressEditBox::ExecuteCommandLine()
|
|||
|
||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
||||
{
|
||||
ULONG eaten;
|
||||
ULONG attributes;
|
||||
HRESULT hr;
|
||||
HWND topLevelWindow;
|
||||
PIDLIST_ABSOLUTE pidlCurrent= NULL;
|
||||
PIDLIST_RELATIVE pidlRelative = NULL;
|
||||
ULONG eaten, attributes;
|
||||
CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlCurrent;
|
||||
CComHeapPtr<ITEMIDLIST_RELATIVE> pidlRelative;
|
||||
CComPtr<IShellFolder> psfCurrent;
|
||||
HRESULT hr;
|
||||
|
||||
ATLASSERT(!m_pidlLastParsed);
|
||||
|
||||
CComPtr<IBrowserService> pbs;
|
||||
hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &pbs));
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
|
||||
HWND topLevelWindow;
|
||||
hr = IUnknown_GetWindow(pbs, &topLevelWindow);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
|
@ -231,7 +214,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
|||
CComPtr<IShellFolder> psfDesktop;
|
||||
hr = SHGetDesktopFolder(&psfDesktop);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
goto cleanup;
|
||||
return hr;
|
||||
|
||||
hr = pbs->GetPidl(&pidlCurrent);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
|
@ -244,18 +227,13 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
|||
hr = psfCurrent->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlRelative, &attributes);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
pidlLastParsed = ILCombine(pidlCurrent, pidlRelative);
|
||||
ILFree(pidlRelative);
|
||||
goto cleanup;
|
||||
m_pidlLastParsed.Attach(ILCombine(pidlCurrent, pidlRelative));
|
||||
return hr;
|
||||
}
|
||||
|
||||
parseabsolute:
|
||||
/* We couldn't parse a relative path, attempt to parse an absolute path */
|
||||
hr = psfDesktop->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlLastParsed, &attributes);
|
||||
|
||||
cleanup:
|
||||
if (pidlCurrent)
|
||||
ILFree(pidlCurrent);
|
||||
hr = psfDesktop->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &m_pidlLastParsed, &attributes);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -277,7 +255,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
|||
/*
|
||||
* Parse the path if it wasn't parsed
|
||||
*/
|
||||
if (!pidlLastParsed)
|
||||
if (!m_pidlLastParsed)
|
||||
{
|
||||
hr = ParseNow(0);
|
||||
|
||||
|
@ -290,7 +268,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
|||
return ShowFileNotFoundError(hr);
|
||||
}
|
||||
|
||||
if (!pidlLastParsed)
|
||||
if (!m_pidlLastParsed)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
@ -315,24 +293,20 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
|||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
hr = psf->CompareIDs(0, pidl, pidlLastParsed);
|
||||
hr = psf->CompareIDs(0, pidl, m_pidlLastParsed);
|
||||
|
||||
SHFree(pidl);
|
||||
|
||||
if (hr == 0)
|
||||
if (hr == S_OK)
|
||||
{
|
||||
if (pidlLastParsed)
|
||||
{
|
||||
ILFree(pidlLastParsed);
|
||||
pidlLastParsed = NULL;
|
||||
}
|
||||
m_pidlLastParsed.Free();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attempt to browse to the parsed pidl
|
||||
*/
|
||||
hr = pisb->BrowseObject(pidlLastParsed, 0);
|
||||
hr = pisb->BrowseObject(m_pidlLastParsed, 0);
|
||||
if (SUCCEEDED(hr))
|
||||
return hr;
|
||||
|
||||
|
@ -346,7 +320,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
|||
|
||||
LPCITEMIDLIST pidlChild;
|
||||
CComPtr<IShellFolder> sf;
|
||||
hr = SHBindToParent(pidlLastParsed, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
|
||||
hr = SHBindToParent(m_pidlLastParsed, IID_PPV_ARG(IShellFolder, &sf), &pidlChild);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
|
@ -374,10 +348,15 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::OnWinEvent(
|
|||
{
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE && fCombobox == (HWND)lParam)
|
||||
{
|
||||
UINT selectedIndex = SendMessageW((HWND)lParam, CB_GETCURSEL, 0, 0);
|
||||
pidlLastParsed = ILClone((LPITEMIDLIST)SendMessageW((HWND)lParam, CB_GETITEMDATA, selectedIndex, 0));
|
||||
INT iItem = (INT)fCombobox.SendMessage(CB_GETCURSEL);
|
||||
PIDLIST_ABSOLUTE pidl =
|
||||
(PIDLIST_ABSOLUTE)fCombobox.SendMessage(CB_GETITEMDATA, iItem);
|
||||
m_pidlLastParsed.Free();
|
||||
if (pidl)
|
||||
m_pidlLastParsed.Attach(ILClone(pidl));
|
||||
|
||||
Execute(0);
|
||||
}
|
||||
break;
|
||||
|
@ -460,12 +439,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Invoke(DISPID dispIdMember, REFIID ri
|
|||
{
|
||||
case DISPID_NAVIGATECOMPLETE2:
|
||||
case DISPID_DOCUMENTCOMPLETE:
|
||||
if (pidlLastParsed)
|
||||
{
|
||||
ILFree(pidlLastParsed);
|
||||
pidlLastParsed = NULL;
|
||||
}
|
||||
|
||||
m_pidlLastParsed.Free();
|
||||
RefreshAddress();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,21 +1,9 @@
|
|||
/*
|
||||
* ReactOS Explorer
|
||||
*
|
||||
* Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
* PROJECT: ReactOS Explorer
|
||||
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||
* PURPOSE: The combo box of the address band
|
||||
* COPYRIGHT: Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||
* Copyright 2023-2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
@ -37,7 +25,7 @@ private:
|
|||
CContainedWindow fEditWindow;
|
||||
DWORD fAdviseCookie;
|
||||
CComPtr<IUnknown> fSite;
|
||||
LPITEMIDLIST pidlLastParsed;
|
||||
CComHeapPtr<ITEMIDLIST_ABSOLUTE> m_pidlLastParsed;
|
||||
HWND hComboBoxEx;
|
||||
public:
|
||||
CAddressEditBox();
|
||||
|
@ -62,7 +50,7 @@ public:
|
|||
|
||||
// *** IAddressEditBox methods ***
|
||||
STDMETHOD(Init)(HWND comboboxEx, HWND editControl, long param14, IUnknown *param18) override;
|
||||
STDMETHOD(SetCurrentDir)(long paramC) override;
|
||||
STDMETHOD(SetCurrentDir)(PCWSTR pszPath) override;
|
||||
STDMETHOD(ParseNow)(long paramC) override;
|
||||
STDMETHOD(Execute)(long paramC) override;
|
||||
STDMETHOD(Save)(long paramC) override;
|
||||
|
|
|
@ -354,7 +354,7 @@ DECLARE_INTERFACE_(IAddressEditBox, IUnknown)
|
|||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||
/*** IAddressEditBox ***/
|
||||
STDMETHOD(Init)(THIS_ HWND comboboxEx, HWND editControl, long param14, IUnknown *param18) PURE;
|
||||
STDMETHOD(SetCurrentDir)(THIS_ long paramC) PURE;
|
||||
STDMETHOD(SetCurrentDir)(THIS_ PCWSTR pszPath) PURE;
|
||||
STDMETHOD(ParseNow)(THIS_ long paramC) PURE;
|
||||
STDMETHOD(Execute)(THIS_ long paramC) PURE;
|
||||
STDMETHOD(Save)(THIS_ long paramC) PURE;
|
||||
|
|
Loading…
Reference in a new issue