Hi
This implements the make new folder button for the SHBrowseForFolders dialog. It's my first patch, so I'm asking for comments. Note, renaming of the new folder is still not supported.
Jon
--- dlls/shell32/brsfolder.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c index cc8a91d..ca2e2c0 100644 --- a/dlls/shell32/brsfolder.c +++ b/dlls/shell32/brsfolder.c @@ -18,7 +18,6 @@ * FIXME: * - many memory leaks * - many flags unimplemented - * - implement new dialog style "make new folder" button * - implement editbox */
@@ -35,6 +34,7 @@ #include "shell32_main.h" #include "shellapi.h" #include "shresdef.h" +#include "shellfolder.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
@@ -677,8 +677,48 @@ static BOOL BrsFolder_OnCommand( browse_info *info, UINT id ) return TRUE;
case IDD_MAKENEWFOLDER: - FIXME("make new folder not implemented\n"); - return TRUE; + if (info->pidlRet == NULL) + return FALSE; + else + { + WCHAR path[MAX_PATH]; + HTREEITEM hParent; + HRESULT hr; + LPITEMIDLIST pidlChild; + IShellFolder *lpsfDesktop, *lpsfParent; + ISFHelper *psfhlp; + + hr = SHGetDesktopFolder(&lpsfDesktop); + if (FAILED(hr)) { + WARN("SHGetDesktopFolder failed! hr = %08x\n", hr); + return FALSE; + } + hr = IShellFolder_BindToObject(lpsfDesktop, info->pidlRet, 0, + &IID_IShellFolder, (LPVOID*)&lpsfParent); + IShellFolder_Release(lpsfDesktop); + if (FAILED(hr)) { + WARN("IShellFolder_BindToObject failed! hr = %08x\n", hr); + return FALSE; + } + IShellFolder_QueryInterface(lpsfParent, &IID_ISFHelper, + (LPVOID*)&psfhlp); + if (!psfhlp) { + WARN("Failed to acquire ISFHelper interface.\n"); + return FALSE; + } + ISFHelper_GetUniqueName(psfhlp, path, MAX_PATH); + hr = ISFHelper_AddFolder(psfhlp, info->hwndTreeView, path, + &pidlChild); + if (FAILED(hr)) + return FALSE; + /* Insert into treeview */ + hParent = TreeView_GetSelection( info->hwndTreeView ); + InsertTreeViewItem( info, lpsfParent, pidlChild, + info->pidlRet, NULL, hParent ); + ILFree(pidlChild); + IShellFolder_Release(lpsfParent); + return TRUE; + } } return FALSE; }