ReactOS  0.4.15-dev-5618-g8866b9d
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 #ifdef __REACTOS__
468  if (ulAttrs != (ulAttrs & SFGAO_FOLDER))
469  {
470  if (!InsertTreeViewItem(info, lpsf, pidlTemp, pidl, pEnumIL, hParent))
471  goto done;
472  }
473 #else
474 
475  if (!InsertTreeViewItem(info, lpsf, pidlTemp, pidl, pEnumIL, hParent))
476  goto done;
477 #endif
478  SHFree(pidlTemp); /* Finally, free the pidl that the shell gave us... */
479  pidlTemp=NULL;
480  }
481 
482 done:
483  ReleaseCapture();
485  SHFree(pidlTemp);
486 }
487 
489 {
491  if (!data)
492  return FALSE;
493  return (data->type == type);
494 }
495 
497 {
498  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
499  LPCITEMIDLIST pidl = lptvid->lpi;
500  BOOL bEnabled = TRUE;
502  HRESULT r;
503 
504  if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) &&
505  !PIDLIsType(pidl, PT_COMP))
506  bEnabled = FALSE;
507  if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS)
508  {
509  dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
510  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
511  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
512  if (FAILED(r) || !(dwAttributes & (SFGAO_FILESYSANCESTOR|SFGAO_FILESYSTEM)))
513  bEnabled = FALSE;
514  }
515 
516  dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM;
517  r = IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1,
518  (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes);
519  if (FAILED(r) ||
520  ((dwAttributes & (SFGAO_FOLDER|SFGAO_FILESYSTEM)) != (SFGAO_FOLDER|SFGAO_FILESYSTEM)))
521  {
522  if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS)
523  bEnabled = FALSE;
525  }
526  else
528 
529  SendMessageW(info->hWnd, BFFM_ENABLEOK, 0, bEnabled);
530 }
531 
533 {
534  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA)pnmtv->itemOld.lParam;
535 
536  TRACE("TVN_DELETEITEMA/W %p\n", lptvid);
537 
538  IShellFolder_Release(lptvid->lpsfParent);
539  if (lptvid->pEnumIL)
540  IEnumIDList_Release(lptvid->pEnumIL);
541  SHFree(lptvid->lpi);
542  SHFree(lptvid->lpifq);
543  SHFree(lptvid);
544  return 0;
545 }
546 
548 {
549  IShellFolder *lpsf2 = NULL;
550  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
551  HRESULT r;
552 
553  TRACE("TVN_ITEMEXPANDINGA/W\n");
554 
555  if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
556  return 0;
557 
558  if (!_ILIsEmpty(lptvid->lpi)) {
559  r = IShellFolder_BindToObject( lptvid->lpsfParent, lptvid->lpi, 0,
560  &IID_IShellFolder, (void**)&lpsf2 );
561  } else {
562  lpsf2 = lptvid->lpsfParent;
563  IShellFolder_AddRef(lpsf2);
564  r = S_OK;
565  }
566 
567  if (SUCCEEDED(r))
568  {
569  FillTreeView( info, lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem, lptvid->pEnumIL);
570  IShellFolder_Release( lpsf2 );
571  }
572 
573  /* My Computer is already sorted and trying to do a simple text
574  * sort will only mess things up */
575  if (!_ILIsMyComputer(lptvid->lpi))
576  SendMessageW( info->hwndTreeView, TVM_SORTCHILDREN,
577  FALSE, (LPARAM)pnmtv->itemNew.hItem );
578 
579  return 0;
580 }
581 
583 {
584  LPTV_ITEMDATA lptvid = (LPTV_ITEMDATA) pnmtv->itemNew.lParam;
586 
587  ILFree(info->pidlRet);
588  info->pidlRet = ILClone(lptvid->lpifq);
589 
590  if (GetName(lptvid->lpsfParent, lptvid->lpi, SHGDN_NORMAL, name))
592 
593  browsefolder_callback( info->lpBrowseInfo, info->hWnd, BFFM_SELCHANGED,
594  (LPARAM)info->pidlRet );
596  return S_OK;
597 }
598 
600 {
601  LPTV_ITEMDATA item_data;
602  WCHAR old_path[MAX_PATH], new_path[MAX_PATH], *p;
603  NMTREEVIEWW nmtv;
604  TVITEMW item;
605 
606  if(!pnmtv->item.pszText)
607  return 0;
608 
609  item.mask = TVIF_HANDLE|TVIF_PARAM;
610  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
611  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
612  item_data = (LPTV_ITEMDATA)item.lParam;
613 
614  SHGetPathFromIDListW(item_data->lpifq, old_path);
615  if(!(p = strrchrW(old_path, '\\')))
616  return 0;
617  p = new_path+(p-old_path+1);
618  memcpy(new_path, old_path, (p-new_path)*sizeof(WCHAR));
619  strcpyW(p, pnmtv->item.pszText);
620 
621  if(!MoveFileW(old_path, new_path))
622  return 0;
623 
624  SHFree(item_data->lpifq);
625  SHFree(item_data->lpi);
626  item_data->lpifq = SHSimpleIDListFromPathW(new_path);
627  IShellFolder_ParseDisplayName(item_data->lpsfParent, NULL, NULL,
628  pnmtv->item.pszText, NULL, &item_data->lpi, NULL);
629 
630  item.mask = TVIF_HANDLE|TVIF_TEXT;
631  item.pszText = pnmtv->item.pszText;
632  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
633 
634  nmtv.itemNew.lParam = item.lParam;
636  return 0;
637 }
638 
640 {
642  SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename);
643  return S_OK;
644 }
645 
646 #ifdef __REACTOS__
647 static void
648 BrsFolder_Delete(browse_info *info, HTREEITEM selected_item)
649 {
650  TV_ITEMW item;
651  TV_ITEMDATA *item_data;
652  SHFILEOPSTRUCTW fileop = { info->hwndTreeView };
653  WCHAR szzFrom[MAX_PATH + 1];
654 
655  /* get item_data */
656  item.mask = TVIF_HANDLE | TVIF_PARAM;
657  item.hItem = selected_item;
658  if (!SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item))
659  {
660  ERR("TVM_GETITEMW failed\n");
661  return;
662  }
663  item_data = (TV_ITEMDATA *)item.lParam;
664 
665  /* get the path */
666  if (!SHGetPathFromIDListW(item_data->lpifq, szzFrom))
667  {
668  ERR("SHGetPathFromIDListW failed\n");
669  return;
670  }
671  szzFrom[lstrlenW(szzFrom) + 1] = 0; /* double NULL-terminated */
672  fileop.pFrom = szzFrom;
673 
674  /* delete folder */
675  fileop.fFlags = FOF_ALLOWUNDO;
676  fileop.wFunc = FO_DELETE;
677  SHFileOperationW(&fileop);
678 }
679 #endif
681 {
682  HTREEITEM selected_item;
683 
684  /* Old dialog doesn't support those advanced features */
685 #ifdef __REACTOS__
686  if (!(info->lpBrowseInfo->ulFlags & BIF_USENEWUI))
687 #else
688  if (!(info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
689 #endif
690  return 0;
691 
692  selected_item = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0);
693 
694  switch (keydown->wVKey)
695  {
696  case VK_F2:
697  BrsFolder_Rename(info, selected_item);
698  break;
699  case VK_DELETE:
700  {
701 #ifdef __REACTOS__
702  BrsFolder_Delete(info, selected_item);
703 #else
704  const ITEMIDLIST *item_id;
705  ISFHelper *psfhlp;
706  HRESULT hr;
707  TVITEMW item;
708  TV_ITEMDATA *item_data;
709 
710  item.mask = TVIF_PARAM;
711  item.mask = TVIF_HANDLE|TVIF_PARAM;
712  item.hItem = selected_item;
713  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
714  item_data = (TV_ITEMDATA *)item.lParam;
715  item_id = item_data->lpi;
716 
717  hr = IShellFolder_QueryInterface(item_data->lpsfParent, &IID_ISFHelper, (void**)&psfhlp);
718  if(FAILED(hr))
719  return 0;
720 
721  /* perform the item deletion - tree view gets updated over shell notification */
722  ISFHelper_DeleteItems(psfhlp, 1, &item_id);
723  ISFHelper_Release(psfhlp);
724 #endif
725  }
726  break;
727  }
728  return 0;
729 }
730 
732 {
733  NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
734 
735  TRACE("%p %x %p msg=%x\n", info, CtlID, lpnmh, pnmtv->hdr.code);
736 
738  return 0;
739 
740  switch (pnmtv->hdr.code)
741  {
742  case TVN_DELETEITEMA:
743  case TVN_DELETEITEMW:
744  return BrsFolder_Treeview_Delete( info, pnmtv );
745 
746  case TVN_ITEMEXPANDINGA:
747  case TVN_ITEMEXPANDINGW:
748  return BrsFolder_Treeview_Expand( info, pnmtv );
749 
750  case TVN_SELCHANGEDA:
751  case TVN_SELCHANGEDW:
752  return BrsFolder_Treeview_Changed( info, pnmtv );
753 
754  case TVN_ENDLABELEDITA:
755  case TVN_ENDLABELEDITW:
757 
758  case TVN_KEYDOWN:
760 
761  default:
762  WARN("unhandled (%d)\n", pnmtv->hdr.code);
763  break;
764  }
765 
766  return 0;
767 }
768 
769 
771 {
772  LPITEMIDLIST computer_pidl;
773  SHChangeNotifyEntry ntreg;
774  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
775 
776  info->hWnd = hWnd;
777  SetPropW( hWnd, L"__WINE_BRSFOLDERDLG_INFO", info );
778 
779  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
780  FIXME("flags BIF_NEWDIALOGSTYLE partially implemented\n");
781  if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS)
782  FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS);
783 
784 #ifdef __REACTOS__
785  if (lpBrowseInfo->ulFlags & BIF_USENEWUI)
786 #else
787  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
788 #endif
789  {
790  RECT rcWnd;
791 
792 #ifdef __REACTOS__
793  /* Resize the treeview if there's not editbox */
794  if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
795  && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
796  {
797  RECT rcEdit, rcTreeView;
798  INT cy;
801  cy = rcTreeView.top - rcEdit.top;
802  MapWindowPoints(NULL, hWnd, (LPPOINT)&rcTreeView, sizeof(RECT) / sizeof(POINT));
803  rcTreeView.top -= cy;
805  rcTreeView.left, rcTreeView.top,
806  rcTreeView.right - rcTreeView.left,
807  rcTreeView.bottom - rcTreeView.top, TRUE);
808  }
809  if (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
811  else
812  info->layout = NULL;
813 #else
815 #endif
816 
817  /* TODO: Windows allows shrinking the windows a bit */
818  GetWindowRect(hWnd, &rcWnd);
819  info->szMin.cx = rcWnd.right - rcWnd.left;
820  info->szMin.cy = rcWnd.bottom - rcWnd.top;
821  }
822  else
823  {
824  info->layout = NULL;
825  }
826 
827  if (lpBrowseInfo->lpszTitle)
829  else
831 
832  if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT)
833 #ifdef __REACTOS__
834  || (lpBrowseInfo->ulFlags & BIF_USENEWUI))
835 #else
836  || (lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
837 #endif
839 
840  /* Hide "Make New Folder" Button? */
841  if ((lpBrowseInfo->ulFlags & BIF_NONEWFOLDERBUTTON)
842  || !(lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE))
844 
845  /* Hide the editbox? */
846  if (!(lpBrowseInfo->ulFlags & BIF_EDITBOX))
847  {
850  }
851 
853  if (info->hwndTreeView)
854  {
856 
857 #ifndef __REACTOS__
858  /* Resize the treeview if there's not editbox */
859  if ((lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE)
860  && !(lpBrowseInfo->ulFlags & BIF_EDITBOX))
861  {
862  RECT rc;
863  GetClientRect(info->hwndTreeView, &rc);
864  SetWindowPos(info->hwndTreeView, HWND_TOP, 0, 0,
865  rc.right, rc.bottom + 40, SWP_NOMOVE);
866  }
867 #endif
868  }
869  else
870  ERR("treeview control missing!\n");
871 
872  /* Register for change notifications */
873  SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, 0, &computer_pidl);
874 
875  ntreg.pidl = computer_pidl;
876  ntreg.fRecursive = TRUE;
877 
879 
880 #ifdef __REACTOS__
881  SetFocus(info->hwndTreeView);
882 #endif
883  browsefolder_callback( info->lpBrowseInfo, hWnd, BFFM_INITIALIZED, 0 );
884 
885 #ifdef __REACTOS__
888  return TRUE;
889 #else
890  return TRUE;
891 #endif
892 }
893 
895 {
896  DWORD flags = BrowseFlagsToSHCONTF(info->lpBrowseInfo->ulFlags);
897  IShellFolder *desktop, *cur;
898 #ifdef __REACTOS__
899  WCHAR wszNewFolder[25];
901 #else
902  ISFHelper *sfhelper;
903 #endif
905  HTREEITEM parent, added;
906  LPTV_ITEMDATA item_data;
907  LPITEMIDLIST new_item;
908  TVITEMW item;
909  HRESULT hr;
910  int len;
911 
912 #ifdef __REACTOS__
913  hr = SHGetDesktopFolder(&desktop);
914  if(FAILED(hr))
915  return hr;
916 
917  if (info->pidlRet)
918  {
919  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
920  IShellFolder_Release(desktop);
921  if(FAILED(hr))
922  return hr;
923 
924  hr = SHGetPathFromIDListW(info->pidlRet, path);
925  }
926  else
927  {
928  cur = desktop;
930  }
931  if(FAILED(hr))
932  return hr;
933 
934  if (!LoadStringW(shell32_hInstance, IDS_NEWFOLDER, wszNewFolder, _countof(wszNewFolder)))
935  return E_FAIL;
936 
937  if (!PathYetAnotherMakeUniqueName(name, path, NULL, wszNewFolder))
938  return E_FAIL;
939 
940  len = strlenW(path);
941  if(len<MAX_PATH && name[len] == L'\\')
942  len++;
943 #else
944  if(!info->pidlRet) {
945  ERR("Make new folder button should be disabled\n");
946  return E_FAIL;
947  }
948 
949  /* Create new directory */
950  hr = SHGetDesktopFolder(&desktop);
951  if(FAILED(hr))
952  return hr;
953 
954  hr = IShellFolder_BindToObject(desktop, info->pidlRet, 0, &IID_IShellFolder, (void**)&cur);
955  IShellFolder_Release(desktop);
956  if(FAILED(hr))
957  return hr;
958 
959  hr = IShellFolder_QueryInterface(cur, &IID_ISFHelper, (void**)&sfhelper);
960  if(FAILED(hr))
961  return hr;
962 
963  if(!SHGetPathFromIDListW(info->pidlRet, name)) {
964  hr = E_FAIL;
965  goto cleanup;
966  }
967 
968  len = strlenW(name);
969  if(len<MAX_PATH)
970  name[len++] = '\\';
971  hr = ISFHelper_GetUniqueName(sfhelper, &name[len], MAX_PATH-len);
972  ISFHelper_Release(sfhelper);
973  if(FAILED(hr))
974  goto cleanup;
975 #endif
976 
977  hr = E_FAIL;
978  if(!CreateDirectoryW(name, NULL))
979  goto cleanup;
980 
981  /* Update parent of newly created directory */
983  if(!parent)
984  goto cleanup;
985 
986  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)parent);
987 
988  memset(&item, 0, sizeof(TVITEMW));
989  item.mask = TVIF_PARAM|TVIF_STATE;
990  item.hItem = parent;
991  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
992  item_data = (LPTV_ITEMDATA)item.lParam;
993  if(!item_data)
994  goto cleanup;
995 
996  if(item_data->pEnumIL)
997  IEnumIDList_Release(item_data->pEnumIL);
998  hr = IShellFolder_EnumObjects(cur, info->hwndTreeView, flags, &item_data->pEnumIL);
999  if(FAILED(hr))
1000  goto cleanup;
1001 
1002  /* Update treeview */
1003  if(!(item.state&TVIS_EXPANDEDONCE)) {
1004  item.mask = TVIF_STATE;
1005  item.state = TVIS_EXPANDEDONCE;
1006  item.stateMask = TVIS_EXPANDEDONCE;
1007  SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item);
1008  }
1009 
1010  hr = IShellFolder_ParseDisplayName(cur, NULL, NULL, name+len, NULL, &new_item, NULL);
1011  if(FAILED(hr))
1012  goto cleanup;
1013 
1014  added = InsertTreeViewItem(info, cur, new_item, item_data->lpifq, NULL, parent);
1015  IShellFolder_Release(cur);
1016  SHFree(new_item);
1017 
1018  SendMessageW(info->hwndTreeView, TVM_SORTCHILDREN, FALSE, (LPARAM)parent);
1019  return BrsFolder_Rename(info, added);
1020 
1021 cleanup:
1022  return hr;
1023 }
1024 
1026 {
1027  LPBROWSEINFOW lpBrowseInfo = info->lpBrowseInfo;
1028 #ifdef __REACTOS__
1030 #endif
1031 
1032  switch (id)
1033  {
1034  case IDOK:
1035 #ifdef __REACTOS__
1036  /* Get the text */
1038  StrTrimW(szPath, L" \t");
1039 
1040  /* The original pidl is owned by the treeview and will be free'd. */
1042  {
1043  /* It's valid path */
1044  info->pidlRet = ILCreateFromPathW(szPath);
1045  }
1046  else
1047  {
1048  info->pidlRet = ILClone(info->pidlRet);
1049  }
1050 #endif
1051  if (info->pidlRet == NULL) /* A null pidl would mean a cancel */
1052  info->pidlRet = _ILCreateDesktop();
1053  pdump( info->pidlRet );
1054  if (lpBrowseInfo->pszDisplayName)
1055  SHGetPathFromIDListW( info->pidlRet, lpBrowseInfo->pszDisplayName );
1056  EndDialog( info->hWnd, 1 );
1057  return TRUE;
1058 
1059  case IDCANCEL:
1060  EndDialog( info->hWnd, 0 );
1061  return TRUE;
1062 
1065  return TRUE;
1066  }
1067  return FALSE;
1068 }
1069 
1071  BOOL is_str, HTREEITEM *pItem)
1072 {
1073  LPITEMIDLIST pidlSelection = selection;
1074  LPCITEMIDLIST pidlCurrent, pidlRoot;
1075  TVITEMEXW item;
1076  BOOL bResult = FALSE;
1077 
1078  memset(&item, 0, sizeof(item));
1079 
1080  /* If 'selection' is a string, convert to a Shell ID List. */
1081  if (is_str) {
1082  IShellFolder *psfDesktop;
1083  HRESULT hr;
1084 
1085  hr = SHGetDesktopFolder(&psfDesktop);
1086  if (FAILED(hr))
1087  goto done;
1088 
1089  hr = IShellFolder_ParseDisplayName(psfDesktop, NULL, NULL,
1090  selection, NULL, &pidlSelection, NULL);
1091  IShellFolder_Release(psfDesktop);
1092  if (FAILED(hr))
1093  goto done;
1094  }
1095 #ifdef __REACTOS__
1096  if (_ILIsDesktop(pidlSelection))
1097  {
1098  item.hItem = TVI_ROOT;
1099  bResult = TRUE;
1100  goto done;
1101  }
1102 #endif
1103 
1104  /* Move pidlCurrent behind the SHITEMIDs in pidlSelection, which are the root of
1105  * the sub-tree currently displayed. */
1106  pidlRoot = info->lpBrowseInfo->pidlRoot;
1107  pidlCurrent = pidlSelection;
1108  while (!_ILIsEmpty(pidlRoot) && _ILIsEqualSimple(pidlRoot, pidlCurrent)) {
1109  pidlRoot = ILGetNext(pidlRoot);
1110  pidlCurrent = ILGetNext(pidlCurrent);
1111  }
1112 
1113  /* The given ID List is not part of the SHBrowseForFolder's current sub-tree. */
1114  if (!_ILIsEmpty(pidlRoot))
1115  goto done;
1116 
1117  /* Initialize item to point to the first child of the root folder. */
1118  item.mask = TVIF_PARAM;
1119  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
1120 
1121  if (item.hItem)
1122  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
1123  (LPARAM)item.hItem);
1124 
1125  /* Walk the tree along the nodes corresponding to the remaining ITEMIDLIST */
1126  while (item.hItem && !_ILIsEmpty(pidlCurrent)) {
1127  LPTV_ITEMDATA pItemData;
1128 
1129  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
1130  pItemData = (LPTV_ITEMDATA)item.lParam;
1131 
1132  if (_ILIsEqualSimple(pItemData->lpi, pidlCurrent)) {
1133  pidlCurrent = ILGetNext(pidlCurrent);
1134  if (!_ILIsEmpty(pidlCurrent)) {
1135  /* Only expand current node and move on to its first child,
1136  * if we didn't already reach the last SHITEMID */
1137  SendMessageW(info->hwndTreeView, TVM_EXPAND, TVE_EXPAND, (LPARAM)item.hItem);
1138  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CHILD,
1139  (LPARAM)item.hItem);
1140  }
1141  } else {
1142  item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_NEXT,
1143  (LPARAM)item.hItem);
1144  }
1145  }
1146 
1147  if (_ILIsEmpty(pidlCurrent) && item.hItem)
1148  bResult = TRUE;
1149 
1150 done:
1151  if (pidlSelection && pidlSelection != selection)
1152  ILFree(pidlSelection);
1153 
1154  if (pItem)
1155  *pItem = item.hItem;
1156 
1157  return bResult;
1158 }
1159 
1161  HTREEITEM hItem;
1162  BOOL bResult;
1163 
1164  if (!selection) return FALSE;
1165 
1166  bResult = BrsFolder_OnSetExpanded(info, selection, is_str, &hItem);
1167  if (bResult)
1168  SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItem );
1169  return bResult;
1170 }
1171 
1173  LPWSTR selectionW = NULL;
1174  BOOL result = FALSE;
1175  int length;
1176 
1177  if (!is_str)
1178  return BrsFolder_OnSetSelectionW(info, selection, is_str);
1179 
1180  if ((length = MultiByteToWideChar(CP_ACP, 0, selection, -1, NULL, 0)) &&
1181  (selectionW = HeapAlloc(GetProcessHeap(), 0, length * sizeof(WCHAR))) &&
1182  MultiByteToWideChar(CP_ACP, 0, selection, -1, selectionW, length))
1183  {
1184  result = BrsFolder_OnSetSelectionW(info, selectionW, is_str);
1185  }
1186 
1187  HeapFree(GetProcessHeap(), 0, selectionW);
1188  return result;
1189 }
1190 
1191 #ifndef __REACTOS__ /* This is a buggy way (resize on title bar) */
1193 {
1194 #ifdef __REACTOS__
1195  if ((info->lpBrowseInfo->ulFlags & BIF_USENEWUI) && !(pos->flags & SWP_NOSIZE))
1196 #else
1197  if ((info->lpBrowseInfo->ulFlags & BIF_NEWDIALOGSTYLE) && !(pos->flags & SWP_NOSIZE))
1198 #endif
1199  {
1200  if (pos->cx < info->szMin.cx)
1201  pos->cx = info->szMin.cx;
1202  if (pos->cy < info->szMin.cy)
1203  pos->cy = info->szMin.cy;
1204  }
1205  return 0;
1206 }
1207 #endif
1208 
1210 {
1211  if (info->layout)
1212  {
1213 #ifdef __REACTOS__
1214  LayoutDestroy(info->layout);
1215 #else
1216  SHFree(info->layout);
1217 #endif
1218  info->layout = NULL;
1219  }
1220 
1221  SHChangeNotifyDeregister(info->hNotify);
1222 
1223  return 0;
1224 }
1225 
1226 /* Find a treeview node by recursively walking the treeview */
1228 {
1229  TV_ITEMW item;
1230  TV_ITEMDATA *item_data;
1231  HRESULT hr;
1232 
1233  item.mask = TVIF_HANDLE | TVIF_PARAM;
1234  item.hItem = hItem;
1235  SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item);
1236  item_data = (TV_ITEMDATA *)item.lParam;
1237 
1238  hr = IShellFolder_CompareIDs(item_data->lpsfParent, 0, item_data->lpifq, pidl);
1239  if(SUCCEEDED(hr) && !HRESULT_CODE(hr))
1240  return hItem;
1241 
1243 
1244  while (hItem)
1245  {
1246  HTREEITEM newItem = BrsFolder_FindItemByPidl(info, pidl, hItem);
1247  if (newItem)
1248  return newItem;
1250  }
1251  return NULL;
1252 }
1253 
1255 {
1256  BOOL ret = TRUE;
1257 
1258  TRACE("(%p)->(%p, %p, 0x%08x)\n", info, pidls[0], pidls[1], event);
1259 
1260  switch (event)
1261  {
1262  case SHCNE_RMDIR:
1263  case SHCNE_DELETE:
1264  {
1265  HTREEITEM handle_root = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_ROOT, 0);
1266  HTREEITEM handle_item = BrsFolder_FindItemByPidl(info, pidls[0], handle_root);
1267 
1268  if (handle_item)
1269  SendMessageW(info->hwndTreeView, TVM_DELETEITEM, 0, (LPARAM)handle_item);
1270 
1271  break;
1272  }
1273  }
1274  return ret;
1275 }
1276 
1277 /*************************************************************************
1278  * BrsFolderDlgProc32 (not an exported API function)
1279  */
1281  LPARAM lParam )
1282 {
1283  browse_info *info;
1284 
1285  TRACE("hwnd=%p msg=%04x 0x%08lx 0x%08lx\n", hWnd, msg, wParam, lParam );
1286 
1287  if (msg == WM_INITDIALOG)
1288  return BrsFolder_OnCreate( hWnd, (browse_info*) lParam );
1289 
1290  info = GetPropW( hWnd, L"__WINE_BRSFOLDERDLG_INFO" );
1291 
1292  switch (msg)
1293  {
1294  case WM_NOTIFY:
1296 
1297  case WM_COMMAND:
1298  return BrsFolder_OnCommand( info, wParam );
1299 
1300 #ifdef __REACTOS__
1301  case WM_GETMINMAXINFO:
1302  ((LPMINMAXINFO)lParam)->ptMinTrackSize.x = info->szMin.cx;
1303  ((LPMINMAXINFO)lParam)->ptMinTrackSize.y = info->szMin.cy;
1304  return 0;
1305 #else /* This is a buggy way (resize on title bar) */
1306  case WM_WINDOWPOSCHANGING:
1308 #endif
1309 
1310  case WM_SIZE:
1311  if (info->layout) /* new style dialogs */
1313  return 0;
1314 
1315  case BFFM_SETSTATUSTEXTA:
1316  TRACE("Set status %s\n", debugstr_a((LPSTR)lParam));
1318  break;
1319 
1320  case BFFM_SETSTATUSTEXTW:
1321  TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam));
1323  break;
1324 
1325  case BFFM_ENABLEOK:
1326  TRACE("Enable %ld\n", lParam);
1327  EnableWindow(GetDlgItem(hWnd, 1), lParam != 0);
1328  break;
1329 
1330  case BFFM_SETOKTEXT: /* unicode only */
1331  TRACE("Set OK text %s\n", debugstr_w((LPWSTR)lParam));
1333  break;
1334 
1335  case BFFM_SETSELECTIONA:
1337 
1338  case BFFM_SETSELECTIONW:
1340 
1341  case BFFM_SETEXPANDED: /* unicode only */
1343 
1344  case SHV_CHANGE_NOTIFY:
1346 
1347  case WM_DESTROY:
1348  return BrsFolder_OnDestroy(info);
1349  }
1350  return FALSE;
1351 }
1352 
1353 /*************************************************************************
1354  * SHBrowseForFolderA [SHELL32.@]
1355  * SHBrowseForFolder [SHELL32.@]
1356  */
1358 {
1359  BROWSEINFOW bi;
1360  LPITEMIDLIST lpid;
1361  INT len;
1362  LPWSTR title;
1363 
1364  TRACE("%p\n", lpbi);
1365 
1366  bi.hwndOwner = lpbi->hwndOwner;
1367  bi.pidlRoot = lpbi->pidlRoot;
1368  if (lpbi->pszDisplayName)
1369  bi.pszDisplayName = HeapAlloc( GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR) );
1370  else
1371  bi.pszDisplayName = NULL;
1372 
1373  if (lpbi->lpszTitle)
1374  {
1375  len = MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, NULL, 0 );
1376  title = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
1377  MultiByteToWideChar( CP_ACP, 0, lpbi->lpszTitle, -1, title, len );
1378  }
1379  else
1380  title = NULL;
1381 
1382  bi.lpszTitle = title;
1383  bi.ulFlags = lpbi->ulFlags;
1384  bi.lpfn = lpbi->lpfn;
1385  bi.lParam = lpbi->lParam;
1386  bi.iImage = lpbi->iImage;
1387  lpid = SHBrowseForFolderW( &bi );
1388  if (bi.pszDisplayName)
1389  {
1391  lpbi->pszDisplayName, MAX_PATH, 0, NULL);
1393  }
1394  HeapFree(GetProcessHeap(), 0, title);
1395  lpbi->iImage = bi.iImage;
1396  return lpid;
1397 }
1398 
1399 
1400 /*************************************************************************
1401  * SHBrowseForFolderW [SHELL32.@]
1402  *
1403  * NOTES
1404  * crashes when passed a null pointer
1405  */
1407 {
1408  browse_info info;
1409  DWORD r;
1410  HRESULT hr;
1411 #ifdef __REACTOS__
1412  WORD wDlgId;
1413 #else
1414  const WCHAR * templateName;
1415  INITCOMMONCONTROLSEX icex;
1416 #endif
1417 
1418  info.hWnd = 0;
1419  info.pidlRet = NULL;
1420  info.lpBrowseInfo = lpbi;
1421  info.hwndTreeView = NULL;
1422 
1423 #ifdef __REACTOS__
1424  info.layout = NULL;
1425 #else
1426  icex.dwSize = sizeof( icex );
1427  icex.dwICC = ICC_TREEVIEW_CLASSES;
1428  InitCommonControlsEx( &icex );
1429 #endif
1430 
1431  hr = OleInitialize(NULL);
1432 
1433 #ifdef __REACTOS__
1434  if (lpbi->ulFlags & BIF_USENEWUI)
1435 #else
1436  if (lpbi->ulFlags & BIF_NEWDIALOGSTYLE)
1437 #endif
1438  wDlgId = IDD_BROWSE_FOR_FOLDER_NEW;
1439  else
1440  wDlgId = IDD_BROWSE_FOR_FOLDER;
1443  if (SUCCEEDED(hr))
1444  OleUninitialize();
1445  if (!r)
1446  {
1447  ILFree(info.pidlRet);
1448  return NULL;
1449  }
1450 
1451  return info.pidlRet;
1452 }
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:547
#define IDC_BROWSE_FOR_FOLDER_FOLDER_TEXT
Definition: shresdef.h:413
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1722
#define IDC_BROWSE_FOR_FOLDER_STATUS
Definition: shresdef.h:415
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:1172
#define SHCNE_RMDIR
Definition: shlobj.h:1746
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:2025
#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:496
#define WARN(fmt,...)
Definition: debug.h:112
static HRESULT BrsFolder_Treeview_Changed(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:582
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:1254
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:488
#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:750
#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:433
#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:416
#define TVN_SELCHANGEDA
Definition: commctrl.h:3647
UINT code
Definition: winuser.h:3149
#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:639
#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:731
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:1766
long LONG
Definition: pedump.c:60
LPWSTR pszDisplayName
Definition: shlobj.h:1129
IEnumIDList * pEnumIL
Definition: brsfolder.c:75
UINT_PTR idFrom
Definition: winuser.h:3148
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:1104
#define BIF_RETURNFSANCESTORS
Definition: shlobj.h:1147
#define TVM_SETIMAGELIST
Definition: commctrl.h:3446
#define VK_F2
Definition: winuser.h:2246
_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:1787
#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:1160
LPSHELLFOLDER lpsfParent
Definition: brsfolder.c:72
#define IDD_BROWSE_FOR_FOLDER
Definition: shresdef.h:410
#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:414
#define VK_DELETE
Definition: winuser.h:2223
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
#define WM_DESTROY
Definition: winuser.h:1599
#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:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
r parent
Definition: btrfs.c:3010
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:1601
#define debugstr_a
Definition: kernel32.h:31
static BOOL BrsFolder_OnSetExpanded(browse_info *info, LPVOID selection, BOOL is_str, HTREEITEM *pItem)
Definition: brsfolder.c:1070
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:1357
#define WM_WINDOWPOSCHANGING
Definition: winuser.h:1651
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:894
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static LRESULT BrsFolder_OnWindowPosChanging(browse_info *info, WINDOWPOS *pos)
Definition: brsfolder.c:1192
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
PCIDLIST_ABSOLUTE pidl
Definition: shlobj.h:1738
#define WM_COMMAND
Definition: winuser.h:1730
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:411
static LRESULT BrsFolder_Treeview_Keydown(browse_info *info, LPNMTVKEYDOWN keydown)
Definition: brsfolder.c:680
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:1406
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:599
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:1209
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:1025
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:228
#define SHCNE_DELETE
Definition: shlobj.h:1744
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:417
#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:770
#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:2558
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:1227
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:3093
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:705
#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:2040
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:1280
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:1729
LPARAM lParam
Definition: combotst.c:139
static char title[]
Definition: ps.c:92
#define WM_GETMINMAXINFO
Definition: winuser.h:1630
#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:735
DWORD dwAnchor
Definition: brsfolder.c:82
static LRESULT BrsFolder_Treeview_Delete(browse_info *info, NMTREEVIEWW *pnmtv)
Definition: brsfolder.c:532
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:412
#define BF_LEFT
Definition: winuser.h:454
#define TVN_ITEMEXPANDINGA
Definition: commctrl.h:3699
struct tagTV_ITEMDATA TV_ITEMDATA