2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright 1999 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-07-24 03:56:03 +02:00
|
|
|
*
|
|
|
|
* FIXME:
|
|
|
|
* - many memory leaks
|
2003-06-06 20:09:38 +02:00
|
|
|
* - many flags unimplemented
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-08-16 20:49:56 +02:00
|
|
|
#include "undocshell.h"
|
2000-08-25 23:33:23 +02:00
|
|
|
#include "shlguid.h"
|
1999-01-26 11:30:55 +01:00
|
|
|
#include "pidl.h"
|
|
|
|
#include "shell32_main.h"
|
1999-04-22 12:11:04 +02:00
|
|
|
#include "shellapi.h"
|
2000-08-25 23:33:23 +02:00
|
|
|
#include "shresdef.h"
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HWND hwndTreeView;
|
2002-12-13 01:30:30 +01:00
|
|
|
static LPBROWSEINFOW lpBrowseInfo;
|
1999-01-26 11:30:55 +01:00
|
|
|
static LPITEMIDLIST pidlRet;
|
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
static void FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq, HTREEITEM hParent, IEnumIDList* lpe);
|
2003-09-02 03:01:06 +02:00
|
|
|
static HTREEITEM InsertTreeViewItem(IShellFolder * lpsf, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL, HTREEITEM hParent);
|
2003-06-06 20:09:38 +02:00
|
|
|
|
|
|
|
#define SUPPORTEDFLAGS (BIF_STATUSTEXT | \
|
|
|
|
BIF_BROWSEFORCOMPUTER | \
|
|
|
|
BIF_RETURNFSANCESTORS | \
|
|
|
|
BIF_RETURNONLYFSDIRS | \
|
|
|
|
BIF_BROWSEINCLUDEFILES)
|
|
|
|
|
|
|
|
static inline DWORD BrowseFlagsToSHCONTF(UINT ulFlags)
|
|
|
|
{
|
|
|
|
return SHCONTF_FOLDERS | (ulFlags & BIF_BROWSEINCLUDEFILES ? SHCONTF_NONFOLDERS : 0);
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2000-08-25 23:33:23 +02:00
|
|
|
static void InitializeTreeView(HWND hwndParent, LPCITEMIDLIST root)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
|
|
|
HIMAGELIST hImageList;
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder * lpsf;
|
1999-01-26 11:30:55 +01:00
|
|
|
HRESULT hr;
|
2003-06-06 20:09:38 +02:00
|
|
|
IEnumIDList * pEnumIL = NULL;
|
|
|
|
LPITEMIDLIST parentofroot;
|
|
|
|
parentofroot = ILClone(root);
|
|
|
|
ILRemoveLastID(parentofroot);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
hwndTreeView = GetDlgItem (hwndParent, IDD_TREEVIEW);
|
1999-01-26 11:30:55 +01:00
|
|
|
Shell_GetImageList(NULL, &hImageList);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("dlg=%p tree=%p\n", hwndParent, hwndTreeView );
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
if (hImageList && hwndTreeView)
|
2003-06-06 20:09:38 +02:00
|
|
|
TreeView_SetImageList(hwndTreeView, hImageList, 0);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
if (_ILIsDesktop (root)) {
|
2000-08-25 23:33:23 +02:00
|
|
|
hr = SHGetDesktopFolder(&lpsf);
|
|
|
|
} else {
|
|
|
|
IShellFolder * lpsfdesktop;
|
|
|
|
|
|
|
|
hr = SHGetDesktopFolder(&lpsfdesktop);
|
|
|
|
if (SUCCEEDED(hr)) {
|
2003-06-06 20:09:38 +02:00
|
|
|
hr = IShellFolder_BindToObject(lpsfdesktop, parentofroot, 0,(REFIID)&IID_IShellFolder,(LPVOID *)&lpsf);
|
2000-08-25 23:33:23 +02:00
|
|
|
IShellFolder_Release(lpsfdesktop);
|
|
|
|
}
|
|
|
|
}
|
2003-06-06 20:09:38 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IShellFolder * pSFRoot;
|
|
|
|
if (_ILIsPidlSimple(root))
|
|
|
|
{
|
|
|
|
pSFRoot = lpsf;
|
|
|
|
IShellFolder_AddRef(pSFRoot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = IShellFolder_BindToObject(lpsf,ILFindLastID(root),0,&IID_IShellFolder,(LPVOID *)&pSFRoot);
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = IShellFolder_EnumObjects(
|
|
|
|
pSFRoot,
|
|
|
|
hwndParent,
|
|
|
|
BrowseFlagsToSHCONTF(lpBrowseInfo->ulFlags),
|
|
|
|
&pEnumIL);
|
|
|
|
IShellFolder_Release(pSFRoot);
|
|
|
|
}
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && hwndTreeView)
|
2003-06-06 20:09:38 +02:00
|
|
|
{
|
|
|
|
TreeView_DeleteAllItems(hwndTreeView);
|
|
|
|
TreeView_Expand(hwndTreeView,
|
|
|
|
InsertTreeViewItem(lpsf, _ILIsPidlSimple(root) ? root : ILFindLastID(root), parentofroot, pEnumIL, TVI_ROOT),
|
|
|
|
TVE_EXPAND);
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
if (SUCCEEDED(hr))
|
2003-06-06 20:09:38 +02:00
|
|
|
IShellFolder_Release(lpsf);
|
|
|
|
|
2000-08-25 23:33:23 +02:00
|
|
|
TRACE("done\n");
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static int GetIcon(LPITEMIDLIST lpi, UINT uFlags)
|
2003-06-06 20:09:38 +02:00
|
|
|
{
|
|
|
|
SHFILEINFOW sfi;
|
2002-12-13 01:30:30 +01:00
|
|
|
SHGetFileInfoW((LPCWSTR)lpi, 0 ,&sfi, sizeof(SHFILEINFOW), uFlags);
|
1999-01-26 11:30:55 +01:00
|
|
|
return sfi.iIcon;
|
|
|
|
}
|
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq, LPTVITEMW lpTV_ITEM)
|
2003-06-06 20:09:38 +02:00
|
|
|
{
|
|
|
|
LPITEMIDLIST pidlDesktop = NULL;
|
|
|
|
|
|
|
|
TRACE("%p %p\n",lpifq, lpTV_ITEM);
|
|
|
|
|
|
|
|
if (!lpifq)
|
|
|
|
{
|
|
|
|
pidlDesktop = _ILCreateDesktop();
|
|
|
|
lpifq = pidlDesktop;
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
lpTV_ITEM->iImage = GetIcon(lpifq, SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
|
|
|
|
lpTV_ITEM->iSelectedImage = GetIcon(lpifq, SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON);
|
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
if (pidlDesktop)
|
|
|
|
ILFree(pidlDesktop);
|
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct tagID
|
|
|
|
{
|
|
|
|
LPSHELLFOLDER lpsfParent;
|
|
|
|
LPITEMIDLIST lpi;
|
|
|
|
LPITEMIDLIST lpifq;
|
2003-06-06 20:09:38 +02:00
|
|
|
IEnumIDList* pEnumIL;
|
1999-01-26 11:30:55 +01:00
|
|
|
} TV_ITEMDATA, *LPTV_ITEMDATA;
|
|
|
|
|
2003-09-02 03:01:06 +02:00
|
|
|
static BOOL GetName(LPSHELLFOLDER lpsf, LPCITEMIDLIST lpi, DWORD dwFlags, LPWSTR lpFriendlyName)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL bSuccess=TRUE;
|
1999-01-26 11:30:55 +01:00
|
|
|
STRRET str;
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("%p %p %lx %p\n", lpsf, lpi, dwFlags, lpFriendlyName);
|
1999-03-14 13:16:21 +01:00
|
|
|
if (SUCCEEDED(IShellFolder_GetDisplayNameOf(lpsf, lpi, dwFlags, &str)))
|
1999-07-28 18:38:45 +02:00
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
if (FAILED(StrRetToStrNW(lpFriendlyName, MAX_PATH, &str, lpi)))
|
1999-09-03 14:38:02 +02:00
|
|
|
{
|
|
|
|
bSuccess = FALSE;
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
TRACE("-- %s\n", debugstr_w(lpFriendlyName));
|
1999-01-26 11:30:55 +01:00
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
2003-09-02 03:01:06 +02:00
|
|
|
static HTREEITEM InsertTreeViewItem(IShellFolder * lpsf, LPCITEMIDLIST pidl, LPCITEMIDLIST pidlParent, IEnumIDList* pEnumIL, HTREEITEM hParent)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
TVITEMW tvi;
|
|
|
|
TVINSERTSTRUCTW tvins;
|
|
|
|
WCHAR szBuff[MAX_PATH];
|
2003-06-06 20:09:38 +02:00
|
|
|
LPTV_ITEMDATA lptvid=0;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
tvi.cChildren= pEnumIL ? 1 : 0;
|
|
|
|
tvi.mask |= TVIF_CHILDREN;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
if (!(lptvid = (LPTV_ITEMDATA)SHAlloc(sizeof(TV_ITEMDATA))))
|
|
|
|
return NULL;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
if (!GetName(lpsf, pidl, SHGDN_NORMAL, szBuff))
|
|
|
|
return NULL;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
tvi.pszText = szBuff;
|
|
|
|
tvi.cchTextMax = MAX_PATH;
|
|
|
|
tvi.lParam = (LPARAM)lptvid;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
IShellFolder_AddRef(lpsf);
|
|
|
|
lptvid->lpsfParent = lpsf;
|
|
|
|
lptvid->lpi = ILClone(pidl);
|
|
|
|
lptvid->lpifq = pidlParent ? ILCombine(pidlParent, pidl) : ILClone(pidl);
|
|
|
|
lptvid->pEnumIL = pEnumIL;
|
|
|
|
GetNormalAndSelectedIcons(lptvid->lpifq, &tvi);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
tvins.DUMMYUNIONNAME.item = tvi;
|
|
|
|
tvins.hInsertAfter = NULL;
|
|
|
|
tvins.hParent = hParent;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
return (HTREEITEM)TreeView_InsertItemW(hwndTreeView, &tvins);
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
static void FillTreeView(IShellFolder * lpsf, LPITEMIDLIST pidl, HTREEITEM hParent, IEnumIDList* lpe)
|
|
|
|
{
|
|
|
|
HTREEITEM hPrev = 0;
|
2003-09-02 03:01:06 +02:00
|
|
|
LPITEMIDLIST pidlTemp = 0;
|
2003-06-06 20:09:38 +02:00
|
|
|
ULONG ulFetched;
|
|
|
|
HRESULT hr;
|
|
|
|
HWND hwnd=GetParent(hwndTreeView);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
TRACE("%p %p %x\n",lpsf, pidl, (INT)hParent);
|
|
|
|
SetCapture(GetParent(hwndTreeView));
|
|
|
|
SetCursor(LoadCursorA(0, IDC_WAITA));
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
while (NOERROR == IEnumIDList_Next(lpe,1,&pidlTemp,&ulFetched))
|
|
|
|
{
|
|
|
|
ULONG ulAttrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
|
|
|
|
IEnumIDList* pEnumIL = NULL;
|
|
|
|
IShellFolder* pSFChild = NULL;
|
2003-09-02 03:01:06 +02:00
|
|
|
IShellFolder_GetAttributesOf(lpsf, 1, (LPCITEMIDLIST*)&pidlTemp, &ulAttrs);
|
2003-06-06 20:09:38 +02:00
|
|
|
if (ulAttrs & SFGAO_FOLDER)
|
|
|
|
{
|
|
|
|
hr = IShellFolder_BindToObject(lpsf,pidlTemp,NULL,&IID_IShellFolder,(LPVOID*)&pSFChild);
|
|
|
|
if (SUCCEEDED(hr))
|
2003-07-02 02:37:16 +02:00
|
|
|
{
|
2003-06-06 20:09:38 +02:00
|
|
|
hr = IShellFolder_EnumObjects(pSFChild, hwnd, BrowseFlagsToSHCONTF(lpBrowseInfo->ulFlags), &pEnumIL);
|
2003-07-02 02:37:16 +02:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
if ((IEnumIDList_Skip(pEnumIL, 1) != S_OK) || FAILED(IEnumIDList_Reset(pEnumIL)))
|
|
|
|
{
|
|
|
|
IEnumIDList_Release(pEnumIL);
|
|
|
|
pEnumIL = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IShellFolder_Release(pSFChild);
|
|
|
|
}
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
2003-06-06 20:09:38 +02:00
|
|
|
|
|
|
|
if (!(hPrev = InsertTreeViewItem(lpsf, pidlTemp, pidl, pEnumIL, hParent)))
|
|
|
|
goto Done;
|
1999-04-22 18:27:50 +02:00
|
|
|
SHFree(pidlTemp); /* Finally, free the pidl that the shell gave us... */
|
2003-06-06 20:09:38 +02:00
|
|
|
pidlTemp=NULL;
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Done:
|
|
|
|
ReleaseCapture();
|
2002-12-13 01:30:30 +01:00
|
|
|
SetCursor(LoadCursorW(0, IDC_ARROWW));
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
if (pidlTemp)
|
1999-03-14 13:16:21 +01:00
|
|
|
SHFree(pidlTemp);
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
static inline BOOL PIDLIsType(LPCITEMIDLIST pidl, PIDLTYPE type)
|
|
|
|
{
|
|
|
|
LPPIDLDATA data = _ILGetDataPointer(pidl);
|
|
|
|
if (!data)
|
|
|
|
return FALSE;
|
|
|
|
return (data->type == type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void BrsFolder_CheckValidSelection(HWND hWndTree, LPTV_ITEMDATA lptvid)
|
|
|
|
{
|
|
|
|
LPCITEMIDLIST pidl = lptvid->lpi;
|
|
|
|
BOOL bEnabled = TRUE;
|
|
|
|
DWORD dwAttributes;
|
|
|
|
if ((lpBrowseInfo->ulFlags & BIF_BROWSEFORCOMPUTER) &&
|
|
|
|
!PIDLIsType(pidl, PT_COMP))
|
|
|
|
bEnabled = FALSE;
|
|
|
|
if (lpBrowseInfo->ulFlags & BIF_RETURNFSANCESTORS)
|
|
|
|
{
|
|
|
|
dwAttributes = SFGAO_FILESYSANCESTOR | SFGAO_FILESYSTEM;
|
2003-09-02 03:01:06 +02:00
|
|
|
if (FAILED(IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1, (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes)) ||
|
2003-06-06 20:09:38 +02:00
|
|
|
!dwAttributes)
|
|
|
|
bEnabled = FALSE;
|
|
|
|
}
|
|
|
|
if (lpBrowseInfo->ulFlags & BIF_RETURNONLYFSDIRS)
|
|
|
|
{
|
|
|
|
dwAttributes = SFGAO_FOLDER | SFGAO_FILESYSTEM;
|
2003-09-02 03:01:06 +02:00
|
|
|
if (FAILED(IShellFolder_GetAttributesOf(lptvid->lpsfParent, 1, (LPCITEMIDLIST*)&lptvid->lpi, &dwAttributes)) ||
|
2003-06-06 20:09:38 +02:00
|
|
|
(dwAttributes != (SFGAO_FOLDER | SFGAO_FILESYSTEM)))
|
|
|
|
bEnabled = FALSE;
|
|
|
|
}
|
|
|
|
SendMessageW(hWndTree, BFFM_ENABLEOK, 0, (LPARAM)bEnabled);
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static LRESULT MsgNotify(HWND hWnd, UINT CtlID, LPNMHDR lpnmh)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh;
|
1999-04-22 18:27:50 +02:00
|
|
|
LPTV_ITEMDATA lptvid; /* Long pointer to TreeView item data */
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder * lpsf2=0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2002-11-22 00:56:42 +01:00
|
|
|
TRACE("%p %x %p msg=%x\n", hWnd, CtlID, lpnmh, pnmtv->hdr.code);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
switch (pnmtv->hdr.idFrom)
|
|
|
|
{ case IDD_TREEVIEW:
|
2002-06-01 01:06:46 +02:00
|
|
|
switch (pnmtv->hdr.code)
|
2003-06-06 20:09:38 +02:00
|
|
|
{
|
|
|
|
case TVN_DELETEITEMA:
|
2002-12-13 01:30:30 +01:00
|
|
|
case TVN_DELETEITEMW:
|
2003-06-06 20:09:38 +02:00
|
|
|
TRACE("TVN_DELETEITEMA/W\n");
|
|
|
|
lptvid=(LPTV_ITEMDATA)pnmtv->itemOld.lParam;
|
|
|
|
IShellFolder_Release(lptvid->lpsfParent);
|
|
|
|
if (lptvid->pEnumIL)
|
|
|
|
IEnumIDList_Release(lptvid->pEnumIL);
|
|
|
|
SHFree(lptvid->lpi);
|
|
|
|
SHFree(lptvid->lpifq);
|
|
|
|
SHFree(lptvid);
|
1999-01-26 11:30:55 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
case TVN_ITEMEXPANDINGA:
|
|
|
|
case TVN_ITEMEXPANDINGW:
|
2003-06-06 20:09:38 +02:00
|
|
|
{
|
|
|
|
TRACE("TVN_ITEMEXPANDINGA/W\n");
|
1999-01-26 11:30:55 +01:00
|
|
|
if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
lptvid=(LPTV_ITEMDATA)pnmtv->itemNew.lParam;
|
1999-03-14 13:16:21 +01:00
|
|
|
if (SUCCEEDED(IShellFolder_BindToObject(lptvid->lpsfParent, lptvid->lpi,0,(REFIID)&IID_IShellFolder,(LPVOID *)&lpsf2)))
|
2003-06-06 20:09:38 +02:00
|
|
|
{ FillTreeView( lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem, lptvid->pEnumIL);
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
TreeView_SortChildren(hwndTreeView, pnmtv->itemNew.hItem, FALSE);
|
|
|
|
}
|
|
|
|
break;
|
2002-12-13 01:30:30 +01:00
|
|
|
case TVN_SELCHANGEDA:
|
|
|
|
case TVN_SELCHANGEDW:
|
1999-01-26 11:30:55 +01:00
|
|
|
lptvid=(LPTV_ITEMDATA)pnmtv->itemNew.lParam;
|
|
|
|
pidlRet = lptvid->lpifq;
|
2000-08-25 23:33:23 +02:00
|
|
|
if (lpBrowseInfo->lpfn)
|
|
|
|
(lpBrowseInfo->lpfn)(hWnd, BFFM_SELCHANGED, (LPARAM)pidlRet, lpBrowseInfo->lParam);
|
2003-06-06 20:09:38 +02:00
|
|
|
BrsFolder_CheckValidSelection(hWnd, lptvid);
|
1999-01-26 11:30:55 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-06-06 20:09:38 +02:00
|
|
|
WARN("unhandled (%d)\n", pnmtv->hdr.code);
|
1999-01-26 11:30:55 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* BrsFolderDlgProc32 (not an exported API function)
|
|
|
|
*/
|
2002-12-13 01:30:30 +01:00
|
|
|
static INT_PTR CALLBACK BrsFolderDlgProc(HWND hWnd, UINT msg, WPARAM wParam,
|
1999-07-31 16:41:43 +02:00
|
|
|
LPARAM lParam )
|
2002-08-14 23:03:55 +02:00
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
TRACE("hwnd=%p msg=%04x 0x%08x 0x%08lx\n", hWnd, msg, wParam, lParam );
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{ case WM_INITDIALOG:
|
|
|
|
pidlRet = NULL;
|
2002-12-13 01:30:30 +01:00
|
|
|
lpBrowseInfo = (LPBROWSEINFOW) lParam;
|
2003-06-06 20:09:38 +02:00
|
|
|
if (lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS)
|
|
|
|
FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~SUPPORTEDFLAGS);
|
2000-08-25 23:33:23 +02:00
|
|
|
if (lpBrowseInfo->lpszTitle) {
|
2002-12-13 01:30:30 +01:00
|
|
|
SetWindowTextW(GetDlgItem(hWnd, IDD_TITLE), lpBrowseInfo->lpszTitle);
|
2000-08-25 23:33:23 +02:00
|
|
|
} else {
|
|
|
|
ShowWindow(GetDlgItem(hWnd, IDD_TITLE), SW_HIDE);
|
|
|
|
}
|
|
|
|
if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT))
|
|
|
|
ShowWindow(GetDlgItem(hWnd, IDD_STATUS), SW_HIDE);
|
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
InitializeTreeView(hWnd, lpBrowseInfo->pidlRoot);
|
2000-08-25 23:33:23 +02:00
|
|
|
|
2003-06-06 20:09:38 +02:00
|
|
|
if (lpBrowseInfo->lpfn)
|
2000-08-25 23:33:23 +02:00
|
|
|
(lpBrowseInfo->lpfn)(hWnd, BFFM_INITIALIZED, 0, lpBrowseInfo->lParam);
|
|
|
|
|
|
|
|
return TRUE;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
case WM_NOTIFY:
|
1999-02-26 12:11:13 +01:00
|
|
|
MsgNotify( hWnd, (UINT)wParam, (LPNMHDR)lParam);
|
1999-01-26 11:30:55 +01:00
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (wParam)
|
|
|
|
{ case IDOK:
|
2002-12-13 01:30:30 +01:00
|
|
|
pdump ( pidlRet );
|
|
|
|
SHGetPathFromIDListW(pidlRet, lpBrowseInfo->pszDisplayName);
|
1999-02-26 12:11:13 +01:00
|
|
|
EndDialog(hWnd, (DWORD) ILClone(pidlRet));
|
1999-01-26 11:30:55 +01:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case IDCANCEL:
|
1999-02-26 12:11:13 +01:00
|
|
|
EndDialog(hWnd, 0);
|
1999-01-26 11:30:55 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2000-08-25 23:33:23 +02:00
|
|
|
case BFFM_SETSTATUSTEXTA:
|
|
|
|
TRACE("Set status %s\n", debugstr_a((LPSTR)lParam));
|
|
|
|
SetWindowTextA(GetDlgItem(hWnd, IDD_STATUS), (LPSTR)lParam);
|
|
|
|
break;
|
|
|
|
case BFFM_SETSTATUSTEXTW:
|
|
|
|
TRACE("Set status %s\n", debugstr_w((LPWSTR)lParam));
|
|
|
|
SetWindowTextW(GetDlgItem(hWnd, IDD_STATUS), (LPWSTR)lParam);
|
|
|
|
break;
|
|
|
|
case BFFM_ENABLEOK:
|
|
|
|
TRACE("Enable %ld\n", lParam);
|
|
|
|
EnableWindow(GetDlgItem(hWnd, 1), (lParam)?TRUE:FALSE);
|
|
|
|
break;
|
2003-06-06 20:09:38 +02:00
|
|
|
case BFFM_SETOKTEXT: /* unicode only */
|
|
|
|
TRACE("Set OK text %s\n", debugstr_w((LPWSTR)wParam));
|
|
|
|
SetWindowTextW(GetDlgItem(hWnd, 1), (LPWSTR)wParam);
|
|
|
|
break;
|
2000-08-25 23:33:23 +02:00
|
|
|
case BFFM_SETSELECTIONA:
|
|
|
|
if (wParam)
|
2003-06-06 20:09:38 +02:00
|
|
|
FIXME("Set selection %s\n", debugstr_a((LPSTR)lParam));
|
2000-08-25 23:33:23 +02:00
|
|
|
else
|
2003-06-06 20:09:38 +02:00
|
|
|
FIXME("Set selection %p\n", (void*)lParam);
|
2000-08-25 23:33:23 +02:00
|
|
|
break;
|
|
|
|
case BFFM_SETSELECTIONW:
|
|
|
|
if (wParam)
|
2003-06-06 20:09:38 +02:00
|
|
|
FIXME("Set selection %s\n", debugstr_w((LPWSTR)lParam));
|
|
|
|
else
|
|
|
|
FIXME("Set selection %p\n", (void*)lParam);
|
|
|
|
break;
|
|
|
|
case BFFM_SETEXPANDED: /* unicode only */
|
|
|
|
if (wParam)
|
|
|
|
FIXME("Set expanded %s\n", debugstr_w((LPWSTR)lParam));
|
2000-08-25 23:33:23 +02:00
|
|
|
else
|
2003-06-06 20:09:38 +02:00
|
|
|
FIXME("Set expanded %p\n", (void*)lParam);
|
2000-08-25 23:33:23 +02:00
|
|
|
break;
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
2000-08-25 23:33:23 +02:00
|
|
|
return FALSE;
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
static WCHAR swBrowseTempName[] = {'S','H','B','R','S','F','O','R','F','O','L','D','E','R','_','M','S','G','B','O','X',0};
|
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
/*************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* SHBrowseForFolderA [SHELL32.@]
|
2001-07-11 20:56:41 +02:00
|
|
|
* SHBrowseForFolder [SHELL32.@]
|
1999-01-26 11:30:55 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
LPITEMIDLIST WINAPI SHBrowseForFolderA (LPBROWSEINFOA lpbi)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
BROWSEINFOW bi;
|
|
|
|
LPITEMIDLIST lpid;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
TRACE("(%p{lpszTitle=%s,owner=%p})\n", lpbi,
|
|
|
|
lpbi ? debugstr_a(lpbi->lpszTitle) : NULL, lpbi ? lpbi->hwndOwner : NULL);
|
|
|
|
|
|
|
|
if (!lpbi)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
bi.hwndOwner = lpbi->hwndOwner;
|
|
|
|
bi.pidlRoot = lpbi->pidlRoot;
|
|
|
|
if (lpbi->pszDisplayName)
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpbi->pszDisplayName, -1, NULL, 0);
|
|
|
|
bi.pszDisplayName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpbi->pszDisplayName, -1, bi.pszDisplayName, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bi.pszDisplayName = NULL;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
if (lpbi->lpszTitle)
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar(CP_ACP, 0, lpbi->lpszTitle, -1, NULL, 0);
|
|
|
|
bi.lpszTitle = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, lpbi->lpszTitle, -1, (LPWSTR)bi.lpszTitle, len);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bi.lpszTitle = NULL;
|
|
|
|
|
|
|
|
bi.ulFlags = lpbi->ulFlags;
|
|
|
|
bi.lpfn = lpbi->lpfn;
|
|
|
|
bi.lParam = lpbi->lParam;
|
|
|
|
bi.iImage = lpbi->iImage;
|
|
|
|
lpid = (LPITEMIDLIST) DialogBoxParamW(shell32_hInstance,
|
|
|
|
swBrowseTempName, lpbi->hwndOwner,
|
|
|
|
BrsFolderDlgProc, (INT)&bi);
|
|
|
|
if (bi.pszDisplayName)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, bi.pszDisplayName, -1, lpbi->pszDisplayName, MAX_PATH, 0, NULL);
|
|
|
|
HeapFree(GetProcessHeap(), 0, bi.pszDisplayName);
|
|
|
|
}
|
|
|
|
if (bi.lpszTitle)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)bi.lpszTitle);
|
|
|
|
}
|
|
|
|
lpbi->iImage = bi.iImage;
|
|
|
|
return lpid;
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
2002-07-19 02:26:02 +02:00
|
|
|
|
2002-12-13 01:30:30 +01:00
|
|
|
|
2002-07-19 02:26:02 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* SHBrowseForFolderW [SHELL32.@]
|
|
|
|
*/
|
|
|
|
LPITEMIDLIST WINAPI SHBrowseForFolderW (LPBROWSEINFOW lpbi)
|
|
|
|
{
|
2002-12-13 01:30:30 +01:00
|
|
|
TRACE("((%p->{lpszTitle=%s,owner=%p})\n", lpbi,
|
|
|
|
lpbi ? debugstr_w(lpbi->lpszTitle) : NULL, lpbi ? lpbi->hwndOwner : 0);
|
|
|
|
|
|
|
|
if (!lpbi)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (LPITEMIDLIST) DialogBoxParamW(shell32_hInstance,
|
|
|
|
swBrowseTempName, lpbi->hwndOwner,
|
|
|
|
BrsFolderDlgProc, (INT)lpbi);
|
2002-07-19 02:26:02 +02:00
|
|
|
}
|