else if (fType == MFT_STRING)
{
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
- if ((ULONG_PTR)HIWORD((ULONG_PTR)dwTypeData) == 0)
+ if (IS_INTRESOURCE(dwTypeData))
{
if (LoadStringW(_AtlBaseModule.GetResourceInstance(), LOWORD((ULONG_PTR)dwTypeData), wszText, _countof(wszText)))
mii.dwTypeData = wszText;
static LPITEMIDLIST _ILCreate(LPCWSTR lpszPath)
{
CComHeapPtr<ITEMIDLIST> lpFSPidl(ILCreateFromPathW(lpszPath));
- if (!(LPITEMIDLIST)lpFSPidl)
+ if (!lpFSPidl)
{
ERR("Failed to create pidl from path\n");
- return 0;
+ return NULL;
}
LPITEMIDLIST lpLastFSPidl = ILFindLastID(lpFSPidl);
- int pathLen = (wcslen(lpszPath) + 1) * sizeof(WCHAR);
+ int pathLen = (PathFindFileNameW(lpszPath) - lpszPath) * sizeof(WCHAR);
int cbData = sizeof(WORD) + pathLen + lpLastFSPidl->mkid.cb;
LPITEMIDLIST pidl = (LPITEMIDLIST) SHAlloc(cbData + sizeof(WORD));
if (!pidl)
p += sizeof(WORD);
memcpy(p, lpszPath, pathLen);
- p += pathLen;
+ p += pathLen - sizeof(WCHAR);
+ *((WCHAR *) p) = '\0';
+ p += sizeof(WCHAR);
memcpy(p, lpLastFSPidl, lpLastFSPidl->mkid.cb);
p += lpLastFSPidl->mkid.cb;
if (!SHCreateThread(SearchThreadProc, pSearchData, NULL, NULL))
{
SHFree(pSearchData);
- return HRESULT_FROM_WIN32(GetLastError());
+ return 0;
}
- return S_OK;
+ return 0;
}
LRESULT CFindFolder::StopSearch(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
m_shellBrowser->SetStatusTextSB(status);
}
- return S_OK;
+ return 0;
}
// *** IShellFolder2 methods ***
if (iColumn == 1)
{
- WCHAR path[MAX_PATH];
- wcscpy(path, _ILGetPath(pidl));
- PathRemoveFileSpecW(path);
- return SHSetStrRet(&pDetails->str, path);
+ return SHSetStrRet(&pDetails->str, _ILGetPath(pidl));
}
return GetDisplayNameOf(pidl, SHGDN_NORMAL, &pDetails->str);
for (UINT i = 0; i < cidl; i++)
{
- WCHAR path[MAX_PATH];
- wcscpy(path, (LPCWSTR) apidl[0]->mkid.abID);
- PathRemoveFileSpecW(path);
- CComHeapPtr<ITEMIDLIST> folderPidl(ILCreateFromPathW(path));
+ CComHeapPtr<ITEMIDLIST> folderPidl(ILCreateFromPathW(_ILGetPath(apidl[i])));
if (!folderPidl)
return E_OUTOFMEMORY;
- CComHeapPtr<ITEMIDLIST> pidl(ILCreateFromPathW((LPCWSTR) apidl[i]->mkid.abID));
- if (!pidl)
- return E_OUTOFMEMORY;
+ LPCITEMIDLIST pidl = _ILGetFSPidl(apidl[i]);
SHOpenFolderAndSelectItems(folderPidl, 1, &pidl, 0);
}
return S_OK;
if (riid == IID_IContextMenu)
{
- WCHAR path[MAX_PATH];
- wcscpy(path, (LPCWSTR) apidl[0]->mkid.abID);
- PathRemoveFileSpecW(path);
- CComHeapPtr<ITEMIDLIST> folderPidl(ILCreateFromPathW(path));
+ CComHeapPtr<ITEMIDLIST> folderPidl(ILCreateFromPathW(_ILGetPath(apidl[0])));
if (!folderPidl)
return E_OUTOFMEMORY;
CComPtr<IShellFolder> pDesktopFolder;
}
case SFVM_WINDOWCREATED:
{
+ // Subclass window to receive window messages
SubclassWindow((HWND) wParam);
+ // Get shell browser for updating status bar text
CComPtr<IServiceProvider> pServiceProvider;
HRESULT hr = m_shellFolderView->QueryInterface(IID_PPV_ARG(IServiceProvider, &pServiceProvider));
if (FAILED_UNEXPECTEDLY(hr))
- {
return hr;
- }
- return pServiceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &m_shellBrowser));
+ hr = pServiceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARG(IShellBrowser, &m_shellBrowser));
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+
+ // Open search bar
+ CComPtr<IWebBrowser2> pWebBrowser2;
+ hr = m_shellBrowser->QueryInterface(IID_PPV_ARG(IWebBrowser2, &pWebBrowser2));
+ if (FAILED_UNEXPECTEDLY(hr))
+ return hr;
+ WCHAR pwszGuid[MAX_PATH];
+ StringFromGUID2(CLSID_FileSearchBand, pwszGuid, _countof(pwszGuid));
+ CComVariant searchBar(pwszGuid);
+ return pWebBrowser2->ShowBrowserBar(&searchBar, NULL, NULL);
}
}
return E_NOTIMPL;
}
//// *** IPersistFolder2 methods ***
-STDMETHODIMP CFindFolder::GetCurFolder(LPITEMIDLIST *pidl)
+STDMETHODIMP CFindFolder::GetCurFolder(PIDLIST_ABSOLUTE *pidl)
{
*pidl = ILClone(m_pidl);
return S_OK;
}
// *** IPersistFolder methods ***
-STDMETHODIMP CFindFolder::Initialize(LPCITEMIDLIST pidl)
+STDMETHODIMP CFindFolder::Initialize(PCIDLIST_ABSOLUTE pidl)
{
m_pidl = ILClone(pidl);
if (!m_pidl)