1999-01-26 11:30:55 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "wine/winuser16.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "heap.h"
|
|
|
|
#include "resource.h"
|
|
|
|
#include "dlgs.h"
|
|
|
|
#include "win.h"
|
|
|
|
#include "sysmetrics.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "authors.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "commctrl.h"
|
|
|
|
#include "spy.h"
|
|
|
|
|
1999-02-02 17:14:23 +01:00
|
|
|
#include "wine/obj_base.h"
|
1999-03-14 13:16:21 +01:00
|
|
|
#include "wine/obj_enumidlist.h"
|
|
|
|
#include "wine/obj_shellfolder.h"
|
1999-03-25 11:57:12 +01:00
|
|
|
|
1999-01-26 11:30:55 +01:00
|
|
|
#include "shell.h"
|
|
|
|
#include "pidl.h"
|
|
|
|
#include "shell32_main.h"
|
|
|
|
|
|
|
|
#define IDD_TREEVIEW 99
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static HWND hwndTreeView;
|
|
|
|
static LPBROWSEINFOA lpBrowseInfo;
|
1999-01-26 11:30:55 +01:00
|
|
|
static LPITEMIDLIST pidlRet;
|
|
|
|
|
|
|
|
static void FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq, HTREEITEM hParent);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static void InitializeTreeView(HWND hwndParent)
|
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;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
TRACE(shell,"dlg=%x tree=%x\n", hwndParent, hwndTreeView );
|
|
|
|
|
|
|
|
if (hImageList && hwndTreeView)
|
|
|
|
{ TreeView_SetImageList(hwndTreeView, hImageList, 0);
|
|
|
|
}
|
|
|
|
|
1999-03-14 13:16:21 +01:00
|
|
|
hr = SHGetDesktopFolder(&lpsf);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr) && hwndTreeView)
|
|
|
|
{ TreeView_DeleteAllItems(hwndTreeView);
|
|
|
|
FillTreeView(lpsf, NULL, TVI_ROOT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
1999-03-14 13:16:21 +01:00
|
|
|
{ IShellFolder_Release(lpsf);
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static int GetIcon(LPITEMIDLIST lpi, UINT uFlags)
|
|
|
|
{ SHFILEINFOA sfi;
|
|
|
|
SHGetFileInfoA((LPCSTR)lpi,0,&sfi, sizeof(SHFILEINFOA), uFlags);
|
1999-01-26 11:30:55 +01:00
|
|
|
return sfi.iIcon;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static void GetNormalAndSelectedIcons(LPITEMIDLIST lpifq,LPTVITEMA lpTV_ITEM)
|
1999-01-26 11:30:55 +01:00
|
|
|
{ TRACE (shell,"%p %p\n",lpifq, lpTV_ITEM);
|
|
|
|
|
|
|
|
lpTV_ITEM->iImage = GetIcon(lpifq, SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
|
|
|
|
lpTV_ITEM->iSelectedImage = GetIcon(lpifq, SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct tagID
|
|
|
|
{
|
|
|
|
LPSHELLFOLDER lpsfParent;
|
|
|
|
LPITEMIDLIST lpi;
|
|
|
|
LPITEMIDLIST lpifq;
|
|
|
|
} TV_ITEMDATA, *LPTV_ITEMDATA;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static BOOL GetName(LPSHELLFOLDER lpsf, LPITEMIDLIST lpi, DWORD dwFlags, LPSTR 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;
|
|
|
|
|
|
|
|
TRACE(shell,"%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-01-26 11:30:55 +01:00
|
|
|
{ bSuccess = StrRetToStrN (lpFriendlyName, MAX_PATH, &str, lpi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bSuccess = FALSE;
|
|
|
|
|
|
|
|
TRACE(shell,"-- %s\n",lpFriendlyName);
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
1999-03-14 13:16:21 +01:00
|
|
|
static void FillTreeView(IShellFolder * lpsf, LPITEMIDLIST pidl, HTREEITEM hParent)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
1999-03-14 13:16:21 +01:00
|
|
|
TVITEMA tvi;
|
|
|
|
TVINSERTSTRUCTA tvins;
|
|
|
|
HTREEITEM hPrev = 0;
|
|
|
|
LPENUMIDLIST lpe=0;
|
1999-01-26 11:30:55 +01:00
|
|
|
LPITEMIDLIST pidlTemp=0;
|
|
|
|
LPTV_ITEMDATA lptvid=0;
|
|
|
|
ULONG ulFetched;
|
|
|
|
HRESULT hr;
|
|
|
|
char szBuff[256];
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND hwnd=GetParent(hwndTreeView);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
TRACE(shell, "%p %p %x\n",lpsf, pidl, (INT)hParent);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
SetCapture(GetParent(hwndTreeView));
|
|
|
|
SetCursor(LoadCursorA(0, IDC_WAITA));
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-03-14 13:16:21 +01:00
|
|
|
hr=IShellFolder_EnumObjects(lpsf,hwnd, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS,&lpe);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{ while (NOERROR == lpe->lpvtbl->fnNext(lpe,1,&pidlTemp,&ulFetched))
|
|
|
|
{ ULONG ulAttrs = SFGAO_HASSUBFOLDER | SFGAO_FOLDER;
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder_GetAttributesOf(lpsf, 1, &pidlTemp, &ulAttrs);
|
1999-01-26 11:30:55 +01:00
|
|
|
if (ulAttrs & (SFGAO_HASSUBFOLDER | SFGAO_FOLDER))
|
|
|
|
{ if (ulAttrs & SFGAO_FOLDER)
|
|
|
|
{ tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
|
|
|
|
|
|
|
if (ulAttrs & SFGAO_HASSUBFOLDER)
|
|
|
|
{ tvi.cChildren=1;
|
|
|
|
tvi.mask |= TVIF_CHILDREN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! ( lptvid = (LPTV_ITEMDATA)SHAlloc(sizeof(TV_ITEMDATA)) ) )
|
|
|
|
goto Done;
|
|
|
|
|
|
|
|
if (!GetName(lpsf, pidlTemp, SHGDN_NORMAL, szBuff))
|
|
|
|
goto Done;
|
|
|
|
|
|
|
|
tvi.pszText = szBuff;
|
|
|
|
tvi.cchTextMax = MAX_PATH;
|
|
|
|
tvi.lParam = (LPARAM)lptvid;
|
|
|
|
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder_AddRef(lpsf);
|
1999-01-26 11:30:55 +01:00
|
|
|
lptvid->lpsfParent = lpsf;
|
|
|
|
lptvid->lpi = ILClone(pidlTemp);
|
|
|
|
lptvid->lpifq = ILCombine(pidl, pidlTemp);
|
|
|
|
GetNormalAndSelectedIcons(lptvid->lpifq, &tvi);
|
|
|
|
|
1999-01-30 14:02:30 +01:00
|
|
|
tvins.DUMMYUNIONNAME.item = tvi;
|
1999-01-26 11:30:55 +01:00
|
|
|
tvins.hInsertAfter = hPrev;
|
|
|
|
tvins.hParent = hParent;
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
hPrev = (HTREEITEM)TreeView_InsertItemA (hwndTreeView, &tvins);
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SHFree(pidlTemp); //Finally, free the pidl that the shell gave us...
|
|
|
|
pidlTemp=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Done:
|
|
|
|
ReleaseCapture();
|
1999-02-26 12:11:13 +01:00
|
|
|
SetCursor(LoadCursorA(0, IDC_ARROWA));
|
1999-01-26 11:30:55 +01:00
|
|
|
|
1999-03-14 13:16:21 +01:00
|
|
|
if (lpe)
|
|
|
|
lpe->lpvtbl->fnRelease(lpe);
|
|
|
|
if (pidlTemp )
|
|
|
|
SHFree(pidlTemp);
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static LRESULT MsgNotify(HWND hWnd, UINT CtlID, LPNMHDR lpnmh)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
NMTREEVIEWA *pnmtv = (NMTREEVIEWA *)lpnmh;
|
1999-01-26 11:30:55 +01:00
|
|
|
LPTV_ITEMDATA lptvid; //Long pointer to TreeView item data
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder * lpsf2=0;
|
1999-01-26 11:30:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
TRACE(shell,"%x %x %p msg=%x\n", hWnd, CtlID, lpnmh, pnmtv->hdr.code);
|
|
|
|
|
|
|
|
switch (pnmtv->hdr.idFrom)
|
|
|
|
{ case IDD_TREEVIEW:
|
|
|
|
switch (pnmtv->hdr.code)
|
|
|
|
{ case TVN_DELETEITEM:
|
|
|
|
{ FIXME(shell,"TVN_DELETEITEM\n");
|
|
|
|
lptvid=(LPTV_ITEMDATA)pnmtv->itemOld.lParam;
|
1999-03-14 13:16:21 +01:00
|
|
|
IShellFolder_Release(lptvid->lpsfParent);
|
1999-01-26 11:30:55 +01:00
|
|
|
SHFree(lptvid->lpi);
|
|
|
|
SHFree(lptvid->lpifq);
|
|
|
|
SHFree(lptvid);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TVN_ITEMEXPANDING:
|
|
|
|
{ FIXME(shell,"TVN_ITEMEXPANDING\n");
|
|
|
|
if ((pnmtv->itemNew.state & TVIS_EXPANDEDONCE))
|
|
|
|
break;
|
|
|
|
|
|
|
|
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)))
|
1999-01-26 11:30:55 +01:00
|
|
|
{ FillTreeView( lpsf2, lptvid->lpifq, pnmtv->itemNew.hItem );
|
|
|
|
}
|
|
|
|
TreeView_SortChildren(hwndTreeView, pnmtv->itemNew.hItem, FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TVN_SELCHANGED:
|
|
|
|
lptvid=(LPTV_ITEMDATA)pnmtv->itemNew.lParam;
|
|
|
|
pidlRet = lptvid->lpifq;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME(shell,"unhandled\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* BrsFolderDlgProc32 (not an exported API function)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
|
1999-01-26 11:30:55 +01:00
|
|
|
LPARAM lParam )
|
|
|
|
{ TRACE(shell,"hwnd=%i msg=%i 0x%08x 0x%08lx\n", hWnd, msg, wParam, lParam );
|
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{ case WM_INITDIALOG:
|
|
|
|
pidlRet = NULL;
|
1999-02-26 12:11:13 +01:00
|
|
|
lpBrowseInfo = (LPBROWSEINFOA) lParam;
|
1999-01-26 11:30:55 +01:00
|
|
|
if (lpBrowseInfo->lpfn)
|
|
|
|
FIXME(shell,"Callbacks not implemented\n");
|
|
|
|
if (lpBrowseInfo->ulFlags)
|
|
|
|
FIXME(shell,"flag %x not implemented\n", lpBrowseInfo->ulFlags);
|
|
|
|
if (lpBrowseInfo->lpszTitle)
|
|
|
|
FIXME(shell,"title %s not displayed\n", lpBrowseInfo->lpszTitle);
|
|
|
|
if ( lpBrowseInfo->pidlRoot )
|
|
|
|
FIXME(shell,"root is desktop\n");
|
|
|
|
|
|
|
|
InitializeTreeView ( hWnd);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (wParam)
|
|
|
|
{ case IDOK:
|
|
|
|
pdump ( pidlRet );
|
|
|
|
_ILGetPidlPath (pidlRet, lpBrowseInfo->pszDisplayName, MAX_PATH);
|
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;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern LPCVOID _Resource_Dlg_SHBRSFORFOLDER_MSGBOX_0_data ;
|
|
|
|
/*************************************************************************
|
|
|
|
* SHBrowseForFolderA [SHELL32.209]
|
|
|
|
*
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
LPITEMIDLIST WINAPI SHBrowseForFolderA (LPBROWSEINFOA lpbi)
|
1999-01-26 11:30:55 +01:00
|
|
|
{
|
|
|
|
TRACE(shell, "(%lx,%s) empty stub!\n", (DWORD)lpbi, lpbi->lpszTitle);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
return (LPITEMIDLIST) DialogBoxIndirectParamA( 0,
|
1999-01-26 11:30:55 +01:00
|
|
|
&_Resource_Dlg_SHBRSFORFOLDER_MSGBOX_0_data, 0,
|
1999-02-26 12:11:13 +01:00
|
|
|
BrsFolderDlgProc, (INT)lpbi );
|
1999-01-26 11:30:55 +01:00
|
|
|
}
|