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