ReactOS 0.4.16-dev-109-gf4cb10f
brfolder.cpp File Reference
#include "precomp.h"
#include <ui/layout.h>
Include dependency graph for brfolder.cpp:

Go to the source code of this file.

Classes

struct  BrFolder
 
struct  BrItemData
 

Macros

#define SHV_CHANGE_NOTIFY   (WM_USER + 0x1111)
 
#define SUPPORTED_FLAGS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static HTREEITEM BrFolder_InsertItem (_Inout_ BrFolder *info, _Inout_ IShellFolder *lpsf, _In_ PCUITEMID_CHILD pidlChild, _In_ PCIDLIST_ABSOLUTE pidlParent, _In_ HTREEITEM hParent)
 
static DWORD BrowseFlagsToSHCONTF (UINT ulFlags)
 
static void BrFolder_Callback (LPBROWSEINFOW lpBrowseInfo, HWND hWnd, UINT uMsg, LPARAM lParam)
 
static BrItemDataBrFolder_GetItemData (BrFolder *info, HTREEITEM hItem)
 
static SFGAOF BrFolder_GetItemAttributes (BrFolder *info, HTREEITEM hItem, SFGAOF Att)
 
static HRESULT BrFolder_GetChildrenEnum (_In_ BrFolder *info, _In_ BrItemData *pItemData, _Outptr_opt_ IEnumIDList **ppEnum)
 
static void BrFolder_InitTreeView (BrFolder *info)
 
static INT BrFolder_GetIcon (PCIDLIST_ABSOLUTE pidl, UINT uFlags)
 
static void BrFolder_GetIconPair (PCIDLIST_ABSOLUTE pidl, LPTVITEMW pItem)
 
static BOOL BrFolder_GetName (IShellFolder *lpsf, PCIDLIST_RELATIVE pidlChild, DWORD dwFlags, LPWSTR lpFriendlyName)
 
static BOOL BrFolder_IsTreeItemInEnum (_Inout_ BrFolder *info, _In_ HTREEITEM hItem, _Inout_ IEnumIDList *pEnum)
 
static BOOL BrFolder_TreeItemHasThisChild (_In_ BrFolder *info, _In_ HTREEITEM hItem, _Outptr_opt_ PITEMID_CHILD pidlChild)
 
static void BrFolder_UpdateItem (_In_ BrFolder *info, _In_ HTREEITEM hItem)
 
static void BrFolder_Expand (_In_ BrFolder *info, _In_ IShellFolder *lpsf, _In_ PCIDLIST_ABSOLUTE pidlFull, _In_ HTREEITEM hParent)
 
static BOOL PIDLIsType (LPCITEMIDLIST pidl, PIDLTYPE type)
 
static void BrFolder_CheckValidSelection (BrFolder *info, BrItemData *pItemData)
 
static LRESULT BrFolder_Treeview_Delete (BrFolder *info, NMTREEVIEWW *pnmtv)
 
static LRESULT BrFolder_Treeview_Expand (BrFolder *info, NMTREEVIEWW *pnmtv)
 
static HRESULT BrFolder_Treeview_Changed (BrFolder *info, NMTREEVIEWW *pnmtv)
 
static LRESULT BrFolder_Treeview_Rename (BrFolder *info, NMTVDISPINFOW *pnmtv)
 
static HRESULT BrFolder_Rename (BrFolder *info, HTREEITEM hItem)
 
static void BrFolder_Delete (BrFolder *info, HTREEITEM hItem)
 
static void BrFolder_Refresh (_Inout_ BrFolder *info)
 
static LRESULT BrFolder_Treeview_Keydown (BrFolder *info, LPNMTVKEYDOWN keydown)
 
static LRESULT BrFolder_OnNotify (BrFolder *info, UINT CtlID, LPNMHDR lpnmh)
 
static BOOL BrFolder_OnInitDialog (HWND hWnd, BrFolder *info)
 
static HRESULT BrFolder_NewFolder (BrFolder *info)
 
static void BrFolder_OnOK (BrFolder *info)
 
static void BrFolder_OnCommand (BrFolder *info, UINT id)
 
static void GetTreeViewItemContextMenuPos (HWND hWnd, HTREEITEM hItem, POINT *ppt)
 
static void BrFolder_OnContextMenu (BrFolder &info, LPARAM lParam)
 
static BOOL BrFolder_OnSetExpandedPidl (BrFolder *info, LPITEMIDLIST pidlSelection, HTREEITEM *phItem)
 
static BOOL BrFolder_OnSetExpandedString (BrFolder *info, LPWSTR pszString, HTREEITEM *phItem)
 
static BOOL BrFolder_OnSetSelectionPidl (BrFolder *info, LPITEMIDLIST pidlSelection)
 
static BOOL BrFolder_OnSetSelectionW (BrFolder *info, LPWSTR pszSelection)
 
static BOOL BrFolder_OnSetSelectionA (BrFolder *info, LPSTR pszSelectionA)
 
static void BrFolder_OnDestroy (BrFolder *info)
 
static void BrFolder_RefreshRecurse (_Inout_ BrFolder *info, _In_ HTREEITEM hTarget)
 
static void BrFolder_OnChangeEx (_Inout_ BrFolder *info, _In_ PCIDLIST_ABSOLUTE pidl0, _In_ PCIDLIST_ABSOLUTE pidl1, _In_ LONG event)
 
static void BrFolder_OnChange (BrFolder *info, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK BrFolderDlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderA (LPBROWSEINFOA lpbi)
 
EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
 

Variables

static const LAYOUT_INFO g_layout_info []
 

Macro Definition Documentation

◆ SHV_CHANGE_NOTIFY

#define SHV_CHANGE_NOTIFY   (WM_USER + 0x1111)

Definition at line 17 of file brfolder.cpp.

◆ SUPPORTED_FLAGS

#define SUPPORTED_FLAGS
Value:
#define BIF_STATUSTEXT
Definition: shlobj.h:1219
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1217
#define BIF_RETURNFSANCESTORS
Definition: shlobj.h:1220
#define BIF_BROWSEINCLUDEFILES
Definition: shlobj.h:1232
#define BIF_NONEWFOLDERBUTTON
Definition: shlobj.h:1227
#define BIF_NEWDIALOGSTYLE
Definition: shlobj.h:1223
#define BIF_BROWSEFORCOMPUTER
Definition: shlobj.h:1230

Definition at line 49 of file brfolder.cpp.

Function Documentation

◆ BrFolder_Callback()

static void BrFolder_Callback ( LPBROWSEINFOW  lpBrowseInfo,
HWND  hWnd,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 68 of file brfolder.cpp.

69{
70 if (!lpBrowseInfo->lpfn)
71 return;
72 lpBrowseInfo->lpfn(hWnd, uMsg, lParam, lpBrowseInfo->lParam);
73}
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: combotst.c:139
BFFCALLBACK lpfn
Definition: shlobj.h:1205
LPARAM lParam
Definition: shlobj.h:1206

Referenced by BrFolder_OnInitDialog(), and BrFolder_Treeview_Changed().

◆ BrFolder_CheckValidSelection()

static void BrFolder_CheckValidSelection ( BrFolder info,
BrItemData pItemData 
)
static

Definition at line 428 of file brfolder.cpp.

429{
430 LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
431 PCIDLIST_RELATIVE pidlChild = pItemData->pidlChild;
433 HRESULT hr;
434
435 BOOL bEnabled = TRUE;
436 if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) && !PIDLIsType(pidlChild, PT_COMP))
437 bEnabled = FALSE;
438
439 if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS)
440 {
441 dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
442 hr = pItemData->lpsfParent->GetAttributesOf(1, &pidlChild, &dwAttributes);
443 if (FAILED(hr) || !(dwAttributes & (SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM)))
444 bEnabled = FALSE;
445 }
446
447 dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM;
448 hr = pItemData->lpsfParent->GetAttributesOf(1, &pidlChild, &dwAttributes);
449 if (FAILED_UNEXPECTEDLY(hr) ||
450 ((dwAttributes & (SFGAO_FOLDER | SFGAO_FILESYSTEM)) != (SFGAO_FOLDER | SFGAO_FILESYSTEM)))
451 {
452 if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS)
453 bEnabled = FALSE;
455 }
456 else
457 {
459 }
460
461 SendMessageW(info->hWnd, BFFM_ENABLEOK, 0, bEnabled);
462}
static BOOL PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type)
Definition: brfolder.cpp:419
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FAILED(hr)
Definition: intsafe.h:51
#define PT_COMP
Definition: pidl.h:99
HRESULT hr
Definition: shlfolder.c:183
#define BFFM_ENABLEOK
Definition: shlobj.h:1244
#define IDC_BROWSE_FOR_FOLDER_NEW_FOLDER
Definition: shresdef.h:436
PCIDLIST_RELATIVE pidlChild
Definition: brfolder.cpp:34
CComPtr< IShellFolder > lpsfParent
Definition: brfolder.cpp:33
UINT ulFlags
Definition: shlobj.h:1204
DWORD dwAttributes
Definition: vdmdbg.h:34
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by BrFolder_Treeview_Changed().

◆ BrFolder_Delete()

static void BrFolder_Delete ( BrFolder info,
HTREEITEM  hItem 
)
static

Definition at line 572 of file brfolder.cpp.

573{
574 SHFILEOPSTRUCTW fileop = { info->hwndTreeView };
575 WCHAR szzFrom[MAX_PATH + 1];
576
577 // Get item_data
579
580 // Get the path
581 if (!SHGetPathFromIDListW(item_data->pidlFull, szzFrom))
582 {
583 ERR("SHGetPathFromIDListW failed\n");
584 return;
585 }
586 szzFrom[lstrlenW(szzFrom) + 1] = UNICODE_NULL; // Double NULL-terminated
587 fileop.pFrom = szzFrom;
588
589 // Delete folder
590 fileop.fFlags = FOF_ALLOWUNDO;
591 fileop.wFunc = FO_DELETE;
592 SHFileOperationW(&fileop);
593}
#define ERR(fmt,...)
Definition: precomp.h:57
static BrItemData * BrFolder_GetItemData(BrFolder *info, HTREEITEM hItem)
Definition: brfolder.cpp:76
#define MAX_PATH
Definition: compat.h:34
#define lstrlenW
Definition: compat.h:750
#define UNICODE_NULL
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1348
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
#define FO_DELETE
Definition: shellapi.h:138
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1988
CComHeapPtr< ITEMIDLIST_ABSOLUTE > pidlFull
Definition: brfolder.cpp:35
LPCWSTR pFrom
Definition: shellapi.h:357
FILEOP_FLAGS fFlags
Definition: shellapi.h:359
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by BrFolder_Treeview_Keydown().

◆ BrFolder_Expand()

static void BrFolder_Expand ( _In_ BrFolder info,
_In_ IShellFolder lpsf,
_In_ PCIDLIST_ABSOLUTE  pidlFull,
_In_ HTREEITEM  hParent 
)
static

Definition at line 387 of file brfolder.cpp.

392{
393 TRACE("%p %p %p\n", lpsf, pidlFull, hParent);
394
395 // No IEnumIDList -> No children
396 BrItemData *pItemData = BrFolder_GetItemData(info, hParent);
398 HRESULT hr = BrFolder_GetChildrenEnum(info, pItemData, &pEnum);
399 if (FAILED(hr))
400 return;
401
402 SetCapture(info->hWnd);
404
406 ULONG ulFetched;
407 while (S_OK == pEnum->Next(1, &pidlTemp, &ulFetched))
408 {
409 if (!BrFolder_InsertItem(info, lpsf, pidlTemp, pidlFull, hParent))
410 break;
411 pidlTemp.Free(); // Finally, free the pidl that the shell gave us...
412 }
413
416}
static HRESULT BrFolder_GetChildrenEnum(_In_ BrFolder *info, _In_ BrItemData *pItemData, _Outptr_opt_ IEnumIDList **ppEnum)
Definition: brfolder.cpp:97
static HTREEITEM BrFolder_InsertItem(_Inout_ BrFolder *info, _Inout_ IShellFolder *lpsf, _In_ PCUITEMID_CHILD pidlChild, _In_ PCIDLIST_ABSOLUTE pidlParent, _In_ HTREEITEM hParent)
Definition: brfolder.cpp:339
void Free()
Definition: atlalloc.h:153
#define NULL
Definition: types.h:112
#define S_OK
Definition: intsafe.h:52
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t ULONG
Definition: typedefs.h:59
HWND WINAPI SetCapture(_In_ HWND hWnd)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2157
#define IDC_WAIT
Definition: winuser.h:689
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by BrFolder_Treeview_Expand().

◆ BrFolder_GetChildrenEnum()

static HRESULT BrFolder_GetChildrenEnum ( _In_ BrFolder info,
_In_ BrItemData pItemData,
_Outptr_opt_ IEnumIDList **  ppEnum 
)
static

Definition at line 97 of file brfolder.cpp.

101{
102 if (!pItemData)
103 return E_FAIL;
104
105 CComPtr<IEnumIDList> pEnumIL;
106 PCUITEMID_CHILD pidlRef = pItemData->pidlChild;
107 ULONG attrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
108 IShellFolder *lpsf = pItemData->lpsfParent;
109 HRESULT hr = lpsf->GetAttributesOf(1, &pidlRef, &attrs);
110 if (FAILED_UNEXPECTEDLY(hr) || !(attrs & SFGAO_FOLDER))
111 return E_FAIL;
112
113 CComPtr<IShellFolder> psfChild;
114 if (_ILIsDesktop(pItemData->pidlFull))
115 hr = SHGetDesktopFolder(&psfChild);
116 else
117 hr = lpsf->BindToObject(pidlRef, NULL, IID_PPV_ARG(IShellFolder, &psfChild));
119 return E_FAIL;
120
121 DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
122 hr = psfChild->EnumObjects(info->hWnd, flags, &pEnumIL);
123 if (hr == S_OK)
124 {
125 if ((pEnumIL->Skip(1) != S_OK) || FAILED(pEnumIL->Reset()))
126 pEnumIL = NULL;
127 }
128
129 if (!pEnumIL || !(attrs & SFGAO_HASSUBFOLDER))
130 return E_FAIL; // No children
131
132 if (ppEnum)
133 *ppEnum = pEnumIL.Detach();
134
135 return S_OK; // There are children
136}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
static DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
Definition: brfolder.cpp:62
T * Detach()
Definition: atlcomcli.h:186
#define E_FAIL
Definition: ddrawi.h:102
GLbitfield flags
Definition: glext.h:7161
HRESULT BindToObject([in] PCUIDLIST_RELATIVE pidl, [in] LPBC pbcReserved, [in] REFIID riid, [out, iid_is(riid)] void **ppvOut)
HRESULT GetAttributesOf([in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in, out] SFGAOF *rgfInOut)
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
#define IID_PPV_ARG(Itype, ppType)

Referenced by BrFolder_Expand(), BrFolder_InsertItem(), BrFolder_RefreshRecurse(), and BrFolder_UpdateItem().

◆ BrFolder_GetIcon()

static INT BrFolder_GetIcon ( PCIDLIST_ABSOLUTE  pidl,
UINT  uFlags 
)
static

Definition at line 198 of file brfolder.cpp.

199{
200 SHFILEINFOW sfi;
201 SHGetFileInfoW((LPCWSTR)pidl, 0, &sfi, sizeof(sfi), uFlags);
202 return sfi.iIcon;
203}
UINT uFlags
Definition: api.c:59
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:414
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by BrFolder_GetIconPair().

◆ BrFolder_GetIconPair()

static void BrFolder_GetIconPair ( PCIDLIST_ABSOLUTE  pidl,
LPTVITEMW  pItem 
)
static

Definition at line 206 of file brfolder.cpp.

207{
208 DWORD flags;
209
211 if (!pidl)
212 {
213 pidlDesktop.Attach(_ILCreateDesktop());
214 pidl = pidlDesktop;
215 }
216
218 pItem->iImage = BrFolder_GetIcon(pidl, flags);
219
221 pItem->iSelectedImage = BrFolder_GetIcon(pidl, flags);
222}
static INT BrFolder_GetIcon(PCIDLIST_ABSOLUTE pidl, UINT uFlags)
Definition: brfolder.cpp:198
void Attach(T *lp)
Definition: atlalloc.h:162
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1641
#define SHGFI_OPENICON
Definition: shellapi.h:178
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:171
#define SHGFI_SMALLICON
Definition: shellapi.h:176
#define SHGFI_PIDL
Definition: shellapi.h:180
int iImage
Definition: commctrl.h:3327
int iSelectedImage
Definition: commctrl.h:3328

Referenced by BrFolder_InsertItem(), and BrFolder_UpdateItem().

◆ BrFolder_GetItemAttributes()

static SFGAOF BrFolder_GetItemAttributes ( BrFolder info,
HTREEITEM  hItem,
SFGAOF  Att 
)
static

Definition at line 89 of file brfolder.cpp.

90{
92 HRESULT hr = item ? item->lpsfParent->GetAttributesOf(1, &item->pidlChild, &Att) : E_FAIL;
93 return SUCCEEDED(hr) ? Att : 0;
94}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static ATOM item
Definition: dde.c:856

Referenced by BrFolder_OnNotify(), and BrFolder_Treeview_Rename().

◆ BrFolder_GetItemData()

static BrItemData * BrFolder_GetItemData ( BrFolder info,
HTREEITEM  hItem 
)
static

Definition at line 76 of file brfolder.cpp.

77{
79 item.hItem = hItem;
80 if (!TreeView_GetItem(info->hwndTreeView, &item))
81 {
82 ERR("TreeView_GetItem failed\n");
83 return NULL;
84 }
85 return (BrItemData *)item.lParam;
86}
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3495
#define TVIF_HANDLE
Definition: commctrl.h:3275
#define TVIF_PARAM
Definition: commctrl.h:3273
HTREEITEM hItem
Definition: treelist.h:37

Referenced by BrFolder_Delete(), BrFolder_Expand(), BrFolder_GetItemAttributes(), BrFolder_IsTreeItemInEnum(), BrFolder_OnContextMenu(), BrFolder_RefreshRecurse(), BrFolder_TreeItemHasThisChild(), BrFolder_Treeview_Rename(), and BrFolder_UpdateItem().

◆ BrFolder_GetName()

static BOOL BrFolder_GetName ( IShellFolder lpsf,
PCIDLIST_RELATIVE  pidlChild,
DWORD  dwFlags,
LPWSTR  lpFriendlyName 
)
static

Definition at line 240 of file brfolder.cpp.

245{
247 STRRET str;
248
249 TRACE("%p %p %x %p\n", lpsf, pidlChild, dwFlags, lpFriendlyName);
250 if (!FAILED_UNEXPECTEDLY(lpsf->GetDisplayNameOf(pidlChild, dwFlags, &str)))
251 bSuccess = StrRetToStrNW(lpFriendlyName, MAX_PATH, &str, pidlChild);
252
253 TRACE("-- %s\n", debugstr_w(lpFriendlyName));
254 return bSuccess;
255}
static BOOLEAN bSuccess
Definition: drive.cpp:477
HRESULT GetDisplayNameOf([in] PCUITEMID_CHILD pidl, [in] SHGDNF uFlags, [out] STRRET *lpName)
#define debugstr_w
Definition: kernel32.h:32
const WCHAR * str
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:85
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by BrFolder_InsertItem(), and BrFolder_Treeview_Changed().

◆ BrFolder_InitTreeView()

static void BrFolder_InitTreeView ( BrFolder info)
static

Definition at line 144 of file brfolder.cpp.

145{
146 HIMAGELIST hImageList;
147 HRESULT hr;
148 CComPtr<IShellFolder> lpsfParent;
149 CComPtr<IEnumIDList> pEnumChildren;
151
152 Shell_GetImageLists(NULL, &hImageList);
153
154 if (hImageList)
155 TreeView_SetImageList(info->hwndTreeView, hImageList, 0);
156
157 /* We want to call BrFolder_InsertItem down the code, in order to insert
158 * the root item of the treeview. Due to BrFolder_InsertItem's signature,
159 * we need the following to do this:
160 *
161 * + An ITEMIDLIST corresponding to _the parent_ of root.
162 * + An ITEMIDLIST, which is a relative path from root's parent to root
163 * (containing a single SHITEMID).
164 * + An IShellFolder interface pointer of root's parent folder.
165 *
166 * If root is 'Desktop', then root's parent is also 'Desktop'.
167 */
168
169 PCIDLIST_ABSOLUTE pidlRoot = info->lpBrowseInfo->pidlRoot;
170 CComHeapPtr<ITEMIDLIST_ABSOLUTE> pidlParent(ILClone(pidlRoot));
171 ILRemoveLastID(pidlParent);
172 PCIDLIST_RELATIVE pidlChild = ILFindLastID(pidlRoot);
173
174 if (_ILIsDesktop(pidlParent))
175 {
176 hr = SHGetDesktopFolder(&lpsfParent);
178 return;
179 }
180 else
181 {
182 CComPtr<IShellFolder> lpsfDesktop;
183 hr = SHGetDesktopFolder(&lpsfDesktop);
185 return;
186
187 hr = lpsfDesktop->BindToObject(pidlParent, NULL, IID_PPV_ARG(IShellFolder, &lpsfParent));
189 return;
190 }
191
192 TreeView_DeleteItem(info->hwndTreeView, TVI_ROOT);
193 hItem = BrFolder_InsertItem(info, lpsfParent, pidlChild, pidlParent, TVI_ROOT);
194 TreeView_Expand(info->hwndTreeView, hItem, TVE_EXPAND);
195}
BOOL WINAPI Shell_GetImageLists(HIMAGELIST *lpBigList, HIMAGELIST *lpSmallList)
Definition: iconcache.cpp:683
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 TreeView_Expand(hwnd, hitem, code)
Definition: commctrl.h:3425
#define TVE_EXPAND
Definition: commctrl.h:3428
#define TVI_ROOT
Definition: commctrl.h:3373
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3452
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3420

Referenced by BrFolder_OnInitDialog().

◆ BrFolder_InsertItem()

static HTREEITEM BrFolder_InsertItem ( _Inout_ BrFolder info,
_Inout_ IShellFolder lpsf,
_In_ PCUITEMID_CHILD  pidlChild,
_In_ PCIDLIST_ABSOLUTE  pidlParent,
_In_ HTREEITEM  hParent 
)
static

Definition at line 339 of file brfolder.cpp.

345{
347 if (!BrFolder_GetName(lpsf, pidlChild, SHGDN_NORMAL, szName))
348 return NULL;
349
350 BrItemData *pItemData = new BrItemData();
351
353 item.pszText = szName;
354 item.cchTextMax = _countof(szName);
355 item.lParam = (LPARAM)pItemData;
356
357 PIDLIST_ABSOLUTE pidlFull =
358 (pidlParent ? ILCombine(pidlParent, pidlChild) : ILClone(pidlChild));
359 BrFolder_GetIconPair(pidlFull, &item);
360
361 pItemData->lpsfParent = lpsf;
362 pItemData->pidlFull.Attach(pidlFull);
363 pItemData->pidlChild = ILFindLastID(pItemData->pidlFull);
364
365 if (BrFolder_GetChildrenEnum(info, pItemData, NULL) == S_OK)
366 item.cChildren = 1;
367
368 TVINSERTSTRUCTW tvins = { hParent };
369 tvins.item = item;
370 return TreeView_InsertItem(info->hwndTreeView, &tvins);
371}
static void BrFolder_GetIconPair(PCIDLIST_ABSOLUTE pidl, LPTVITEMW pItem)
Definition: brfolder.cpp:206
static BOOL BrFolder_GetName(IShellFolder *lpsf, PCIDLIST_RELATIVE pidlChild, DWORD dwFlags, LPWSTR lpFriendlyName)
Definition: brfolder.cpp:240
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:718
static const WCHAR szName[]
Definition: powrprof.c:45
#define TVIF_TEXT
Definition: commctrl.h:3271
#define TVIF_IMAGE
Definition: commctrl.h:3272
#define TVIF_CHILDREN
Definition: commctrl.h:3277
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3417
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3276
#define _countof(array)
Definition: sndvol32.h:70
LONG_PTR LPARAM
Definition: windef.h:208

Referenced by BrFolder_Expand(), BrFolder_InitTreeView(), BrFolder_NewFolder(), and BrFolder_RefreshRecurse().

◆ BrFolder_IsTreeItemInEnum()

static BOOL BrFolder_IsTreeItemInEnum ( _Inout_ BrFolder info,
_In_ HTREEITEM  hItem,
_Inout_ IEnumIDList pEnum 
)
static

Definition at line 258 of file brfolder.cpp.

262{
264 if (!pItemData)
265 return FALSE;
266
267 pEnum->Reset();
268
270 while (pEnum->Next(1, &pidlTemp, NULL) == S_OK)
271 {
272 if (ILIsEqual(pidlTemp, pItemData->pidlChild))
273 return TRUE;
274
275 pidlTemp.Free();
276 }
277
278 return FALSE;
279}
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:548

Referenced by BrFolder_RefreshRecurse().

◆ BrFolder_NewFolder()

static HRESULT BrFolder_NewFolder ( BrFolder info)
static

Definition at line 768 of file brfolder.cpp.

769{
770 CComPtr<IShellFolder> desktop, cur;
771 WCHAR wszNewFolder[25], path[MAX_PATH], name[MAX_PATH];
772
773 HRESULT hr = SHGetDesktopFolder(&desktop);
775 return hr;
776
777 if (info->pidlRet)
778 {
779 hr = desktop->BindToObject(info->pidlRet, NULL, IID_PPV_ARG(IShellFolder, &cur));
781 return hr;
782
783 hr = SHGetPathFromIDListW(info->pidlRet, path);
784 }
785 else
786 {
787 cur = desktop;
789 }
790
792 return hr;
793
794 hr = E_FAIL;
795 if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
796 return hr;
797
798 if (!PathYetAnotherMakeUniqueName(name, path, NULL, wszNewFolder))
799 return hr;
800
801 INT len = lstrlenW(path);
802 if (len < MAX_PATH && name[len] == L'\\')
803 len++;
804
806 return hr;
807
808 // Update parent of newly created directory
809 HTREEITEM hParent = TreeView_GetSelection(info->hwndTreeView);
810 if (!hParent)
811 return hr;
812
813 TreeView_Expand(info->hwndTreeView, hParent, TVE_EXPAND);
814
816 item.hItem = hParent;
817 TreeView_GetItem(info->hwndTreeView, &item);
818 BrItemData *item_data = (BrItemData *)item.lParam;
819 if (!item_data)
820 return hr;
821
822 // Update treeview
823 if (!(item.state & TVIS_EXPANDEDONCE))
824 {
825 item.mask = TVIF_STATE;
826 item.state = item.stateMask = TVIS_EXPANDEDONCE;
827 TreeView_SetItem(info->hwndTreeView, &item);
828 }
829
831 hr = cur->ParseDisplayName(NULL, NULL, name + len, NULL, &pidlNew, NULL);
833 return hr;
834
835 HTREEITEM hAdded = BrFolder_InsertItem(info, cur, pidlNew, item_data->pidlFull, hParent);
836 TreeView_SortChildren(info->hwndTreeView, hParent, FALSE);
837 return BrFolder_Rename(info, hAdded);
838}
#define shell32_hInstance
static HRESULT BrFolder_Rename(BrFolder *info, HTREEITEM hItem)
Definition: brfolder.cpp:564
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:699
#define IDS_NEWFOLDER
FxCollectionEntry * cur
GLenum GLsizei len
Definition: glext.h:6722
if(dx< 0)
Definition: linetemp.h:194
#define L(x)
Definition: ntvdm.h:50
#define TreeView_SortChildren(hwnd, hitem, recurse)
Definition: commctrl.h:3547
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3290
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3478
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3502
#define TVIF_STATE
Definition: commctrl.h:3274
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2188
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2149
Definition: name.c:39
int32_t INT
Definition: typedefs.h:58
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)

Referenced by BrFolder_OnCommand().

◆ BrFolder_OnChange()

static void BrFolder_OnChange ( BrFolder info,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1199 of file brfolder.cpp.

1200{
1201 // We use SHCNRF_NewDelivery method
1202 HANDLE hChange = (HANDLE)wParam;
1203 DWORD dwProcID = (DWORD)lParam;
1204
1205 PIDLIST_ABSOLUTE *ppidl = NULL;
1206 LONG event;
1207 HANDLE hLock = SHChangeNotification_Lock(hChange, dwProcID, &ppidl, &event);
1208 if (hLock == NULL)
1209 {
1210 ERR("hLock == NULL\n");
1211 return;
1212 }
1213
1214 BrFolder_OnChangeEx(info, ppidl[0], ppidl[1], (event & ~SHCNE_INTERRUPT));
1215
1217}
static void BrFolder_OnChangeEx(_Inout_ BrFolder *info, _In_ PCIDLIST_ABSOLUTE pidl0, _In_ PCIDLIST_ABSOLUTE pidl1, _In_ LONG event)
Definition: brfolder.cpp:1169
EXTERN_C HANDLE WINAPI SHChangeNotification_Lock(HANDLE hTicket, DWORD dwOwnerPID, LPITEMIDLIST **lppidls, LPLONG lpwEventId)
EXTERN_C BOOL WINAPI SHChangeNotification_Unlock(HANDLE hLock)
WPARAM wParam
Definition: combotst.c:138
struct _cl_event * event
Definition: glext.h:7739
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define SHCNE_INTERRUPT
Definition: shlobj.h:1915
PVOID HANDLE
Definition: typedefs.h:73

Referenced by BrFolderDlgProc().

◆ BrFolder_OnChangeEx()

static void BrFolder_OnChangeEx ( _Inout_ BrFolder info,
_In_ PCIDLIST_ABSOLUTE  pidl0,
_In_ PCIDLIST_ABSOLUTE  pidl1,
_In_ LONG  event 
)
static

Definition at line 1169 of file brfolder.cpp.

1174{
1175 TRACE("(%p)->(%p, %p, 0x%lX)\n", info, pidl0, pidl1, event);
1176
1177 switch (event)
1178 {
1179 case SHCNE_DRIVEADD:
1180 case SHCNE_MKDIR:
1181 case SHCNE_CREATE:
1182 case SHCNE_DRIVEREMOVED:
1183 case SHCNE_RMDIR:
1184 case SHCNE_DELETE:
1185 case SHCNE_RENAMEFOLDER:
1186 case SHCNE_RENAMEITEM:
1187 case SHCNE_UPDATEDIR:
1188 case SHCNE_UPDATEITEM:
1189 {
1190 // FIXME: Avoid full refresh and optimize for speed. Use pidl0 and pidl1
1192 break;
1193 }
1194 }
1195}
static void BrFolder_Refresh(_Inout_ BrFolder *info)
Definition: brfolder.cpp:1156
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1897
#define SHCNE_RMDIR
Definition: shlobj.h:1894
#define SHCNE_DELETE
Definition: shlobj.h:1892
#define SHCNE_MKDIR
Definition: shlobj.h:1893
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1903
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1890
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1902
#define SHCNE_CREATE
Definition: shlobj.h:1891
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1907
#define SHCNE_DRIVEADD
Definition: shlobj.h:1898

Referenced by BrFolder_OnChange().

◆ BrFolder_OnCommand()

static void BrFolder_OnCommand ( BrFolder info,
UINT  id 
)
static

Definition at line 873 of file brfolder.cpp.

874{
875 switch (id)
876 {
877 case IDOK:
878 {
880 EndDialog(info->hWnd, IDOK);
881 break;
882 }
883 case IDCANCEL:
884 {
885 EndDialog(info->hWnd, IDCANCEL);
886 break;
887 }
889 {
891 break;
892 }
893 }
894}
static HRESULT BrFolder_NewFolder(BrFolder *info)
Definition: brfolder.cpp:768
static void BrFolder_OnOK(BrFolder *info)
Definition: brfolder.cpp:841
#define IDCANCEL
Definition: winuser.h:834
#define IDOK
Definition: winuser.h:833
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by BrFolderDlgProc().

◆ BrFolder_OnContextMenu()

static void BrFolder_OnContextMenu ( BrFolder info,
LPARAM  lParam 
)
static

Definition at line 909 of file brfolder.cpp.

910{
911 enum { IDC_TOGGLE = 1, ID_FIRSTCMD, ID_LASTCMD = 0xffff };
912 HTREEITEM hSelected = TreeView_GetSelection(info.hwndTreeView);
913 CMINVOKECOMMANDINFOEX ici = { sizeof(ici), CMIC_MASK_PTINVOKE, info.hWnd };
914 ici.nShow = SW_SHOW;
915 ici.ptInvoke.x = GET_X_LPARAM(lParam);
916 ici.ptInvoke.y = GET_Y_LPARAM(lParam);
917 if ((int)lParam == -1) // Keyboard
918 {
919 GetTreeViewItemContextMenuPos(info.hwndTreeView, hSelected, &ici.ptInvoke);
920 }
921 else // Get correct item for right-click on not current item
922 {
923 TVHITTESTINFO hti = { ici.ptInvoke };
924 ScreenToClient(info.hwndTreeView, &hti.pt);
925 hSelected = TreeView_HitTest(info.hwndTreeView, &hti);
926 }
928 if (!item)
929 return; // Not on an item
930
931 TV_ITEM tvi;
932 tvi.mask = TVIF_STATE | TVIF_CHILDREN;
933 tvi.stateMask = TVIS_EXPANDED;
934 tvi.hItem = hSelected;
935 TreeView_GetItem(info.hwndTreeView, &tvi);
936
938 HRESULT hr = item->lpsfParent->GetUIObjectOf(info.hWnd, 1, &item->pidlChild,
939 IID_IContextMenu, NULL, (void**)&pcm);
940 if (FAILED(hr))
941 return;
942
943 HMENU hMenu = CreatePopupMenu();
944 if (!hMenu)
945 return;
946 info.pContextMenu = pcm;
947 UINT cmf = ((GetKeyState(VK_SHIFT) < 0) ? CMF_EXTENDEDVERBS : 0) | CMF_CANRENAME;
948 hr = pcm->QueryContextMenu(hMenu, 0, ID_FIRSTCMD, ID_LASTCMD, CMF_EXPLORE | cmf);
949 if (hr > 0)
950 _InsertMenuItemW(hMenu, 0, TRUE, 0, MFT_SEPARATOR, NULL, 0);
951 _InsertMenuItemW(hMenu, 0, TRUE, IDC_TOGGLE, MFT_STRING,
953 MFS_DEFAULT | (tvi.cChildren ? 0 : MFS_GRAYED));
954
955 UINT cmd = TrackPopupMenuEx(hMenu, TPM_RETURNCMD, ici.ptInvoke.x, ici.ptInvoke.y, info.hWnd, NULL);
956 ici.lpVerb = MAKEINTRESOURCEA(cmd - ID_FIRSTCMD);
957 if (cmd == IDC_TOGGLE)
958 {
959 TreeView_SelectItem(info.hwndTreeView, hSelected);
960 TreeView_Expand(info.hwndTreeView, hSelected, TVE_TOGGLE);
961 }
962 else if (cmd != 0 && GetDfmCmd(pcm, ici.lpVerb) == DFM_CMD_RENAME)
963 {
964 BrFolder_Rename(&info, hSelected);
965 }
966 else if (cmd != 0)
967 {
968 if (GetKeyState(VK_SHIFT) < 0)
969 ici.fMask |= CMIC_MASK_SHIFT_DOWN;
970 if (GetKeyState(VK_CONTROL) < 0)
971 ici.fMask |= CMIC_MASK_CONTROL_DOWN;
972 pcm->InvokeCommand((CMINVOKECOMMANDINFO*)&ici);
973 }
974 info.pContextMenu = NULL;
975 DestroyMenu(hMenu);
976}
#define IDS_COLLAPSE
Definition: resource.h:144
#define IDS_EXPAND
Definition: resource.h:143
static void GetTreeViewItemContextMenuPos(HWND hWnd, HTREEITEM hItem, POINT *ppt)
Definition: brfolder.cpp:897
UINT GetDfmCmd(_In_ IContextMenu *pCM, _In_ LPCSTR verba)
Definition: utils.cpp:1376
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
unsigned int UINT
Definition: ndis.h:50
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3486
#define TVE_TOGGLE
Definition: commctrl.h:3429
#define TV_ITEM
Definition: commctrl.h:3305
#define TVIS_EXPANDED
Definition: commctrl.h:3289
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3518
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define DFM_CMD_RENAME
Definition: shlobj.h:2620
Definition: ftp_var.h:139
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
HMENU WINAPI CreatePopupMenu(void)
Definition: menu.c:838
#define VK_CONTROL
Definition: winuser.h:2206
#define MFT_SEPARATOR
Definition: winuser.h:747
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define MFS_DEFAULT
Definition: winuser.h:751
#define MFS_GRAYED
Definition: winuser.h:754
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define VK_SHIFT
Definition: winuser.h:2205
#define MFT_STRING
Definition: winuser.h:749
#define SW_SHOW
Definition: winuser.h:778
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define TPM_RETURNCMD
Definition: winuser.h:2390
SHORT WINAPI GetKeyState(_In_ int)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by BrFolderDlgProc().

◆ BrFolder_OnDestroy()

static void BrFolder_OnDestroy ( BrFolder info)
static

Definition at line 1098 of file brfolder.cpp.

1099{
1100 if (info->layout)
1101 {
1102 LayoutDestroy(info->layout);
1103 info->layout = NULL;
1104 }
1105
1106 SHChangeNotifyDeregister(info->hChangeNotify);
1107}
EXTERN_C BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify)
static __inline void LayoutDestroy(LAYOUT_DATA *pData)
Definition: layout.h:252

Referenced by BrFolderDlgProc().

◆ BrFolder_OnInitDialog()

static BOOL BrFolder_OnInitDialog ( HWND  hWnd,
BrFolder info 
)
static

Definition at line 677 of file brfolder.cpp.

678{
681 LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
682
683 info->hWnd = hWnd;
685
686 if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
687 FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n");
688
689 if (lpBrowseInfo->ulFlags & ~SUPPORTED_FLAGS)
690 FIXME("flags %x not implemented\n", (lpBrowseInfo->ulFlags & ~SUPPORTED_FLAGS));
691
692 info->layout = NULL;
693 if (lpBrowseInfo->ulFlags & BIF_USENEWUI)
694 {
695 RECT rcWnd;
696
697 // Resize the treeview if there's not editbox
698 if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) &&
699 !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
700 {
701 RECT rcEdit, rcTreeView;
704 LONG cy = rcTreeView.top - rcEdit.top;
705 MapWindowPoints(NULL, hWnd, (LPPOINT)&rcTreeView, sizeof(RECT) / sizeof(POINT));
706 rcTreeView.top -= cy;
708 rcTreeView.left, rcTreeView.top,
709 rcTreeView.right - rcTreeView.left,
710 rcTreeView.bottom - rcTreeView.top, TRUE);
711 }
712
713 if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
715
716 // TODO: Windows allows shrinking the windows a bit
717 GetWindowRect(hWnd, &rcWnd);
718 info->szMin.cx = rcWnd.right - rcWnd.left;
719 info->szMin.cy = rcWnd.bottom - rcWnd.top;
720 }
721
722 if (lpBrowseInfo->lpszTitle)
724 else
726
727 if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT) || (lpBrowseInfo->ulFlags & BIF_USENEWUI))
729
730 // Hide "Make New Folder" Button?
731 if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON) ||
732 !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
733 {
735 }
736
737 // Hide the editbox?
738 if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX))
739 {
742 }
743
745 if (info->hwndTreeView)
747 else
748 ERR("treeview control missing!\n");
749
750 // Register for change notifications
751 SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, 0, &pidlDesktop);
752
753 ntreg.pidl = pidlDesktop;
754 ntreg.fRecursive = TRUE;
755 info->hChangeNotify = SHChangeNotifyRegister(hWnd,
758 SHV_CHANGE_NOTIFY, 1, &ntreg);
759
760 BrFolder_Callback(info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0);
761
764 return TRUE;
765}
#define FIXME(fmt,...)
Definition: precomp.h:53
static void BrFolder_Callback(LPBROWSEINFOW lpBrowseInfo, HWND hWnd, UINT uMsg, LPARAM lParam)
Definition: brfolder.cpp:68
static const LAYOUT_INFO g_layout_info[]
Definition: brfolder.cpp:38
#define SHV_CHANGE_NOTIFY
Definition: brfolder.cpp:17
#define SUPPORTED_FLAGS
Definition: brfolder.cpp:49
static void BrFolder_InitTreeView(BrFolder *info)
Definition: brfolder.cpp:144
EXTERN_C ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, INT fSources, LONG wEventMask, UINT uMsg, INT cItems, SHChangeNotifyEntry *lpItems)
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3150
static __inline LAYOUT_DATA * LayoutInit(HWND hwndParent, const LAYOUT_INFO *pLayouts, INT cLayouts)
Definition: layout.h:207
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define BIF_USENEWUI
Definition: shlobj.h:1224
#define SHCNRF_NewDelivery
Definition: shlobj.h:1938
#define SHCNRF_ShellLevel
Definition: shlobj.h:1936
#define CSIDL_DESKTOP
Definition: shlobj.h:2173
#define BFFM_INITIALIZED
Definition: shlobj.h:1236
#define SHCNE_ALLEVENTS
Definition: shlobj.h:1914
#define BIF_EDITBOX
Definition: shlobj.h:1221
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1914
#define SHACF_URLHISTORY
Definition: shlwapi.h:1915
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1919
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:437
#define IDC_BROWSE_FOR_FOLDER_TREEVIEW
Definition: shresdef.h:441
#define IDC_BROWSE_FOR_FOLDER_STATUS
Definition: shresdef.h:439
#define IDC_BROWSE_FOR_FOLDER_TITLE
Definition: shresdef.h:440
#define IDC_BROWSE_FOR_FOLDER_FOLDER
Definition: shresdef.h:438
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1886
LPCWSTR lpszTitle
Definition: shlobj.h:1203
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SW_HIDE
Definition: winuser.h:771
#define DWLP_USER
Definition: winuser.h:875
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SetWindowLongPtrW
Definition: winuser.h:5358
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by BrFolderDlgProc().

◆ BrFolder_OnNotify()

static LRESULT BrFolder_OnNotify ( BrFolder info,
UINT  CtlID,
LPNMHDR  lpnmh 
)
static

Definition at line 631 of file brfolder.cpp.

632{
633 NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
634
635 TRACE("%p %x %p msg=%x\n", info, CtlID, lpnmh, pnmtv->hdr.code);
636
638 return 0;
639
640 switch (pnmtv->hdr.code)
641 {
642 case TVN_DELETEITEMA:
643 case TVN_DELETEITEMW:
644 return BrFolder_Treeview_Delete(info, pnmtv);
645
648 return BrFolder_Treeview_Expand(info, pnmtv);
649
650 case TVN_SELCHANGEDA:
651 case TVN_SELCHANGEDW:
652 return BrFolder_Treeview_Changed(info, pnmtv);
653
656 {
657 NMTVDISPINFO &tvdi = *(NMTVDISPINFO*)lpnmh;
658 UINT att = BrFolder_GetItemAttributes(info, tvdi.item.hItem, SFGAO_CANRENAME);
659 return !(att & SFGAO_CANRENAME);
660 }
661
664
665 case TVN_KEYDOWN:
667
668 default:
669 WARN("unhandled (%d)\n", pnmtv->hdr.code);
670 break;
671 }
672
673 return 0;
674}
#define WARN(fmt,...)
Definition: precomp.h:61
static LRESULT BrFolder_Treeview_Expand(BrFolder *info, NMTREEVIEWW *pnmtv)
Definition: brfolder.cpp:476
static SFGAOF BrFolder_GetItemAttributes(BrFolder *info, HTREEITEM hItem, SFGAOF Att)
Definition: brfolder.cpp:89
static HRESULT BrFolder_Treeview_Changed(BrFolder *info, NMTREEVIEWW *pnmtv)
Definition: brfolder.cpp:510
static LRESULT BrFolder_Treeview_Keydown(BrFolder *info, LPNMTVKEYDOWN keydown)
Definition: brfolder.cpp:599
static LRESULT BrFolder_Treeview_Rename(BrFolder *info, NMTVDISPINFOW *pnmtv)
Definition: brfolder.cpp:527
static LRESULT BrFolder_Treeview_Delete(BrFolder *info, NMTREEVIEWW *pnmtv)
Definition: brfolder.cpp:465
#define TVN_KEYDOWN
Definition: commctrl.h:3718
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3704
#define NMTVDISPINFO
Definition: commctrl.h:3680
#define TVN_BEGINLABELEDITA
Definition: commctrl.h:3714
#define TVN_SELCHANGEDW
Definition: commctrl.h:3653
#define TVN_DELETEITEMA
Definition: commctrl.h:3712
#define TVN_ITEMEXPANDINGW
Definition: commctrl.h:3705
#define TVN_BEGINLABELEDITW
Definition: commctrl.h:3715
#define TVN_SELCHANGEDA
Definition: commctrl.h:3652
#define TVN_ENDLABELEDITW
Definition: commctrl.h:3717
#define TVN_DELETEITEMW
Definition: commctrl.h:3713
UINT_PTR idFrom
Definition: winuser.h:3161
UINT code
Definition: winuser.h:3162

Referenced by BrFolderDlgProc().

◆ BrFolder_OnOK()

static void BrFolder_OnOK ( BrFolder info)
static

Definition at line 841 of file brfolder.cpp.

842{
843 // Get the text
846 StrTrimW(szPath, L" \t");
847
848 // The original pidl is owned by the treeview and will be free'd.
850 info->pidlRet = ILCreateFromPathW(szPath); // It's valid path
851 else
852 info->pidlRet = ILClone(info->pidlRet);
853
854 if (!info->pidlRet) // A null pidl would mean a cancel
855 info->pidlRet = _ILCreateDesktop();
856
857 pdump(info->pidlRet);
858
859 LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
860 if (!lpBrowseInfo->pszDisplayName)
861 return;
862
863 SHFILEINFOW fileInfo = { NULL };
864 lpBrowseInfo->pszDisplayName[0] = UNICODE_NULL;
865 if (SHGetFileInfoW((LPCWSTR)info->pidlRet, 0, &fileInfo, sizeof(fileInfo),
867 {
868 lstrcpynW(lpBrowseInfo->pszDisplayName, fileInfo.szDisplayName, MAX_PATH);
869 }
870}
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:311
#define lstrcpynW
Definition: compat.h:738
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1877
LPCWSTR szPath
Definition: env.c:37
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1003
#define SHGFI_DISPLAYNAME
Definition: shellapi.h:166
WCHAR szDisplayName[MAX_PATH]
Definition: shellapi.h:375
LPWSTR pszDisplayName
Definition: shlobj.h:1202
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263

Referenced by BrFolder_OnCommand().

◆ BrFolder_OnSetExpandedPidl()

static BOOL BrFolder_OnSetExpandedPidl ( BrFolder info,
LPITEMIDLIST  pidlSelection,
HTREEITEM phItem 
)
static

Definition at line 979 of file brfolder.cpp.

980{
981 if (_ILIsDesktop(pidlSelection))
982 {
983 if (phItem)
984 *phItem = TVI_ROOT;
985 return TRUE;
986 }
987
988 // Move pidlCurrent behind the SHITEMIDs in pidlSelection, which are the root of
989 // the sub-tree currently displayed.
990 PCIDLIST_ABSOLUTE pidlRoot = info->lpBrowseInfo->pidlRoot;
991 LPITEMIDLIST pidlCurrent = pidlSelection;
992 while (!_ILIsEmpty(pidlRoot) && _ILIsEqualSimple(pidlRoot, pidlCurrent))
993 {
994 pidlRoot = ILGetNext(pidlRoot);
995 pidlCurrent = ILGetNext(pidlCurrent);
996 }
997
998 // The given ID List is not part of the SHBrowseForFolder's current sub-tree.
999 if (!_ILIsEmpty(pidlRoot))
1000 {
1001 if (phItem)
1002 *phItem = NULL;
1003 return FALSE;
1004 }
1005
1006 // Initialize item to point to the first child of the root folder.
1008 item.hItem = TreeView_GetRoot(info->hwndTreeView);
1009 if (item.hItem)
1010 item.hItem = TreeView_GetChild(info->hwndTreeView, item.hItem);
1011
1012 // Walk the tree along the nodes corresponding to the remaining ITEMIDLIST
1013 while (item.hItem && !_ILIsEmpty(pidlCurrent))
1014 {
1015 TreeView_GetItem(info->hwndTreeView, &item);
1016 BrItemData *pItemData = (BrItemData *)item.lParam;
1017
1018 if (_ILIsEqualSimple(pItemData->pidlChild, pidlCurrent))
1019 {
1020 pidlCurrent = ILGetNext(pidlCurrent);
1021 if (!_ILIsEmpty(pidlCurrent))
1022 {
1023 // Only expand current node and move on to its first child,
1024 // if we didn't already reach the last SHITEMID
1025 TreeView_Expand(info->hwndTreeView, item.hItem, TVE_EXPAND);
1026 item.hItem = TreeView_GetChild(info->hwndTreeView, item.hItem);
1027 }
1028 }
1029 else
1030 {
1031 item.hItem = TreeView_GetNextSibling(info->hwndTreeView, item.hItem);
1032 }
1033 }
1034
1035 if (phItem)
1036 *phItem = item.hItem;
1037
1038 return (_ILIsEmpty(pidlCurrent) && item.hItem);
1039}
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:872
static BOOL _ILIsEqualSimple(LPCITEMIDLIST pidlA, LPCITEMIDLIST pidlB)
Definition: pidl.h:261
static BOOL _ILIsEmpty(LPCITEMIDLIST pidl)
Definition: pidl.h:267
#define TreeView_GetChild(hwnd, hitem)
Definition: commctrl.h:3471
#define TreeView_GetRoot(hwnd)
Definition: commctrl.h:3480
#define TreeView_GetNextSibling(hwnd, hitem)
Definition: commctrl.h:3472
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by BrFolder_OnSetExpandedString(), BrFolder_OnSetSelectionPidl(), and BrFolderDlgProc().

◆ BrFolder_OnSetExpandedString()

static BOOL BrFolder_OnSetExpandedString ( BrFolder info,
LPWSTR  pszString,
HTREEITEM phItem 
)
static

Definition at line 1042 of file brfolder.cpp.

1043{
1044 CComPtr<IShellFolder> psfDesktop;
1045 HRESULT hr = SHGetDesktopFolder(&psfDesktop);
1047 return FALSE;
1048
1050 hr = psfDesktop->ParseDisplayName(NULL, NULL, pszString, NULL, &pidlSelection, NULL);
1052 return FALSE;
1053
1054 return BrFolder_OnSetExpandedPidl(info, pidlSelection, phItem);
1055}
static BOOL BrFolder_OnSetExpandedPidl(BrFolder *info, LPITEMIDLIST pidlSelection, HTREEITEM *phItem)
Definition: brfolder.cpp:979
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505

Referenced by BrFolder_OnSetSelectionW(), and BrFolderDlgProc().

◆ BrFolder_OnSetSelectionA()

static BOOL BrFolder_OnSetSelectionA ( BrFolder info,
LPSTR  pszSelectionA 
)
static

Definition at line 1084 of file brfolder.cpp.

1085{
1086 if (!pszSelectionA)
1087 return FALSE;
1088
1089 CComHeapPtr<WCHAR> pszSelectionW;
1090 __SHCloneStrAtoW(&pszSelectionW, pszSelectionA);
1091 if (!pszSelectionW)
1092 return FALSE;
1093
1094 return BrFolder_OnSetSelectionW(info, pszSelectionW);
1095}
static BOOL BrFolder_OnSetSelectionW(BrFolder *info, LPWSTR pszSelection)
Definition: brfolder.cpp:1071
static __inline LPWSTR __SHCloneStrAtoW(WCHAR **target, const char *source)
Definition: shell32_main.h:168

Referenced by BrFolderDlgProc().

◆ BrFolder_OnSetSelectionPidl()

static BOOL BrFolder_OnSetSelectionPidl ( BrFolder info,
LPITEMIDLIST  pidlSelection 
)
static

Definition at line 1058 of file brfolder.cpp.

1059{
1060 if (!pidlSelection)
1061 return FALSE;
1062
1064 BOOL ret = BrFolder_OnSetExpandedPidl(info, pidlSelection, &hItem);
1065 if (ret)
1066 TreeView_SelectItem(info->hwndTreeView, hItem);
1067 return ret;
1068}
int ret

Referenced by BrFolderDlgProc().

◆ BrFolder_OnSetSelectionW()

static BOOL BrFolder_OnSetSelectionW ( BrFolder info,
LPWSTR  pszSelection 
)
static

Definition at line 1071 of file brfolder.cpp.

1072{
1073 if (!pszSelection)
1074 return FALSE;
1075
1077 BOOL ret = BrFolder_OnSetExpandedString(info, pszSelection, &hItem);
1078 if (ret)
1079 TreeView_SelectItem(info->hwndTreeView, hItem);
1080 return ret;
1081}
static BOOL BrFolder_OnSetExpandedString(BrFolder *info, LPWSTR pszString, HTREEITEM *phItem)
Definition: brfolder.cpp:1042

Referenced by BrFolder_OnSetSelectionA(), and BrFolderDlgProc().

◆ BrFolder_Refresh()

static void BrFolder_Refresh ( _Inout_ BrFolder info)
static

Definition at line 1156 of file brfolder.cpp.

1157{
1158 HTREEITEM hRoot = TreeView_GetRoot(info->hwndTreeView);
1159
1160 SendMessageW(info->hwndTreeView, WM_SETREDRAW, FALSE, 0);
1161
1163
1164 SendMessageW(info->hwndTreeView, WM_SETREDRAW, TRUE, 0);
1165 InvalidateRect(info->hwndTreeView, NULL, TRUE);
1166}
static void BrFolder_RefreshRecurse(_Inout_ BrFolder *info, _In_ HTREEITEM hTarget)
Definition: brfolder.cpp:1110
static HTREEITEM hRoot
Definition: treeview.c:383
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define WM_SETREDRAW
Definition: winuser.h:1619

Referenced by BrFolder_OnChangeEx(), and BrFolder_Treeview_Keydown().

◆ BrFolder_RefreshRecurse()

static void BrFolder_RefreshRecurse ( _Inout_ BrFolder info,
_In_ HTREEITEM  hTarget 
)
static

Definition at line 1110 of file brfolder.cpp.

1113{
1114 // Get enum
1116 BrItemData *pItemData = BrFolder_GetItemData(info, hTarget);
1117 HRESULT hrEnum = BrFolder_GetChildrenEnum(info, pItemData, &pEnum);
1118
1119 // Insert new items
1120 if (SUCCEEDED(hrEnum))
1121 {
1123 while (S_OK == pEnum->Next(1, &pidlTemp, NULL))
1124 {
1125 if (!BrFolder_TreeItemHasThisChild(info, hTarget, pidlTemp))
1126 {
1127 BrFolder_InsertItem(info, pItemData->lpsfParent, pidlTemp, pItemData->pidlFull,
1128 hTarget);
1129 }
1130 pidlTemp.Free();
1131 }
1132 }
1133
1134 // Delete zombie items and update items
1135 HTREEITEM hItem, hNextItem;
1136 for (hItem = TreeView_GetChild(info->hwndTreeView, hTarget); hItem; hItem = hNextItem)
1137 {
1138 hNextItem = TreeView_GetNextSibling(info->hwndTreeView, hItem);
1139
1140 if (FAILED(hrEnum) || !BrFolder_IsTreeItemInEnum(info, hItem, pEnum))
1141 {
1142 TreeView_DeleteItem(info->hwndTreeView, hItem);
1143 hNextItem = TreeView_GetChild(info->hwndTreeView, hTarget);
1144 continue;
1145 }
1146
1149 }
1150
1151 if (SUCCEEDED(hrEnum))
1152 TreeView_SortChildren(info->hwndTreeView, hTarget, FALSE);
1153}
static BOOL BrFolder_IsTreeItemInEnum(_Inout_ BrFolder *info, _In_ HTREEITEM hItem, _Inout_ IEnumIDList *pEnum)
Definition: brfolder.cpp:258
static void BrFolder_UpdateItem(_In_ BrFolder *info, _In_ HTREEITEM hItem)
Definition: brfolder.cpp:299
static BOOL BrFolder_TreeItemHasThisChild(_In_ BrFolder *info, _In_ HTREEITEM hItem, _Outptr_opt_ PITEMID_CHILD pidlChild)
Definition: brfolder.cpp:282

Referenced by BrFolder_Refresh(), and BrFolder_RefreshRecurse().

◆ BrFolder_Rename()

static HRESULT BrFolder_Rename ( BrFolder info,
HTREEITEM  hItem 
)
static

Definition at line 564 of file brfolder.cpp.

565{
566 TreeView_SelectItem(info->hwndTreeView, hItem);
567 TreeView_EditLabel(info->hwndTreeView, hItem);
568 return S_OK;
569}
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3509

Referenced by BrFolder_NewFolder(), BrFolder_OnContextMenu(), and BrFolder_Treeview_Keydown().

◆ BrFolder_TreeItemHasThisChild()

static BOOL BrFolder_TreeItemHasThisChild ( _In_ BrFolder info,
_In_ HTREEITEM  hItem,
_Outptr_opt_ PITEMID_CHILD  pidlChild 
)
static

Definition at line 282 of file brfolder.cpp.

286{
287 for (hItem = TreeView_GetChild(info->hwndTreeView, hItem); hItem;
288 hItem = TreeView_GetNextSibling(info->hwndTreeView, hItem))
289 {
291 if (ILIsEqual(pItemData->pidlChild, pidlChild))
292 return TRUE;
293 }
294
295 return FALSE;
296}

Referenced by BrFolder_RefreshRecurse().

◆ BrFolder_Treeview_Changed()

static HRESULT BrFolder_Treeview_Changed ( BrFolder info,
NMTREEVIEWW pnmtv 
)
static

Definition at line 510 of file brfolder.cpp.

511{
512 BrItemData *pItemData = (BrItemData *)pnmtv->itemNew.lParam;
513
514 ILFree(info->pidlRet);
515 info->pidlRet = ILClone(pItemData->pidlFull);
516
518 if (BrFolder_GetName(pItemData->lpsfParent, pItemData->pidlChild, SHGDN_NORMAL, szName))
520
521 BrFolder_Callback(info->lpBrowseInfo, info->hWnd, BFFM_SELCHANGED, (LPARAM)info->pidlRet);
523 return S_OK;
524}
static void BrFolder_CheckValidSelection(BrFolder *info, BrItemData *pItemData)
Definition: brfolder.cpp:428
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:946
#define BFFM_SELCHANGED
Definition: shlobj.h:1237
TVITEMW itemNew
Definition: commctrl.h:3643
LPARAM lParam
Definition: commctrl.h:3330

Referenced by BrFolder_OnNotify(), and BrFolder_Treeview_Rename().

◆ BrFolder_Treeview_Delete()

static LRESULT BrFolder_Treeview_Delete ( BrFolder info,
NMTREEVIEWW pnmtv 
)
static

Definition at line 465 of file brfolder.cpp.

466{
467 BrItemData *pItemData = (BrItemData *)pnmtv->itemOld.lParam;
468
469 TRACE("TVN_DELETEITEMA/W %p\n", pItemData);
470
471 delete pItemData;
472 return 0;
473}
TVITEMW itemOld
Definition: commctrl.h:3642

Referenced by BrFolder_OnNotify().

◆ BrFolder_Treeview_Expand()

static LRESULT BrFolder_Treeview_Expand ( BrFolder info,
NMTREEVIEWW pnmtv 
)
static

Definition at line 476 of file brfolder.cpp.

477{
478 BrItemData *pItemData = (BrItemData *)pnmtv->itemNew.lParam;
479
480 TRACE("TVN_ITEMEXPANDINGA/W\n");
481
482 if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
483 return 0;
484
485 HRESULT hr = S_OK;
487 if (!_ILIsEmpty(pItemData->pidlChild))
488 {
489 hr = pItemData->lpsfParent->BindToObject(pItemData->pidlChild, NULL,
490 IID_PPV_ARG(IShellFolder, &lpsf2));
491 }
492 else
493 {
494 lpsf2 = pItemData->lpsfParent;
495 }
496
497 HTREEITEM hItem = pnmtv->itemNew.hItem;
499 BrFolder_Expand(info, lpsf2, pItemData->pidlFull, hItem);
500
501 // My Computer is already sorted and trying to do a simple text
502 // sort will only mess things up
503 if (!_ILIsMyComputer(pItemData->pidlChild))
504 TreeView_SortChildren(info->hwndTreeView, hItem, FALSE);
505
506 return 0;
507}
static void BrFolder_Expand(_In_ BrFolder *info, _In_ IShellFolder *lpsf, _In_ PCIDLIST_ABSOLUTE pidlFull, _In_ HTREEITEM hParent)
Definition: brfolder.cpp:387
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1976
HTREEITEM hItem
Definition: commctrl.h:3322
UINT state
Definition: commctrl.h:3323

Referenced by BrFolder_OnNotify().

◆ BrFolder_Treeview_Keydown()

static LRESULT BrFolder_Treeview_Keydown ( BrFolder info,
LPNMTVKEYDOWN  keydown 
)
static

Definition at line 599 of file brfolder.cpp.

600{
601 // Old dialog doesn't support those advanced features
602 if (!(info->lpBrowseInfo->ulFlags & BIF_USENEWUI))
603 return 0;
604
605 HTREEITEM hItem = TreeView_GetSelection(info->hwndTreeView);
606
607 switch (keydown->wVKey)
608 {
609 case VK_F2:
611 break;
612 case VK_DELETE:
614 break;
615 case 'R':
616 {
617 if (GetKeyState(VK_CONTROL) < 0) // Ctrl+R
619 break;
620 }
621 case VK_F5:
622 {
624 break;
625 }
626 }
627 return 0;
628}
static void BrFolder_Delete(BrFolder *info, HTREEITEM hItem)
Definition: brfolder.cpp:572
#define VK_F5
Definition: winuser.h:2262
#define VK_DELETE
Definition: winuser.h:2236
#define VK_F2
Definition: winuser.h:2259

Referenced by BrFolder_OnNotify().

◆ BrFolder_Treeview_Rename()

static LRESULT BrFolder_Treeview_Rename ( BrFolder info,
NMTVDISPINFOW pnmtv 
)
static

Definition at line 527 of file brfolder.cpp.

528{
529 if (!pnmtv->item.pszText)
530 return FALSE;
531
532 HTREEITEM hItem = TreeView_GetSelection(info->hwndTreeView);
534 ASSERT(data);
535 ASSERT(BrFolder_GetItemAttributes(info, hItem, SFGAO_CANRENAME) & SFGAO_CANRENAME);
536
537 PITEMID_CHILD newChild;
538 HRESULT hr = data->lpsfParent->SetNameOf(info->hWnd, data->pidlChild,
539 pnmtv->item.pszText, SHGDN_NORMAL, &newChild);
540 if (FAILED(hr))
541 return FALSE;
542
543 LPITEMIDLIST newFull;
544 if (SUCCEEDED(hr = SHILClone(data->pidlFull, &newFull)))
545 {
546 ILRemoveLastID(newFull);
547 if (SUCCEEDED(hr = SHILAppend(newChild, &newFull)))
548 {
549 data->pidlFull.Free();
550 data->pidlFull.Attach(newFull);
551 data->pidlChild = ILFindLastID(data->pidlFull);
552 }
553 newChild = NULL; // SHILAppend is nuts and frees this
554 }
555 ILFree(newChild);
556
557 NMTREEVIEWW nmtv;
558 nmtv.itemNew.lParam = (LPARAM)data;
560 return TRUE;
561}
HRESULT SHILAppend(_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:73
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:13
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ASSERT(a)
Definition: mode.c:44
TVITEMW item
Definition: commctrl.h:3677
LPWSTR pszText
Definition: commctrl.h:3325

Referenced by BrFolder_OnNotify().

◆ BrFolder_UpdateItem()

static void BrFolder_UpdateItem ( _In_ BrFolder info,
_In_ HTREEITEM  hItem 
)
static

Definition at line 299 of file brfolder.cpp.

302{
304 if (!pItemData)
305 return;
306
308 item.hItem = hItem;
309
310 BrFolder_GetIconPair(pItemData->pidlFull, &item);
311
312 item.cChildren = 0;
314 if (BrFolder_GetChildrenEnum(info, pItemData, &pEnum) == S_OK)
315 {
317 if (pEnum->Next(1, &pidlTemp, NULL) == S_OK)
318 ++item.cChildren;
319 }
320
321 TreeView_SetItem(info->hwndTreeView, &item);
322}

Referenced by BrFolder_RefreshRecurse().

◆ BrFolderDlgProc()

static INT_PTR CALLBACK BrFolderDlgProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1223 of file brfolder.cpp.

1224{
1225 if (uMsg == WM_INITDIALOG)
1227
1229 if (!info)
1230 return 0;
1231
1232 if (info->pContextMenu)
1233 {
1235 if (SHForwardContextMenuMsg(info->pContextMenu, uMsg, wParam,
1236 lParam, &result, TRUE) == S_OK)
1237 {
1239 return TRUE;
1240 }
1241 }
1242
1243 switch (uMsg)
1244 {
1245 case WM_NOTIFY:
1247 return TRUE;
1248
1249 case WM_COMMAND:
1251 break;
1252
1253 case WM_CONTEXTMENU:
1254 if (info->hwndTreeView == (HWND)wParam)
1256 break;
1257
1258 case WM_GETMINMAXINFO:
1259 ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = info->szMin.cx;
1260 ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = info->szMin.cy;
1261 break;
1262
1263 case WM_SIZE:
1264 if (info->layout) // New style dialogs
1266 break;
1267
1270 break;
1271
1274 break;
1275
1276 case BFFM_ENABLEOK:
1278 break;
1279
1280 case BFFM_SETOKTEXT: // Unicode only
1282 break;
1283
1284 case BFFM_SETSELECTIONA:
1285 if (wParam) // String
1287 else // PIDL
1289
1290 case BFFM_SETSELECTIONW:
1291 if (wParam) // String
1293 else // PIDL
1295
1296 case BFFM_SETEXPANDED: // Unicode only
1297 if (wParam) // String
1299 else // PIDL
1301
1302 case SHV_CHANGE_NOTIFY:
1304 break;
1305
1306 case WM_DESTROY:
1308 break;
1309 }
1310
1311 return 0;
1312}
static void BrFolder_OnContextMenu(BrFolder &info, LPARAM lParam)
Definition: brfolder.cpp:909
static void BrFolder_OnChange(BrFolder *info, WPARAM wParam, LPARAM lParam)
Definition: brfolder.cpp:1199
static BOOL BrFolder_OnSetSelectionPidl(BrFolder *info, LPITEMIDLIST pidlSelection)
Definition: brfolder.cpp:1058
static LRESULT BrFolder_OnNotify(BrFolder *info, UINT CtlID, LPNMHDR lpnmh)
Definition: brfolder.cpp:631
static BOOL BrFolder_OnSetSelectionA(BrFolder *info, LPSTR pszSelectionA)
Definition: brfolder.cpp:1084
static BOOL BrFolder_OnInitDialog(HWND hWnd, BrFolder *info)
Definition: brfolder.cpp:677
static void BrFolder_OnCommand(BrFolder *info, UINT id)
Definition: brfolder.cpp:873
static void BrFolder_OnDestroy(BrFolder *info)
Definition: brfolder.cpp:1098
GLuint64EXT * result
Definition: glext.h:11304
static __inline void LayoutUpdate(HWND ignored1, LAYOUT_DATA *pData, LPCVOID ignored2, UINT ignored3)
Definition: layout.h:188
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define WM_NOTIFY
Definition: richedit.h:61
HRESULT WINAPI SHForwardContextMenuMsg(IUnknown *pUnk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult, BOOL useIContextMenu2)
Definition: rosordinal.c:11
#define BFFM_SETOKTEXT
Definition: shlobj.h:1248
#define BFFM_SETEXPANDED
Definition: shlobj.h:1249
#define BFFM_SETSELECTIONW
Definition: shlobj.h:1246
#define BFFM_SETSTATUSTEXTW
Definition: shlobj.h:1247
#define BFFM_SETSTATUSTEXTA
Definition: shlobj.h:1243
#define BFFM_SETSELECTIONA
Definition: shlobj.h:1245
#define SetWindowLongPtr
Definition: treelist.c:70
LONG_PTR LRESULT
Definition: windef.h:209
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define WM_SIZE
Definition: winuser.h:1614
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_GETMINMAXINFO
Definition: winuser.h:1643
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define DWLP_MSGRESULT
Definition: winuser.h:873
struct tagMINMAXINFO * LPMINMAXINFO
#define WM_DESTROY
Definition: winuser.h:1612
char * LPSTR
Definition: xmlstorage.h:182

Referenced by SHBrowseForFolderW().

◆ BrowseFlagsToSHCONTF()

static DWORD BrowseFlagsToSHCONTF ( UINT  ulFlags)
inlinestatic

Definition at line 62 of file brfolder.cpp.

63{
64 return SHCONTF_FOLDERS | ((ulFlags & BIF_BROWSEINCLUDEFILES) ? SHCONTF_NONFOLDERS : 0);
65}

Referenced by BrFolder_GetChildrenEnum().

◆ GetTreeViewItemContextMenuPos()

static void GetTreeViewItemContextMenuPos ( HWND  hWnd,
HTREEITEM  hItem,
POINT ppt 
)
static

Definition at line 897 of file brfolder.cpp.

898{
899 RECT rc;
901 {
902 ppt->x = (rc.left + rc.right) / 2;
903 ppt->y = (rc.top + rc.bottom) / 2;
904 }
905 ClientToScreen(hWnd, ppt);
906}
#define TreeView_GetItemRect(hwnd, hitem, prc, code)
Definition: commctrl.h:3434
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)

Referenced by BrFolder_OnContextMenu().

◆ PIDLIsType()

static BOOL PIDLIsType ( LPCITEMIDLIST  pidl,
PIDLTYPE  type 
)
inlinestatic

Definition at line 419 of file brfolder.cpp.

420{
422 if (!data)
423 return FALSE;
424 return (data->type == type);
425}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2160

Referenced by BrFolder_CheckValidSelection().

◆ SHBrowseForFolderA()

EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderA ( LPBROWSEINFOA  lpbi)

Definition at line 1320 of file brfolder.cpp.

1321{
1322 BROWSEINFOW bi;
1323 bi.hwndOwner = lpbi->hwndOwner;
1324 bi.pidlRoot = lpbi->pidlRoot;
1325
1327 bi.pszDisplayName = (lpbi->pszDisplayName ? szName : NULL);
1328
1329 CComHeapPtr<WCHAR> pszTitle;
1330 if (lpbi->lpszTitle)
1331 __SHCloneStrAtoW(&pszTitle, lpbi->lpszTitle);
1332 bi.lpszTitle = pszTitle;
1333
1334 bi.ulFlags = lpbi->ulFlags;
1335 bi.lpfn = lpbi->lpfn;
1336 bi.lParam = lpbi->lParam;
1337 bi.iImage = lpbi->iImage;
1339
1340 if (bi.pszDisplayName)
1342
1343 lpbi->iImage = bi.iImage;
1344 return pidl;
1345}
EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brfolder.cpp:1352
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2791
LPCSTR lpszTitle
Definition: shlobj.h:1192
PCIDLIST_ABSOLUTE pidlRoot
Definition: shlobj.h:1190
BFFCALLBACK lpfn
Definition: shlobj.h:1194
HWND hwndOwner
Definition: shlobj.h:1189
LPSTR pszDisplayName
Definition: shlobj.h:1191
UINT ulFlags
Definition: shlobj.h:1193
LPARAM lParam
Definition: shlobj.h:1195
PCIDLIST_ABSOLUTE pidlRoot
Definition: shlobj.h:1201
HWND hwndOwner
Definition: shlobj.h:1200

Referenced by test_click_make_new_folder_button(), and test_selection().

◆ SHBrowseForFolderW()

EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderW ( LPBROWSEINFOW  lpbi)

Definition at line 1352 of file brfolder.cpp.

1353{
1354 TRACE("%p\n", lpbi);
1355
1356 BrFolder info = { lpbi };
1357
1359
1363 if (SUCCEEDED(hr))
1365
1366 if (ret != IDOK)
1367 {
1368 ILFree(info.pidlRet);
1369 return NULL;
1370 }
1371
1372 return info.pidlRet;
1373}
static INT_PTR CALLBACK BrFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: brfolder.cpp:1223
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
#define IDD_BROWSE_FOR_FOLDER_NEW
Definition: shresdef.h:435
#define IDD_BROWSE_FOR_FOLDER
Definition: shresdef.h:434
int32_t INT_PTR
Definition: typedefs.h:64
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by CBandSiteMenu::_CreateNewISFBand(), BtrfsSend::AddClone(), CShellDispatch::BrowseForFolder(), BtrfsSend::BrowseParent(), ChooseFolder(), CHSourceDlgProc(), FileExtractDialogWndProc(), CZipExtract::CExtractSettingsPage::OnBrowse(), SHBrowseForFolderA(), SHBrowseForFolderWrapW(), and WelcomeDlgProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )

Variable Documentation

◆ g_layout_info