ReactOS 0.4.16-dev-188-g678aa63
shellbrowser.cpp File Reference
#include "precomp.h"
#include <shellapi.h>
#include <htiframe.h>
#include <strsafe.h>
#include "newatlinterfaces.h"
Include dependency graph for shellbrowser.cpp:

Go to the source code of this file.

Classes

class  CToolbarProxy
 
struct  MenuBandInfo
 
class  CShellBrowser
 
class  CShellBrowser::barInfo
 

Functions

HRESULT IUnknown_ShowDW (IUnknown *punk, BOOL fShow)
 
void DeleteMenuItems (HMENU theMenu, unsigned int firstIDToDelete, unsigned int lastIDToDelete)
 
HRESULT WINAPI SHBindToFolder (LPCITEMIDLIST path, IShellFolder **newFolder)
 
HRESULT CreateProgressDialog (REFIID riid, void **ppv)
 
BOOL WINAPI _ILIsPidlSimple (LPCITEMIDLIST pidl)
 
HRESULT WINAPI SHBindToFolderIDListParent (IShellFolder *unused, LPCITEMIDLIST pidl, const IID *riid, LPVOID *ppv, LPITEMIDLIST *ppidlLast)
 
HRESULT IEGetNameAndFlagsEx (LPITEMIDLIST pidl, SHGDNF uFlags, long param10, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
 
HRESULT IEGetNameAndFlags (LPITEMIDLIST pidl, SHGDNF uFlags, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)
 
BOOL CALLBACK AddFolderOptionsPage (HPROPSHEETPAGE thePage, LPARAM lParam)
 
bool IUnknownIsEqual (IUnknown *int1, IUnknown *int2)
 
static BOOL _ILIsNetworkPlace (LPCITEMIDLIST pidl)
 
static BOOL CreateShortcut (IN LPCWSTR pszLnkFileName, IN LPCITEMIDLIST pidl, IN LPCWSTR pszDescription OPTIONAL)
 
HRESULT GetFavsLocation (HWND hWnd, LPITEMIDLIST *pPidl)
 
HRESULT CShellBrowser_CreateInstance (REFIID riid, void **ppv)
 

Variables

static const unsigned int folderOptionsPageCountMax = 20
 
static const long BTP_DONT_UPDATE_HISTORY = 0
 
static const long BTP_UPDATE_CUR_HISTORY = 1
 
static const long BTP_UPDATE_NEXT_HISTORY = 2
 
static const long BTP_ACTIVATE_NOFOCUS = 0x04
 
BOOL createNewStuff = false
 
static const TCHAR szCabinetWndClass [] = TEXT("CabinetWClass")
 

Function Documentation

◆ _ILIsNetworkPlace()

static BOOL _ILIsNetworkPlace ( LPCITEMIDLIST  pidl)
static

Definition at line 2516 of file shellbrowser.cpp.

2517{
2520}
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SHGetPathFromIDListWrapW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: ordinal.c:3472
BOOL WINAPI PathIsUNCW(LPCWSTR lpszPath)
Definition: path.c:2266
LPCWSTR szPath
Definition: env.c:37
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CShellBrowser::GetPropertyBag().

◆ _ILIsPidlSimple()

BOOL WINAPI _ILIsPidlSimple ( LPCITEMIDLIST  pidl)

Definition at line 912 of file shellbrowser.cpp.

913{
914 LPCITEMIDLIST pidlnext;
915 WORD length;
916 BOOL ret;
917
918 ret = TRUE;
919 if (! _ILIsDesktop(pidl))
920 {
921 length = pidl->mkid.cb;
922 pidlnext =
923 reinterpret_cast<LPCITEMIDLIST>(
924 reinterpret_cast<const BYTE *>(pidl) + length);
925 if (pidlnext->mkid.cb != 0)
926 ret = FALSE;
927 }
928 return ret;
929}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
int ret
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CFSFolder::CompareIDs(), CDesktopFolder::GetDisplayNameOf(), CDrivesFolder::GetDisplayNameOf(), CFSFolder::GetDisplayNameOf(), HCR_GetFolderAttributes(), SHBindToFolderIDListParent(), and SHELL32_BindToSF().

◆ AddFolderOptionsPage()

BOOL CALLBACK AddFolderOptionsPage ( HPROPSHEETPAGE  thePage,
LPARAM  lParam 
)

Definition at line 1413 of file shellbrowser.cpp.

1414{
1415 PROPSHEETHEADER* sheetInfo = reinterpret_cast<PROPSHEETHEADER*>(lParam);
1416 if (sheetInfo->nPages >= folderOptionsPageCountMax)
1417 return FALSE;
1418 sheetInfo->phpage[sheetInfo->nPages] = thePage;
1419 sheetInfo->nPages++;
1420 return TRUE;
1421}
LPARAM lParam
Definition: combotst.c:139
static const unsigned int folderOptionsPageCountMax
#define PROPSHEETHEADER
Definition: prsht.h:392

Referenced by CShellBrowser::DoFolderOptions().

◆ CreateProgressDialog()

HRESULT CreateProgressDialog ( REFIID  riid,
void **  ppv 
)

◆ CreateShortcut()

static BOOL CreateShortcut ( IN LPCWSTR  pszLnkFileName,
IN LPCITEMIDLIST  pidl,
IN LPCWSTR pszDescription  OPTIONAL 
)
static

Definition at line 3882 of file shellbrowser.cpp.

3886{
3887 IPersistFile *pPF;
3888 IShellLinkW *pSL;
3890 if (FAILED(hr))
3891 return hr;
3892
3893 hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
3894 IID_IShellLinkW, (LPVOID*)&pSL);
3895 if (SUCCEEDED(hr))
3896 {
3897 pSL->SetIDList(pidl);
3898
3899 if (pszDescription)
3900 pSL->SetDescription(pszDescription);
3901
3902 hr = pSL->QueryInterface(IID_IPersistFile, (LPVOID*)&pPF);
3903 if (SUCCEEDED(hr))
3904 {
3905 hr = pPF->Save(pszLnkFileName, TRUE);
3906 pPF->Release();
3907 }
3908 pSL->Release();
3909 }
3910
3912
3913 return SUCCEEDED(hr);
3914}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
HRESULT SetIDList([in] PCIDLIST_ABSOLUTE pidl)
HRESULT SetDescription([in] LPCWSTR pszName)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsrefcnt Release()
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const GUID IID_IPersistFile
HRESULT hr
Definition: shlfolder.c:183

Referenced by CShellBrowser::OnAddToFavorites().

◆ CShellBrowser_CreateInstance()

HRESULT CShellBrowser_CreateInstance ( REFIID  riid,
void **  ppv 
)

Definition at line 4131 of file shellbrowser.cpp.

4132{
4133 return ShellObjectCreatorInit<CShellBrowser>(riid, ppv);
4134}
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by ExplorerMessageLoop().

◆ DeleteMenuItems()

void DeleteMenuItems ( HMENU  theMenu,
unsigned int  firstIDToDelete,
unsigned int  lastIDToDelete 
)

Definition at line 131 of file shellbrowser.cpp.

132{
133 MENUITEMINFO menuItemInfo;
134 int menuItemCount;
135 int curIndex;
136
137 menuItemCount = GetMenuItemCount(theMenu);
138 curIndex = 0;
139 while (curIndex < menuItemCount)
140 {
141 menuItemInfo.cbSize = sizeof(menuItemInfo);
142 menuItemInfo.fMask = MIIM_ID;
143 if (GetMenuItemInfo(theMenu, curIndex, TRUE, &menuItemInfo) &&
144 menuItemInfo.wID >= firstIDToDelete && menuItemInfo.wID <= lastIDToDelete)
145 {
146 DeleteMenu(theMenu, curIndex, MF_BYPOSITION);
147 menuItemCount--;
148 }
149 else
150 curIndex++;
151 }
152}
#define MIIM_ID
Definition: winuser.h:725
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
BOOL WINAPI DeleteMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_BYPOSITION
Definition: winuser.h:203
#define GetMenuItemInfo
Definition: winuser.h:5800

Referenced by CShellBrowser::UpdateGotoMenu().

◆ GetFavsLocation()

HRESULT GetFavsLocation ( HWND  hWnd,
LPITEMIDLIST pPidl 
)

Definition at line 3916 of file shellbrowser.cpp.

3917{
3919 if (FAILED(hr))
3921
3922 return hr;
3923}
HWND hWnd
Definition: settings.c:17
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3257
#define CSIDL_FAVORITES
Definition: shlobj.h:2179
#define CSIDL_COMMON_FAVORITES
Definition: shlobj.h:2203

Referenced by CShellBrowser::OnAddToFavorites(), and CShellBrowser::OnOrganizeFavorites().

◆ IEGetNameAndFlags()

HRESULT IEGetNameAndFlags ( LPITEMIDLIST  pidl,
SHGDNF  uFlags,
LPWSTR  pszBuf,
UINT  cchBuf,
SFGAOF rgfInOut 
)

Definition at line 1000 of file shellbrowser.cpp.

1001{
1002 return IEGetNameAndFlagsEx(pidl, uFlags, 0, pszBuf, cchBuf, rgfInOut);
1003}
UINT uFlags
Definition: api.c:59
HRESULT IEGetNameAndFlagsEx(LPITEMIDLIST pidl, SHGDNF uFlags, long param10, LPWSTR pszBuf, UINT cchBuf, SFGAOF *rgfInOut)

Referenced by CShellBrowser::BrowseToPath(), CAddressEditBox::RefreshAddress(), and CShellBrowser::UpdateWindowTitle().

◆ IEGetNameAndFlagsEx()

HRESULT IEGetNameAndFlagsEx ( LPITEMIDLIST  pidl,
SHGDNF  uFlags,
long  param10,
LPWSTR  pszBuf,
UINT  cchBuf,
SFGAOF rgfInOut 
)

Definition at line 968 of file shellbrowser.cpp.

970{
971 CComPtr<IShellFolder> parentFolder;
972 LPITEMIDLIST childPIDL = NULL;
973 STRRET L108;
974 HRESULT hResult;
975
976 hResult = SHBindToFolderIDListParent(NULL, pidl, &IID_PPV_ARG(IShellFolder, &parentFolder), &childPIDL);
977 if (FAILED(hResult))
978 goto cleanup;
979
980 hResult = parentFolder->GetDisplayNameOf(childPIDL, uFlags, &L108);
981 if (FAILED(hResult))
982 goto cleanup;
983
984 StrRetToBufW(&L108, childPIDL, pszBuf, cchBuf);
985 if (rgfInOut)
986 {
987 hResult = parentFolder->GetAttributesOf(1, const_cast<LPCITEMIDLIST *>(&childPIDL), rgfInOut);
988 if (FAILED(hResult))
989 goto cleanup;
990 }
991
992 hResult = S_OK;
993
994cleanup:
995 if (childPIDL)
996 ILFree(childPIDL);
997 return hResult;
998}
HRESULT WINAPI SHBindToFolderIDListParent(IShellFolder *unused, LPCITEMIDLIST pidl, const IID *riid, LPVOID *ppv, LPITEMIDLIST *ppidlLast)
static void cleanup(void)
Definition: main.c:1335
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
#define S_OK
Definition: intsafe.h:52
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:946
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define IID_PPV_ARG(Itype, ppType)

Referenced by IEGetNameAndFlags().

◆ IUnknown_ShowDW()

HRESULT IUnknown_ShowDW ( IUnknown punk,
BOOL  fShow 
)

Definition at line 105 of file internettoolbar.cpp.

106{
107 CComPtr<IDockingWindow> dockingWindow;
108 HRESULT hResult = punk->QueryInterface(IID_PPV_ARG(IDockingWindow, &dockingWindow));
109 if (FAILED_UNEXPECTEDLY(hResult))
110 return hResult;
111 hResult = dockingWindow->ShowDW(fShow);
112 if (FAILED_UNEXPECTEDLY(hResult))
113 return hResult;
114 return S_OK;
115}
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121

Referenced by CShellBrowser::Exec(), CShellBrowser::Initialize(), and CInternetToolbar::ShowDW().

◆ IUnknownIsEqual()

bool IUnknownIsEqual ( IUnknown int1,
IUnknown int2 
)

Definition at line 1972 of file shellbrowser.cpp.

1973{
1974 CComPtr<IUnknown> int1Retry;
1975 CComPtr<IUnknown> int2Retry;
1976 HRESULT hResult;
1977
1978 if (int1 == int2)
1979 return true;
1980 if (int1 == NULL || int2 == NULL)
1981 return false;
1982 hResult = int1->QueryInterface(IID_PPV_ARG(IUnknown, &int1Retry));
1983 if (FAILED_UNEXPECTEDLY(hResult))
1984 return false;
1985 hResult = int2->QueryInterface(IID_PPV_ARG(IUnknown, &int2Retry));
1986 if (FAILED_UNEXPECTEDLY(hResult))
1987 return false;
1988 if (int1Retry == int2Retry)
1989 return true;
1990 return false;
1991}
static BYTE int1[]
Definition: cert.c:3154
static BYTE int2[]
Definition: cert.c:3155

Referenced by CShellBrowser::Exec(), CShellBrowser::GetBorderDW(), and CShellBrowser::SetBorderSpaceDW().

◆ SHBindToFolder()

HRESULT WINAPI SHBindToFolder ( LPCITEMIDLIST  path,
IShellFolder **  newFolder 
)

Definition at line 154 of file shellbrowser.cpp.

155{
156 CComPtr<IShellFolder> desktop;
157
158 HRESULT hr = ::SHGetDesktopFolder(&desktop);
160 return E_FAIL;
161 if (path == NULL || path->mkid.cb == 0)
162 {
163 *newFolder = desktop;
164 desktop.p->AddRef ();
165 return S_OK;
166 }
167 return desktop->BindToObject (path, NULL, IID_PPV_ARG(IShellFolder, newFolder));
168}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define E_FAIL
Definition: ddrawi.h:102

Referenced by CShellBrowser::BrowseToPIDL().

◆ SHBindToFolderIDListParent()

HRESULT WINAPI SHBindToFolderIDListParent ( IShellFolder unused,
LPCITEMIDLIST  pidl,
const IID riid,
LPVOID ppv,
LPITEMIDLIST ppidlLast 
)

Definition at line 931 of file shellbrowser.cpp.

933{
935 LPITEMIDLIST pidlChild;
936 LPITEMIDLIST pidlParent;
937 HRESULT hResult;
938
939 hResult = E_FAIL;
940 if (ppv == NULL)
941 return E_POINTER;
942 *ppv = NULL;
943 if (ppidlLast != NULL)
944 *ppidlLast = NULL;
945 if (_ILIsPidlSimple(pidl))
946 {
947 if (ppidlLast != NULL)
948 *ppidlLast = ILClone(pidl);
949 hResult = SHGetDesktopFolder((IShellFolder **)ppv);
950 }
951 else
952 {
953 pidlChild = ILClone(ILFindLastID(pidl));
954 pidlParent = ILClone(pidl);
955 ILRemoveLastID(pidlParent);
956 hResult = SHGetDesktopFolder(&psf);
957 if (SUCCEEDED(hResult))
958 hResult = psf->BindToObject(pidlParent, NULL, *riid, ppv);
959 if (SUCCEEDED(hResult) && ppidlLast != NULL)
960 *ppidlLast = pidlChild;
961 else
962 ILFree(pidlChild);
963 ILFree(pidlParent);
964 }
965 return hResult;
966}
BOOL WINAPI _ILIsPidlSimple(LPCITEMIDLIST pidl)
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:198
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:221
#define E_POINTER
Definition: winerror.h:2365

Referenced by IEGetNameAndFlagsEx().

Variable Documentation

◆ BTP_ACTIVATE_NOFOCUS

const long BTP_ACTIVATE_NOFOCUS = 0x04
static

Definition at line 123 of file shellbrowser.cpp.

Referenced by CShellBrowser::BrowseObject(), and CShellBrowser::BrowseToPath().

◆ BTP_DONT_UPDATE_HISTORY

const long BTP_DONT_UPDATE_HISTORY = 0
static

Definition at line 120 of file shellbrowser.cpp.

Referenced by CShellBrowser::LoadHistory().

◆ BTP_UPDATE_CUR_HISTORY

◆ BTP_UPDATE_NEXT_HISTORY

◆ createNewStuff

BOOL createNewStuff = false

Definition at line 125 of file shellbrowser.cpp.

◆ folderOptionsPageCountMax

const unsigned int folderOptionsPageCountMax = 20
static

Definition at line 119 of file shellbrowser.cpp.

Referenced by AddFolderOptionsPage(), and CShellBrowser::DoFolderOptions().

◆ szCabinetWndClass

const TCHAR szCabinetWndClass[] = TEXT("CabinetWClass")
static

Definition at line 170 of file shellbrowser.cpp.

Referenced by CShellBrowser::GetWndClassInfo().