Commit 125102f5 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Improved a bit the folder browsing implementation.

parent 010bc4e7
#include <stdlib.h>
#include <string.h>
#include "winerror.h"
#include "heap.h"
#include "dlgs.h"
#include "debugtools.h"
#include "winreg.h"
#include "winnls.h"
#include "commctrl.h"
#include "wine/obj_base.h"
#include "wine/obj_enumidlist.h"
#include "wine/obj_shellfolder.h"
#include "wine/undocshell.h"
#include "shlguid.h"
#include "pidl.h"
#include "shell32_main.h"
#include "shellapi.h"
#include "shlguid.h"
#include "shresdef.h"
DEFAULT_DEBUG_CHANNEL(shell);
#define IDD_TREEVIEW 99
DEFAULT_DEBUG_CHANNEL(shell)
static HWND hwndTreeView;
static LPBROWSEINFOA lpBrowseInfo;
......@@ -29,7 +17,7 @@ static LPITEMIDLIST pidlRet;
static void FillTreeView(LPSHELLFOLDER lpsf, LPITEMIDLIST lpifq, HTREEITEM hParent);
static void InitializeTreeView(HWND hwndParent)
static void InitializeTreeView(HWND hwndParent, LPCITEMIDLIST root)
{
HIMAGELIST hImageList;
IShellFolder * lpsf;
......@@ -44,7 +32,22 @@ static void InitializeTreeView(HWND hwndParent)
{ TreeView_SetImageList(hwndTreeView, hImageList, 0);
}
/* so far, this method doesn't work (still missing the upper level), keep the old way */
#if 0
if (root == NULL) {
hr = SHGetDesktopFolder(&lpsf);
} else {
IShellFolder * lpsfdesktop;
hr = SHGetDesktopFolder(&lpsfdesktop);
if (SUCCEEDED(hr)) {
hr = IShellFolder_BindToObject(lpsfdesktop, root, 0,(REFIID)&IID_IShellFolder,(LPVOID *)&lpsf);
IShellFolder_Release(lpsfdesktop);
}
}
#else
hr = SHGetDesktopFolder(&lpsf);
#endif
if (SUCCEEDED(hr) && hwndTreeView)
{ TreeView_DeleteAllItems(hwndTreeView);
......@@ -54,6 +57,7 @@ static void InitializeTreeView(HWND hwndParent)
if (SUCCEEDED(hr))
{ IShellFolder_Release(lpsf);
}
TRACE("done\n");
}
static int GetIcon(LPITEMIDLIST lpi, UINT uFlags)
......@@ -206,10 +210,12 @@ static LRESULT MsgNotify(HWND hWnd, UINT CtlID, LPNMHDR lpnmh)
case TVN_SELCHANGEDA:
lptvid=(LPTV_ITEMDATA)pnmtv->itemNew.lParam;
pidlRet = lptvid->lpifq;
if (lpBrowseInfo->lpfn)
(lpBrowseInfo->lpfn)(hWnd, BFFM_SELCHANGED, (LPARAM)pidlRet, lpBrowseInfo->lParam);
break;
default:
FIXME("unhandled\n");
FIXME("unhandled (%d)\n", pnmtv->hdr.code);
break;
}
break;
......@@ -233,17 +239,27 @@ static BOOL WINAPI BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
{ case WM_INITDIALOG:
pidlRet = NULL;
lpBrowseInfo = (LPBROWSEINFOA) lParam;
if (lpBrowseInfo->lpfn)
FIXME("Callbacks not implemented\n");
if (lpBrowseInfo->ulFlags)
FIXME("flag %x not implemented\n", lpBrowseInfo->ulFlags);
if (lpBrowseInfo->lpszTitle)
FIXME("title %s not displayed\n", lpBrowseInfo->lpszTitle);
if (lpBrowseInfo->ulFlags & ~(BIF_STATUSTEXT))
FIXME("flags %x not implemented\n", lpBrowseInfo->ulFlags & ~(BIF_STATUSTEXT));
if (lpBrowseInfo->lpszTitle) {
SetWindowTextA(GetDlgItem(hWnd, IDD_TITLE), lpBrowseInfo->lpszTitle);
} else {
ShowWindow(GetDlgItem(hWnd, IDD_TITLE), SW_HIDE);
}
if (!(lpBrowseInfo->ulFlags & BIF_STATUSTEXT))
ShowWindow(GetDlgItem(hWnd, IDD_STATUS), SW_HIDE);
if ( lpBrowseInfo->pidlRoot )
FIXME("root is desktop\n");
InitializeTreeView ( hWnd);
return 1;
InitializeTreeView( hWnd, lpBrowseInfo->pidlRoot );
if (lpBrowseInfo->lpfn) {
(lpBrowseInfo->lpfn)(hWnd, BFFM_INITIALIZED, 0, lpBrowseInfo->lParam);
(lpBrowseInfo->lpfn)(hWnd, BFFM_SELCHANGED, 0/*FIXME*/, lpBrowseInfo->lParam);
}
return TRUE;
case WM_NOTIFY:
MsgNotify( hWnd, (UINT)wParam, (LPNMHDR)lParam);
......@@ -260,10 +276,35 @@ static BOOL WINAPI BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
case IDCANCEL:
EndDialog(hWnd, 0);
return TRUE;
break;
}
break;
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;
case BFFM_SETSELECTIONA:
if (wParam)
TRACE("Set selection %s\n", debugstr_a((LPSTR)lParam));
else
TRACE("Set selection %p\n", (void*)lParam);
break;
case BFFM_SETSELECTIONW:
if (wParam)
TRACE("Set selection %s\n", debugstr_w((LPWSTR)lParam));
else
TRACE("Set selection %p\n", (void*)lParam);
break;
}
return 0;
return FALSE;
}
/*************************************************************************
......@@ -272,9 +313,11 @@ static BOOL WINAPI BrsFolderDlgProc( HWND hWnd, UINT msg, WPARAM wParam,
*/
LPITEMIDLIST WINAPI SHBrowseForFolderA (LPBROWSEINFOA lpbi)
{
TRACE("(%p{lpszTitle=%s})\n", lpbi, debugstr_a(lpbi->lpszTitle));
TRACE("(%p{lpszTitle=%s,owner=%i})\n",
lpbi, debugstr_a(lpbi->lpszTitle), lpbi->hwndOwner);
return (LPITEMIDLIST) DialogBoxParamA( shell32_hInstance,
"SHBRSFORFOLDER_MSGBOX", lpbi->hwndOwner,
"SHBRSFORFOLDER_MSGBOX",
lpbi->hwndOwner,
BrsFolderDlgProc, (INT)lpbi );
}
......@@ -15,7 +15,7 @@
* and translated. The language 0,0 is a hack to get it
* loaded properly for all languages by pretending that
* they are neutral.
* The menus are not jet properly implemented.
* The menus are not yet properly implemented.
* Don't localize it yet. (js)
*/
......@@ -91,17 +91,20 @@ BEGIN
MENUITEM "&Properties", FCIDM_SHVIEW_PROPERTIES
END
END
SHBRSFORFOLDER_MSGBOX DIALOG 15, 40, 128, 152
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
SHBRSFORFOLDER_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 15, 40, 188, 192
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Choose a Directory:"
FONT 8, "Helv"
{
DEFPUSHBUTTON "OK", 1, 4, 132, 50, 12
PUSHBUTTON "Cancel", 2, 58, 132, 50, 12
CONTROL "Tree1",99,"SysTreeView32",
DEFPUSHBUTTON "OK", 1, 80, 176, 50, 12, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP
PUSHBUTTON "Cancel", 2, 134, 176, 50, 12, WS_GROUP | WS_TABSTOP
LTEXT "", IDD_TITLE, 4, 4, 18, 12
LTEXT "", IDD_STATUS, 4, 25, 18, 12
CONTROL "Tree1",IDD_TREEVIEW,"SysTreeView32",
TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT |
WS_BORDER | WS_TABSTOP,
4, 4, 120, 120
4, 40, 180, 120
}
/*
......
......@@ -26,4 +26,10 @@
#define IDS_CREATEFOLDER_CAPTION 31
#define IDS_DELETEFOLDER_TEXT 32
#define IDS_DELETEFOLDER_CAPTION 33
/* browse for folder dialog box */
#define IDD_STATUS 97
#define IDD_TITLE 98
#define IDD_TREEVIEW 99
#endif
......@@ -239,25 +239,12 @@ typedef struct tagBROWSEINFOW {
#define BFFM_SETSELECTIONW (WM_USER+103)
#define BFFM_SETSTATUSTEXTW (WM_USER+104)
/*
#ifdef UNICODE
#define SHBrowseForFolder SHBrowseForFolderW
#define BFFM_SETSTATUSTEXT BFFM_SETSTATUSTEXTW
#define BFFM_SETSELECTION BFFM_SETSELECTIONW
#define BFFM_VALIDATEFAILED BFFM_VALIDATEFAILEDW
#else
#define SHBrowseForFolder SHBrowseForFolderA
#define BFFM_SETSTATUSTEXT BFFM_SETSTATUSTEXTA
#define BFFM_SETSELECTION BFFM_SETSELECTIONA
#define BFFM_VALIDATEFAILED BFFM_VALIDATEFAILEDA
#endif
*/
LPITEMIDLIST WINAPI SHBrowseForFolderA(LPBROWSEINFOA lpbi);
LPITEMIDLIST WINAPI SHBrowseForFolder32W(LPBROWSEINFOW lpbi);
LPITEMIDLIST WINAPI SHBrowseForFolderW(LPBROWSEINFOW lpbi);
#define SHBrowseForFolder WINELIB_NAME_AW(SHBrowseForFolder)
#define BFFM_SETSTATUSTEXT WINELIB_NAME_AW(BFFM_SETSTATUSTEXT)
#define BFFM_SETSELECTION WINELIB_NAME_AW(BFFM_SETSELECTION)
#define BFFM_VALIDATEFAILED WINELIB_NAME_AW(BFFM_VALIDATEFAILED)
/****************************************************************************
* SHGetDataFromIDList API
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment