ReactOS  0.4.15-dev-4603-gb922b6d
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 #ifdef __REACTOS__
42  #include <shlwapi.h>
43  #include "ui/layout.h" /* Resizable window */
44 #endif
45 
47 
48 #define SHV_CHANGE_NOTIFY (WM_USER + 0x1111)
49 
50 #ifndef __REACTOS__ /* Defined in "layout.h" */
51 /* original margins and control size */
52 typedef struct tagLAYOUT_DATA
53 {
56 } LAYOUT_DATA;
57 #endif
58 
59 typedef struct tagbrowse_info
60 {
65  LAYOUT_DATA *layout; /* filled by LayoutInit, used by LayoutUpdate */
67  ULONG hNotify; /* change notification handle */
68 } browse_info;
69 
70 typedef struct tagTV_ITEMDATA
71 {
72  LPSHELLFOLDER lpsfParent; /* IShellFolder of the parent */
73  LPITEMIDLIST lpi; /* PIDL relative to parent */
74  LPITEMIDLIST lpifq; /* Fully qualified PIDL */
75  IEnumIDList* pEnumIL; /* Children iterator */
77 
78 #ifndef __REACTOS__ /* Defined in "layout.h" */
79 typedef struct tagLAYOUT_INFO
80 {
81  int iItemId; /* control id */
82  DWORD dwAnchor; /* BF_* flags specifying which margins should remain constant */
83 } LAYOUT_INFO;
84 #endif
85 
86 static const LAYOUT_INFO g_layout_info[] =
87 {
90 #ifndef __REACTOS__ /* Duplicated */
92 #endif
94 #ifdef __REACTOS__
96 #else
99 #endif
103 };
104 
105 #define LAYOUT_INFO_COUNT (sizeof(g_layout_info)/sizeof(g_layout_info[0]))
106 
107 #define SUPPORTEDFLAGS (BIF_STATUSTEXT | \
108  BIF_BROWSEFORCOMPUTER | \
109  BIF_RETURNFSANCESTORS | \
110  BIF_RETURNONLYFSDIRS | \
111  BIF_NONEWFOLDERBUTTON | \
112  BIF_NEWDIALOGSTYLE | \
113  BIF_BROWSEINCLUDEFILES)
114 
115 static void FillTreeView(browse_info*, LPSHELLFOLDER,
119 
120 static inline DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
121 {
122  return SHCONTF_FOLDERS | (ulFlags & BIF_BROWSEINCLUDEFILES ? SHCONTF_NONFOLDERS : 0);
123 }
124 
125 static void browsefolder_callback( LPBROWSEINFOW lpBrowseInfo, HWND hWnd,
126  UINT msg, LPARAM param )
127 {
128  if (!lpBrowseInfo->lpfn)
129  return;
130  lpBrowseInfo->lpfn( hWnd, msg, param, lpBrowseInfo->lParam );
131 }
132 
133 #ifndef __REACTOS__ /* Defined in "layout.h" */
134 static LAYOUT_DATA *LayoutInit(HWND hwnd, const LAYOUT_INFO *layout_info, int layout_count)
135 {
136  LAYOUT_DATA *data;
137  RECT rcWnd;
138  int i;
139 
140  GetClientRect(hwnd, &rcWnd);
141  data = SHAlloc(sizeof(LAYOUT_DATA)*layout_count);
142  for (i = 0; i < layout_count; i++)
143  {
144  RECT r;
145  HWND hItem = GetDlgItem(hwnd, layout_info[i].iItemId);
146 
147  if (hItem == NULL)
148  ERR("Item %d not found\n", i);
149  GetWindowRect(hItem, &r);
151 
152  data[i].left = r.left;
153  data[i].right = rcWnd.right - r.right;
154  data[i].width = r.right - r.left;
155 
156  data[i].top = r.top;
157  data[i].bottom = rcWnd.bottom - r.bottom;
158  data[i].height = r.bottom - r.top;
159  }
160  return data;
161 }
162 
163 static void LayoutUpdate(HWND hwnd, LAYOUT_DATA *data, const LAYOUT_INFO *layout_info, int layout_count)
164 {
165  RECT rcWnd;
166  int i;
167 
168  GetClientRect(hwnd, &rcWnd);
169  for (i = 0; i < layout_count; i++)
170  {
171  RECT r;
172  HWND hItem = GetDlgItem(hwnd, layout_info[i].iItemId);
173 
174  GetWindowRect(hItem, &r);
176 
177  if (layout_info[i].dwAnchor & BF_RIGHT)
178  {
179  r.right = rcWnd.right - data[i].right;
180  if (!(layout_info[i].dwAnchor & BF_LEFT))
181  r.left = r.right - data[i].width;
182  }
183 
184  if (layout_info[i].dwAnchor & BF_BOTTOM)
185  {
186  r.bottom = rcWnd.bottom - data[i].bottom;
187  if (!(layout_info[i].dwAnchor & BF_TOP))
188  r.top = r.bottom - data[i].height;
189  }
190 
191  SetWindowPos(hItem, NULL, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER);
192  }
193 }
194 #endif
195 
196 
197 /******************************************************************************
198  * InitializeTreeView [Internal]
199  *
200  * Called from WM_INITDIALOG handler.
201  *
202  * PARAMS
203  * hwndParent [I] The BrowseForFolder dialog
204  * root [I] ITEMIDLIST of the root shell folder
205  */
207 {
208  LPITEMIDLIST pidlParent, pidlChild;
209  HIMAGELIST hImageList;
210  HRESULT hr;
211  IShellFolder *lpsfParent, *lpsfRoot;
212  IEnumIDList * pEnumChildren = NULL;
213  HTREEITEM item;
214  DWORD flags;
215  LPCITEMIDLIST root = info->lpBrowseInfo->pidlRoot;
216 
217  TRACE("%p\n", info );
218 
219  Shell_GetImageLists(NULL, &hImageList);
220 
221  if (hImageList)
222  SendMessageW( info->hwndTreeView, TVM_SETIMAGELIST, 0, (LPARAM)hImageList );
223 
224  /* We want to call InsertTreeViewItem down the code, in order to insert
225  * the root item of the treeview. Due to InsertTreeViewItem's signature,
226  * we need the following to do this:
227  *
228  * + An ITEMIDLIST corresponding to _the parent_ of root.
229  * + An ITEMIDLIST, which is a relative path from root's parent to root
230  * (containing a single SHITEMID).
231  * + An IShellFolder interface pointer of root's parent folder.
232  *
233  * If root is 'Desktop', then root's parent is also 'Desktop'.
234  */
235 
236  pidlParent = ILClone(root);
237  ILRemoveLastID(pidlParent);
238  pidlChild = ILClone(ILFindLastID(root));
239 
240  if (_ILIsDesktop(pidlParent)) {
241  hr = SHGetDesktopFolder(&lpsfParent);
242  } else {
243  IShellFolder *lpsfDesktop;
244  hr = SHGetDesktopFolder(&lpsfDesktop);
245  if (FAILED(hr)) {
246  WARN("SHGetDesktopFolder failed! hr = %08x\n", hr);
247  ILFree(pidlChild);
248  ILFree(pidlParent);
249  return;
250  }
251  hr = IShellFolder_BindToObject(lpsfDesktop, pidlParent, 0, &IID_IShellFolder, (LPVOID*)&lpsfParent);
252  IShellFolder_Release(lpsfDesktop);
253  }
254 
255  if (FAILED(hr)) {
256  WARN("Could not bind to parent shell folder! hr = %08x\n", hr);
257  ILFree(pidlChild);
258  ILFree(pidlParent);
259  return;
260  }
261 
262  if (!_ILIsEmpty(pidlChild)) {
263  hr = IShellFolder_BindToObject(lpsfParent, pidlChild, 0, &IID_IShellFolder, (LPVOID*)&lpsfRoot);
264  } else {
265  lpsfRoot = lpsfParent;
266  hr = IShellFolder_AddRef(lpsfParent);
267  }
268 
269  if (FAILED(hr)) {
270  WARN("Could not bind to root shell folder! hr = %08x\n", hr);
271  IShellFolder_Release(lpsfParent);
272  ILFree(pidlChild);
273  ILFree(pidlParent);
274  return;
275  }
276 
277  flags = BrowseFlagsToSHCONTF( info->lpBrowseInfo->ulFlags );
278  hr = IShellFolder_EnumObjects( lpsfRoot, info->hWnd, flags, &pEnumChildren );
279  if (FAILED(hr)) {
280  WARN("Could not get child iterator! hr = %08x\n", hr);
281  IShellFolder_Release(lpsfParent);
282  IShellFolder_Release(lpsfRoot);
283  ILFree(pidlChild);
284  ILFree(pidlParent);
285  return;
286  }
287 
288  SendMessageW( info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT );
289  item = InsertTreeViewItem( info, lpsfParent, pidlChild,
290  pidlParent, pEnumChildren, TVI_ROOT );
291  SendMessageW( info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item );
292 
293  ILFree(pidlChild);
294  ILFree(pidlParent);
295  IShellFolder_Release(lpsfRoot);
296  IShellFolder_Release(lpsfParent);
297 }
298 
300 {
301  SHFILEINFOW sfi;
302  SHGetFileInfoW((LPCWSTR)lpi, 0 ,&sfi, sizeof(SHFILEINFOW), uFlags);
303  return sfi.iIcon;
304 }
305 
306 static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
307 {
308  LPITEMIDLIST pidlDesktop = NULL;
309  DWORD flags;
310 
311  TRACE("%p %p\n",lpifq, lpTV_ITEM);
312 
313  if (!lpifq)
314  {
315  pidlDesktop = _ILCreateDesktop();
316  lpifq = pidlDesktop;
317  }
318 
320  lpTV_ITEM->iImage = GetIcon( lpifq, flags );
321 
323  lpTV_ITEM->iSelectedImage = GetIcon( lpifq, flags );
324 
325  if (pidlDesktop)
326  ILFree( pidlDesktop );
327 }
328 
329 /******************************************************************************
330  * GetName [Internal]
331  *
332  * Query a shell folder for the display name of one of its children
333  *
334  * PARAMS
335  * lpsf [I] IShellFolder interface of the folder to be queried.
336  * lpi [I] ITEMIDLIST of the child, relative to parent
337  * dwFlags [I] as in IShellFolder::GetDisplayNameOf
338  * lpFriendlyName [O] The desired display name in unicode
339  *
340  * RETURNS
341  * Success: TRUE
342  * Failure: FALSE
343  */
344 static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
345 {
347  STRRET str;
348 
349  TRACE("%p %p %x %p\n", lpsf, lpi, dwFlags, lpFriendlyName);
350  if (SUCCEEDED(IShellFolder_GetDisplayNameOf(lpsf, lpi, dwFlags, &str)))
351  bSuccess = StrRetToStrNW(lpFriendlyName, MAX_PATH, &str, lpi);
352  else
353  bSuccess = FALSE;
354 
355  TRACE("-- %s\n", debugstr_w(lpFriendlyName));
356  return bSuccess;
357 }
358 
359 /******************************************************************************
360  * InsertTreeViewItem [Internal]
361  *
362  * PARAMS
363  * info [I] data for the dialog
364  * lpsf [I] IShellFolder interface of the item's parent shell folder
365  * pidl [I] ITEMIDLIST of the child to insert, relative to parent
366  * pidlParent [I] ITEMIDLIST of the parent shell folder
367  * pEnumIL [I] Iterator for the children of the item to be inserted
368  * hParent [I] The treeview-item that represents the parent shell folder
369  *
370  * RETURNS
371  * Success: Handle to the created and inserted treeview-item
372  * Failure: NULL
373  */
375  LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL,
376  HTREEITEM hParent)
377 {
378  TVITEMW tvi;
379  TVINSERTSTRUCTW tvins;
380  WCHAR szBuff[MAX_PATH];
381  LPTV_ITEMDATA lptvid=0;
382 
384 
385  tvi.cChildren= pEnumIL ? 1 : 0;
386  tvi.mask |= TVIF_CHILDREN;
387 
388  if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff))
389  return NULL;
390 
391  lptvid = SHAlloc( sizeof(TV_ITEMDATA) );
392  if (!lptvid)
393  return NULL;
394 
395  tvi.pszText = szBuff;
396  tvi.cchTextMax = MAX_PATH;
397  tvi.lParam = (LPARAM)lptvid;
398 
399  IShellFolder_AddRef(lpsf);
400  lptvid->lpsfParent = lpsf;
401  lptvid->lpi = ILClone(pidl);
402  lptvid->lpifq = pidlParent ? ILCombine(pidlParent, pidl) : ILClone(pidl);
403  lptvid->pEnumIL = pEnumIL;
404  GetNormalAndSelectedIcons(lptvid->lpifq, &tvi);
405 
406  tvins.u.item = tvi;
407  tvins.hInsertAfter = NULL;
408  tvins.hParent = hParent;
409 
410  return TreeView_InsertItem( info->hwndTreeView, &tvins );
411 }
412 
413 /******************************************************************************
414  * FillTreeView [Internal]
415  *
416  * For each child (given by lpe) of the parent shell folder, which is given by
417  * lpsf and whose PIDL is pidl, insert a treeview-item right under hParent
418  *
419  * PARAMS
420  * info [I] data for the dialog
421  * lpsf [I] IShellFolder interface of the parent shell folder
422  * pidl [I] ITEMIDLIST of the parent shell folder
423  * hParent [I] The treeview item that represents the parent shell folder
424  * lpe [I] An iterator for the children of the parent shell folder
425  */
427  LPITEMIDLIST pidl, HTREEITEM hParent, IEnumIDList* lpe)
428 {
429  LPITEMIDLIST pidlTemp = 0;
430  ULONG ulFetched;
431  HRESULT hr;
432  HWND hwnd = GetParent( info->hwndTreeView );
433 
434  TRACE("%p %p %p %p\n",lpsf, pidl, hParent, lpe);
435 
436  /* No IEnumIDList -> No children */
437  if (!lpe) return;
438 
439  SetCapture( hwnd );
441 
442  while (S_OK == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))
443  {
444  ULONG ulAttrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
445  IEnumIDList* pEnumIL = NULL;
446  IShellFolder* pSFChild = NULL;
447  IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulAttrs);
448  if (ulAttrs & SFGAO_FOLDER)
449  {
450  hr = IShellFolder_BindToObject(lpsf,pidlTemp,NULL,&IID_IShellFolder,(LPVOID*)&pSFChild);
451  if (SUCCEEDED(hr))
452  {
453  DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
454  hr = IShellFolder_EnumObjects(pSFChild, hwnd, flags, &pEnumIL);
455  if (hr == S_OK)
456  {
457  if ((IEnumIDList_Skip(pEnumIL, 1) != S_OK) ||
458  FAILED(IEnumIDList_Reset(pEnumIL)))
459  {
460  IEnumIDList_Release(pEnumIL);
461  pEnumIL = NULL;
462  }
463  }
464  IShellFolder_Release(pSFChild);
465  }
466  }
467 
468  if (!InsertTreeViewItem(info, lpsf, pidlTemp, pidl, pEnumIL, hParent))
469  goto done;
470  SHFree(pidlTemp); /* Finally, free the pidl that the shell gave us... */
471  pidlTemp=NULL;
472  }
473 
474 done:
475  ReleaseCapture();
477  SHFree(pidlTemp);
478 }
479 
481 {
483  if (!data)
484  return FALSE;
485  return (data->type == type);
486 }
487 
489 {
490  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
491  LPCITEMIDLIST pidl = lptvid->lpi;
492  BOOL bEnabled = TRUE;
494  HRESULT r;
495 
496  if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) &&
497  !PIDLIsType(pidl, PT_COMP))
498  bEnabled = FALSE;
499  if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS)
500  {
501  dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
502  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
503  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
504  if (FAILED(r) || !(dwAttributes & (SFGAO_FILESYSANCESTOR|SFGAO_FILESYSTEM)))
505  bEnabled = FALSE;
506  }
507 
508  dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM;
509  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
510  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
511  if (FAILED(r) ||
512  ((dwAttributes & (SFGAO_FOLDER|SFGAO_FILESYSTEM)) != (SFGAO_FOLDER|SFGAO_FILESYSTEM)))
513  {
514  if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS)
515  bEnabled = FALSE;
517  }
518  else
520 
521  SendMessageW(info->hWnd, BFFM_ENABLEOK, 0, bEnabled);
522 }
523 
525 {
526  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA)pnmtv->itemOld.lParam;
527 
528  TRACE("TVN_DELETEITEMA/W %p\n", lptvid);
529 
530  IShellFolder_Release(lptvid->lpsfParent);
531  if (lptvid->pEnumIL)
532  IEnumIDList_Release(lptvid->pEnumIL);
533  SHFree(lptvid->lpi);
534  SHFree(lptvid->lpifq);
535  SHFree(lptvid);
536  return 0;
537 }
538 
540 {
541  IShellFolder *lpsf2 = NULL;
542  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
543  HRESULT r;
544 
545  TRACE("TVN_ITEMEXPANDINGA/W\n");
546 
547  if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
548  return 0;
549 
550  if (!_ILIsEmpty(lptvid->lpi)) {
551  r = IShellFolder_BindToObject( lptvid->lpsfParent, lptvid->lpi, 0,
552  &IID_IShellFolder, (void**)&lpsf2 );
553  } else {
554  lpsf2 = lptvid->lpsfParent;
555  IShellFolder_AddRef(lpsf2);
556  r = S_OK;
557  }
558 
559  if (SUCCEEDED(r))
560  {
561  FillTreeView( info, lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem, lptvid->pEnumIL);
562  IShellFolder_Release( lpsf2 );
563  }
564 
565  /* My Computer is already sorted and trying to do a simple text
566  * sort will only mess things up */
567  if (!_ILIsMyComputer(lptvid->lpi))
568  SendMessageW( info->hwndTreeView, TVM_SORTCHILDREN,
569  FALSE, (LPARAM)pnmtv->itemNew.hItem );
570 
571  return 0;
572 }
573 
575 {
576  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
578 
579  ILFree(info->pidlRet);
580  info->pidlRet = ILClone(lptvid->lpifq);
581 
582  if (GetName(lptvid->lpsfParent, lptvid->lpi, SHGDN_NORMAL, name))
584 
585  browsefolder_callback( info->lpBrowseInfo, info->hWnd, BFFM_SELCHANGED,
586  (LPARAM)info->pidlRet );
588  return S_OK;
589 }
590 
592 {
593  LPTV_ITEMDATA item_data;
594  WCHAR old_path[MAX_PATH], new_path[MAX_PATH], *p;
595  NMTREEVIEWW nmtv;
596  TVITEMW item;
597 
598  if(!pnmtv->item.pszText)
599  return 0;
600 
601  item.mask = TVIF_HANDLE|TVIF_PARAM;
602  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
603  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
604  item_data = (LPTV_ITEMDATA)item.lParam;
605 
606  SHGetPathFromIDListW(item_data->lpifq, old_path);
607  if(!(p = strrchrW(old_path, '\\')))
608  return 0;
609  p = new_path+(p-old_path+1);
610  memcpy(new_path, old_path, (p-new_path)*sizeof(WCHAR));
611  strcpyW(p, pnmtv->item.pszText);
612 
613  if(!MoveFileW(old_path, new_path))
614  return 0;
615 
616  SHFree(item_data->lpifq);
617  SHFree(item_data->lpi);
618  item_data->lpifq = SHSimpleIDListFromPathW(new_path);
619  IShellFolder_ParseDisplayName(item_data->lpsfParent, NULL, NULL,
620  pnmtv->item.pszText, NULL, &item_data->lpi, NULL);
621 
622  item.mask = TVIF_HANDLE|TVIF_TEXT;
623  item.pszText = pnmtv->item.pszText;
624  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
625 
626  nmtv.itemNew.lParam = item.lParam;
628  return 0;
629 }
630 
632 {
634  SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename);
635  return S_OK;
636 }
637 
638 #ifdef __REACTOS__
639 static void
640 BrsFolder_Delete(browse_info *info, HTREEITEM selected_item)
641 {
642  TV_ITEMW item;
643  TV_ITEMDATA *item_data;
644  SHFILEOPSTRUCTW fileop = { info->hwndTreeView };
645  WCHAR szzFrom[MAX_PATH + 1];
646 
647  /* get item_data */
648  item.mask = TVIF_HANDLE | TVIF_PARAM;
649  item.hItem = selected_item;
650  if (!SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item))
651  {
652  ERR("TVM_GETITEMW failed\n");
653  return;
654  }
655  item_data = (TV_ITEMDATA *)item.lParam;
656 
657  /* get the path */
658  if (!SHGetPathFromIDListW(item_data->lpifq, szzFrom))
659  {
660  ERR("SHGetPathFromIDListW failed\n");
661  return;
662  }
663  szzFrom[lstrlenW(szzFrom) + 1] = 0; /* double NULL-terminated */
664  fileop.pFrom = szzFrom;
665 
666  /* delete folder */
667  fileop.fFlags = FOF_ALLOWUNDO;
668  fileop.wFunc = FO_DELETE;
669  SHFileOperationW(&fileop);
670 }
671 #endif
673 {
674  HTREEITEM selected_item;
675 
676  /* Old dialog doesn't support those advanced features */
677 #ifdef __REACTOS__
678  if (!(info->lpBrowseInfo->ulFlags & BIF_USENEWUI))
679 #else
680  if (!(info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
681 #endif
682  return 0;
683 
684  selected_item = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
685 
686  switch (keydown->wVKey)
687  {
688  case VK_F2:
689  BrsFolder_Rename(info, selected_item);
690  break;
691  case VK_DELETE:
692  {
693 #ifdef __REACTOS__
694  BrsFolder_Delete(info, selected_item);
695 #else
696  const ITEMIDLIST *item_id;
697  ISFHelper *psfhlp;
698  HRESULT hr;
699  TVITEMW item;
700  TV_ITEMDATA *item_data;
701 
702  item.mask = TVIF_PARAM;
703  item.mask = TVIF_HANDLE|TVIF_PARAM;
704  item.hItem = selected_item;
705  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
706  item_data = (TV_ITEMDATA *)item.lParam;
707  item_id = item_data->lpi;
708 
709  hr = IShellFolder_QueryInterface(item_data->lpsfParent, &IID_ISFHelper, (void**)&psfhlp);
710  if(FAILED(hr))
711  return 0;
712 
713  /* perform the item deletion - tree view gets updated over shell notification */
714  ISFHelper_DeleteItems(psfhlp, 1, &item_id);
715  ISFHelper_Release(psfhlp);
716 #endif
717  }
718  break;
719  }
720  return 0;
721 }
722 
724 {
725  NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
726 
727  TRACE("%p %x %p msg=%x\n", info, CtlID, lpnmh, pnmtv->hdr.code);
728 
730  return 0;
731 
732  switch (pnmtv->hdr.code)
733  {
734  case TVN_DELETEITEMA:
735  case TVN_DELETEITEMW:
736  return BrsFolder_Treeview_Delete( info, pnmtv );
737 
738  case TVN_ITEMEXPANDINGA:
739  case TVN_ITEMEXPANDINGW:
740  return BrsFolder_Treeview_Expand( info, pnmtv );
741 
742  case TVN_SELCHANGEDA:
743  case TVN_SELCHANGEDW:
744  return BrsFolder_Treeview_Changed( info, pnmtv );
745 
746  case TVN_ENDLABELEDITA:
747  case TVN_ENDLABELEDITW:
749 
750  case TVN_KEYDOWN:
752 
753  default:
754  WARN("unhandled (%d)\n", pnmtv->hdr.code);
755  break;
756  }
757 
758  return 0;
759 }
760 
761 
763 {
764  LPITEMIDLIST computer_pidl;
765  SHChangeNotifyEntry ntreg;
766  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
767 
768  info->hWnd = hWnd;
769  SetPropW( hWnd, L"__WINE_BRSFOLDERDLG_INFO", info );
770 
771  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
772  FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n");
773  if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS)
774  FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS);
775 
776 #ifdef __REACTOS__
777  if (lpBrowseInfo->ulFlags & BIF_USENEWUI)
778 #else
779  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
780 #endif
781  {
782  RECT rcWnd;
783 
784 #ifdef __REACTOS__
785  /* Resize the treeview if there's not editbox */
786  if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
787  && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
788  {
789  RECT rcEdit, rcTreeView;
790  INT cy;
793  cy = rcTreeView.top - rcEdit.top;
794  MapWindowPoints(NULL, hWnd, (LPPOINT)&rcTreeView, sizeof(RECT) / sizeof(POINT));
795  rcTreeView.top -= cy;
797  rcTreeView.left, rcTreeView.top,
798  rcTreeView.right - rcTreeView.left,
799  rcTreeView.bottom - rcTreeView.top, TRUE);
800  }
801  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
803  else
804  info->layout = NULL;
805 #else
807 #endif
808 
809  /* TODO: Windows allows shrinking the windows a bit */
810  GetWindowRect(hWnd, &rcWnd);
811  info->szMin.cx = rcWnd.right - rcWnd.left;
812  info->szMin.cy = rcWnd.bottom - rcWnd.top;
813  }
814  else
815  {
816  info->layout = NULL;
817  }
818 
819  if (lpBrowseInfo->lpszTitle)
821  else
823 
824  if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT)
825 #ifdef __REACTOS__
826  || (lpBrowseInfo->ulFlags & BIF_USENEWUI))
827 #else
828  || (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
829 #endif
831 
832  /* Hide "Make New Folder" Button? */
833  if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON)
834  || !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
836 
837  /* Hide the editbox? */
838  if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX))
839  {
842  }
843 
845  if (info->hwndTreeView)
846  {
848 
849 #ifndef __REACTOS__
850  /* Resize the treeview if there's not editbox */
851  if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
852  && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
853  {
854  RECT rc;
855  GetClientRect(info->hwndTreeView, &rc);
856  SetWindowPos(info->hwndTreeView, HWND_TOP, 0, 0,
857  rc.right, rc.bottom + 40, SWP_NOMOVE);
858  }
859 #endif
860  }
861  else
862  ERR("treeview control missing!\n");
863 
864  /* Register for change notifications */
865  SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, 0, &computer_pidl);
866 
867  ntreg.pidl = computer_pidl;
868  ntreg.fRecursive = TRUE;
869 
871 
872 #ifdef __REACTOS__
873  SetFocus(info->hwndTreeView);
874 #endif
875  browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 );
876 
877 #ifdef __REACTOS__
880  return TRUE;
881 #else
882  return TRUE;
883 #endif
884 }
885 
887 {
888  DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
889  IShellFolder *desktop, *cur;
890 #ifdef __REACTOS__
891  WCHAR wszNewFolder[25];
893 #else
894  ISFHelper *sfhelper;
895 #endif
897  HTREEITEM parent, added;
898  LPTV_ITEMDATA item_data;
899  LPITEMIDLIST new_item;
900  TVITEMW item;
901  HRESULT hr;
902  int len;
903 
904 #ifdef __REACTOS__
905  hr = SHGetDesktopFolder(&desktop);
906  if(FAILED(hr))
907  return hr;
908 
909  if (info->pidlRet)
910  {
911  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
912  IShellFolder_Release(desktop);
913  if(FAILED(hr))
914  return hr;
915 
916  hr = SHGetPathFromIDListW(info->pidlRet, path);
917  }
918  else
919  {
920  cur = desktop;
922  }
923  if(FAILED(hr))
924  return hr;
925 
926  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
927  return E_FAIL;
928 
929  if (!PathYetAnotherMakeUniqueName(name, path, NULL, wszNewFolder))
930  return E_FAIL;
931 
932  len = strlenW(path);
933  if(len<MAX_PATH && name[len] == L'\\')
934  len++;
935 #else
936  if(!info->pidlRet) {
937  ERR("Make new folder button should be disabled\n");
938  return E_FAIL;
939  }
940 
941  /* Create new directory */
942  hr = SHGetDesktopFolder(&desktop);
943  if(FAILED(hr))
944  return hr;
945 
946  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
947  IShellFolder_Release(desktop);
948  if(FAILED(hr))
949  return hr;
950 
951  hr = IShellFolder_QueryInterface(cur, &IID_ISFHelper, (void**)&sfhelper);
952  if(FAILED(hr))
953  return hr;
954 
955  if(!SHGetPathFromIDListW(info->pidlRet, name)) {
956  hr = E_FAIL;
957  goto cleanup;
958  }
959 
960  len = strlenW(name);
961  if(len<MAX_PATH)
962  name[len++] = '\\';
963  hr = ISFHelper_GetUniqueName(sfhelper, &name[len], MAX_PATH-len);
964  ISFHelper_Release(sfhelper);
965  if(FAILED(hr))
966  goto cleanup;
967 #endif
968 
969  hr = E_FAIL;
970  if(!CreateDirectoryW(name, NULL))
971  goto cleanup;
972 
973  /* Update parent of newly created directory */
975  if(!parent)
976  goto cleanup;
977 
978  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)parent);
979 
980  memset(&item, 0, sizeof(TVITEMW));
981  item.mask = TVIF_PARAM|TVIF_STATE;
982  item.hItem = parent;
983  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
984  item_data = (LPTV_ITEMDATA)item.lParam;
985  if(!item_data)
986  goto cleanup;
987 
988  if(item_data->pEnumIL)
989  IEnumIDList_Release(item_data->pEnumIL);
990  hr = IShellFolder_EnumObjects(cur, info->hwndTreeView, flags, &item_data->pEnumIL);
991  if(FAILED(hr))
992  goto cleanup;
993 
994  /* Update treeview */
995  if(!(item.state&TVIS_EXPANDEDONCE)) {
996  item.mask = TVIF_STATE;
997  item.state = TVIS_EXPANDEDONCE;
998  item.stateMask = TVIS_EXPANDEDONCE;
999  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
1000  }
1001 
1002  hr = IShellFolder_ParseDisplayName(cur, NULL, NULL, name+len, NULL, &new_item, NULL);
1003  if(FAILED(hr))
1004  goto cleanup;
1005 
1006  added = InsertTreeViewItem(info, cur, new_item, item_data->lpifq, NULL, parent);
1007  IShellFolder_Release(cur);
1008  SHFree(new_item);
1009 
1010  SendMessageW(info->hwndTreeView, TVM_SORTCHILDREN, FALSE, (LPARAM)parent);
1011  return BrsFolder_Rename(info, added);
1012 
1013 cleanup:
1014  return hr;
1015 }
1016 
1018 {
1019  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
1020 #ifdef __REACTOS__
1022 #endif
1023 
1024  switch (id)
1025  {
1026  case IDOK:
1027 #ifdef __REACTOS__
1028  /* Get the text */
1030  StrTrimW(szPath, L" \t");
1031 
1032  /* The original pidl is owned by the treeview and will be free'd. */
1034  {
1035  /* It's valid path */
1036  info->pidlRet = ILCreateFromPathW(szPath);
1037  }
1038  else
1039  {
1040  info->pidlRet = ILClone(info->pidlRet);
1041  }
1042 #endif
1043  if (info->pidlRet == NULL) /* A null pidl would mean a cancel */
1044  info->pidlRet = _ILCreateDesktop();
1045  pdump( info->pidlRet );
1046  if (lpBrowseInfo->pszDisplayName)
1047  SHGetPathFromIDListW( info->pidlRet, lpBrowseInfo->pszDisplayName );
1048  EndDialog( info->hWnd, 1 );
1049  return TRUE;
1050 
1051  case IDCANCEL:
1052  EndDialog( info->hWnd, 0 );
1053  return TRUE;
1054 
1057  return TRUE;
1058  }
1059  return FALSE;
1060 }
1061 
1063  BOOL is_str, HTREEITEM *pItem)
1064 {
1065  LPITEMIDLIST pidlSelection = selection;
1066  LPCITEMIDLIST pidlCurrent, pidlRoot;
1067  TVITEMEXW item;
1068  BOOL bResult = FALSE;
1069 
1070  memset(&item, 0, sizeof(item));
1071 
1072  /* If 'selection' is a string, convert to a Shell ID List. */
1073  if (is_str) {
1074  IShellFolder *psfDesktop;
1075  HRESULT hr;
1076 
1077  hr = SHGetDesktopFolder(&psfDesktop);
1078  if (FAILED(hr))
1079  goto done;
1080 
1081  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL,
1082  selection, NULL, &pidlSelection, NULL);
1083  IShellFolder_Release(psfDesktop);
1084  if (FAILED(hr))
1085  goto done;
1086  }
1087 #ifdef __REACTOS__
1088  if (_ILIsDesktop(pidlSelection))
1089  {
1090  item.hItem = TVI_ROOT;
1091  bResult = TRUE;
1092  goto done;
1093  }
1094 #endif
1095 
1096  /* Move pidlCurrent behind the SHITEMIDs in pidlSelection, which are the root of
1097  * the sub-tree currently displayed. */
1098  pidlRoot = info->lpBrowseInfo->pidlRoot;
1099  pidlCurrent = pidlSelection;
1100  while (!_ILIsEmpty(pidlRoot) && _ILIsEqualSimple(pidlRoot, pidlCurrent)) {
1101  pidlRoot = ILGetNext(pidlRoot);
1102  pidlCurrent = ILGetNext(pidlCurrent);
1103  }
1104 
1105  /* The given ID List is not part of the SHBrowseForFolder's current sub-tree. */
1106  if (!_ILIsEmpty(pidlRoot))
1107  goto done;
1108 
1109  /* Initialize item to point to the first child of the root folder. */
1110  item.mask = TVIF_PARAM;
1111  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
1112 
1113  if (item.hItem)
1114  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
1115  (LPARAM)item.hItem);
1116 
1117  /* Walk the tree along the nodes corresponding to the remaining ITEMIDLIST */
1118  while (item.hItem && !_ILIsEmpty(pidlCurrent)) {
1119  LPTV_ITEMDATA pItemData;
1120 
1121  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
1122  pItemData = (LPTV_ITEMDATA)item.lParam;
1123 
1124  if (_ILIsEqualSimple(pItemData->lpi, pidlCurrent)) {
1125  pidlCurrent = ILGetNext(pidlCurrent);
1126  if (!_ILIsEmpty(pidlCurrent)) {
1127  /* Only expand current node and move on to its first child,
1128  * if we didn't already reach the last SHITEMID */
1129  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item.hItem);
1130  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
1131  (LPARAM)item.hItem);
1132  }
1133  } else {
1134  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_NEXT,
1135  (LPARAM)item.hItem);
1136  }
1137  }
1138 
1139  if (_ILIsEmpty(pidlCurrent) && item.hItem)
1140  bResult = TRUE;
1141 
1142 done:
1143  if (pidlSelection && pidlSelection != selection)
1144  ILFree(pidlSelection);
1145 
1146  if (pItem)
1147  *pItem = item.hItem;
1148 
1149  return bResult;
1150 }
1151 
1153  HTREEITEM hItem;
1154  BOOL bResult;
1155 
1156  if (!selection) return FALSE;
1157 
1158  bResult = BrsFolder_OnSetExpanded(info, selection, is_str, &hItem);
1159  if (bResult)
1160  SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem );
1161  return bResult;
1162 }
1163 
1165  LPWSTR selectionW = NULL;
1166  BOOL result = FALSE;
1167  int length;
1168 
1169  if (!is_str)
1170  return BrsFolder_OnSetSelectionW(info, selection, is_str);
1171 
1172  if ((length = MultiByteToWideChar(CP_ACP, 0, selection, -1, NULL, 0)) &&
1173  (selectionW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR))) &&
1174  MultiByteToWideChar(CP_ACP, 0, selection, -1, selectionW, length))
1175  {
1176  result = BrsFolder_OnSetSelectionW(info, selectionW, is_str);
1177  }
1178 
1179  HeapFree(GetProcessHeap(), 0, selectionW);
1180  return result;
1181 }
1182 
1183 #ifndef __REACTOS__ /* This is a buggy way (resize on title bar) */
1185 {
1186 #ifdef __REACTOS__
1187  if ((info->lpBrowseInfo->ulFlags & BIF_USENEWUI) && !(pos->flags & SWP_NOSIZE))
1188 #else
1189  if ((info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) && !(pos->flags & SWP_NOSIZE))
1190 #endif
1191  {
1192  if (pos->cx < info->szMin.cx)
1193  pos->cx = info->szMin.cx;
1194  if (pos->cy < info->szMin.cy)
1195  pos->cy = info->szMin.cy;
1196  }
1197  return 0;
1198 }
1199 #endif
1200 
1202 {
1203  if (info->layout)
1204  {
1205 #ifdef __REACTOS__
1206  LayoutDestroy(info->layout);
1207 #else
1208  SHFree(info->layout);
1209 #endif
1210  info->layout = NULL;
1211  }
1212 
1213  SHChangeNotifyDeregister(info->hNotify);
1214 
1215  return 0;
1216 }
1217 
1218 /* Find a treeview node by recursively walking the treeview */
1220 {
1221  TV_ITEMW item;
1222  TV_ITEMDATA *item_data;
1223  HRESULT hr;
1224 
1225  item.mask = TVIF_HANDLE | TVIF_PARAM;
1226  item.hItem = hItem;
1227  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
1228  item_data = (TV_ITEMDATA *)item.lParam;
1229 
1230  hr = IShellFolder_CompareIDs(item_data->lpsfParent, 0, item_data->lpifq, pidl);
1231  if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
1232  return hItem;
1233 
1235 
1236  while (hItem)
1237  {
1238  HTREEITEM newItem = BrsFolder_FindItemByPidl(info, pidl, hItem);
1239  if (newItem)
1240  return newItem;
1242  }
1243  return NULL;
1244 }
1245 
1247 {
1248  BOOL ret = TRUE;
1249 
1250  TRACE("(%p)->(%p, %p, 0x%08x)\n", info, pidls[0], pidls[1], event);
1251 
1252  switch (event)
1253  {
1254  case SHCNE_RMDIR:
1255  case SHCNE_DELETE:
1256  {
1257  HTREEITEM handle_root = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
1258  HTREEITEM handle_item = BrsFolder_FindItemByPidl(info, pidls[0], handle_root);
1259 
1260  if (handle_item)
1261  SendMessageW(info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)handle_item);
1262 
1263  break;
1264  }
1265  }
1266  return ret;
1267 }
1268 
1269 /*************************************************************************
1270  * BrsFolderDlgProc32 (not an exported API function)
1271  */
1273  LPARAM lParam )
1274 {
1275  browse_info *info;
1276 
1277  TRACE("hwnd=%p msg=%04x 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam );
1278 
1279  if (msg == WM_INITDIALOG)
1280  return BrsFolder_OnCreate( hWnd, (browse_info*) lParam );
1281 
1282  info = GetPropW( hWnd, L"__WINE_BRSFOLDERDLG_INFO" );
1283 
1284  switch (msg)
1285  {
1286  case WM_NOTIFY:
1288 
1289  case WM_COMMAND:
1290  return BrsFolder_OnCommand( info, wParam );
1291 
1292 #ifdef __REACTOS__
1293  case WM_GETMINMAXINFO:
1294  ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = info->szMin.cx;
1295  ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = info->szMin.cy;
1296  return 0;
1297 #else /* This is a buggy way (resize on title bar) */
1298  case WM_WINDOWPOSCHANGING:
1300 #endif
1301 
1302  case WM_SIZE:
1303  if (info->layout) /* new style dialogs */
1305  return 0;
1306 
1307  case BFFM_SETSTATUSTEXTA:
1308  TRACE("Set status %s\n", debugstr_a((LPSTR)lParam));
1310  break;
1311 
1312  case BFFM_SETSTATUSTEXTW:
1313  TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam));
1315  break;
1316 
1317  case BFFM_ENABLEOK:
1318  TRACE("Enable %ld\n", lParam);
1319  EnableWindow(GetDlgItem(hWnd, 1), lParam != 0);
1320  break;
1321 
1322  case BFFM_SETOKTEXT: /* unicode only */
1323  TRACE("Set OK text %s\n", debugstr_w((LPWSTR)lParam));
1325  break;
1326 
1327  case BFFM_SETSELECTIONA:
1329 
1330  case BFFM_SETSELECTIONW:
1332 
1333  case BFFM_SETEXPANDED: /* unicode only */
1335 
1336  case SHV_CHANGE_NOTIFY:
1338 
1339  case WM_DESTROY:
1340  return BrsFolder_OnDestroy(info);
1341  }
1342  return FALSE;
1343 }
1344 
1345 /*************************************************************************
1346  * SHBrowseForFolderA [SHELL32.@]
1347  * SHBrowseForFolder [SHELL32.@]
1348  */
1350 {
1351  BROWSEINFOW bi;
1352  LPITEMIDLIST lpid;
1353  INT len;
1354  LPWSTR title;
1355 
1356  TRACE("%p\n", lpbi);
1357 
1358  bi.hwndOwner = lpbi->hwndOwner;
1359  bi.pidlRoot = lpbi->pidlRoot;
1360  if (lpbi->pszDisplayName)
1361  bi.pszDisplayName = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) );
1362  else
1363  bi.pszDisplayName = NULL;
1364 
1365  if (lpbi->lpszTitle)
1366  {
1367  len = MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, NULL, 0 );
1368  title = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1369  MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, title, len );
1370  }
1371  else
1372  title = NULL;
1373 
1374  bi.lpszTitle = title;
1375  bi.ulFlags = lpbi->ulFlags;
1376  bi.lpfn = lpbi->lpfn;
1377  bi.lParam = lpbi->lParam;
1378  bi.iImage = lpbi->iImage;
1379  lpid = SHBrowseForFolderW( &bi );
1380  if (bi.pszDisplayName)
1381  {
1383  lpbi->pszDisplayName, MAX_PATH, 0, NULL);
1385  }
1386  HeapFree(GetProcessHeap(), 0, title);
1387  lpbi->iImage = bi.iImage;
1388  return lpid;
1389 }
1390 
1391 
1392 /*************************************************************************
1393  * SHBrowseForFolderW [SHELL32.@]
1394  *
1395  * NOTES
1396  * crashes when passed a null pointer
1397  */
1399 {
1400  browse_info info;
1401  DWORD r;
1402  HRESULT hr;
1403 #ifdef __REACTOS__
1404  WORD wDlgId;
1405 #else
1406  const WCHAR * templateName;
1407  INITCOMMONCONTROLSEX icex;
1408 #endif
1409 
1410  info.hWnd = 0;
1411  info.pidlRet = NULL;
1412  info.lpBrowseInfo = lpbi;
1413  info.hwndTreeView = NULL;
1414 
1415 #ifdef __REACTOS__
1416  info.layout = NULL;
1417 #else
1418  icex.dwSize = sizeof( icex );
1419  icex.dwICC = ICC_TREEVIEW_CLASSES;
1420  InitCommonControlsEx( &icex );
1421 #endif
1422 
1423  hr = OleInitialize(NULL);
1424 
1425 #ifdef __REACTOS__
1426  if (lpbi->ulFlags & BIF_USENEWUI)
1427 #else
1428  if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
1429 #endif
1430  wDlgId = IDD_BROWSE_FOR_FOLDER_NEW;
1431  else
1432  wDlgId = IDD_BROWSE_FOR_FOLDER;
1435  if (SUCCEEDED(hr))
1436  OleUninitialize();
1437  if (!r)
1438  {
1439  ILFree(info.pidlRet);
1440  return NULL;
1441  }
1442 
1443  return info.pidlRet;
1444 }
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:539
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:407
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1722
#define IDC_BROWSE_FOR_FOLDER_STATUS
Definition: shresdef.h:409
struct tagLAYOUT_DATA LAYOUT_DATA
int cchTextMax
Definition: commctrl.h:3321
#define SHGFI_SYSICONINDEX
Definition: shellapi.h:169
#define IDS_NEWFOLDER
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
static BOOL BrsFolder_OnSetSelectionA(browse_info *info, LPVOID selection, BOOL is_str)
Definition: brsfolder.c:1164
#define SHCNE_RMDIR
Definition: shlobj.h:1733
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1578
#define IDOK
Definition: winuser.h:824
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2187
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:925
HTREEITEM hParent
Definition: commctrl.h:3393
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1602
TVITEMW itemOld
Definition: commctrl.h:3637
static BOOL _ILIsEmpty(LPCITEMIDLIST pidl)
Definition: pidl.h:257
static HTREEITEM InsertTreeViewItem(browse_info *, IShellFolder *, LPCITEMIDLIST, LPCITEMIDLIST, IEnumIDList *, HTREEITEM)
Definition: brsfolder.c:374
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
static __inline void LayoutDestroy(LAYOUT_DATA *pData)
Definition: layout.h:251
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:111
static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
Definition: brsfolder.c:306
HRESULT hr
Definition: shlfolder.c:183
GLuint64EXT * result
Definition: glext.h:11304
struct tagTV_ITEMDATA * LPTV_ITEMDATA
#define TV_ITEMW
Definition: commctrl.h:3297
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define TVM_EXPAND
Definition: commctrl.h:3419
#define TVM_SELECTITEM
Definition: commctrl.h:3478
LPITEMIDLIST lpifq
Definition: brsfolder.c:74
#define TVM_SORTCHILDREN
Definition: commctrl.h:3541
#define TVGN_CARET
Definition: commctrl.h:3461
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:1931
#define TRUE
Definition: types.h:120
#define CSIDL_DESKTOP
Definition: shlobj.h:2012
#define TVN_DELETEITEMA
Definition: commctrl.h:3707
static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
Definition: brsfolder.c:344
#define SW_HIDE
Definition: winuser.h:762
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define LAYOUT_INFO_COUNT
Definition: brsfolder.c:105
#define CP_ACP
Definition: compat.h:109
int iImage
Definition: commctrl.h:3322
static void BrsFolder_CheckValidSelection(browse_info *info, LPTV_ITEMDATA lptvid)
Definition: brsfolder.c:488
#define WARN(fmt,...)
Definition: debug.h:112
static HRESULT BrsFolder_Treeview_Changed(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:574
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:699
#define TVGN_NEXT
Definition: commctrl.h:3453
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3264
#define BIF_BROWSEINCLUDEFILES
Definition: shlobj.h:1159
static LRESULT BrsFolder_OnChange(browse_info *info, const LPCITEMIDLIST *pidls, LONG event)
Definition: brsfolder.c:1246
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1294
#define CALLBACK
Definition: compat.h:35
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:851
HWND hWnd
Definition: settings.c:17
LPARAM lParam
Definition: commctrl.h:3325
static BOOL PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type)
Definition: brsfolder.c:480
#define BF_BOTTOM
Definition: winuser.h:457
#define BFFM_INITIALIZED
Definition: shlobj.h:1163
LONG top
Definition: windef.h:307
#define FOF_ALLOWUNDO
Definition: shellapi.h:144
LAYOUT_DATA * layout
Definition: brsfolder.c:65
HWND hwndOwner
Definition: shlobj.h:1127
#define HWND_TOP
Definition: winuser.h:1197
#define BFFM_SETSELECTIONA
Definition: shlobj.h:1172
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define BIF_NONEWFOLDERBUTTON
Definition: shlobj.h:1154
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:212
#define TVIS_EXPANDEDONCE
Definition: commctrl.h:3285
#define BIF_EDITBOX
Definition: shlobj.h:1148
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1237
UINT uFlags
Definition: api.c:59
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
UINT mask
Definition: commctrl.h:3316
int32_t INT_PTR
Definition: typedefs.h:64
if(dx==0 &&dy==0)
Definition: linetemp.h:174
char * LPSTR
Definition: xmlstorage.h:182
FILEOP_FLAGS fFlags
Definition: shellapi.h:357
LONG right
Definition: windef.h:308
#define lstrlenW
Definition: compat.h:609
#define E_FAIL
Definition: ddrawi.h:102
struct tagLAYOUT_INFO LAYOUT_INFO
LPWSTR pszText
Definition: commctrl.h:3320
BFFCALLBACK lpfn
Definition: shlobj.h:1121
#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:58
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1982
static BOOLEAN bSuccess
Definition: drive.cpp:430
#define BFFM_SETEXPANDED
Definition: shlobj.h:1176
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:251
#define IDC_BROWSE_FOR_FOLDER_TITLE
Definition: shresdef.h:410
#define TVN_SELCHANGEDA
Definition: commctrl.h:3647
UINT code
Definition: winuser.h:3139
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVN_ENDLABELEDITW
Definition: commctrl.h:3712
static DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
Definition: brsfolder.c:120
static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename)
Definition: brsfolder.c:631
#define ICC_TREEVIEW_CLASSES
Definition: commctrl.h:59
#define L(x)
Definition: ntvdm.h:50
static LRESULT BrsFolder_OnNotify(browse_info *info, UINT CtlID, LPNMHDR lpnmh)
Definition: brsfolder.c:723
LPSTR pszDisplayName
Definition: shlobj.h:1118
#define TVM_SETITEMW
Definition: commctrl.h:3493
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
#define TVIF_CHILDREN
Definition: commctrl.h:3272
#define FALSE
Definition: types.h:117
HWND hwndTreeView
Definition: brsfolder.c:62
HTREEITEM hInsertAfter
Definition: commctrl.h:3394
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SHCNE_ALLEVENTS
Definition: shlobj.h:1753
long LONG
Definition: pedump.c:60
LPWSTR pszDisplayName
Definition: shlobj.h:1129
IEnumIDList * pEnumIL
Definition: brsfolder.c:75
UINT_PTR idFrom
Definition: winuser.h:3138
static struct _test_info info[]
Definition: SetCursorPos.c:19
if SUCCEEDED(hr)
#define debugstr_w
Definition: kernel32.h:32
#define SHGFI_PIDL
Definition: shellapi.h:178
#define FIXME(fmt,...)
Definition: debug.h:111
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1044
#define BIF_RETURNFSANCESTORS
Definition: shlobj.h:1147
#define TVM_SETIMAGELIST
Definition: commctrl.h:3446
#define VK_F2
Definition: winuser.h:2236
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:585
HTREEITEM hItem
Definition: treelist.h:37
const WCHAR * str
#define TVGN_ROOT
Definition: commctrl.h:3452
#define SHCNRF_InterruptLevel
Definition: shlobj.h:1774
#define SHACF_FILESYSTEM
Definition: shlwapi.h:1912
#define SHGFI_OPENICON
Definition: shellapi.h:176
struct tagMINMAXINFO * LPMINMAXINFO
#define SHV_CHANGE_NOTIFY
Definition: brsfolder.c:48
#define IDC_WAIT
Definition: winuser.h:684
#define BFFM_SETSELECTIONW
Definition: shlobj.h:1173
ULONG hNotify
Definition: brsfolder.c:67
LONG_PTR LPARAM
Definition: windef.h:208
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:189
LPITEMIDLIST pidlRet
Definition: brsfolder.c:64
static BOOL BrsFolder_OnSetSelectionW(browse_info *info, LPVOID selection, BOOL is_str)
Definition: brsfolder.c:1152
LPSHELLFOLDER lpsfParent
Definition: brsfolder.c:72
#define IDD_BROWSE_FOR_FOLDER
Definition: shresdef.h:404
#define TVN_ITEMEXPANDINGW
Definition: commctrl.h:3700
int cChildren
Definition: commctrl.h:3324
#define TVN_SELCHANGEDW
Definition: commctrl.h:3648
#define IDC_BROWSE_FOR_FOLDER_FOLDER
Definition: shresdef.h:408
#define VK_DELETE
Definition: winuser.h:2213
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
#define WM_DESTROY
Definition: winuser.h:1596
#define TVN_DELETEITEMW
Definition: commctrl.h:3708
HRESULT WINAPI SHAutoComplete(HWND hwndEdit, DWORD dwFlags)
Definition: autocomp.cpp:191
static LAYOUT_DATA * LayoutInit(HWND hwnd, const LAYOUT_INFO *layout_info, int layout_count)
Definition: brsfolder.c:134
LPCWSTR lpszTitle
Definition: shlobj.h:1130
TVITEMW itemNew
Definition: commctrl.h:3638
BYTE PIDLTYPE
Definition: pidl.h:108
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
#define BIF_STATUSTEXT
Definition: shlobj.h:1146
#define BIF_NEWDIALOGSTYLE
Definition: shlobj.h:1150
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
r parent
Definition: btrfs.c:2979
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1120
__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:163
#define TVM_EDITLABELW
Definition: commctrl.h:3500
DWORD_PTR WINAPI SHGetFileInfoW(LPCWSTR path, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags)
Definition: shell32_main.c:414
#define WM_SIZE
Definition: winuser.h:1598
#define debugstr_a
Definition: kernel32.h:31
static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection, BOOL is_str, HTREEITEM *pItem)
Definition: brsfolder.c:1062
LONG HRESULT
Definition: typedefs.h:79
BOOL WINAPI SetWindowTextA(_In_ HWND, _In_opt_ LPCSTR)
#define BF_RIGHT
Definition: winuser.h:456
EXTERN_C BOOL WINAPI SHChangeNotifyDeregister(ULONG hNotify)
#define _countof(array)
Definition: sndvol32.h:68
#define TVN_ENDLABELEDITA
Definition: commctrl.h:3711
LPITEMIDLIST WINAPI SHBrowseForFolderA(LPBROWSEINFOA lpbi)
Definition: brsfolder.c:1349
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1648
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
PCIDLIST_ABSOLUTE pidlRoot
Definition: shlobj.h:1117
unsigned long DWORD
Definition: ntddk_ex.h:95
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2074
#define BIF_USENEWUI
Definition: shlobj.h:1151
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define TVE_EXPAND
Definition: commctrl.h:3423
GLbitfield flags
Definition: glext.h:7161
#define TVI_ROOT
Definition: commctrl.h:3368
LPCSTR lpszTitle
Definition: shlobj.h:1119
LPCWSTR pFrom
Definition: shellapi.h:355
int ret
#define TVM_DELETEITEM
Definition: commctrl.h:3414
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:893
static HRESULT BrsFolder_NewFolder(browse_info *info)
Definition: brsfolder.c:886
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static LRESULT BrsFolder_OnWindowPosChanging(browse_info *info, WINDOWPOS *pos)
Definition: brsfolder.c:1184
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1725
#define WM_COMMAND
Definition: winuser.h:1727
struct _cl_event * event
Definition: glext.h:7739
PCIDLIST_ABSOLUTE pidlRoot
Definition: shlobj.h:1128
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define TVGN_CHILD
Definition: commctrl.h:3456
static int GetIcon(LPCITEMIDLIST lpi, UINT uFlags)
Definition: brsfolder.c:299
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2059
#define IDD_BROWSE_FOR_FOLDER_NEW
Definition: shresdef.h:405
static LRESULT BrsFolder_Treeview_Keydown(browse_info *info, LPNMTVKEYDOWN keydown)
Definition: brsfolder.c:672
UINT ulFlags
Definition: shlobj.h:1120
BOOL WINAPI Shell_GetImageLists(HIMAGELIST *lpBigList, HIMAGELIST *lpSmallList)
Definition: iconcache.cpp:700
#define TVIF_HANDLE
Definition: commctrl.h:3270
FxCollectionEntry * cur
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:1398
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
#define TVM_GETNEXTITEM
Definition: commctrl.h:3449
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define BFFM_ENABLEOK
Definition: shlobj.h:1171
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:591
LPARAM lParam
Definition: shlobj.h:1122
#define S_OK
Definition: intsafe.h:52
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:1131
#define shell32_hInstance
static INT BrsFolder_OnDestroy(browse_info *info)
Definition: brsfolder.c:1201
static ATOM item
Definition: dde.c:856
#define BIF_RETURNONLYFSDIRS
Definition: shlobj.h:1144
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
LPARAM lParam
Definition: shlobj.h:1133
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
static void browsefolder_callback(LPBROWSEINFOW lpBrowseInfo, HWND hWnd, UINT msg, LPARAM param)
Definition: brsfolder.c:125
#define TVIF_TEXT
Definition: commctrl.h:3266
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
LPCWSTR szPath
Definition: env.c:37
static BOOL BrsFolder_OnCommand(browse_info *info, UINT id)
Definition: brsfolder.c:1017
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define SHCNE_DELETE
Definition: shlobj.h:1731
int iSelectedImage
Definition: commctrl.h:3323
static void InitializeTreeView(browse_info *info)
Definition: brsfolder.c:206
#define BF_TOP
Definition: winuser.h:455
#define BFFM_SELCHANGED
Definition: shlobj.h:1164
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:311
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BFFM_SETSTATUSTEXTA
Definition: shlobj.h:1170
BFFCALLBACK lpfn
Definition: shlobj.h:1132
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define SUPPORTEDFLAGS
Definition: brsfolder.c:107
#define IDC_BROWSE_FOR_FOLDER_TREEVIEW
Definition: shresdef.h:411
#define HWND_DESKTOP
Definition: winuser.h:1199
static void FillTreeView(browse_info *, LPSHELLFOLDER, LPITEMIDLIST, HTREEITEM, IEnumIDList *)
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HTREEITEM hItem
Definition: commctrl.h:3317
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
static BOOL BrsFolder_OnCreate(HWND hWnd, browse_info *info)
Definition: brsfolder.c:762
#define MultiByteToWideChar
Definition: compat.h:110
BOOL WINAPI StrTrimW(LPWSTR lpszStr, LPCWSTR lpszTrim)
Definition: string.c:1869
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:326
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define HRESULT_CODE(hr)
Definition: winerror.h:76
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2348
Definition: name.c:38
TVITEMW item
Definition: commctrl.h:3672
LPBROWSEINFOW lpBrowseInfo
Definition: brsfolder.c:63
EXTERN_C ULONG WINAPI SHChangeNotifyRegister(HWND hwnd, INT fSources, LONG wEventMask, UINT uMsg, INT cItems, SHChangeNotifyEntry *lpItems)
unsigned int ULONG
Definition: retypes.h:1
static HTREEITEM BrsFolder_FindItemByPidl(browse_info *info, LPCITEMIDLIST pidl, HTREEITEM hItem)
Definition: brsfolder.c:1219
LONG bottom
Definition: windef.h:309
#define TVIF_STATE
Definition: commctrl.h:3269
char * cleanup(char *str)
Definition: wpickclick.c:99
#define TVM_GETITEMW
Definition: commctrl.h:3486
UINT state
Definition: commctrl.h:3318
#define SWP_NOMOVE
Definition: winuser.h:1234
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2883
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)
#define SHACF_FILESYS_ONLY
Definition: shlwapi.h:1917
BOOL WINAPI PathYetAnotherMakeUniqueName(LPWSTR buffer, LPCWSTR path, LPCWSTR shortname, LPCWSTR longname)
Definition: shellpath.c:492
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define BFFM_SETOKTEXT
Definition: shlobj.h:1175
#define TVIF_PARAM
Definition: commctrl.h:3268
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2027
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:982
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:1272
LPITEMIDLIST lpi
Definition: brsfolder.c:73
LONG_PTR LRESULT
Definition: windef.h:209
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define SHACF_URLHISTORY
Definition: shlwapi.h:1913
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
HWND hwndOwner
Definition: shlobj.h:1116
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define BFFM_SETSTATUSTEXTW
Definition: shlobj.h:1174
#define FO_DELETE
Definition: shellapi.h:135
#define BIF_BROWSEFORCOMPUTER
Definition: shlobj.h:1157
#define WM_INITDIALOG
Definition: winuser.h:1726
LPARAM lParam
Definition: combotst.c:139
static char title[]
Definition: ps.c:92
#define WM_GETMINMAXINFO
Definition: winuser.h:1627
#define TVN_KEYDOWN
Definition: commctrl.h:3713
static const LAYOUT_INFO g_layout_info[]
Definition: brsfolder.c:86
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
#define HeapFree(x, y, z)
Definition: compat.h:594
DWORD dwAnchor
Definition: brsfolder.c:82
static LRESULT BrsFolder_Treeview_Delete(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:524
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:85
#define IDC_BROWSE_FOR_FOLDER_NEW_FOLDER
Definition: shresdef.h:406
#define BF_LEFT
Definition: winuser.h:454
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3699
struct tagTV_ITEMDATA TV_ITEMDATA