ReactOS 0.4.15-dev-8222-g9164419
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:438
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: debug.h:113
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:1342
#define FOF_ALLOWUNDO
Definition: shellapi.h:147
#define FO_DELETE
Definition: shellapi.h:138
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1987
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:2136
#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:415
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:1635
#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:3322
int iSelectedImage
Definition: commctrl.h:3323

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:3490
#define TVIF_HANDLE
Definition: commctrl.h:3270
#define TVIF_PARAM
Definition: commctrl.h:3268
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:433
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:3420
#define TVE_EXPAND
Definition: commctrl.h:3423
#define TVI_ROOT
Definition: commctrl.h:3368
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
#define TreeView_DeleteItem(hwnd, hitem)
Definition: commctrl.h:3415

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:712
static const WCHAR szName[]
Definition: powrprof.c:45
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define TVIF_CHILDREN
Definition: commctrl.h:3272
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#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:3542
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3285
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_SetItem(hwnd, pitem)
Definition: commctrl.h:3497
#define TVIF_STATE
Definition: commctrl.h:3269
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2181
@ SHGFP_TYPE_CURRENT
Definition: shlobj.h:2142
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 1200 of file brfolder.cpp.

1201{
1202 // We use SHCNRF_NewDelivery method
1203 HANDLE hChange = (HANDLE)wParam;
1204 DWORD dwProcID = (DWORD)lParam;
1205
1206 PIDLIST_ABSOLUTE *ppidl = NULL;
1207 LONG event;
1208 HANDLE hLock = SHChangeNotification_Lock(hChange, dwProcID, &ppidl, &event);
1209 if (hLock == NULL)
1210 {
1211 ERR("hLock == NULL\n");
1212 return;
1213 }
1214
1215 BrFolder_OnChangeEx(info, ppidl[0], ppidl[1], (event & ~SHCNE_INTERRUPT));
1216
1218}
static void BrFolder_OnChangeEx(_Inout_ BrFolder *info, _In_ PCIDLIST_ABSOLUTE pidl0, _In_ PCIDLIST_ABSOLUTE pidl1, _In_ LONG event)
Definition: brfolder.cpp:1170
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:1908
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 1170 of file brfolder.cpp.

1175{
1176 TRACE("(%p)->(%p, %p, 0x%lX)\n", info, pidl0, pidl1, event);
1177
1178 switch (event)
1179 {
1180 case SHCNE_DRIVEADD:
1181 case SHCNE_MKDIR:
1182 case SHCNE_CREATE:
1183 case SHCNE_DRIVEREMOVED:
1184 case SHCNE_RMDIR:
1185 case SHCNE_DELETE:
1186 case SHCNE_RENAMEFOLDER:
1187 case SHCNE_RENAMEITEM:
1188 case SHCNE_UPDATEDIR:
1189 case SHCNE_UPDATEITEM:
1190 {
1191 // FIXME: Avoid full refresh and optimize for speed. Use pidl0 and pidl1
1193 break;
1194 }
1195 }
1196}
static void BrFolder_Refresh(_Inout_ BrFolder *info)
Definition: brfolder.cpp:1157
#define SHCNE_DRIVEREMOVED
Definition: shlobj.h:1890
#define SHCNE_RMDIR
Definition: shlobj.h:1887
#define SHCNE_DELETE
Definition: shlobj.h:1885
#define SHCNE_MKDIR
Definition: shlobj.h:1886
#define SHCNE_UPDATEITEM
Definition: shlobj.h:1896
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1883
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1895
#define SHCNE_CREATE
Definition: shlobj.h:1884
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1900
#define SHCNE_DRIVEADD
Definition: shlobj.h:1891

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:831
#define IDOK
Definition: winuser.h:830
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_NODEFAULT | 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 TreeView_SelectItem(info.hwndTreeView, hSelected);
965 TreeView_EditLabel(info.hwndTreeView, hSelected);
966 }
967 else if (cmd != 0)
968 {
969 if (GetKeyState(VK_SHIFT) < 0)
970 ici.fMask |= CMIC_MASK_SHIFT_DOWN;
971 if (GetKeyState(VK_CONTROL) < 0)
972 ici.fMask |= CMIC_MASK_CONTROL_DOWN;
973 pcm->InvokeCommand((CMINVOKECOMMANDINFO*)&ici);
974 }
975 info.pContextMenu = NULL;
976 DestroyMenu(hMenu);
977}
#define IDS_COLLAPSE
Definition: resource.h:191
#define IDS_EXPAND
Definition: resource.h:190
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:3481
#define TVE_TOGGLE
Definition: commctrl.h:3424
#define TV_ITEM
Definition: commctrl.h:3300
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define TreeView_EditLabel(hwnd, hitem)
Definition: commctrl.h:3504
#define TreeView_HitTest(hwnd, lpht)
Definition: commctrl.h:3513
void WINAPI _InsertMenuItemW(HMENU hmenu, UINT indexMenu, BOOL fByPosition, UINT wID, UINT fType, LPCWSTR dwTypeData, UINT fState)
#define DFM_CMD_RENAME
Definition: shlobj.h:2613
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:2203
#define MFT_SEPARATOR
Definition: winuser.h:744
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
#define MFS_DEFAULT
Definition: winuser.h:748
#define MFS_GRAYED
Definition: winuser.h:751
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
BOOL WINAPI DestroyMenu(_In_ HMENU)
#define VK_SHIFT
Definition: winuser.h:2202
#define MFT_STRING
Definition: winuser.h:746
#define SW_SHOW
Definition: winuser.h:775
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define TPM_RETURNCMD
Definition: winuser.h:2387
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 1099 of file brfolder.cpp.

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

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;
684 SetPropW(hWnd, L"__WINE_BRSFOLDERDLG_INFO", info);
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: debug.h:114
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:206
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
#define BIF_USENEWUI
Definition: shlobj.h:1224
#define SHCNRF_NewDelivery
Definition: shlobj.h:1931
#define SHCNRF_ShellLevel
Definition: shlobj.h:1929
#define CSIDL_DESKTOP
Definition: shlobj.h:2166
#define BFFM_INITIALIZED
Definition: shlobj.h:1236
#define SHCNE_ALLEVENTS
Definition: shlobj.h:1907
#define BIF_EDITBOX
Definition: shlobj.h:1221
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1912
#define SHACF_URLHISTORY
Definition: shlwapi.h:1913
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1917
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:439
#define IDC_BROWSE_FOR_FOLDER_TREEVIEW
Definition: shresdef.h:443
#define IDC_BROWSE_FOR_FOLDER_STATUS
Definition: shresdef.h:441
#define IDC_BROWSE_FOR_FOLDER_TITLE
Definition: shresdef.h:442
#define IDC_BROWSE_FOR_FOLDER_FOLDER
Definition: shresdef.h:440
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1879
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:768
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)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
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: debug.h:115
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:3713
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3699
#define NMTVDISPINFO
Definition: commctrl.h:3675
#define TVN_BEGINLABELEDITA
Definition: commctrl.h:3709
#define TVN_SELCHANGEDW
Definition: commctrl.h:3648
#define TVN_DELETEITEMA
Definition: commctrl.h:3707
#define TVN_ITEMEXPANDINGW
Definition: commctrl.h:3700
#define TVN_BEGINLABELEDITW
Definition: commctrl.h:3710
#define TVN_SELCHANGEDA
Definition: commctrl.h:3647
#define TVN_ENDLABELEDITW
Definition: commctrl.h:3712
#define TVN_DELETEITEMW
Definition: commctrl.h:3708
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159

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:997
#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 980 of file brfolder.cpp.

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

1044{
1045 CComPtr<IShellFolder> psfDesktop;
1046 HRESULT hr = SHGetDesktopFolder(&psfDesktop);
1048 return FALSE;
1049
1051 hr = psfDesktop->ParseDisplayName(NULL, NULL, pszString, NULL, &pidlSelection, NULL);
1053 return FALSE;
1054
1055 return BrFolder_OnSetExpandedPidl(info, pidlSelection, phItem);
1056}
static BOOL BrFolder_OnSetExpandedPidl(BrFolder *info, LPITEMIDLIST pidlSelection, HTREEITEM *phItem)
Definition: brfolder.cpp:980
_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 1085 of file brfolder.cpp.

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

Referenced by BrFolderDlgProc().

◆ BrFolder_OnSetSelectionPidl()

static BOOL BrFolder_OnSetSelectionPidl ( BrFolder info,
LPITEMIDLIST  pidlSelection 
)
static

Definition at line 1059 of file brfolder.cpp.

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

Referenced by BrFolderDlgProc().

◆ BrFolder_OnSetSelectionW()

static BOOL BrFolder_OnSetSelectionW ( BrFolder info,
LPWSTR  pszSelection 
)
static

Definition at line 1072 of file brfolder.cpp.

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

Referenced by BrFolder_OnSetSelectionA(), and BrFolderDlgProc().

◆ BrFolder_Refresh()

static void BrFolder_Refresh ( _Inout_ BrFolder info)
static

Definition at line 1157 of file brfolder.cpp.

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

Referenced by BrFolder_OnChangeEx(), and BrFolder_Treeview_Keydown().

◆ BrFolder_RefreshRecurse()

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

Definition at line 1111 of file brfolder.cpp.

1114{
1115 // Get enum
1117 BrItemData *pItemData = BrFolder_GetItemData(info, hTarget);
1118 HRESULT hrEnum = BrFolder_GetChildrenEnum(info, pItemData, &pEnum);
1119
1120 // Insert new items
1121 if (SUCCEEDED(hrEnum))
1122 {
1124 while (S_OK == pEnum->Next(1, &pidlTemp, NULL))
1125 {
1126 if (!BrFolder_TreeItemHasThisChild(info, hTarget, pidlTemp))
1127 {
1128 BrFolder_InsertItem(info, pItemData->lpsfParent, pidlTemp, pItemData->pidlFull,
1129 hTarget);
1130 }
1131 pidlTemp.Free();
1132 }
1133 }
1134
1135 // Delete zombie items and update items
1136 HTREEITEM hItem, hNextItem;
1137 for (hItem = TreeView_GetChild(info->hwndTreeView, hTarget); hItem; hItem = hNextItem)
1138 {
1139 hNextItem = TreeView_GetNextSibling(info->hwndTreeView, hItem);
1140
1141 if (FAILED(hrEnum) || !BrFolder_IsTreeItemInEnum(info, hItem, pEnum))
1142 {
1143 TreeView_DeleteItem(info->hwndTreeView, hItem);
1144 hNextItem = TreeView_GetChild(info->hwndTreeView, hTarget);
1145 continue;
1146 }
1147
1150 }
1151
1152 if (SUCCEEDED(hrEnum))
1153 TreeView_SortChildren(info->hwndTreeView, hTarget, FALSE);
1154}
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}

Referenced by BrFolder_NewFolder(), 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:940
#define BFFM_SELCHANGED
Definition: shlobj.h:1237
TVITEMW itemNew
Definition: commctrl.h:3638
LPARAM lParam
Definition: commctrl.h:3325

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:3637

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:1972
HTREEITEM hItem
Definition: commctrl.h:3317
UINT state
Definition: commctrl.h:3318

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:2259
#define VK_DELETE
Definition: winuser.h:2233
#define VK_F2
Definition: winuser.h:2256

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:3672
LPWSTR pszText
Definition: commctrl.h:3320

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 1224 of file brfolder.cpp.

1225{
1226 if (uMsg == WM_INITDIALOG)
1228
1229 BrFolder *info = (BrFolder *)GetPropW(hWnd, L"__WINE_BRSFOLDERDLG_INFO");
1230 if (!info)
1231 return 0;
1232
1233 if (info->pContextMenu)
1234 {
1236 if (SHForwardContextMenuMsg(info->pContextMenu, uMsg, wParam,
1237 lParam, &result, TRUE) == S_OK)
1238 {
1240 return TRUE;
1241 }
1242 }
1243
1244 switch (uMsg)
1245 {
1246 case WM_NOTIFY:
1248 return TRUE;
1249
1250 case WM_COMMAND:
1252 break;
1253
1254 case WM_CONTEXTMENU:
1255 if (info->hwndTreeView == (HWND)wParam)
1257 break;
1258
1259 case WM_GETMINMAXINFO:
1260 ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = info->szMin.cx;
1261 ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = info->szMin.cy;
1262 break;
1263
1264 case WM_SIZE:
1265 if (info->layout) // New style dialogs
1267 break;
1268
1271 break;
1272
1275 break;
1276
1277 case BFFM_ENABLEOK:
1279 break;
1280
1281 case BFFM_SETOKTEXT: // Unicode only
1283 break;
1284
1285 case BFFM_SETSELECTIONA:
1286 if (wParam) // String
1288 else // PIDL
1290
1291 case BFFM_SETSELECTIONW:
1292 if (wParam) // String
1294 else // PIDL
1296
1297 case BFFM_SETEXPANDED: // Unicode only
1298 if (wParam) // String
1300 else // PIDL
1302
1303 case SHV_CHANGE_NOTIFY:
1305 break;
1306
1307 case WM_DESTROY:
1309 break;
1310 }
1311
1312 return 0;
1313}
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:1200
static BOOL BrFolder_OnSetSelectionPidl(BrFolder *info, LPITEMIDLIST pidlSelection)
Definition: brfolder.cpp:1059
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:1085
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:1099
GLuint64EXT * result
Definition: glext.h:11304
static __inline void LayoutUpdate(HWND ignored1, LAYOUT_DATA *pData, LPCVOID ignored2, UINT ignored3)
Definition: layout.h:187
#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 WM_SIZE
Definition: winuser.h:1611
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
#define WM_GETMINMAXINFO
Definition: winuser.h:1640
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define DWLP_MSGRESULT
Definition: winuser.h:870
struct tagMINMAXINFO * LPMINMAXINFO
#define WM_DESTROY
Definition: winuser.h:1609
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:3429
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:2228

Referenced by BrFolder_CheckValidSelection().

◆ SHBrowseForFolderA()

EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderA ( LPBROWSEINFOA  lpbi)

Definition at line 1321 of file brfolder.cpp.

1322{
1323 BROWSEINFOW bi;
1324 bi.hwndOwner = lpbi->hwndOwner;
1325 bi.pidlRoot = lpbi->pidlRoot;
1326
1328 bi.pszDisplayName = (lpbi->pszDisplayName ? szName : NULL);
1329
1330 CComHeapPtr<WCHAR> pszTitle;
1331 if (lpbi->lpszTitle)
1332 __SHCloneStrAtoW(&pszTitle, lpbi->lpszTitle);
1333 bi.lpszTitle = pszTitle;
1334
1335 bi.ulFlags = lpbi->ulFlags;
1336 bi.lpfn = lpbi->lpfn;
1337 bi.lParam = lpbi->lParam;
1338 bi.iImage = lpbi->iImage;
1340
1341 if (bi.pszDisplayName)
1343
1344 lpbi->iImage = bi.iImage;
1345 return pidl;
1346}
EXTERN_C LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brfolder.cpp:1353
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 1353 of file brfolder.cpp.

1354{
1355 TRACE("%p\n", lpbi);
1356
1357 BrFolder info = { lpbi };
1358
1360
1364 if (SUCCEEDED(hr))
1366
1367 if (ret != IDOK)
1368 {
1369 ILFree(info.pidlRet);
1370 return NULL;
1371 }
1372
1373 return info.pidlRet;
1374}
static INT_PTR CALLBACK BrFolderDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: brfolder.cpp:1224
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:437
#define IDD_BROWSE_FOR_FOLDER
Definition: shresdef.h:436
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