ReactOS  0.4.13-dev-235-g7373cb3
brsfolder.c
Go to the documentation of this file.
1 /*
2  * Copyright 1999 Juergen Schmied
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  *
18  * FIXME:
19  * - many memory leaks
20  * - many flags unimplemented
21  * - implement editbox
22  */
23 
24 #define WIN32_NO_STATUS
25 #define _INC_WINDOWS
26 #define COBJMACROS
27 #define NONAMELESSUNION
28 #define NONAMELESSSTRUCT
29 
30 #include <windef.h>
31 #include <winbase.h>
32 #include <shlobj.h>
33 #include <undocshell.h>
34 #include <shellapi.h>
35 #include <wine/debug.h>
36 #include <wine/unicode.h>
37 
38 #include "pidl.h"
39 #include "shell32_main.h"
40 #include "shresdef.h"
41 
43 
44 /* original margins and control size */
45 typedef struct tagLAYOUT_DATA
46 {
49 } LAYOUT_DATA;
50 
51 typedef struct tagbrowse_info
52 {
57  LAYOUT_DATA *layout; /* filled by LayoutInit, used by LayoutUpdate */
59 } browse_info;
60 
61 typedef struct tagTV_ITEMDATA
62 {
63  LPSHELLFOLDER lpsfParent; /* IShellFolder of the parent */
64  LPITEMIDLIST lpi; /* PIDL relative to parent */
65  LPITEMIDLIST lpifq; /* Fully qualified PIDL */
66  IEnumIDList* pEnumIL; /* Children iterator */
68 
69 typedef struct tagLAYOUT_INFO
70 {
71  int iItemId; /* control id */
72  DWORD dwAnchor; /* BF_* flags specifying which margins should remain constant */
73 } LAYOUT_INFO;
74 
75 static const LAYOUT_INFO g_layout_info[] =
76 {
86 };
87 
88 #define LAYOUT_INFO_COUNT (sizeof(g_layout_info)/sizeof(g_layout_info[0]))
89 
90 #define SUPPORTEDFLAGS (BIF_STATUSTEXT | \
91  BIF_BROWSEFORCOMPUTER | \
92  BIF_RETURNFSANCESTORS | \
93  BIF_RETURNONLYFSDIRS | \
94  BIF_NONEWFOLDERBUTTON | \
95  BIF_NEWDIALOGSTYLE | \
96  BIF_BROWSEINCLUDEFILES)
97 
98 static void FillTreeView(browse_info*, LPSHELLFOLDER,
102 
103 static const WCHAR szBrowseFolderInfo[] = {
104  '_','_','W','I','N','E','_',
105  'B','R','S','F','O','L','D','E','R','D','L','G','_',
106  'I','N','F','O',0
107 };
108 
109 static inline DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
110 {
111  return SHCONTF_FOLDERS | (ulFlags & BIF_BROWSEINCLUDEFILES ? SHCONTF_NONFOLDERS : 0);
112 }
113 
114 static void browsefolder_callback( LPBROWSEINFOW lpBrowseInfo, HWND hWnd,
115  UINT msg, LPARAM param )
116 {
117  if (!lpBrowseInfo->lpfn)
118  return;
119  lpBrowseInfo->lpfn( hWnd, msg, param, lpBrowseInfo->lParam );
120 }
121 
122 static LAYOUT_DATA *LayoutInit(HWND hwnd, const LAYOUT_INFO *layout_info, int layout_count)
123 {
124  LAYOUT_DATA *data;
125  RECT rcWnd;
126  int i;
127 
128  GetClientRect(hwnd, &rcWnd);
129  data = SHAlloc(sizeof(LAYOUT_DATA)*layout_count);
130  for (i = 0; i < layout_count; i++)
131  {
132  RECT r;
133  HWND hItem = GetDlgItem(hwnd, layout_info[i].iItemId);
134 
135  if (hItem == NULL)
136  ERR("Item %d not found\n", i);
137  GetWindowRect(hItem, &r);
139 
140  data[i].left = r.left;
141  data[i].right = rcWnd.right - r.right;
142  data[i].width = r.right - r.left;
143 
144  data[i].top = r.top;
145  data[i].bottom = rcWnd.bottom - r.bottom;
146  data[i].height = r.bottom - r.top;
147  }
148  return data;
149 }
150 
151 static void LayoutUpdate(HWND hwnd, LAYOUT_DATA *data, const LAYOUT_INFO *layout_info, int layout_count)
152 {
153  RECT rcWnd;
154  int i;
155 
156  GetClientRect(hwnd, &rcWnd);
157  for (i = 0; i < layout_count; i++)
158  {
159  RECT r;
160  HWND hItem = GetDlgItem(hwnd, layout_info[i].iItemId);
161 
162  GetWindowRect(hItem, &r);
164 
165  if (layout_info[i].dwAnchor & BF_RIGHT)
166  {
167  r.right = rcWnd.right - data[i].right;
168  if (!(layout_info[i].dwAnchor & BF_LEFT))
169  r.left = r.right - data[i].width;
170  }
171 
172  if (layout_info[i].dwAnchor & BF_BOTTOM)
173  {
174  r.bottom = rcWnd.bottom - data[i].bottom;
175  if (!(layout_info[i].dwAnchor & BF_TOP))
176  r.top = r.bottom - data[i].height;
177  }
178 
179  SetWindowPos(hItem, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER);
180  }
181 }
182 
183 
184 /******************************************************************************
185  * InitializeTreeView [Internal]
186  *
187  * Called from WM_INITDIALOG handler.
188  *
189  * PARAMS
190  * hwndParent [I] The BrowseForFolder dialog
191  * root [I] ITEMIDLIST of the root shell folder
192  */
194 {
195  LPITEMIDLIST pidlParent, pidlChild;
196  HIMAGELIST hImageList;
197  HRESULT hr;
198  IShellFolder *lpsfParent, *lpsfRoot;
199  IEnumIDList * pEnumChildren = NULL;
200  HTREEITEM item;
201  DWORD flags;
202  LPCITEMIDLIST root = info->lpBrowseInfo->pidlRoot;
203 
204  TRACE("%p\n", info );
205 
206  Shell_GetImageLists(NULL, &hImageList);
207 
208  if (hImageList)
209  SendMessageW( info->hwndTreeView, TVM_SETIMAGELIST, 0, (LPARAM)hImageList );
210 
211  /* We want to call InsertTreeViewItem down the code, in order to insert
212  * the root item of the treeview. Due to InsertTreeViewItem's signature,
213  * we need the following to do this:
214  *
215  * + An ITEMIDLIST corresponding to _the parent_ of root.
216  * + An ITEMIDLIST, which is a relative path from root's parent to root
217  * (containing a single SHITEMID).
218  * + An IShellFolder interface pointer of root's parent folder.
219  *
220  * If root is 'Desktop', then root's parent is also 'Desktop'.
221  */
222 
223  pidlParent = ILClone(root);
224  ILRemoveLastID(pidlParent);
225  pidlChild = ILClone(ILFindLastID(root));
226 
227  if (_ILIsDesktop(pidlParent)) {
228  hr = SHGetDesktopFolder(&lpsfParent);
229  } else {
230  IShellFolder *lpsfDesktop;
231  hr = SHGetDesktopFolder(&lpsfDesktop);
232  if (FAILED(hr)) {
233  WARN("SHGetDesktopFolder failed! hr = %08x\n", hr);
234  ILFree(pidlChild);
235  ILFree(pidlParent);
236  return;
237  }
238  hr = IShellFolder_BindToObject(lpsfDesktop, pidlParent, 0, &IID_IShellFolder, (LPVOID*)&lpsfParent);
239  IShellFolder_Release(lpsfDesktop);
240  }
241 
242  if (FAILED(hr)) {
243  WARN("Could not bind to parent shell folder! hr = %08x\n", hr);
244  ILFree(pidlChild);
245  ILFree(pidlParent);
246  return;
247  }
248 
249  if (!_ILIsEmpty(pidlChild)) {
250  hr = IShellFolder_BindToObject(lpsfParent, pidlChild, 0, &IID_IShellFolder, (LPVOID*)&lpsfRoot);
251  } else {
252  lpsfRoot = lpsfParent;
253  hr = IShellFolder_AddRef(lpsfParent);
254  }
255 
256  if (FAILED(hr)) {
257  WARN("Could not bind to root shell folder! hr = %08x\n", hr);
258  IShellFolder_Release(lpsfParent);
259  ILFree(pidlChild);
260  ILFree(pidlParent);
261  return;
262  }
263 
264  flags = BrowseFlagsToSHCONTF( info->lpBrowseInfo->ulFlags );
265  hr = IShellFolder_EnumObjects( lpsfRoot, info->hWnd, flags, &pEnumChildren );
266  if (FAILED(hr)) {
267  WARN("Could not get child iterator! hr = %08x\n", hr);
268  IShellFolder_Release(lpsfParent);
269  IShellFolder_Release(lpsfRoot);
270  ILFree(pidlChild);
271  ILFree(pidlParent);
272  return;
273  }
274 
275  SendMessageW( info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT );
276  item = InsertTreeViewItem( info, lpsfParent, pidlChild,
277  pidlParent, pEnumChildren, TVI_ROOT );
278  SendMessageW( info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item );
279 
280  ILFree(pidlChild);
281  ILFree(pidlParent);
282  IShellFolder_Release(lpsfRoot);
283  IShellFolder_Release(lpsfParent);
284 }
285 
287 {
288  SHFILEINFOW sfi;
289  SHGetFileInfoW((LPCWSTR)lpi, 0 ,&sfi, sizeof(SHFILEINFOW), uFlags);
290  return sfi.iIcon;
291 }
292 
293 static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
294 {
295  LPITEMIDLIST pidlDesktop = NULL;
296  DWORD flags;
297 
298  TRACE("%p %p\n",lpifq, lpTV_ITEM);
299 
300  if (!lpifq)
301  {
302  pidlDesktop = _ILCreateDesktop();
303  lpifq = pidlDesktop;
304  }
305 
307  lpTV_ITEM->iImage = GetIcon( lpifq, flags );
308 
310  lpTV_ITEM->iSelectedImage = GetIcon( lpifq, flags );
311 
312  if (pidlDesktop)
313  ILFree( pidlDesktop );
314 }
315 
316 /******************************************************************************
317  * GetName [Internal]
318  *
319  * Query a shell folder for the display name of one of its children
320  *
321  * PARAMS
322  * lpsf [I] IShellFolder interface of the folder to be queried.
323  * lpi [I] ITEMIDLIST of the child, relative to parent
324  * dwFlags [I] as in IShellFolder::GetDisplayNameOf
325  * lpFriendlyName [O] The desired display name in unicode
326  *
327  * RETURNS
328  * Success: TRUE
329  * Failure: FALSE
330  */
331 static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
332 {
334  STRRET str;
335 
336  TRACE("%p %p %x %p\n", lpsf, lpi, dwFlags, lpFriendlyName);
337  if (SUCCEEDED(IShellFolder_GetDisplayNameOf(lpsf, lpi, dwFlags, &str)))
338  bSuccess = StrRetToStrNW(lpFriendlyName, MAX_PATH, &str, lpi);
339  else
340  bSuccess = FALSE;
341 
342  TRACE("-- %s\n", debugstr_w(lpFriendlyName));
343  return bSuccess;
344 }
345 
346 /******************************************************************************
347  * InsertTreeViewItem [Internal]
348  *
349  * PARAMS
350  * info [I] data for the dialog
351  * lpsf [I] IShellFolder interface of the item's parent shell folder
352  * pidl [I] ITEMIDLIST of the child to insert, relative to parent
353  * pidlParent [I] ITEMIDLIST of the parent shell folder
354  * pEnumIL [I] Iterator for the children of the item to be inserted
355  * hParent [I] The treeview-item that represents the parent shell folder
356  *
357  * RETURNS
358  * Success: Handle to the created and inserted treeview-item
359  * Failure: NULL
360  */
362  LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL,
364 {
365  TVITEMW tvi;
366  TVINSERTSTRUCTW tvins;
367  WCHAR szBuff[MAX_PATH];
368  LPTV_ITEMDATA lptvid=0;
369 
371 
372  tvi.cChildren= pEnumIL ? 1 : 0;
373  tvi.mask |= TVIF_CHILDREN;
374 
375  if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff))
376  return NULL;
377 
378  lptvid = SHAlloc( sizeof(TV_ITEMDATA) );
379  if (!lptvid)
380  return NULL;
381 
382  tvi.pszText = szBuff;
383  tvi.cchTextMax = MAX_PATH;
384  tvi.lParam = (LPARAM)lptvid;
385 
386  IShellFolder_AddRef(lpsf);
387  lptvid->lpsfParent = lpsf;
388  lptvid->lpi = ILClone(pidl);
389  lptvid->lpifq = pidlParent ? ILCombine(pidlParent, pidl) : ILClone(pidl);
390  lptvid->pEnumIL = pEnumIL;
391  GetNormalAndSelectedIcons(lptvid->lpifq, &tvi);
392 
393  tvins.u.item = tvi;
394  tvins.hInsertAfter = NULL;
395  tvins.hParent = hParent;
396 
397  return TreeView_InsertItem( info->hwndTreeView, &tvins );
398 }
399 
400 /******************************************************************************
401  * FillTreeView [Internal]
402  *
403  * For each child (given by lpe) of the parent shell folder, which is given by
404  * lpsf and whose PIDL is pidl, insert a treeview-item right under hParent
405  *
406  * PARAMS
407  * info [I] data for the dialog
408  * lpsf [I] IShellFolder interface of the parent shell folder
409  * pidl [I] ITEMIDLIST of the parent shell folder
410  * hParent [I] The treeview item that represents the parent shell folder
411  * lpe [I] An iterator for the children of the parent shell folder
412  */
415 {
416  LPITEMIDLIST pidlTemp = 0;
417  ULONG ulFetched;
418  HRESULT hr;
419  HWND hwnd = GetParent( info->hwndTreeView );
420 
421  TRACE("%p %p %p %p\n",lpsf, pidl, hParent, lpe);
422 
423  /* No IEnumIDList -> No children */
424  if (!lpe) return;
425 
426  SetCapture( hwnd );
428 
429  while (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))
430  {
431  ULONG ulAttrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
432  IEnumIDList* pEnumIL = NULL;
433  IShellFolder* pSFChild = NULL;
434  IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulAttrs);
435  if (ulAttrs & SFGAO_FOLDER)
436  {
437  hr = IShellFolder_BindToObject(lpsf,pidlTemp,NULL,&IID_IShellFolder,(LPVOID*)&pSFChild);
438  if (SUCCEEDED(hr))
439  {
440  DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
441  hr = IShellFolder_EnumObjects(pSFChild, hwnd, flags, &pEnumIL);
442  if (hr == S_OK)
443  {
444  if ((IEnumIDList_Skip(pEnumIL, 1) != S_OK) ||
445  FAILED(IEnumIDList_Reset(pEnumIL)))
446  {
447  IEnumIDList_Release(pEnumIL);
448  pEnumIL = NULL;
449  }
450  }
451  IShellFolder_Release(pSFChild);
452  }
453  }
454 
455  if (!InsertTreeViewItem(info, lpsf, pidlTemp, pidl, pEnumIL, hParent))
456  goto done;
457  SHFree(pidlTemp); /* Finally, free the pidl that the shell gave us... */
458  pidlTemp=NULL;
459  }
460 
461 done:
462  ReleaseCapture();
464  SHFree(pidlTemp);
465 }
466 
468 {
470  if (!data)
471  return FALSE;
472  return (data->type == type);
473 }
474 
476 {
477  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
478  LPCITEMIDLIST pidl = lptvid->lpi;
479  BOOL bEnabled = TRUE;
481  HRESULT r;
482 
483  if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) &&
484  !PIDLIsType(pidl, PT_COMP))
485  bEnabled = FALSE;
486  if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS)
487  {
488  dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
489  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
490  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
491  if (FAILED(r) || !(dwAttributes & (SFGAO_FILESYSANCESTOR|SFGAO_FILESYSTEM)))
492  bEnabled = FALSE;
493  }
494 
495  dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM;
496  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
497  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
498  if (FAILED(r) ||
499  ((dwAttributes & (SFGAO_FOLDER|SFGAO_FILESYSTEM)) != (SFGAO_FOLDER|SFGAO_FILESYSTEM)))
500  {
501  if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS)
502  bEnabled = FALSE;
504  }
505  else
507 
508  SendMessageW(info->hWnd, BFFM_ENABLEOK, 0, bEnabled);
509 }
510 
512 {
513  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA)pnmtv->itemOld.lParam;
514 
515  TRACE("TVN_DELETEITEMA/W %p\n", lptvid);
516 
517  IShellFolder_Release(lptvid->lpsfParent);
518  if (lptvid->pEnumIL)
519  IEnumIDList_Release(lptvid->pEnumIL);
520  SHFree(lptvid->lpi);
521  SHFree(lptvid->lpifq);
522  SHFree(lptvid);
523  return 0;
524 }
525 
527 {
528  IShellFolder *lpsf2 = NULL;
529  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
530  HRESULT r;
531 
532  TRACE("TVN_ITEMEXPANDINGA/W\n");
533 
534  if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
535  return 0;
536 
537  if (!_ILIsEmpty(lptvid->lpi)) {
538  r = IShellFolder_BindToObject( lptvid->lpsfParent, lptvid->lpi, 0,
539  &IID_IShellFolder, (void**)&lpsf2 );
540  } else {
541  lpsf2 = lptvid->lpsfParent;
542  IShellFolder_AddRef(lpsf2);
543  r = S_OK;
544  }
545 
546  if (SUCCEEDED(r))
547  {
548  FillTreeView( info, lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem, lptvid->pEnumIL);
549  IShellFolder_Release( lpsf2 );
550  }
551 
552  /* My Computer is already sorted and trying to do a simple text
553  * sort will only mess things up */
554  if (!_ILIsMyComputer(lptvid->lpi))
555  SendMessageW( info->hwndTreeView, TVM_SORTCHILDREN,
556  FALSE, (LPARAM)pnmtv->itemNew.hItem );
557 
558  return 0;
559 }
560 
562 {
563  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
565 
566  ILFree(info->pidlRet);
567  info->pidlRet = ILClone(lptvid->lpifq);
568 
569  if (GetName(lptvid->lpsfParent, lptvid->lpi, SHGDN_NORMAL, name))
571 
572  browsefolder_callback( info->lpBrowseInfo, info->hWnd, BFFM_SELCHANGED,
573  (LPARAM)info->pidlRet );
575  return S_OK;
576 }
577 
579 {
580  LPTV_ITEMDATA item_data;
581  WCHAR old_path[MAX_PATH], new_path[MAX_PATH], *p;
582  NMTREEVIEWW nmtv;
583  TVITEMW item;
584 
585  if(!pnmtv->item.pszText)
586  return 0;
587 
588  item.mask = TVIF_HANDLE|TVIF_PARAM;
589  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
590  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
591  item_data = (LPTV_ITEMDATA)item.lParam;
592 
593  SHGetPathFromIDListW(item_data->lpifq, old_path);
594  if(!(p = strrchrW(old_path, '\\')))
595  return 0;
596  p = new_path+(p-old_path+1);
597  memcpy(new_path, old_path, (p-new_path)*sizeof(WCHAR));
598  strcpyW(p, pnmtv->item.pszText);
599 
600  if(!MoveFileW(old_path, new_path))
601  return 0;
602 
603  SHFree(item_data->lpifq);
604  SHFree(item_data->lpi);
605  item_data->lpifq = SHSimpleIDListFromPathW(new_path);
606  IShellFolder_ParseDisplayName(item_data->lpsfParent, NULL, NULL,
607  pnmtv->item.pszText, NULL, &item_data->lpi, NULL);
608 
609  item.mask = TVIF_HANDLE|TVIF_TEXT;
610  item.pszText = pnmtv->item.pszText;
611  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
612 
613  nmtv.itemNew.lParam = item.lParam;
615  return 0;
616 }
617 
619 {
620  NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
621 
622  TRACE("%p %x %p msg=%x\n", info, CtlID, lpnmh, pnmtv->hdr.code);
623 
625  return 0;
626 
627  switch (pnmtv->hdr.code)
628  {
629  case TVN_DELETEITEMA:
630  case TVN_DELETEITEMW:
631  return BrsFolder_Treeview_Delete( info, pnmtv );
632 
633  case TVN_ITEMEXPANDINGA:
634  case TVN_ITEMEXPANDINGW:
635  return BrsFolder_Treeview_Expand( info, pnmtv );
636 
637  case TVN_SELCHANGEDA:
638  case TVN_SELCHANGEDW:
639  return BrsFolder_Treeview_Changed( info, pnmtv );
640 
641  case TVN_ENDLABELEDITA:
642  case TVN_ENDLABELEDITW:
644 
645  default:
646  WARN("unhandled (%d)\n", pnmtv->hdr.code);
647  break;
648  }
649 
650  return 0;
651 }
652 
653 
655 {
656  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
657 
658  info->hWnd = hWnd;
660 
661  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
662  FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n");
663  if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS)
664  FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS);
665 
666  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
667  {
668  RECT rcWnd;
669 
671 
672  /* TODO: Windows allows shrinking the windows a bit */
673  GetWindowRect(hWnd, &rcWnd);
674  info->szMin.cx = rcWnd.right - rcWnd.left;
675  info->szMin.cy = rcWnd.bottom - rcWnd.top;
676  }
677  else
678  {
679  info->layout = NULL;
680  }
681 
682  if (lpBrowseInfo->lpszTitle)
684  else
686 
687  if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT)
688  || (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
690 
691  /* Hide "Make New Folder" Button? */
692  if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON)
693  || !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
695 
696  /* Hide the editbox? */
697  if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX))
698  {
701  }
702 
704  if (info->hwndTreeView)
705  {
707 
708  /* Resize the treeview if there's not editbox */
709  if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
710  && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
711  {
712  RECT rc;
713  GetClientRect(info->hwndTreeView, &rc);
714  SetWindowPos(info->hwndTreeView, HWND_TOP, 0, 0,
715  rc.right, rc.bottom + 40, SWP_NOMOVE);
716  }
717  }
718  else
719  ERR("treeview control missing!\n");
720 
721  browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 );
722 
723  return TRUE;
724 }
725 
727 {
729  SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename);
730  return S_OK;
731 }
732 
734 {
735  DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
736  IShellFolder *desktop, *cur;
737 #ifdef __REACTOS__
738  WCHAR wszNewFolder[25];
740 #else
741  ISFHelper *sfhelper;
742 #endif
744  HTREEITEM parent, added;
745  LPTV_ITEMDATA item_data;
746  LPITEMIDLIST new_item;
747  TVITEMW item;
748  HRESULT hr;
749  int len;
750 
751 #ifdef __REACTOS__
752  hr = SHGetDesktopFolder(&desktop);
753  if(FAILED(hr))
754  return hr;
755 
756  if (info->pidlRet)
757  {
758  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
759  IShellFolder_Release(desktop);
760  if(FAILED(hr))
761  return hr;
762 
763  hr = SHGetPathFromIDListW(info->pidlRet, path);
764  }
765  else
766  {
767  cur = desktop;
769  }
770  if(FAILED(hr))
771  return hr;
772 
773  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
774  return E_FAIL;
775 
776  if (!PathYetAnotherMakeUniqueName(name, path, NULL, wszNewFolder))
777  return E_FAIL;
778 
779  len = strlenW(path);
780  if(len<MAX_PATH && name[len] == L'\\')
781  len++;
782 #else
783  if(!info->pidlRet) {
784  ERR("Make new folder button should be disabled\n");
785  return E_FAIL;
786  }
787 
788  /* Create new directory */
789  hr = SHGetDesktopFolder(&desktop);
790  if(FAILED(hr))
791  return hr;
792 
793  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
794  IShellFolder_Release(desktop);
795  if(FAILED(hr))
796  return hr;
797 
798  hr = IShellFolder_QueryInterface(cur, &IID_ISFHelper, (void**)&sfhelper);
799  if(FAILED(hr))
800  return hr;
801 
802  if(!SHGetPathFromIDListW(info->pidlRet, name)) {
803  hr = E_FAIL;
804  goto cleanup;
805  }
806 
807  len = strlenW(name);
808  if(len<MAX_PATH)
809  name[len++] = '\\';
810  hr = ISFHelper_GetUniqueName(sfhelper, &name[len], MAX_PATH-len);
811  ISFHelper_Release(sfhelper);
812  if(FAILED(hr))
813  goto cleanup;
814 #endif
815 
816  hr = E_FAIL;
817  if(!CreateDirectoryW(name, NULL))
818  goto cleanup;
819 
820  /* Update parent of newly created directory */
822  if(!parent)
823  goto cleanup;
824 
825  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)parent);
826 
827  memset(&item, 0, sizeof(TVITEMW));
828  item.mask = TVIF_PARAM|TVIF_STATE;
829  item.hItem = parent;
830  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
831  item_data = (LPTV_ITEMDATA)item.lParam;
832  if(!item_data)
833  goto cleanup;
834 
835  if(item_data->pEnumIL)
836  IEnumIDList_Release(item_data->pEnumIL);
837  hr = IShellFolder_EnumObjects(cur, info->hwndTreeView, flags, &item_data->pEnumIL);
838  if(FAILED(hr))
839  goto cleanup;
840 
841  /* Update treeview */
842  if(!(item.state&TVIS_EXPANDEDONCE)) {
843  item.mask = TVIF_STATE;
844  item.state = TVIS_EXPANDEDONCE;
845  item.stateMask = TVIS_EXPANDEDONCE;
846  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
847  }
848 
849  hr = IShellFolder_ParseDisplayName(cur, NULL, NULL, name+len, NULL, &new_item, NULL);
850  if(FAILED(hr))
851  goto cleanup;
852 
853  added = InsertTreeViewItem(info, cur, new_item, item_data->lpifq, NULL, parent);
854  IShellFolder_Release(cur);
855  SHFree(new_item);
856 
858  return BrsFolder_Rename(info, added);
859 
860 cleanup:
861  return hr;
862 }
863 
865 {
866  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
867 
868  switch (id)
869  {
870  case IDOK:
871 #ifdef __REACTOS__
872  /* The original pidl is owned by the treeview and will be free'd. */
873  info->pidlRet = ILClone(info->pidlRet);
874 #endif
875  if (info->pidlRet == NULL) /* A null pidl would mean a cancel */
876  info->pidlRet = _ILCreateDesktop();
877  pdump( info->pidlRet );
878  if (lpBrowseInfo->pszDisplayName)
879  SHGetPathFromIDListW( info->pidlRet, lpBrowseInfo->pszDisplayName );
880  EndDialog( info->hWnd, 1 );
881  return TRUE;
882 
883  case IDCANCEL:
884  EndDialog( info->hWnd, 0 );
885  return TRUE;
886 
889  return TRUE;
890  }
891  return FALSE;
892 }
893 
895  BOOL is_str, HTREEITEM *pItem)
896 {
897  LPITEMIDLIST pidlSelection = selection;
898  LPCITEMIDLIST pidlCurrent, pidlRoot;
899  TVITEMEXW item;
900  BOOL bResult = FALSE;
901 
902  memset(&item, 0, sizeof(item));
903 
904  /* If 'selection' is a string, convert to a Shell ID List. */
905  if (is_str) {
906  IShellFolder *psfDesktop;
907  HRESULT hr;
908 
909  hr = SHGetDesktopFolder(&psfDesktop);
910  if (FAILED(hr))
911  goto done;
912 
913  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL,
914  selection, NULL, &pidlSelection, NULL);
915  IShellFolder_Release(psfDesktop);
916  if (FAILED(hr))
917  goto done;
918  }
919 
920  /* Move pidlCurrent behind the SHITEMIDs in pidlSelection, which are the root of
921  * the sub-tree currently displayed. */
922  pidlRoot = info->lpBrowseInfo->pidlRoot;
923  pidlCurrent = pidlSelection;
924  while (!_ILIsEmpty(pidlRoot) && _ILIsEqualSimple(pidlRoot, pidlCurrent)) {
925  pidlRoot = ILGetNext(pidlRoot);
926  pidlCurrent = ILGetNext(pidlCurrent);
927  }
928 
929  /* The given ID List is not part of the SHBrowseForFolder's current sub-tree. */
930  if (!_ILIsEmpty(pidlRoot))
931  goto done;
932 
933  /* Initialize item to point to the first child of the root folder. */
934  item.mask = TVIF_PARAM;
935  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
936 
937  if (item.hItem)
938  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
939  (LPARAM)item.hItem);
940 
941  /* Walk the tree along the nodes corresponding to the remaining ITEMIDLIST */
942  while (item.hItem && !_ILIsEmpty(pidlCurrent)) {
943  LPTV_ITEMDATA pItemData;
944 
945  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
946  pItemData = (LPTV_ITEMDATA)item.lParam;
947 
948  if (_ILIsEqualSimple(pItemData->lpi, pidlCurrent)) {
949  pidlCurrent = ILGetNext(pidlCurrent);
950  if (!_ILIsEmpty(pidlCurrent)) {
951  /* Only expand current node and move on to its first child,
952  * if we didn't already reach the last SHITEMID */
953  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item.hItem);
954  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
955  (LPARAM)item.hItem);
956  }
957  } else {
958  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_NEXT,
959  (LPARAM)item.hItem);
960  }
961  }
962 
963  if (_ILIsEmpty(pidlCurrent) && item.hItem)
964  bResult = TRUE;
965 
966 done:
967  if (pidlSelection && pidlSelection != selection)
968  ILFree(pidlSelection);
969 
970  if (pItem)
971  *pItem = item.hItem;
972 
973  return bResult;
974 }
975 
978  BOOL bResult;
979 
980  if (!selection) return FALSE;
981 
982  bResult = BrsFolder_OnSetExpanded(info, selection, is_str, &hItem);
983  if (bResult)
985  return bResult;
986 }
987 
989  LPWSTR selectionW = NULL;
990  BOOL result = FALSE;
991  int length;
992 
993  if (!is_str)
994  return BrsFolder_OnSetSelectionW(info, selection, is_str);
995 
996  if ((length = MultiByteToWideChar(CP_ACP, 0, selection, -1, NULL, 0)) &&
997  (selectionW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR))) &&
998  MultiByteToWideChar(CP_ACP, 0, selection, -1, selectionW, length))
999  {
1000  result = BrsFolder_OnSetSelectionW(info, selectionW, is_str);
1001  }
1002 
1003  HeapFree(GetProcessHeap(), 0, selectionW);
1004  return result;
1005 }
1006 
1008 {
1009  if ((info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) && !(pos->flags & SWP_NOSIZE))
1010  {
1011  if (pos->cx < info->szMin.cx)
1012  pos->cx = info->szMin.cx;
1013  if (pos->cy < info->szMin.cy)
1014  pos->cy = info->szMin.cy;
1015  }
1016  return 0;
1017 }
1018 
1020 {
1021  if (info->layout)
1022  {
1023  SHFree(info->layout);
1024  info->layout = NULL;
1025  }
1026 
1027  return 0;
1028 }
1029 
1030 /*************************************************************************
1031  * BrsFolderDlgProc32 (not an exported API function)
1032  */
1034  LPARAM lParam )
1035 {
1036  browse_info *info;
1037 
1038  TRACE("hwnd=%p msg=%04x 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam );
1039 
1040  if (msg == WM_INITDIALOG)
1041  return BrsFolder_OnCreate( hWnd, (browse_info*) lParam );
1042 
1044 
1045  switch (msg)
1046  {
1047  case WM_NOTIFY:
1049 
1050  case WM_COMMAND:
1051  return BrsFolder_OnCommand( info, wParam );
1052 
1053  case WM_WINDOWPOSCHANGING:
1055 
1056  case WM_SIZE:
1057  if (info->layout) /* new style dialogs */
1059  return 0;
1060 
1061  case BFFM_SETSTATUSTEXTA:
1062  TRACE("Set status %s\n", debugstr_a((LPSTR)lParam));
1064  break;
1065 
1066  case BFFM_SETSTATUSTEXTW:
1067  TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam));
1069  break;
1070 
1071  case BFFM_ENABLEOK:
1072  TRACE("Enable %ld\n", lParam);
1073  EnableWindow(GetDlgItem(hWnd, 1), lParam != 0);
1074  break;
1075 
1076  case BFFM_SETOKTEXT: /* unicode only */
1077  TRACE("Set OK text %s\n", debugstr_w((LPWSTR)lParam));
1079  break;
1080 
1081  case BFFM_SETSELECTIONA:
1083 
1084  case BFFM_SETSELECTIONW:
1086 
1087  case BFFM_SETEXPANDED: /* unicode only */
1089 
1090  case WM_DESTROY:
1091  return BrsFolder_OnDestroy(info);
1092  }
1093  return FALSE;
1094 }
1095 
1096 #ifndef __REACTOS__
1097 static const WCHAR swBrowseTemplateName[] = {
1098  'S','H','B','R','S','F','O','R','F','O','L','D','E','R','_','M','S','G','B','O','X',0};
1099 static const WCHAR swNewBrowseTemplateName[] = {
1100  'S','H','N','E','W','B','R','S','F','O','R','F','O','L','D','E','R','_','M','S','G','B','O','X',0};
1101 #endif
1102 
1103 /*************************************************************************
1104  * SHBrowseForFolderA [SHELL32.@]
1105  * SHBrowseForFolder [SHELL32.@]
1106  */
1108 {
1109  BROWSEINFOW bi;
1110  LPITEMIDLIST lpid;
1111  INT len;
1112  LPWSTR title;
1113 
1114  TRACE("%p\n", lpbi);
1115 
1116  bi.hwndOwner = lpbi->hwndOwner;
1117  bi.pidlRoot = lpbi->pidlRoot;
1118  if (lpbi->pszDisplayName)
1119  bi.pszDisplayName = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) );
1120  else
1121  bi.pszDisplayName = NULL;
1122 
1123  if (lpbi->lpszTitle)
1124  {
1125  len = MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, NULL, 0 );
1126  title = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1127  MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, title, len );
1128  }
1129  else
1130  title = NULL;
1131 
1132  bi.lpszTitle = title;
1133  bi.ulFlags = lpbi->ulFlags;
1134  bi.lpfn = lpbi->lpfn;
1135  bi.lParam = lpbi->lParam;
1136  bi.iImage = lpbi->iImage;
1137  lpid = SHBrowseForFolderW( &bi );
1138  if (bi.pszDisplayName)
1139  {
1141  lpbi->pszDisplayName, MAX_PATH, 0, NULL);
1143  }
1144  HeapFree(GetProcessHeap(), 0, title);
1145  lpbi->iImage = bi.iImage;
1146  return lpid;
1147 }
1148 
1149 
1150 /*************************************************************************
1151  * SHBrowseForFolderW [SHELL32.@]
1152  *
1153  * NOTES
1154  * crashes when passed a null pointer
1155  */
1157 {
1158  browse_info info;
1159  DWORD r;
1160  HRESULT hr;
1161 #ifdef __REACTOS__
1162  WORD wDlgId;
1163 #else
1164  const WCHAR * templateName;
1165  INITCOMMONCONTROLSEX icex;
1166 #endif
1167 
1168  info.hWnd = 0;
1169  info.pidlRet = NULL;
1170  info.lpBrowseInfo = lpbi;
1171  info.hwndTreeView = NULL;
1172 
1173 #ifndef __REACTOS__
1174  icex.dwSize = sizeof( icex );
1175  icex.dwICC = ICC_TREEVIEW_CLASSES;
1176  InitCommonControlsEx( &icex );
1177 #endif
1178 
1179  hr = OleInitialize(NULL);
1180 
1181  if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
1182  wDlgId = IDD_BROWSE_FOR_FOLDER_NEW;
1183  else
1184  wDlgId = IDD_BROWSE_FOR_FOLDER;
1187  if (SUCCEEDED(hr))
1188  OleUninitialize();
1189  if (!r)
1190  {
1191  ILFree(info.pidlRet);
1192  return NULL;
1193  }
1194 
1195  return info.pidlRet;
1196 }
WINE_DEFAULT_DEBUG_CHANNEL(shell)
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static LRESULT BrsFolder_Treeview_Expand(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:526
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:361
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define IDC_BROWSE_FOR_FOLDER_STATUS
Definition: shresdef.h:363
struct tagLAYOUT_DATA LAYOUT_DATA
int cchTextMax
Definition: commctrl.h:3293
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define IDS_NEWFOLDER
static BOOL BrsFolder_OnSetSelectionA(browse_info *info, LPVOID selection, BOOL is_str)
Definition: brsfolder.c:988
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2162
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HTREEITEM hParent
Definition: commctrl.h:3365
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1588
TVITEMW itemOld
Definition: commctrl.h:3609
static BOOL _ILIsEmpty(LPCITEMIDLIST pidl)
Definition: pidl.h:256
static HTREEITEM InsertTreeViewItem(browse_info *, IShellFolder *, LPCITEMIDLIST, LPCITEMIDLIST, IEnumIDList *, HTREEITEM)
Definition: brsfolder.c:361
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define WideCharToMultiByte
Definition: compat.h:101
static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
Definition: brsfolder.c:293
HRESULT hr
Definition: shlfolder.c:183
struct tagTV_ITEMDATA * LPTV_ITEMDATA
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TVM_EXPAND
Definition: commctrl.h:3391
#define TVM_SELECTITEM
Definition: commctrl.h:3450
LPITEMIDLIST lpifq
Definition: brsfolder.c:65
#define TVM_SORTCHILDREN
Definition: commctrl.h:3513
#define TVGN_CARET
Definition: commctrl.h:3433
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1906
#define TVN_DELETEITEMA
Definition: commctrl.h:3679
static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
Definition: brsfolder.c:331
#define SW_HIDE
Definition: winuser.h:762
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define LAYOUT_INFO_COUNT
Definition: brsfolder.c:88
LPCITEMIDLIST pidlRoot
Definition: shlobj.h:1108
#define CP_ACP
Definition: compat.h:99
int iImage
Definition: commctrl.h:3294
#define _countof(array)
Definition: fontsub.cpp:30
static void BrsFolder_CheckValidSelection(browse_info *info, LPTV_ITEMDATA lptvid)
Definition: brsfolder.c:475
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT BrsFolder_Treeview_Changed(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:561
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define TVGN_NEXT
Definition: commctrl.h:3425
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3236
#define BIF_BROWSEINCLUDEFILES
Definition: shlobj.h:1150
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1280
#define CALLBACK
Definition: compat.h:27
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: commctrl.h:3297
static BOOL PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type)
Definition: brsfolder.c:467
#define BF_BOTTOM
Definition: winuser.h:457
#define BFFM_INITIALIZED
Definition: shlobj.h:1154
LONG top
Definition: windef.h:292
LAYOUT_DATA * layout
Definition: brsfolder.c:57
HWND hwndOwner
Definition: shlobj.h:1118
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define HWND_TOP
Definition: winuser.h:1193
#define BFFM_SETSELECTIONA
Definition: shlobj.h:1163
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define BIF_NONEWFOLDERBUTTON
Definition: shlobj.h:1145
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3257
#define BIF_EDITBOX
Definition: shlobj.h:1139
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3243
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
UINT uFlags
Definition: api.c:60
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
UINT mask
Definition: commctrl.h:3288
int32_t INT_PTR
Definition: typedefs.h:62
char * LPSTR
Definition: xmlstorage.h:182
LONG right
Definition: windef.h:293
#define E_FAIL
Definition: ddrawi.h:102
struct tagLAYOUT_INFO LAYOUT_INFO
LPWSTR pszText
Definition: commctrl.h:3292
BFFCALLBACK lpfn
Definition: shlobj.h:1112
#define SHGFI_SMALLICON
Definition: shellapi.h:174
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
static BOOLEAN bSuccess
Definition: drive.cpp:417
#define BFFM_SETEXPANDED
Definition: shlobj.h:1167
WPARAM wParam
Definition: combotst.c:138
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
int selection
Definition: ctm.c:92
DWORD dwAttributes
Definition: vdmdbg.h:34
static BOOL _ILIsEqualSimple(LPCITEMIDLIST pidlA, LPCITEMIDLIST pidlB)
Definition: pidl.h:250
#define IDC_BROWSE_FOR_FOLDER_TITLE
Definition: shresdef.h:364
struct _test_info info[]
Definition: SetCursorPos.c:19
#define TVN_SELCHANGEDA
Definition: commctrl.h:3619
UINT code
Definition: winuser.h:3112
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3384
#define TVN_ENDLABELEDITW
Definition: commctrl.h:3684
static DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
Definition: brsfolder.c:109
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename)
Definition: brsfolder.c:726
#define ICC_TREEVIEW_CLASSES
Definition: commctrl.h:59
static LRESULT BrsFolder_OnNotify(browse_info *info, UINT CtlID, LPNMHDR lpnmh)
Definition: brsfolder.c:618
LPSTR pszDisplayName
Definition: shlobj.h:1109
#define TVM_SETITEMW
Definition: commctrl.h:3465
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
#define TVIF_CHILDREN
Definition: commctrl.h:3244
HINSTANCE shell32_hInstance
Definition: misc.cpp:82
HWND hwndTreeView
Definition: brsfolder.c:54
HTREEITEM hInsertAfter
Definition: commctrl.h:3366
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LPWSTR pszDisplayName
Definition: shlobj.h:1120
IEnumIDList * pEnumIL
Definition: brsfolder.c:66
UINT_PTR idFrom
Definition: winuser.h:3111
#define debugstr_w
Definition: kernel32.h:32
#define SHGFI_PIDL
Definition: shellapi.h:178
#define FIXME(fmt,...)
Definition: debug.h:110
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
#define BIF_RETURNFSANCESTORS
Definition: shlobj.h:1138
#define TVM_SETIMAGELIST
Definition: commctrl.h:3418
HTREEITEM hItem
Definition: treelist.h:37
const WCHAR * str
#define TVGN_ROOT
Definition: commctrl.h:3424
smooth NULL
Definition: ftsmooth.c:416
#define SHGFI_OPENICON
Definition: shellapi.h:176
#define IDC_WAIT
Definition: winuser.h:684
#define BFFM_SETSELECTIONW
Definition: shlobj.h:1164
LONG_PTR LPARAM
Definition: windef.h:208
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
LPITEMIDLIST pidlRet
Definition: brsfolder.c:56
static BOOL BrsFolder_OnSetSelectionW(browse_info *info, LPVOID selection, BOOL is_str)
Definition: brsfolder.c:976
LPSHELLFOLDER lpsfParent
Definition: brsfolder.c:63
#define IDD_BROWSE_FOR_FOLDER
Definition: shresdef.h:358
#define TVN_ITEMEXPANDINGW
Definition: commctrl.h:3672
int cChildren
Definition: commctrl.h:3296
#define TVN_SELCHANGEDW
Definition: commctrl.h:3620
#define IDC_BROWSE_FOR_FOLDER_FOLDER
Definition: shresdef.h:362
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
static const WCHAR swNewBrowseTemplateName[]
Definition: brsfolder.c:1099
#define WM_DESTROY
Definition: winuser.h:1591
#define TVN_DELETEITEMW
Definition: commctrl.h:3680
static LAYOUT_DATA * LayoutInit(HWND hwnd, const LAYOUT_INFO *layout_info, int layout_count)
Definition: brsfolder.c:122
LPCWSTR lpszTitle
Definition: shlobj.h:1121
TVITEMW itemNew
Definition: commctrl.h:3610
LPCITEMIDLIST pidlRoot
Definition: shlobj.h:1119
BYTE PIDLTYPE
Definition: pidl.h:108
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define BIF_STATUSTEXT
Definition: shlobj.h:1137
#define BIF_NEWDIALOGSTYLE
Definition: shlobj.h:1141
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
r parent
Definition: btrfs.c:2677
if(!(yy_init))
Definition: macro.lex.yy.c:714
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1111
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void LayoutUpdate(HWND hwnd, LAYOUT_DATA *data, const LAYOUT_INFO *layout_info, int layout_count)
Definition: brsfolder.c:151
#define TVM_EDITLABELW
Definition: commctrl.h:3472
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:410
#define WM_SIZE
Definition: winuser.h:1593
#define debugstr_a
Definition: kernel32.h:31
static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection, BOOL is_str, HTREEITEM *pItem)
Definition: brsfolder.c:894
LONG HRESULT
Definition: typedefs.h:77
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define BF_RIGHT
Definition: winuser.h:456
#define TVN_ENDLABELEDITA
Definition: commctrl.h:3683
LPITEMIDLIST WINAPI SHBrowseForFolderA(LPBROWSEINFOA lpbi)
Definition: brsfolder.c:1107
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1643
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define TVE_EXPAND
Definition: commctrl.h:3395
GLbitfield flags
Definition: glext.h:7161
#define TVI_ROOT
Definition: commctrl.h:3340
LPCSTR lpszTitle
Definition: shlobj.h:1110
#define TVM_DELETEITEM
Definition: commctrl.h:3386
static const WCHAR L[]
Definition: oid.c:1250
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
static HRESULT BrsFolder_NewFolder(browse_info *info)
Definition: brsfolder.c:733
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
static LRESULT BrsFolder_OnWindowPosChanging(browse_info *info, WINDOWPOS *pos)
Definition: brsfolder.c:1007
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define WM_COMMAND
Definition: winuser.h:1716
#define TVGN_CHILD
Definition: commctrl.h:3428
static int GetIcon(LPCITEMIDLIST lpi, UINT uFlags)
Definition: brsfolder.c:286
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
#define IDD_BROWSE_FOR_FOLDER_NEW
Definition: shresdef.h:359
UINT ulFlags
Definition: shlobj.h:1111
BOOL WINAPI Shell_GetImageLists(HIMAGELIST *lpBigList, HIMAGELIST *lpSmallList)
Definition: iconcache.cpp:706
#define TVIF_HANDLE
Definition: commctrl.h:3242
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi)
Definition: brsfolder.c:1156
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:172
#define SWP_NOSIZE
Definition: winuser.h:1230
#define ERR(fmt,...)
Definition: debug.h:109
#define TVM_GETNEXTITEM
Definition: commctrl.h:3421
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define BFFM_ENABLEOK
Definition: shlobj.h:1162
HWND WINAPI GetParent(_In_ HWND)
#define PT_COMP
Definition: pidl.h:99
static LRESULT BrsFolder_Treeview_Rename(browse_info *info, NMTVDISPINFOW *pnmtv)
Definition: brsfolder.c:578
LPARAM lParam
Definition: shlobj.h:1113
#define S_OK
Definition: intsafe.h:59
HWND WINAPI SetCapture(_In_ HWND hWnd)
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
UINT ulFlags
Definition: shlobj.h:1122
static INT BrsFolder_OnDestroy(browse_info *info)
Definition: brsfolder.c:1019
static ATOM item
Definition: dde.c:856
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1135
LPARAM lParam
Definition: shlobj.h:1124
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
static void browsefolder_callback(LPBROWSEINFOW lpBrowseInfo, HWND hWnd, UINT msg, LPARAM param)
Definition: brsfolder.c:114
#define TVIF_TEXT
Definition: commctrl.h:3238
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
static BOOL BrsFolder_OnCommand(browse_info *info, UINT id)
Definition: brsfolder.c:864
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
int iSelectedImage
Definition: commctrl.h:3295
static void InitializeTreeView(browse_info *info)
Definition: brsfolder.c:193
#define BF_TOP
Definition: winuser.h:455
#define BFFM_SELCHANGED
Definition: shlobj.h:1155
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:248
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BFFM_SETSTATUSTEXTA
Definition: shlobj.h:1161
Definition: services.c:325
BFFCALLBACK lpfn
Definition: shlobj.h:1123
#define TVIF_IMAGE
Definition: commctrl.h:3239
#define SUPPORTEDFLAGS
Definition: brsfolder.c:90
#define IDC_BROWSE_FOR_FOLDER_TREEVIEW
Definition: shresdef.h:365
#define HWND_DESKTOP
Definition: winuser.h:1195
static void FillTreeView(browse_info *, LPSHELLFOLDER, LPITEMIDLIST, HTREEITEM, IEnumIDList *)
unsigned int UINT
Definition: ndis.h:50
HTREEITEM hItem
Definition: commctrl.h:3289
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
static BOOL BrsFolder_OnCreate(HWND hWnd, browse_info *info)
Definition: brsfolder.c:654
static const WCHAR swBrowseTemplateName[]
Definition: brsfolder.c:1097
#define MultiByteToWideChar
Definition: compat.h:100
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:331
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2888
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2085
Definition: name.c:36
TVITEMW item
Definition: commctrl.h:3644
static const WCHAR szBrowseFolderInfo[]
Definition: brsfolder.c:103
LPBROWSEINFOW lpBrowseInfo
Definition: brsfolder.c:55
unsigned int ULONG
Definition: retypes.h:1
LONG bottom
Definition: windef.h:294
#define TVIF_STATE
Definition: commctrl.h:3241
char * cleanup(char *str)
Definition: wpickclick.c:99
#define TVM_GETITEMW
Definition: commctrl.h:3458
UINT state
Definition: commctrl.h:3290
#define SWP_NOMOVE
Definition: winuser.h:1229
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:319
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define BFFM_SETOKTEXT
Definition: shlobj.h:1166
#define TVIF_PARAM
Definition: commctrl.h:3240
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2018
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
static INT_PTR CALLBACK BrsFolderDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: brsfolder.c:1033
LPITEMIDLIST lpi
Definition: brsfolder.c:64
LONG_PTR LRESULT
Definition: windef.h:209
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:233
HWND hwndOwner
Definition: shlobj.h:1107
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define BFFM_SETSTATUSTEXTW
Definition: shlobj.h:1165
#define BIF_BROWSEFORCOMPUTER
Definition: shlobj.h:1148
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
static char title[]
Definition: ps.c:92
static const LAYOUT_INFO g_layout_info[]
Definition: brsfolder.c:75
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD dwAnchor
Definition: brsfolder.c:72
static LRESULT BrsFolder_Treeview_Delete(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:511
struct tagbrowse_info browse_info
#define WM_NOTIFY
Definition: richedit.h:61
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:84
#define IDC_BROWSE_FOR_FOLDER_NEW_FOLDER
Definition: shresdef.h:360
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define BF_LEFT
Definition: winuser.h:454
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3671
struct tagTV_ITEMDATA TV_ITEMDATA