Commit 7b7f4c61 authored by David Hedberg's avatar David Hedberg Committed by Alexandre Julliard

comdlg32: ::SetFileTypeIndex and ::GetFileTypeIndex uses a one-based index.

parent 4cda4195
...@@ -1880,10 +1880,9 @@ static HRESULT WINAPI IFileDialog2_fnSetFileTypeIndex(IFileDialog2 *iface, UINT ...@@ -1880,10 +1880,9 @@ static HRESULT WINAPI IFileDialog2_fnSetFileTypeIndex(IFileDialog2 *iface, UINT
if(!This->filterspecs) if(!This->filterspecs)
return E_FAIL; return E_FAIL;
if(iFileType >= This->filterspec_count) iFileType = max(iFileType, 1);
This->filetypeindex = This->filterspec_count - 1; iFileType = min(iFileType, This->filterspec_count);
else This->filetypeindex = iFileType-1;
This->filetypeindex = iFileType;
return S_OK; return S_OK;
} }
...@@ -1896,7 +1895,10 @@ static HRESULT WINAPI IFileDialog2_fnGetFileTypeIndex(IFileDialog2 *iface, UINT ...@@ -1896,7 +1895,10 @@ static HRESULT WINAPI IFileDialog2_fnGetFileTypeIndex(IFileDialog2 *iface, UINT
if(!piFileType) if(!piFileType)
return E_INVALIDARG; return E_INVALIDARG;
*piFileType = This->filetypeindex; if(This->filterspec_count == 0)
*piFileType = 0;
else
*piFileType = This->filetypeindex + 1;
return S_OK; return S_OK;
} }
......
...@@ -643,8 +643,6 @@ static void test_basics(void) ...@@ -643,8 +643,6 @@ static void test_basics(void)
hr = IFileOpenDialog_SetFileTypes(pfod, 0, filterspec); hr = IFileOpenDialog_SetFileTypes(pfod, 0, filterspec);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, -1);
ok(hr == E_FAIL, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, 0); hr = IFileOpenDialog_SetFileTypeIndex(pfod, 0);
ok(hr == E_FAIL, "got 0x%08x.\n", hr); ok(hr == E_FAIL, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, 1); hr = IFileOpenDialog_SetFileTypeIndex(pfod, 1);
...@@ -655,25 +653,39 @@ static void test_basics(void) ...@@ -655,25 +653,39 @@ static void test_basics(void)
ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr); ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, 0); hr = IFileOpenDialog_SetFileTypeIndex(pfod, 0);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_GetFileTypeIndex(pfod, &filetype);
ok(hr == S_OK, "got 0x%08x.\n", hr);
ok(filetype == 1, "got %d\n", filetype);
hr = IFileOpenDialog_SetFileTypeIndex(pfod, 100); hr = IFileOpenDialog_SetFileTypeIndex(pfod, 100);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_GetFileTypeIndex(pfod, &filetype);
ok(hr == S_OK, "got 0x%08x.\n", hr);
ok(filetype == 1, "got %d\n", filetype);
hr = IFileOpenDialog_SetFileTypes(pfod, 1, filterspec); hr = IFileOpenDialog_SetFileTypes(pfod, 1, filterspec);
ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr); ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr);
hr = IFileOpenDialog_SetFileTypes(pfod, 1, &filterspec[1]); hr = IFileOpenDialog_SetFileTypes(pfod, 1, &filterspec[1]);
ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr); ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_SetFileTypeIndex(pfsd, -1);
ok(hr == E_FAIL, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 0); hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 0);
ok(hr == E_FAIL, "got 0x%08x.\n", hr); ok(hr == E_FAIL, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 1); hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 1);
ok(hr == E_FAIL, "got 0x%08x.\n", hr); ok(hr == E_FAIL, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_SetFileTypes(pfsd, 1, filterspec); hr = IFileSaveDialog_SetFileTypes(pfsd, 2, filterspec);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_GetFileTypeIndex(pfsd, &filetype);
ok(hr == S_OK, "got 0x%08x.\n", hr);
/* I hope noone relies on this one */
todo_wine ok(filetype == 0, "got %d\n", filetype);
hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 0); hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 0);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_GetFileTypeIndex(pfsd, &filetype);
ok(hr == S_OK, "got 0x%08x.\n", hr);
ok(filetype == 1, "got %d\n", filetype);
hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 100); hr = IFileSaveDialog_SetFileTypeIndex(pfsd, 100);
ok(hr == S_OK, "got 0x%08x.\n", hr); ok(hr == S_OK, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_GetFileTypeIndex(pfsd, &filetype);
ok(hr == S_OK, "got 0x%08x.\n", hr);
ok(filetype == 2, "got %d\n", filetype);
hr = IFileSaveDialog_SetFileTypes(pfsd, 1, filterspec); hr = IFileSaveDialog_SetFileTypes(pfsd, 1, filterspec);
ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr); ok(hr == E_UNEXPECTED, "got 0x%08x.\n", hr);
hr = IFileSaveDialog_SetFileTypes(pfsd, 1, &filterspec[1]); hr = IFileSaveDialog_SetFileTypes(pfsd, 1, &filterspec[1]);
......
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