Reactos

[BROWSEUI] Accept relative path on Address Bar (#8633)

Improve usability of Address Bar.
JIRA issue: CORE-19704
- Modify CAddressEditBox::ParseNow
to accept relative path.
- Add SBSP_SAMEBROWSER |
SBSP_ABSOLUTE flags for
IShellBrowser::BrowseObject.

authored by

Katayama Hirofumi MZ and committed by
GitHub
9e64b600 63506696

+26 -7
+26 -7
dll/win32/browseui/addresseditbox.cpp
··· 184 184 CComPtr<IShellFolder> psfCurrent; 185 185 HRESULT hr; 186 186 187 - ATLASSERT(!m_pidlLastParsed); 187 + m_pidlLastParsed.Free(); 188 188 189 189 CComPtr<IBrowserService> pbs; 190 190 hr = IUnknown_QueryService(fSite, SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &pbs)); ··· 220 220 if (FAILED_UNEXPECTEDLY(hr)) 221 221 goto parseabsolute; 222 222 223 - hr = psfDesktop->BindToObject(pidlCurrent, NULL, IID_PPV_ARG(IShellFolder, &psfCurrent)); 224 - if (FAILED_UNEXPECTEDLY(hr)) 225 - goto parseabsolute; 223 + if (!pidlCurrent->mkid.cb) 224 + { 225 + psfCurrent = psfDesktop; 226 + } 227 + else 228 + { 229 + hr = psfDesktop->BindToObject(pidlCurrent, NULL, IID_PPV_ARG(IShellFolder, &psfCurrent)); 230 + if (FAILED_UNEXPECTEDLY(hr)) 231 + goto parseabsolute; 232 + 233 + WCHAR szPath[MAX_PATH], szFullPath[MAX_PATH]; 234 + if (PathIsRelativeW(address) && SHGetPathFromIDListW(pidlCurrent, szPath)) 235 + { 236 + PathAppendW(szPath, address); 237 + if (GetFullPathNameW(szPath, _countof(szFullPath), szFullPath, NULL)) 238 + { 239 + address.Free(); 240 + SHStrDupW(szFullPath, &address); 241 + } 242 + } 243 + } 226 244 227 - hr = psfCurrent->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlRelative, &attributes); 245 + hr = psfCurrent->ParseDisplayName(topLevelWindow, NULL, address, &eaten, &pidlRelative, &attributes); 228 246 if (SUCCEEDED(hr)) 229 247 { 230 248 m_pidlLastParsed.Attach(ILCombine(pidlCurrent, pidlRelative)); 231 - return hr; 249 + return S_OK; 232 250 } 233 251 234 252 parseabsolute: ··· 271 289 272 290 if (!m_pidlLastParsed) 273 291 return E_FAIL; 292 + 274 293 bParsedForExec = TRUE; 275 294 } 276 295 ··· 304 323 /* 305 324 * Attempt to browse to the parsed pidl 306 325 */ 307 - hr = pisb->BrowseObject(m_pidlLastParsed, 0); 326 + hr = pisb->BrowseObject(m_pidlLastParsed, SBSP_SAMEBROWSER | SBSP_ABSOLUTE); 308 327 if (SUCCEEDED(hr)) 309 328 return hr; 310 329