Commit e80d8fe0 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

shell32: Reimplement IFolderView2_SetCurrentViewMode() with modern behaviours.

Only pre-win7 systems return E_INVALIDARG for invalid values, and only pre-vista systems accept FVM_AUTO as a view mode, others fall it back to FVM_ICON. Let's switch to modern behaviours, so that we don't need additional code for handling that when using it to implement IExplorerBrowser_SetFolderSettings().
parent 7f363820
......@@ -2709,25 +2709,20 @@ static HRESULT WINAPI FolderView_GetCurrentViewMode(IFolderView2 *iface, UINT *m
static HRESULT WINAPI FolderView_SetCurrentViewMode(IFolderView2 *iface, UINT mode)
{
IShellViewImpl *This = impl_from_IFolderView2(iface);
DWORD dwStyle;
TRACE("%p, %u.\n", This, mode);
IShellViewImpl *shellview = impl_from_IFolderView2(iface);
DWORD style;
if((mode < FVM_FIRST || mode > FVM_LAST) &&
(mode != FVM_AUTO))
return E_INVALIDARG;
TRACE("folder view %p, mode %u.\n", iface, mode);
/* Windows before Vista uses LVM_SETVIEW and possibly
LVM_SETEXTENDEDLISTVIEWSTYLE to set the style of the listview,
while later versions seem to accomplish this through other
means. */
dwStyle = ViewModeToListStyle(mode);
SetStyle(This, dwStyle, LVS_TYPEMASK);
if (mode == FVM_AUTO)
mode = FVM_ICON;
/* This will not necessarily be the actual mode set above.
This mimics the behavior of Windows XP. */
This->FolderSettings.ViewMode = mode;
if (mode >= FVM_FIRST && mode <= FVM_LAST)
{
style = ViewModeToListStyle(mode);
SetStyle(shellview, style, LVS_TYPEMASK);
shellview->FolderSettings.ViewMode = mode;
}
return S_OK;
}
......
......@@ -1110,13 +1110,23 @@ static void test_GetSetCurrentViewMode(void)
hr = IFolderView_SetCurrentViewMode(fview, FVM_AUTO);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
viewmode = 0xdeadbeef;
hr = IFolderView_GetCurrentViewMode(fview, &viewmode);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(viewmode == FVM_ICON || broken(viewmode == FVM_AUTO) /* pre vista */, "Got view mode %d.\n", viewmode);
hr = IFolderView_SetCurrentViewMode(fview, FVM_LIST);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
viewmode = 0xdeadbeef;
hr = IFolderView_GetCurrentViewMode(fview, &viewmode);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(viewmode == FVM_LIST, "Got view mode %d.\n", viewmode);
hr = IFolderView_SetCurrentViewMode(fview, 0);
ok(hr == E_INVALIDARG || broken(hr == S_OK),
"got (0x%08lx)\n", hr);
ok(hr == S_OK || broken(hr == E_INVALIDARG) /* pre win7 */, "Got hr %#lx.\n", hr);
viewmode = 0xdeadbeef;
hr = IFolderView_GetCurrentViewMode(fview, &viewmode);
ok(hr == S_OK, "got (0x%08lx)\n", hr);
ok(viewmode == FVM_LIST || broken(viewmode == 0) /* pre vista */, "Got view mode %d.\n", viewmode);
for(i = 1; i < 9; i++)
{
......@@ -1134,8 +1144,12 @@ static void test_GetSetCurrentViewMode(void)
}
hr = IFolderView_SetCurrentViewMode(fview, 9);
ok(hr == E_INVALIDARG || broken(hr == S_OK),
"got (0x%08lx)\n", hr);
ok(hr == S_OK || broken(hr == E_INVALIDARG) /* pre win7 */, "Got hr %#lx.\n", hr);
viewmode = 0xdeadbeef;
hr = IFolderView_GetCurrentViewMode(fview, &viewmode);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(viewmode == FVM_CONTENT || broken(viewmode == 9) /* pre vista */ ||
broken(viewmode == FVM_THUMBSTRIP) /* vista */, "Got view mode %d.\n", viewmode);
/* Test messages */
hwnd_lv = subclass_listview(hwnd);
......
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