mirror of
https://github.com/reactos/reactos.git
synced 2025-05-19 00:54:18 +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
|
* PROJECT: ReactOS Explorer
|
||||||
*
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
* Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
* PURPOSE: The combo box of the address band
|
||||||
* Copyright 2023 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
* COPYRIGHT: Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||||
*
|
* Copyright 2023-2025 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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
This class handles the combo box of the address band.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -34,15 +17,12 @@ TODO:
|
||||||
CAddressEditBox::CAddressEditBox() :
|
CAddressEditBox::CAddressEditBox() :
|
||||||
fCombobox(WC_COMBOBOXEXW, this),
|
fCombobox(WC_COMBOBOXEXW, this),
|
||||||
fEditWindow(WC_EDITW, this),
|
fEditWindow(WC_EDITW, this),
|
||||||
fSite(NULL),
|
fSite(NULL)
|
||||||
pidlLastParsed(NULL)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CAddressEditBox::~CAddressEditBox()
|
CAddressEditBox::~CAddressEditBox()
|
||||||
{
|
{
|
||||||
if (pidlLastParsed)
|
|
||||||
ILFree(pidlLastParsed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *pOwner)
|
HRESULT STDMETHODCALLTYPE CAddressEditBox::SetOwner(IUnknown *pOwner)
|
||||||
|
@ -90,9 +70,11 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Init(HWND comboboxEx, HWND editContro
|
||||||
return hResult;
|
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)
|
BOOL CAddressEditBox::GetComboBoxText(CComHeapPtr<WCHAR>& pszText)
|
||||||
|
@ -196,19 +178,20 @@ BOOL CAddressEditBox::ExecuteCommandLine()
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
||||||
{
|
{
|
||||||
ULONG eaten;
|
ULONG eaten, attributes;
|
||||||
ULONG attributes;
|
CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlCurrent;
|
||||||
HRESULT hr;
|
CComHeapPtr<ITEMIDLIST_RELATIVE> pidlRelative;
|
||||||
HWND topLevelWindow;
|
|
||||||
PIDLIST_ABSOLUTE pidlCurrent= NULL;
|
|
||||||
PIDLIST_RELATIVE pidlRelative = NULL;
|
|
||||||
CComPtr<IShellFolder> psfCurrent;
|
CComPtr<IShellFolder> psfCurrent;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
ATLASSERT(!m_pidlLastParsed);
|
||||||
|
|
||||||
CComPtr<IBrowserService> pbs;
|
CComPtr<IBrowserService> pbs;
|
||||||
hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &pbs));
|
hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &pbs));
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
HWND topLevelWindow;
|
||||||
hr = IUnknown_GetWindow(pbs, &topLevelWindow);
|
hr = IUnknown_GetWindow(pbs, &topLevelWindow);
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
@ -231,7 +214,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
||||||
CComPtr<IShellFolder> psfDesktop;
|
CComPtr<IShellFolder> psfDesktop;
|
||||||
hr = SHGetDesktopFolder(&psfDesktop);
|
hr = SHGetDesktopFolder(&psfDesktop);
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
goto cleanup;
|
return hr;
|
||||||
|
|
||||||
hr = pbs->GetPidl(&pidlCurrent);
|
hr = pbs->GetPidl(&pidlCurrent);
|
||||||
if (FAILED_UNEXPECTEDLY(hr))
|
if (FAILED_UNEXPECTEDLY(hr))
|
||||||
|
@ -244,18 +227,13 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::ParseNow(long paramC)
|
||||||
hr = psfCurrent->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlRelative, &attributes);
|
hr = psfCurrent->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlRelative, &attributes);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
pidlLastParsed = ILCombine(pidlCurrent, pidlRelative);
|
m_pidlLastParsed.Attach(ILCombine(pidlCurrent, pidlRelative));
|
||||||
ILFree(pidlRelative);
|
return hr;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parseabsolute:
|
parseabsolute:
|
||||||
/* We couldn't parse a relative path, attempt to parse an absolute path */
|
/* We couldn't parse a relative path, attempt to parse an absolute path */
|
||||||
hr = psfDesktop->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlLastParsed, &attributes);
|
hr = psfDesktop->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &m_pidlLastParsed, &attributes);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (pidlCurrent)
|
|
||||||
ILFree(pidlCurrent);
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +255,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
||||||
/*
|
/*
|
||||||
* Parse the path if it wasn't parsed
|
* Parse the path if it wasn't parsed
|
||||||
*/
|
*/
|
||||||
if (!pidlLastParsed)
|
if (!m_pidlLastParsed)
|
||||||
{
|
{
|
||||||
hr = ParseNow(0);
|
hr = ParseNow(0);
|
||||||
|
|
||||||
|
@ -290,7 +268,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
||||||
return ShowFileNotFoundError(hr);
|
return ShowFileNotFoundError(hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pidlLastParsed)
|
if (!m_pidlLastParsed)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,24 +293,20 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
hr = psf->CompareIDs(0, pidl, pidlLastParsed);
|
hr = psf->CompareIDs(0, pidl, m_pidlLastParsed);
|
||||||
|
|
||||||
SHFree(pidl);
|
SHFree(pidl);
|
||||||
|
|
||||||
if (hr == 0)
|
if (hr == S_OK)
|
||||||
{
|
{
|
||||||
if (pidlLastParsed)
|
m_pidlLastParsed.Free();
|
||||||
{
|
|
||||||
ILFree(pidlLastParsed);
|
|
||||||
pidlLastParsed = NULL;
|
|
||||||
}
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to browse to the parsed pidl
|
* Attempt to browse to the parsed pidl
|
||||||
*/
|
*/
|
||||||
hr = pisb->BrowseObject(pidlLastParsed, 0);
|
hr = pisb->BrowseObject(m_pidlLastParsed, 0);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
@ -346,7 +320,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Execute(long paramC)
|
||||||
|
|
||||||
LPCITEMIDLIST pidlChild;
|
LPCITEMIDLIST pidlChild;
|
||||||
CComPtr<IShellFolder> sf;
|
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))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
|
@ -374,10 +348,15 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::OnWinEvent(
|
||||||
{
|
{
|
||||||
case WM_COMMAND:
|
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);
|
INT iItem = (INT)fCombobox.SendMessage(CB_GETCURSEL);
|
||||||
pidlLastParsed = ILClone((LPITEMIDLIST)SendMessageW((HWND)lParam, CB_GETITEMDATA, selectedIndex, 0));
|
PIDLIST_ABSOLUTE pidl =
|
||||||
|
(PIDLIST_ABSOLUTE)fCombobox.SendMessage(CB_GETITEMDATA, iItem);
|
||||||
|
m_pidlLastParsed.Free();
|
||||||
|
if (pidl)
|
||||||
|
m_pidlLastParsed.Attach(ILClone(pidl));
|
||||||
|
|
||||||
Execute(0);
|
Execute(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -460,12 +439,7 @@ HRESULT STDMETHODCALLTYPE CAddressEditBox::Invoke(DISPID dispIdMember, REFIID ri
|
||||||
{
|
{
|
||||||
case DISPID_NAVIGATECOMPLETE2:
|
case DISPID_NAVIGATECOMPLETE2:
|
||||||
case DISPID_DOCUMENTCOMPLETE:
|
case DISPID_DOCUMENTCOMPLETE:
|
||||||
if (pidlLastParsed)
|
m_pidlLastParsed.Free();
|
||||||
{
|
|
||||||
ILFree(pidlLastParsed);
|
|
||||||
pidlLastParsed = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshAddress();
|
RefreshAddress();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS Explorer
|
* PROJECT: ReactOS Explorer
|
||||||
*
|
* LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
|
||||||
* Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
* PURPOSE: The combo box of the address band
|
||||||
*
|
* COPYRIGHT: Copyright 2009 Andrew Hill <ash77 at domain reactos.org>
|
||||||
* This library is free software; you can redistribute it and/or
|
* Copyright 2023-2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -37,7 +25,7 @@ private:
|
||||||
CContainedWindow fEditWindow;
|
CContainedWindow fEditWindow;
|
||||||
DWORD fAdviseCookie;
|
DWORD fAdviseCookie;
|
||||||
CComPtr<IUnknown> fSite;
|
CComPtr<IUnknown> fSite;
|
||||||
LPITEMIDLIST pidlLastParsed;
|
CComHeapPtr<ITEMIDLIST_ABSOLUTE> m_pidlLastParsed;
|
||||||
HWND hComboBoxEx;
|
HWND hComboBoxEx;
|
||||||
public:
|
public:
|
||||||
CAddressEditBox();
|
CAddressEditBox();
|
||||||
|
@ -62,7 +50,7 @@ public:
|
||||||
|
|
||||||
// *** IAddressEditBox methods ***
|
// *** IAddressEditBox methods ***
|
||||||
STDMETHOD(Init)(HWND comboboxEx, HWND editControl, long param14, IUnknown *param18) override;
|
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(ParseNow)(long paramC) override;
|
||||||
STDMETHOD(Execute)(long paramC) override;
|
STDMETHOD(Execute)(long paramC) override;
|
||||||
STDMETHOD(Save)(long paramC) override;
|
STDMETHOD(Save)(long paramC) override;
|
||||||
|
|
|
@ -354,7 +354,7 @@ DECLARE_INTERFACE_(IAddressEditBox, IUnknown)
|
||||||
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
STDMETHOD_(ULONG,Release)(THIS) PURE;
|
||||||
/*** IAddressEditBox ***/
|
/*** IAddressEditBox ***/
|
||||||
STDMETHOD(Init)(THIS_ HWND comboboxEx, HWND editControl, long param14, IUnknown *param18) PURE;
|
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(ParseNow)(THIS_ long paramC) PURE;
|
||||||
STDMETHOD(Execute)(THIS_ long paramC) PURE;
|
STDMETHOD(Execute)(THIS_ long paramC) PURE;
|
||||||
STDMETHOD(Save)(THIS_ long paramC) PURE;
|
STDMETHOD(Save)(THIS_ long paramC) PURE;
|
||||||
|
|
Loading…
Reference in a new issue