Commit 3ed6413a authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

shell32: Reimplement IExplorerBrowser_SetFolderSettings() with support of setting flags.

parent 49490f85
......@@ -340,24 +340,6 @@ static void size_panes(ExplorerBrowserImpl *This)
TRUE);
}
static HRESULT change_viewmode(ExplorerBrowserImpl *This, UINT viewmode)
{
IFolderView *pfv;
HRESULT hr;
if(!This->psv)
return E_FAIL;
hr = IShellView_QueryInterface(This->psv, &IID_IFolderView, (void*)&pfv);
if(SUCCEEDED(hr))
{
hr = IFolderView_SetCurrentViewMode(pfv, This->fs.ViewMode);
IFolderView_Release(pfv);
}
return hr;
}
static HRESULT create_new_shellview(ExplorerBrowserImpl *This, IShellItem *psi)
{
IShellBrowser *psb = &This->IShellBrowser_iface;
......@@ -988,17 +970,32 @@ static HRESULT WINAPI IExplorerBrowser_fnSetEmptyText(IExplorerBrowser *iface,
static HRESULT WINAPI IExplorerBrowser_fnSetFolderSettings(IExplorerBrowser *iface,
const FOLDERSETTINGS *pfs)
{
ExplorerBrowserImpl *This = impl_from_IExplorerBrowser(iface);
TRACE("%p (%p)\n", This, pfs);
ExplorerBrowserImpl *browser = impl_from_IExplorerBrowser(iface);
IFolderView2 *view;
HRESULT hr;
TRACE("explorer browser %p, settings %p.\n", iface, pfs);
if(!pfs)
if (!pfs)
return E_INVALIDARG;
This->fs.ViewMode = pfs->ViewMode;
This->fs.fFlags = pfs->fFlags | FWF_NOCLIENTEDGE;
if (pfs->ViewMode)
browser->fs.ViewMode = pfs->ViewMode;
browser->fs.fFlags = pfs->fFlags;
/* Change the settings of the current view, if any. */
return change_viewmode(This, This->fs.ViewMode);
if (!browser->psv)
return E_INVALIDARG;
hr = IShellView_QueryInterface(browser->psv, &IID_IFolderView2, (void **)&view);
if (SUCCEEDED(hr))
{
hr = IFolderView2_SetCurrentViewMode(view, browser->fs.ViewMode);
if (SUCCEEDED(hr))
if (SUCCEEDED(hr))
hr = IFolderView2_SetCurrentFolderFlags(view, ~FWF_NONE, browser->fs.fFlags);
IFolderView2_Release(view);
}
return hr;
}
static HRESULT WINAPI IExplorerBrowser_fnAdvise(IExplorerBrowser *iface,
......
......@@ -1688,6 +1688,23 @@ static void setup_window(void)
ok(hwnd != NULL, "Failed to create window for tests.\n");
}
#define CHECK_SETTINGS(browser,expected) _check_settings(browser, expected, __LINE__)
static void _check_settings(IExplorerBrowser *browser, FOLDERSETTINGS expected, int line)
{
FOLDERSETTINGS settings;
IShellView *view;
HRESULT hr;
hr = IExplorerBrowser_GetCurrentView(browser, &IID_IShellView, (void **)&view);
ok_(__FILE__,line)(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IShellView_GetCurrentInfo(view, &settings);
ok_(__FILE__,line)(hr == S_OK, "Got hr %#lx.\n", hr);
ok_(__FILE__,line)(!memcmp(&settings, &expected, sizeof(settings)),
"Got settings {view mode: %d, flags: %#x}, expected {view mode: %d, flags: %#x}.\n",
settings.ViewMode, settings.fFlags, expected.ViewMode, expected.fFlags);
IShellView_Release(view);
}
static void test_folder_settings(void)
{
IExplorerBrowser *browser;
......@@ -1702,7 +1719,45 @@ static void test_folder_settings(void)
settings.ViewMode = 0; settings.fFlags = FWF_NONE;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
settings.ViewMode = FVM_ICON; settings.fFlags = FWF_SNAPTOGRID;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
ebrowser_browse_to_desktop(browser);
settings.ViewMode = FVM_AUTO; settings.fFlags = FWF_AUTOARRANGE;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(settings.ViewMode == FVM_AUTO && settings.fFlags == FWF_AUTOARRANGE,
"Got view mode %d, flags %#x.\n", settings.ViewMode, settings.fFlags);
settings.ViewMode = FVM_ICON; settings.fFlags = FWF_AUTOARRANGE;
CHECK_SETTINGS(browser, settings);
settings.ViewMode = FVM_LIST; settings.fFlags = FWF_AUTOARRANGE;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
settings.ViewMode = 0; settings.fFlags = FWF_SNAPTOGRID;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(settings.ViewMode == 0 && settings.fFlags == FWF_SNAPTOGRID,
"Got view mode %d, flags %#x.\n", settings.ViewMode, settings.fFlags);
settings.ViewMode = FVM_LIST;
CHECK_SETTINGS(browser, settings);
settings.ViewMode = FVM_LAST + 1; settings.fFlags = FWF_AUTOARRANGE;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
settings.ViewMode = FVM_LIST;
CHECK_SETTINGS(browser, settings);
settings.ViewMode = FVM_ICON; settings.fFlags = FWF_NONE;
hr = IExplorerBrowser_SetFolderSettings(browser, &settings);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(settings.ViewMode == FVM_ICON && settings.fFlags == FWF_NONE,
"Got view mode %d, flags %#x.\n", settings.ViewMode, settings.fFlags);
CHECK_SETTINGS(browser, settings);
IExplorerBrowser_Release(browser);
}
......
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