2 * Unit tests for the Common Item Dialog
4 * Copyright 2010,2011 David Hedberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/test.h"
28 static HRESULT (WINAPI
*pSHCreateShellItem
)(LPCITEMIDLIST
,IShellFolder
*,LPCITEMIDLIST
,IShellItem
**);
29 static HRESULT (WINAPI
*pSHGetIDListFromObject
)(IUnknown
*, PIDLIST_ABSOLUTE
*);
30 static HRESULT (WINAPI
*pSHCreateItemFromParsingName
)(PCWSTR
,IBindCtx
*,REFIID
,void**);
32 static void init_function_pointers(void)
34 HMODULE hmod
= GetModuleHandleA("shell32.dll");
36 #define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hmod, #f))
37 MAKEFUNC(SHCreateShellItem
);
38 MAKEFUNC(SHGetIDListFromObject
);
39 MAKEFUNC(SHCreateItemFromParsingName
);
44 DEFINE_GUID(IID_IFileDialogCustomizeAlt
, 0x8016B7B3, 0x3D49, 0x4504, 0xA0,0xAA, 0x2A,0x37,0x49,0x4E,0x60,0x6F);
46 /**************************************************************************
47 * IFileDialogEvents implementation
50 IFileDialogEvents IFileDialogEvents_iface
;
53 LONG OnFileOk
, OnFolderChanging
, OnFolderChange
;
54 LONG OnSelectionChange
, OnShareViolation
, OnTypeChange
;
57 BOOL set_filename_tried
;
59 } IFileDialogEventsImpl
;
61 static inline IFileDialogEventsImpl
*impl_from_IFileDialogEvents(IFileDialogEvents
*iface
)
63 return CONTAINING_RECORD(iface
, IFileDialogEventsImpl
, IFileDialogEvents_iface
);
66 static HRESULT WINAPI
IFileDialogEvents_fnQueryInterface(IFileDialogEvents
*iface
, REFIID riid
, void **ppv
)
69 ok(0, "Unexpectedly called.\n");
73 static ULONG WINAPI
IFileDialogEvents_fnAddRef(IFileDialogEvents
*iface
)
75 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
76 return InterlockedIncrement(&This
->ref
);
79 static ULONG WINAPI
IFileDialogEvents_fnRelease(IFileDialogEvents
*iface
)
81 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
82 LONG ref
= InterlockedDecrement(&This
->ref
);
85 HeapFree(GetProcessHeap(), 0, This
);
90 static HRESULT WINAPI
IFileDialogEvents_fnOnFileOk(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
92 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
97 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChanging(IFileDialogEvents
*iface
,
99 IShellItem
*psiFolder
)
101 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
102 This
->OnFolderChanging
++;
106 static void test_customize_onfolderchange(IFileDialog
*pfd
);
108 static LRESULT CALLBACK
test_customize_dlgproc(HWND hwnd
, UINT message
, LPARAM lparam
, WPARAM wparam
)
110 WNDPROC oldwndproc
= GetPropA(hwnd
, "WT_OLDWC");
112 if(message
== WM_USER
+0x1234)
114 IFileDialog
*pfd
= (IFileDialog
*)lparam
;
115 test_customize_onfolderchange(pfd
);
118 return CallWindowProcW(oldwndproc
, hwnd
, message
, lparam
, wparam
);
121 static HRESULT WINAPI
IFileDialogEvents_fnOnFolderChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
123 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
128 This
->OnFolderChange
++;
130 if(This
->set_filename
)
132 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
133 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
135 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
136 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
137 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
139 IOleWindow_Release(pow
);
141 hr
= IFileDialog_SetFileName(pfd
, This
->set_filename
);
142 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
144 if(!This
->set_filename_tried
)
146 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDOK
, 0);
148 This
->set_filename_tried
= TRUE
;
155 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
156 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
158 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
159 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
160 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
162 IOleWindow_Release(pow
);
164 /* On Vista, the custom control area of the dialog is not
165 * fully set up when the first OnFolderChange event is
167 oldwndproc
= (WNDPROC
)GetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
);
168 SetPropA(dlg_hwnd
, "WT_OLDWC", (HANDLE
)oldwndproc
);
169 SetWindowLongPtrW(dlg_hwnd
, GWLP_WNDPROC
, (LPARAM
)test_customize_dlgproc
);
171 br
= PostMessageW(dlg_hwnd
, WM_USER
+0x1234, (LPARAM
)pfd
, 0);
178 static HRESULT WINAPI
IFileDialogEvents_fnOnSelectionChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
180 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
181 This
->OnSelectionChange
++;
185 static HRESULT WINAPI
IFileDialogEvents_fnOnShareViolation(IFileDialogEvents
*iface
,
188 FDE_SHAREVIOLATION_RESPONSE
*pResponse
)
190 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
191 This
->OnShareViolation
++;
195 static HRESULT WINAPI
IFileDialogEvents_fnOnTypeChange(IFileDialogEvents
*iface
, IFileDialog
*pfd
)
197 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
198 This
->OnTypeChange
++;
202 static HRESULT WINAPI
IFileDialogEvents_fnOnOverwrite(IFileDialogEvents
*iface
,
205 FDE_OVERWRITE_RESPONSE
*pResponse
)
207 IFileDialogEventsImpl
*This
= impl_from_IFileDialogEvents(iface
);
212 static const IFileDialogEventsVtbl vt_IFileDialogEvents
= {
213 IFileDialogEvents_fnQueryInterface
,
214 IFileDialogEvents_fnAddRef
,
215 IFileDialogEvents_fnRelease
,
216 IFileDialogEvents_fnOnFileOk
,
217 IFileDialogEvents_fnOnFolderChanging
,
218 IFileDialogEvents_fnOnFolderChange
,
219 IFileDialogEvents_fnOnSelectionChange
,
220 IFileDialogEvents_fnOnShareViolation
,
221 IFileDialogEvents_fnOnTypeChange
,
222 IFileDialogEvents_fnOnOverwrite
225 static IFileDialogEvents
*IFileDialogEvents_Constructor(void)
227 IFileDialogEventsImpl
*This
;
229 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IFileDialogEventsImpl
));
230 This
->IFileDialogEvents_iface
.lpVtbl
= &vt_IFileDialogEvents
;
233 return &This
->IFileDialogEvents_iface
;
236 static BOOL
test_instantiation(void)
239 IFileOpenDialog
*pfod
;
240 IFileSaveDialog
*pfsd
;
241 IServiceProvider
*psp
;
247 /* Instantiate FileOpenDialog */
248 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
249 &IID_IFileOpenDialog
, (void**)&pfod
);
252 skip("Could not instantiate the FileOpenDialog.\n");
255 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
257 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog
, (void**)&pfd
);
258 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
259 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
261 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&punk
);
262 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
263 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
265 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
266 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
267 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
269 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileSaveDialog
, (void**)&pfsd
);
270 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
271 if(SUCCEEDED(hr
)) IFileSaveDialog_Release(pfsd
);
273 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IServiceProvider
, (void**)&psp
);
274 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
277 IExplorerBrowser
*peb
;
280 hr
= IServiceProvider_QueryService(psp
, &SID_SExplorerBrowserFrame
, &IID_ICommDlgBrowser
, (void**)&punk
);
281 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
282 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
284 /* since win8, the result is E_NOTIMPL for all other services */
285 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IExplorerBrowser
, (void**)&peb
);
286 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
287 if(SUCCEEDED(hr
)) IExplorerBrowser_Release(peb
);
288 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IShellBrowser
, (void**)&psb
);
289 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
290 if(SUCCEEDED(hr
)) IShellBrowser_Release(psb
);
291 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_ICommDlgBrowser
, (void**)&punk
);
292 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
293 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
295 hr
= IServiceProvider_QueryService(psp
, &SID_STopLevelBrowser
, &IID_IUnknown
, (void**)&punk
);
296 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
297 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
298 hr
= IServiceProvider_QueryService(psp
, &IID_IUnknown
, &IID_IUnknown
, (void**)&punk
);
299 ok(hr
== E_NOTIMPL
|| broken(hr
== E_FAIL
), "got 0x%08x (expected E_NOTIMPL)\n", hr
);
300 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
302 IServiceProvider_Release(psp
);
305 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialogEvents
, (void**)&punk
);
306 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
307 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
309 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowser
, (void**)&punk
);
310 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
311 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
313 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
314 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
315 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
317 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_ICommDlgBrowser3
, (void**)&punk
);
318 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
319 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
321 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IShellBrowser
, (void**)&punk
);
322 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
323 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
325 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
326 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
331 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
332 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
334 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
335 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
339 /* Crashes on win7 */
340 IOleWindow_GetWindow(pow
, NULL
);
343 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
344 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
345 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
347 IOleWindow_Release(pow
);
350 ref
= IFileOpenDialog_Release(pfod
);
351 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
353 /* Instantiate FileSaveDialog */
354 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
355 &IID_IFileSaveDialog
, (void**)&pfsd
);
358 skip("Could not instantiate the FileSaveDialog.\n");
361 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
363 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog
, (void**)&pfd
);
364 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
365 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
367 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomize
, (void**)&punk
);
368 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
369 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
371 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogCustomizeAlt
, (void**)&punk
);
372 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
373 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
375 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileOpenDialog
, (void**)&pfod
);
376 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
377 if(SUCCEEDED(hr
)) IFileOpenDialog_Release(pfod
);
379 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialogEvents
, (void**)&punk
);
380 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
381 if(SUCCEEDED(hr
)) IFileDialog_Release(pfd
);
383 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowser
, (void**)&punk
);
384 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
385 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
387 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IExplorerBrowserEvents
, (void**)&punk
);
388 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
389 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
391 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_ICommDlgBrowser3
, (void**)&punk
);
392 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
393 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
395 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IShellBrowser
, (void**)&punk
);
396 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
397 if(SUCCEEDED(hr
)) IUnknown_Release(punk
);
399 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IOleWindow
, (void**)&pow
);
400 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
405 hr
= IOleWindow_ContextSensitiveHelp(pow
, TRUE
);
406 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
408 hr
= IOleWindow_ContextSensitiveHelp(pow
, FALSE
);
409 todo_wine
ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
413 /* Crashes on win7 */
414 IOleWindow_GetWindow(pow
, NULL
);
417 hr
= IOleWindow_GetWindow(pow
, &hwnd
);
418 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
419 ok(hwnd
== NULL
, "Got %p\n", hwnd
);
421 IOleWindow_Release(pow
);
425 ref
= IFileSaveDialog_Release(pfsd
);
426 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
430 static void test_basics(void)
432 IFileOpenDialog
*pfod
;
433 IFileSaveDialog
*pfsd
;
435 FILEOPENDIALOGOPTIONS fdoptions
;
436 IShellFolder
*psfdesktop
;
437 IShellItem
*psi
, *psidesktop
, *psi_original
;
438 IShellItemArray
*psia
;
445 const WCHAR txt
[] = {'t','x','t', 0};
446 const WCHAR null
[] = {0};
447 const WCHAR fname1
[] = {'f','n','a','m','e','1', 0};
448 const WCHAR fspec1
[] = {'*','.','t','x','t',0};
449 const WCHAR fname2
[] = {'f','n','a','m','e','2', 0};
450 const WCHAR fspec2
[] = {'*','.','e','x','e',0};
451 COMDLG_FILTERSPEC filterspec
[2] = {{fname1
, fspec1
}, {fname2
, fspec2
}};
453 /* This should work on every platform with IFileDialog */
454 SHGetDesktopFolder(&psfdesktop
);
455 hr
= pSHGetIDListFromObject((IUnknown
*)psfdesktop
, &pidl
);
458 hr
= pSHCreateShellItem(NULL
, NULL
, pidl
, &psidesktop
);
461 IShellFolder_Release(psfdesktop
);
464 skip("Failed to get ShellItem from DesktopFolder, skipping tests.\n");
469 /* Instantiate FileOpenDialog and FileSaveDialog */
470 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
471 &IID_IFileOpenDialog
, (void**)&pfod
);
472 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
473 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
474 &IID_IFileSaveDialog
, (void**)&pfsd
);
475 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
477 /* ClearClientData */
480 hr
= IFileOpenDialog_ClearClientData(pfod
);
481 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
482 hr
= IFileSaveDialog_ClearClientData(pfsd
);
483 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
487 hr
= IFileOpenDialog_GetOptions(pfod
, NULL
);
488 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
489 hr
= IFileSaveDialog_GetOptions(pfsd
, NULL
);
490 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
492 /* Check default options */
493 hr
= IFileOpenDialog_GetOptions(pfod
, &fdoptions
);
494 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
495 ok(fdoptions
== (FOS_PATHMUSTEXIST
| FOS_FILEMUSTEXIST
| FOS_NOCHANGEDIR
),
496 "Unexpected default options: 0x%08x\n", fdoptions
);
497 hr
= IFileSaveDialog_GetOptions(pfsd
, &fdoptions
);
498 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
499 ok(fdoptions
== (FOS_OVERWRITEPROMPT
| FOS_NOREADONLYRETURN
| FOS_PATHMUSTEXIST
| FOS_NOCHANGEDIR
),
500 "Unexpected default options: 0x%08x\n", fdoptions
);
503 hr
= IFileOpenDialog_GetResult(pfod
, NULL
);
504 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
505 hr
= IFileSaveDialog_GetResult(pfsd
, NULL
);
506 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
508 psi
= (void*)0xdeadbeef;
509 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
510 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
511 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
512 psi
= (void*)0xdeadbeef;
513 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
514 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
515 ok(psi
== (void*)0xdeadbeef, "got %p.\n", psi
);
517 /* GetCurrentSelection */
519 /* Crashes on Vista/W2K8. Tests below passes on Windows 7 */
520 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, NULL
);
521 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
522 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, NULL
);
523 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
524 hr
= IFileOpenDialog_GetCurrentSelection(pfod
, &psi
);
525 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
526 hr
= IFileSaveDialog_GetCurrentSelection(pfsd
, &psi
);
527 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
531 hr
= IFileOpenDialog_GetFileName(pfod
, NULL
);
532 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
533 filename
= (void*)0xdeadbeef;
534 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
535 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
536 ok(filename
== NULL
, "got %p\n", filename
);
537 hr
= IFileSaveDialog_GetFileName(pfsd
, NULL
);
538 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
539 filename
= (void*)0xdeadbeef;
540 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
541 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
542 ok(filename
== NULL
, "got %p\n", filename
);
544 /* GetFileTypeIndex */
545 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, NULL
);
546 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
548 hr
= IFileOpenDialog_GetFileTypeIndex(pfod
, &filetype
);
549 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
550 ok(filetype
== 0, "got %d.\n", filetype
);
551 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, NULL
);
552 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
554 hr
= IFileSaveDialog_GetFileTypeIndex(pfsd
, &filetype
);
555 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
556 ok(filetype
== 0, "got %d.\n", filetype
);
558 /* SetFileTypes / SetFileTypeIndex */
559 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, NULL
);
560 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
561 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
562 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
564 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, -1);
565 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
566 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
567 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
568 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 1);
569 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
570 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
571 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
572 hr
= IFileOpenDialog_SetFileTypes(pfod
, 0, filterspec
);
573 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
574 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 0);
575 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
576 hr
= IFileOpenDialog_SetFileTypeIndex(pfod
, 100);
577 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
578 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, filterspec
);
579 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
580 hr
= IFileOpenDialog_SetFileTypes(pfod
, 1, &filterspec
[1]);
581 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
583 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, -1);
584 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
585 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
586 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
587 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 1);
588 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
589 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
590 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
591 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 0);
592 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
593 hr
= IFileSaveDialog_SetFileTypeIndex(pfsd
, 100);
594 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
595 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, filterspec
);
596 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
597 hr
= IFileSaveDialog_SetFileTypes(pfsd
, 1, &filterspec
[1]);
598 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
603 hr
= IFileOpenDialog_SetFilter(pfod
, NULL
);
604 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
605 hr
= IFileSaveDialog_SetFilter(pfsd
, NULL
);
606 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
610 hr
= IFileOpenDialog_SetFolder(pfod
, NULL
);
611 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
612 hr
= IFileSaveDialog_SetFolder(pfsd
, NULL
);
613 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
615 /* SetDefaultExtension */
616 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, NULL
);
617 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
618 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, txt
);
619 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
620 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, null
);
621 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
623 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, NULL
);
624 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
625 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, txt
);
626 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
627 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, null
);
628 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
630 /* SetDefaultFolder */
631 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, NULL
);
632 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
633 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, NULL
);
634 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
636 hr
= IFileOpenDialog_SetDefaultFolder(pfod
, psidesktop
);
637 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
638 hr
= IFileSaveDialog_SetDefaultFolder(pfsd
, psidesktop
);
639 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
643 /* Crashes under Windows 7 */
644 IFileOpenDialog_SetDefaultFolder(pfod
, (void*)0x1234);
645 IFileSaveDialog_SetDefaultFolder(pfsd
, (void*)0x1234);
648 /* GetFolder / SetFolder */
649 hr
= IFileOpenDialog_GetFolder(pfod
, NULL
);
650 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
652 hr
= IFileOpenDialog_GetFolder(pfod
, &psi_original
);
653 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
656 hr
= IFileOpenDialog_SetFolder(pfod
, psidesktop
);
657 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
658 hr
= IFileOpenDialog_SetFolder(pfod
, psi_original
);
659 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
660 IShellItem_Release(psi_original
);
663 hr
= IFileSaveDialog_GetFolder(pfsd
, &psi_original
);
664 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
667 hr
= IFileSaveDialog_SetFolder(pfsd
, psidesktop
);
668 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
669 hr
= IFileSaveDialog_SetFolder(pfsd
, psi_original
);
670 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
671 IShellItem_Release(psi_original
);
677 /* Crashes under Windows 7 */
678 IFileOpenDialog_AddPlace(pfod
, NULL
, 0);
679 IFileSaveDialog_AddPlace(pfsd
, NULL
, 0);
684 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
+ 1);
685 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
686 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_BOTTOM
);
687 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
688 hr
= IFileOpenDialog_AddPlace(pfod
, psidesktop
, FDAP_TOP
);
689 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
691 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
+ 1);
692 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
693 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_BOTTOM
);
694 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
695 hr
= IFileSaveDialog_AddPlace(pfsd
, psidesktop
, FDAP_TOP
);
696 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
700 hr
= IFileOpenDialog_SetFileName(pfod
, NULL
);
701 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
702 hr
= IFileOpenDialog_SetFileName(pfod
, null
);
703 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
704 hr
= IFileOpenDialog_SetFileName(pfod
, txt
);
705 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
706 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
707 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
708 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
709 CoTaskMemFree(filename
);
711 hr
= IFileSaveDialog_SetFileName(pfsd
, NULL
);
712 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
713 hr
= IFileSaveDialog_SetFileName(pfsd
, null
);
714 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
715 hr
= IFileSaveDialog_SetFileName(pfsd
, txt
);
716 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
717 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
718 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
719 ok(!lstrcmpW(filename
, txt
), "Strings do not match.\n");
720 CoTaskMemFree(filename
);
722 /* SetFileNameLabel */
723 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, NULL
);
724 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
725 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, null
);
726 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
727 hr
= IFileOpenDialog_SetFileNameLabel(pfod
, txt
);
728 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
730 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, NULL
);
731 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
732 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, null
);
733 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
734 hr
= IFileSaveDialog_SetFileNameLabel(pfsd
, txt
);
735 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
738 hr
= IFileOpenDialog_Close(pfod
, S_FALSE
);
739 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
740 hr
= IFileSaveDialog_Close(pfsd
, S_FALSE
);
741 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
743 /* SetOkButtonLabel */
744 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, NULL
);
745 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
746 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, null
);
747 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
748 hr
= IFileOpenDialog_SetOkButtonLabel(pfod
, txt
);
749 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
750 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, NULL
);
751 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
752 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, null
);
753 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
754 hr
= IFileSaveDialog_SetOkButtonLabel(pfsd
, txt
);
755 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
758 hr
= IFileOpenDialog_SetTitle(pfod
, NULL
);
759 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
760 hr
= IFileOpenDialog_SetTitle(pfod
, null
);
761 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
762 hr
= IFileOpenDialog_SetTitle(pfod
, txt
);
763 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
764 hr
= IFileSaveDialog_SetTitle(pfsd
, NULL
);
765 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
766 hr
= IFileSaveDialog_SetTitle(pfsd
, null
);
767 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
768 hr
= IFileSaveDialog_SetTitle(pfsd
, txt
);
769 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
771 /** IFileOpenDialog specific **/
776 /* Crashes under Windows 7 */
777 IFileOpenDialog_GetResults(pfod
, NULL
);
779 psia
= (void*)0xdeadbeef;
780 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
781 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
782 ok(psia
== NULL
, "got %p.\n", psia
);
784 /* GetSelectedItems */
787 /* Crashes under W2K8 */
788 hr
= IFileOpenDialog_GetSelectedItems(pfod
, NULL
);
789 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
790 psia
= (void*)0xdeadbeef;
791 hr
= IFileOpenDialog_GetSelectedItems(pfod
, &psia
);
792 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
793 ok(psia
== (void*)0xdeadbeef, "got %p.\n", psia
);
796 /** IFileSaveDialog specific **/
798 /* ApplyProperties */
801 /* Crashes under windows 7 */
802 IFileSaveDialog_ApplyProperties(pfsd
, NULL
, NULL
, NULL
, NULL
);
803 IFileSaveDialog_ApplyProperties(pfsd
, psidesktop
, NULL
, NULL
, NULL
);
807 hr
= IFileSaveDialog_GetProperties(pfsd
, NULL
);
808 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
809 pps
= (void*)0xdeadbeef;
810 hr
= IFileSaveDialog_GetProperties(pfsd
, &pps
);
811 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x\n", hr
);
812 ok(pps
== (void*)0xdeadbeef, "got %p\n", pps
);
817 /* Crashes under W2K8 */
818 hr
= IFileSaveDialog_SetProperties(pfsd
, NULL
);
819 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
822 /* SetCollectedProperties */
825 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, TRUE
);
826 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
827 hr
= IFileSaveDialog_SetCollectedProperties(pfsd
, NULL
, FALSE
);
828 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
834 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, NULL
);
835 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
836 hr
= IFileSaveDialog_SetSaveAsItem(pfsd
, psidesktop
);
837 ok(hr
== MK_E_NOOBJECT
, "got 0x%08x\n", hr
);
842 hr
= IFileOpenDialog_QueryInterface(pfod
, &IID_IFileDialog2
, (void**)&pfd2
);
843 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
846 /* SetCancelButtonLabel */
847 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
848 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
849 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
850 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
851 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
852 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
854 /* SetNavigationRoot */
857 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
858 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
859 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
860 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
863 IFileDialog2_Release(pfd2
);
866 hr
= IFileSaveDialog_QueryInterface(pfsd
, &IID_IFileDialog2
, (void**)&pfd2
);
867 ok((hr
== S_OK
) || broken(hr
== E_NOINTERFACE
), "got 0x%08x\n", hr
);
870 /* SetCancelButtonLabel */
871 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, NULL
);
872 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
873 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, null
);
874 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
875 hr
= IFileDialog2_SetOkButtonLabel(pfd2
, txt
);
876 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
878 /* SetNavigationRoot */
881 hr
= IFileDialog2_SetNavigationRoot(pfd2
, NULL
);
882 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
883 hr
= IFileDialog2_SetNavigationRoot(pfd2
, psidesktop
);
884 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
887 IFileDialog2_Release(pfd2
);
891 IShellItem_Release(psidesktop
);
892 ref
= IFileOpenDialog_Release(pfod
);
893 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
894 ref
= IFileSaveDialog_Release(pfsd
);
895 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
898 static void ensure_zero_events_(const char *file
, int line
, IFileDialogEventsImpl
*impl
)
900 ok_(file
, line
)(!impl
->OnFileOk
, "OnFileOk: %d\n", impl
->OnFileOk
);
901 ok_(file
, line
)(!impl
->OnFolderChanging
, "OnFolderChanging: %d\n", impl
->OnFolderChanging
);
902 ok_(file
, line
)(!impl
->OnFolderChange
, "OnFolderChange: %d\n", impl
->OnFolderChange
);
903 ok_(file
, line
)(!impl
->OnSelectionChange
, "OnSelectionChange: %d\n", impl
->OnSelectionChange
);
904 ok_(file
, line
)(!impl
->OnShareViolation
, "OnShareViolation: %d\n", impl
->OnShareViolation
);
905 ok_(file
, line
)(!impl
->OnTypeChange
, "OnTypeChange: %d\n", impl
->OnTypeChange
);
906 ok_(file
, line
)(!impl
->OnOverwrite
, "OnOverwrite: %d\n", impl
->OnOverwrite
);
907 impl
->OnFileOk
= impl
->OnFolderChanging
= impl
->OnFolderChange
= 0;
908 impl
->OnSelectionChange
= impl
->OnShareViolation
= impl
->OnTypeChange
= 0;
909 impl
->OnOverwrite
= 0;
911 #define ensure_zero_events(impl) ensure_zero_events_(__FILE__, __LINE__, impl)
913 static void test_advise_helper(IFileDialog
*pfd
)
915 IFileDialogEventsImpl
*pfdeimpl
;
916 IFileDialogEvents
*pfde
;
921 pfde
= IFileDialogEvents_Constructor();
922 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
924 hr
= IFileDialog_Advise(pfd
, NULL
, NULL
);
925 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
926 hr
= IFileDialog_Advise(pfd
, pfde
, NULL
);
927 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
928 hr
= IFileDialog_Advise(pfd
, NULL
, &cookie
[0]);
929 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
930 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
931 ensure_zero_events(pfdeimpl
);
933 hr
= IFileDialog_Unadvise(pfd
, 0);
934 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
935 for(i
= 0; i
< 10; i
++) {
936 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[i
]);
937 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
938 ok(cookie
[i
] == i
+1, "Got cookie: %d\n", cookie
[i
]);
940 ok(pfdeimpl
->ref
== 10+1, "got ref %d\n", pfdeimpl
->ref
);
941 ensure_zero_events(pfdeimpl
);
943 for(i
= 3; i
< 7; i
++) {
944 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
945 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
947 ok(pfdeimpl
->ref
== 6+1, "got ref %d\n", pfdeimpl
->ref
);
948 ensure_zero_events(pfdeimpl
);
950 for(i
= 0; i
< 3; i
++) {
951 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
952 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
954 ok(pfdeimpl
->ref
== 3+1, "got ref %d\n", pfdeimpl
->ref
);
955 ensure_zero_events(pfdeimpl
);
957 for(i
= 7; i
< 10; i
++) {
958 hr
= IFileDialog_Unadvise(pfd
, cookie
[i
]);
959 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
961 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
962 ensure_zero_events(pfdeimpl
);
964 hr
= IFileDialog_Unadvise(pfd
, cookie
[9]+1);
965 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
966 ok(pfdeimpl
->ref
== 1, "got ref %d\n", pfdeimpl
->ref
);
967 ensure_zero_events(pfdeimpl
);
969 hr
= IFileDialog_Advise(pfd
, pfde
, &cookie
[0]);
970 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
971 todo_wine
ok(cookie
[0] == 1, "got cookie: %d\n", cookie
[0]);
972 ok(pfdeimpl
->ref
== 1+1, "got ref %d\n", pfdeimpl
->ref
);
973 ensure_zero_events(pfdeimpl
);
975 hr
= IFileDialog_Unadvise(pfd
, cookie
[0]);
979 /* Unadvising already unadvised cookies crashes on
981 IFileDialog_Unadvise(pfd
, cookie
[0]);
985 IFileDialogEvents_Release(pfde
);
988 static void test_advise(void)
994 trace("Testing FileOpenDialog (advise)\n");
995 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
996 &IID_IFileDialog
, (void**)&pfd
);
997 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
998 test_advise_helper(pfd
);
999 ref
= IFileDialog_Release(pfd
);
1000 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1002 trace("Testing FileSaveDialog (advise)\n");
1003 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1004 &IID_IFileDialog
, (void**)&pfd
);
1005 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1006 test_advise_helper(pfd
);
1007 ref
= IFileDialog_Release(pfd
);
1008 ok(!ref
, "Got refcount %d, should have been released.\n", ref
);
1011 static void touch_file(LPCWSTR filename
)
1014 file
= CreateFileW(filename
, GENERIC_WRITE
, 0, NULL
, CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1015 ok(file
!= INVALID_HANDLE_VALUE
, "Failed to create file.\n");
1019 static void test_filename_savedlg_(LPCWSTR set_filename
, LPCWSTR defext
,
1020 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1021 LPCWSTR exp_filename
, const char *file
, int line
)
1023 IFileSaveDialog
*pfsd
;
1024 IFileDialogEventsImpl
*pfdeimpl
;
1025 IFileDialogEvents
*pfde
;
1032 hr
= CoCreateInstance(&CLSID_FileSaveDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1033 &IID_IFileSaveDialog
, (void**)&pfsd
);
1034 ok_(file
,line
)(hr
== S_OK
, "Got 0x%08x\n", hr
);
1038 hr
= IFileSaveDialog_SetFileTypes(pfsd
, fs_count
, filterspec
);
1039 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1044 hr
= IFileSaveDialog_SetDefaultExtension(pfsd
, defext
);
1045 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1048 pfde
= IFileDialogEvents_Constructor();
1049 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1050 pfdeimpl
->set_filename
= set_filename
;
1051 hr
= IFileSaveDialog_Advise(pfsd
, pfde
, &cookie
);
1052 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1054 hr
= IFileSaveDialog_Show(pfsd
, NULL
);
1055 ok_(file
,line
)(hr
== S_OK
, "Show failed: Got 0x%08x\n", hr
);
1057 hr
= IFileSaveDialog_GetFileName(pfsd
, &filename
);
1058 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1059 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "Got %s\n", wine_dbgstr_w(filename
));
1060 CoTaskMemFree(filename
);
1062 hr
= IFileSaveDialog_GetResult(pfsd
, &psi
);
1063 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1065 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1066 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName failed: Got 0x%08x\n", hr
);
1067 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetDisplayName) Got %s\n", wine_dbgstr_w(filename
));
1068 CoTaskMemFree(filename
);
1069 IShellItem_Release(psi
);
1071 hr
= IFileSaveDialog_Unadvise(pfsd
, cookie
);
1072 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1074 ref
= IFileSaveDialog_Release(pfsd
);
1075 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1077 IFileDialogEvents_Release(pfde
);
1079 #define test_filename_savedlg(set_filename, defext, filterspec, fs_count, exp_filename) \
1080 test_filename_savedlg_(set_filename, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1082 static void test_filename_opendlg_(LPCWSTR set_filename
, IShellItem
*psi_current
, LPCWSTR defext
,
1083 const COMDLG_FILTERSPEC
*filterspec
, UINT fs_count
,
1084 LPCWSTR exp_filename
, const char *file
, int line
)
1086 IFileOpenDialog
*pfod
;
1087 IFileDialogEventsImpl
*pfdeimpl
;
1088 IFileDialogEvents
*pfde
;
1091 IShellItemArray
*psia
;
1096 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1097 &IID_IFileOpenDialog
, (void**)&pfod
);
1098 ok_(file
,line
)(hr
== S_OK
, "CoCreateInstance failed: Got 0x%08x\n", hr
);
1102 hr
= IFileOpenDialog_SetDefaultExtension(pfod
, defext
);
1103 ok_(file
,line
)(hr
== S_OK
, "SetDefaultExtensions failed: Got 0x%08x\n", hr
);
1108 hr
= IFileOpenDialog_SetFileTypes(pfod
, 2, filterspec
);
1109 ok_(file
,line
)(hr
== S_OK
, "SetFileTypes failed: Got 0x%08x\n", hr
);
1112 hr
= IFileOpenDialog_SetFolder(pfod
, psi_current
);
1113 ok_(file
,line
)(hr
== S_OK
, "SetFolder failed: Got 0x%08x\n", hr
);
1115 pfde
= IFileDialogEvents_Constructor();
1116 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1117 pfdeimpl
->set_filename
= set_filename
;
1118 pfdeimpl
->set_filename_tried
= FALSE
;
1119 hr
= IFileOpenDialog_Advise(pfod
, pfde
, &cookie
);
1120 ok_(file
,line
)(hr
== S_OK
, "Advise failed: Got 0x%08x\n", hr
);
1122 hr
= IFileOpenDialog_Show(pfod
, NULL
);
1123 ok_(file
,line
)(hr
== S_OK
|| (!exp_filename
&& hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
)),
1124 "Show failed: Got 0x%08x\n", hr
);
1127 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1128 ok_(file
,line
)(hr
== S_OK
, "GetResult failed: Got 0x%08x\n", hr
);
1130 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1131 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Result) failed: Got 0x%08x\n", hr
);
1132 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResult) Got %s\n", wine_dbgstr_w(filename
));
1133 CoTaskMemFree(filename
);
1134 IShellItem_Release(psi
);
1136 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1137 ok_(file
,line
)(hr
== S_OK
, "GetResults failed: Got 0x%08x\n", hr
);
1138 hr
= IShellItemArray_GetItemAt(psia
, 0, &psi
);
1139 ok_(file
,line
)(hr
== S_OK
, "GetItemAt failed: Got 0x%08x\n", hr
);
1141 hr
= IShellItem_GetDisplayName(psi
, SIGDN_PARENTRELATIVEPARSING
, &filename
);
1142 ok_(file
,line
)(hr
== S_OK
, "GetDisplayName(Results) failed: Got 0x%08x\n", hr
);
1143 ok_(file
,line
)(!lstrcmpW(filename
, exp_filename
), "(GetResults) Got %s\n", wine_dbgstr_w(filename
));
1144 CoTaskMemFree(filename
);
1146 IShellItem_Release(psi
);
1147 IShellItemArray_Release(psia
);
1151 hr
= IFileOpenDialog_GetResult(pfod
, &psi
);
1152 ok_(file
,line
)(hr
== E_UNEXPECTED
, "GetResult: Got 0x%08x\n", hr
);
1154 hr
= IFileOpenDialog_GetResults(pfod
, &psia
);
1155 ok_(file
,line
)(hr
== E_FAIL
, "GetResults: Got 0x%08x\n", hr
);
1158 hr
= IFileOpenDialog_GetFileName(pfod
, &filename
);
1159 ok_(file
,line
)(hr
== S_OK
, "GetFileName failed: Got 0x%08x\n", hr
);
1160 ok_(file
,line
)(!lstrcmpW(filename
, set_filename
), "(GetFileName) Got %s\n", wine_dbgstr_w(filename
));
1161 CoTaskMemFree(filename
);
1164 hr
= IFileOpenDialog_Unadvise(pfod
, cookie
);
1165 ok_(file
,line
)(hr
== S_OK
, "Unadvise failed: Got 0x%08x\n", hr
);
1167 ref
= IFileOpenDialog_Release(pfod
);
1168 ok_(file
,line
)(!ref
, "Got refcount %d, should have been released.\n", ref
);
1170 IFileDialogEvents_Release(pfde
);
1172 #define test_filename_opendlg(set_filename, psi, defext, filterspec, fs_count, exp_filename) \
1173 test_filename_opendlg_(set_filename, psi, defext, filterspec, fs_count, exp_filename, __FILE__, __LINE__)
1175 static void test_filename(void)
1177 IShellItem
*psi_current
;
1179 WCHAR buf
[MAX_PATH
];
1181 static const WCHAR filename_noextW
[] = {'w','i','n','e','t','e','s','t',0};
1182 static const WCHAR filename_dotextW
[] = {'w','i','n','e','t','e','s','t','.',0};
1183 static const WCHAR filename_dotanddefW
[] = {'w','i','n','e','t','e','s','t','.','.','w','t','e',0};
1184 static const WCHAR filename_defextW
[] = {'w','i','n','e','t','e','s','t','.','w','t','e',0};
1185 static const WCHAR filename_ext1W
[] = {'w','i','n','e','t','e','s','t','.','w','t','1',0};
1186 static const WCHAR filename_ext2W
[] = {'w','i','n','e','t','e','s','t','.','w','t','2',0};
1187 static const WCHAR filename_ext1anddefW
[] =
1188 {'w','i','n','e','t','e','s','t','.','w','t','1','.','w','t','e',0};
1189 static const WCHAR defextW
[] = {'w','t','e',0};
1190 static const WCHAR desc1
[] = {'d','e','s','c','r','i','p','t','i','o','n','1',0};
1191 static const WCHAR desc2
[] = {'d','e','s','c','r','i','p','t','i','o','n','2',0};
1192 static const WCHAR descdef
[] = {'d','e','f','a','u','l','t',' ','d','e','s','c',0};
1193 static const WCHAR ext1
[] = {'*','.','w','t','1',0};
1194 static const WCHAR ext2
[] = {'*','.','w','t','2',0};
1195 static const WCHAR extdef
[] = {'*','.','w','t','e',0};
1196 static const WCHAR complexext
[] = {'*','.','w','t','2',';','*','.','w','t','1',0};
1198 static const COMDLG_FILTERSPEC filterspec
[] = {
1199 { desc1
, ext1
}, { desc2
, ext2
}, { descdef
, extdef
}
1201 static const COMDLG_FILTERSPEC filterspec2
[] = {
1202 { desc1
, complexext
}
1206 test_filename_savedlg(filename_noextW
, NULL
, NULL
, 0, filename_noextW
);
1207 /* Default extension */
1208 test_filename_savedlg(filename_noextW
, defextW
, NULL
, 0, filename_defextW
);
1209 /* Default extension on filename ending with a . */
1210 test_filename_savedlg(filename_dotextW
, defextW
, NULL
, 0, filename_dotanddefW
);
1211 /* Default extension on filename with default extension */
1212 test_filename_savedlg(filename_defextW
, defextW
, NULL
, 0, filename_defextW
);
1213 /* Default extension on filename with another extension */
1214 test_filename_savedlg(filename_ext1W
, defextW
, NULL
, 0, filename_ext1anddefW
);
1215 /* Default extension, filterspec without default extension */
1216 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 2, filename_ext1W
);
1217 /* Default extension, filterspec with default extension */
1218 test_filename_savedlg(filename_noextW
, defextW
, filterspec
, 3, filename_ext1W
);
1219 /* Default extension, filterspec with "complex" extension */
1220 test_filename_savedlg(filename_noextW
, defextW
, filterspec2
, 1, filename_ext2W
);
1222 GetCurrentDirectoryW(MAX_PATH
, buf
);
1223 ok(!!pSHCreateItemFromParsingName
, "SHCreateItemFromParsingName is missing.\n");
1224 hr
= pSHCreateItemFromParsingName(buf
, NULL
, &IID_IShellItem
, (void**)&psi_current
);
1225 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1227 touch_file(filename_noextW
);
1228 touch_file(filename_defextW
);
1229 touch_file(filename_ext2W
);
1231 /* IFileOpenDialog, default extension */
1232 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_noextW
);
1233 /* IFileOpenDialog, default extension and filterspec */
1234 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, filterspec
, 2, filename_noextW
);
1236 DeleteFileW(filename_noextW
);
1237 /* IFileOpenDialog, default extension, noextW deleted */
1238 test_filename_opendlg(filename_noextW
, psi_current
, defextW
, NULL
, 0, filename_defextW
);
1239 if(0) /* Interactive */
1241 /* IFileOpenDialog, filterspec, no default extension, noextW deleted */
1242 test_filename_opendlg(filename_noextW
, psi_current
, NULL
, filterspec
, 2, NULL
);
1245 IShellItem_Release(psi_current
);
1246 DeleteFileW(filename_defextW
);
1247 DeleteFileW(filename_ext2W
);
1250 static const WCHAR label
[] = {'l','a','b','e','l',0};
1251 static const WCHAR label2
[] = {'t','e','s','t',0};
1252 static const WCHAR menuW
[] = {'m','e','n','u','_','i','t','e','m',0};
1253 static const WCHAR pushbutton1W
[] = {'p','u','s','h','b','u','t','t','o','n','_','i','t','e','m',0};
1254 static const WCHAR pushbutton2W
[] = {'p','u','s','h','b','u','t','t','o','n','2','_','i','t','e','m',0};
1255 static const WCHAR comboboxitem1W
[] = {'c','o','m','b','o','b','o','x','1','_','i','t','e','m',0};
1256 static const WCHAR comboboxitem2W
[] = {'c','o','m','b','o','b','o','x','2','_','i','t','e','m',0};
1257 static const WCHAR radiobutton1W
[] = {'r','a','d','i','o','b','u','t','t','o','n','1','_','i','t','e','m',0};
1258 static const WCHAR radiobutton2W
[] = {'r','a','d','i','o','b','u','t','t','o','n','2','_','i','t','e','m',0};
1259 static const WCHAR checkbutton1W
[] = {'c','h','e','c','k','b','u','t','t','o','n','1','_','i','t','e','m',0};
1260 static const WCHAR checkbutton2W
[] = {'c','h','e','c','k','b','u','t','t','o','n','2','_','i','t','e','m',0};
1261 static const WCHAR editbox1W
[] = {'e','d','i','t','b','o','x','W','1','_','i','t','e','m',0};
1262 static const WCHAR editbox2W
[] = {'e','d','i','t','b','o','x','W','2','_','i','t','e','m',0};
1263 static const WCHAR textW
[] = {'t','e','x','t','_','i','t','e','m',0};
1264 static const WCHAR text2W
[] = {'t','e','x','t','2','_','i','t','e','m',0};
1265 static const WCHAR separatorW
[] = {'s','e','p','a','r','a','t','o','r','_','i','t','e','m',0};
1266 static const WCHAR visualgroup1W
[] = {'v','i','s','u','a','l','g','r','o','u','p','1',0};
1267 static const WCHAR visualgroup2W
[] = {'v','i','s','u','a','l','g','r','o','u','p','2',0};
1269 static const WCHAR floatnotifysinkW
[] = {'F','l','o','a','t','N','o','t','i','f','y','S','i','n','k',0};
1270 static const WCHAR RadioButtonListW
[] = {'R','a','d','i','o','B','u','t','t','o','n','L','i','s','t',0};
1273 LPCWSTR
class, text
;
1276 static BOOL CALLBACK
find_window_callback(HWND hwnd
, LPARAM lparam
)
1278 struct fw_arg
*arg
= (struct fw_arg
*)lparam
;
1283 GetClassNameW(hwnd
, buf
, 1024);
1284 if(lstrcmpW(buf
, arg
->class))
1290 GetWindowTextW(hwnd
, buf
, 1024);
1291 if(lstrcmpW(buf
, arg
->text
))
1295 arg
->hwnd_res
= hwnd
;
1299 static HWND
find_window(HWND parent
, LPCWSTR
class, LPCWSTR text
)
1301 struct fw_arg arg
= {class, text
, NULL
};
1303 EnumChildWindows(parent
, find_window_callback
, (LPARAM
)&arg
);
1304 return arg
.hwnd_res
;
1307 static void test_customize_onfolderchange(IFileDialog
*pfd
)
1310 HWND dlg_hwnd
, item
, item_parent
;
1317 hr
= IFileDialog_QueryInterface(pfd
, &IID_IOleWindow
, (void**)&pow
);
1318 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1319 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
1320 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1321 ok(dlg_hwnd
!= NULL
, "Got NULL.\n");
1322 IOleWindow_Release(pow
);
1324 item
= find_window(dlg_hwnd
, NULL
, checkbutton2W
);
1325 ok(item
!= NULL
, "Failed to find item.\n");
1326 item_parent
= GetParent(item
);
1327 GetClassNameW(item_parent
, buf
, 1024);
1328 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1329 item
= find_window(dlg_hwnd
, NULL
, text2W
);
1330 ok(item
!= NULL
, "Failed to find item.\n");
1331 item_parent
= GetParent(item
);
1332 GetClassNameW(item_parent
, buf
, 1024);
1333 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1334 item
= find_window(dlg_hwnd
, NULL
, radiobutton1W
);
1335 todo_wine
ok(item
!= NULL
, "Failed to find item.\n");
1336 item_parent
= GetParent(item
);
1337 GetClassNameW(item_parent
, buf
, 1024);
1338 todo_wine
ok(!lstrcmpW(buf
, RadioButtonListW
), "Got %s\n", wine_dbgstr_w(buf
));
1339 item_parent
= GetParent(item_parent
);
1340 GetClassNameW(item_parent
, buf
, 1024);
1341 ok(!lstrcmpW(buf
, floatnotifysinkW
), "Got %s\n", wine_dbgstr_w(buf
));
1343 item
= find_window(dlg_hwnd
, NULL
, pushbutton1W
);
1344 ok(item
== NULL
, "Found item: %p\n", item
);
1345 item
= find_window(dlg_hwnd
, NULL
, pushbutton2W
);
1346 ok(item
== NULL
, "Found item: %p\n", item
);
1347 item
= find_window(dlg_hwnd
, NULL
, comboboxitem1W
);
1348 ok(item
== NULL
, "Found item: %p\n", item
);
1349 item
= find_window(dlg_hwnd
, NULL
, comboboxitem2W
);
1350 ok(item
== NULL
, "Found item: %p\n", item
);
1351 item
= find_window(dlg_hwnd
, NULL
, radiobutton2W
);
1352 ok(item
== NULL
, "Found item: %p\n", item
);
1353 item
= find_window(dlg_hwnd
, NULL
, checkbutton1W
);
1354 ok(item
== NULL
, "Found item: %p\n", item
);
1355 item
= find_window(dlg_hwnd
, NULL
, editbox1W
);
1356 ok(item
== NULL
, "Found item: %p\n", item
);
1357 item
= find_window(dlg_hwnd
, NULL
, editbox2W
);
1358 ok(item
== NULL
, "Found item: %p\n", item
);
1359 item
= find_window(dlg_hwnd
, NULL
, textW
);
1360 ok(item
== NULL
, "Found item: %p\n", item
);
1361 item
= find_window(dlg_hwnd
, NULL
, separatorW
);
1362 ok(item
== NULL
, "Found item: %p\n", item
);
1363 item
= find_window(dlg_hwnd
, NULL
, visualgroup1W
);
1364 ok(item
== NULL
, "Found item: %p\n", item
);
1365 item
= find_window(dlg_hwnd
, NULL
, visualgroup2W
);
1366 ok(item
== NULL
, "Found item: %p\n", item
);
1368 br
= PostMessageW(dlg_hwnd
, WM_COMMAND
, IDCANCEL
, 0);
1372 static void test_customize(void)
1375 IFileDialogCustomize
*pfdc
;
1376 IFileDialogEventsImpl
*pfdeimpl
;
1377 IFileDialogEvents
*pfde
;
1379 CDCONTROLSTATEF cdstate
;
1386 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1387 &IID_IFileDialog
, (void**)&pfod
);
1388 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1390 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1391 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1394 skip("Skipping IFileDialogCustomize tests.\n");
1395 IFileDialog_Release(pfod
);
1400 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1401 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1402 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton1W
);
1403 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1405 hr
= IFileDialog_QueryInterface(pfod
, &IID_IOleWindow
, (void**)&pow
);
1406 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1407 hr
= IOleWindow_GetWindow(pow
, &dlg_hwnd
);
1408 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1409 ok(dlg_hwnd
== NULL
, "NULL\n");
1410 IOleWindow_Release(pow
);
1412 cdstate
= 0xdeadbeef;
1413 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1414 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1415 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1417 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1418 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1420 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1421 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1423 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, i
);
1424 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1425 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
1426 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1428 cdstate
= 0xdeadbeef;
1429 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1430 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1431 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1433 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1434 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1435 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1436 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1438 cdstate
= 0xdeadbeef;
1439 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1440 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1441 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1442 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1443 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1444 cdstate
= 0xdeadbeef;
1445 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1446 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1447 todo_wine
ok(!cdstate
, "got 0x%08x.\n", cdstate
);
1448 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1449 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1450 cdstate
= 0xdeadbeef;
1451 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1452 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1453 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1455 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1456 todo_wine
ok(hr
== E_NOTIMPL
, "got 0x%08x (control: %d).\n", hr
, i
);
1458 hr
= IFileDialogCustomize_AddMenu(pfdc
, i
, menuW
);
1459 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1460 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1461 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1463 cdstate
= 0xdeadbeef;
1464 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1465 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1466 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1468 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1469 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1470 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1471 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1473 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1474 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1476 hr
= IFileDialogCustomize_AddPushButton(pfdc
, i
, pushbutton2W
);
1477 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1478 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, pushbutton2W
);
1479 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1481 cdstate
= 0xdeadbeef;
1482 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1483 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1484 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1486 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1487 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1489 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1490 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1492 hr
= IFileDialogCustomize_AddComboBox(pfdc
, i
);
1493 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1494 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1495 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1497 cdstate
= 0xdeadbeef;
1498 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1499 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1500 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1502 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1503 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1504 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1505 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1507 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1508 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1510 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, i
);
1511 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1512 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1513 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1515 cdstate
= 0xdeadbeef;
1516 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1517 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1518 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1520 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1521 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1522 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, radiobutton1W
);
1523 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1525 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, radiobutton2W
);
1526 todo_wine
ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1528 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, i
, label
, TRUE
);
1529 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1530 hr
= IFileDialogCustomize_AddCheckButton(pfdc
, ++i
, checkbutton1W
, TRUE
);
1531 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1533 cdstate
= 0xdeadbeef;
1534 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1535 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1536 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1538 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1539 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1541 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, checkbutton2W
);
1542 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1547 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1548 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1549 ok(checked
, "checkbox not checked.\n");
1551 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, FALSE
);
1552 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1554 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1555 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1556 ok(!checked
, "checkbox checked.\n");
1558 hr
= IFileDialogCustomize_SetCheckButtonState(pfdc
, i
, TRUE
);
1559 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1561 hr
= IFileDialogCustomize_GetCheckButtonState(pfdc
, i
, &checked
);
1562 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1563 ok(checked
, "checkbox not checked.\n");
1566 hr
= IFileDialogCustomize_AddEditBox(pfdc
, i
, label
);
1567 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1568 hr
= IFileDialogCustomize_AddEditBox(pfdc
, ++i
, editbox1W
);
1569 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1571 cdstate
= 0xdeadbeef;
1572 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1573 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1574 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1576 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1577 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1579 /* Does not affect the text in the editbox */
1580 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, editbox2W
);
1581 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1583 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1584 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1587 ok(!lstrcmpW(tmpstr
, editbox1W
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1588 CoTaskMemFree(tmpstr
);
1591 hr
= IFileDialogCustomize_SetEditBoxText(pfdc
, i
, label2
);
1592 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1594 hr
= IFileDialogCustomize_GetEditBoxText(pfdc
, i
, &tmpstr
);
1595 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1598 ok(!lstrcmpW(tmpstr
, label2
), "got %s.\n", wine_dbgstr_w(tmpstr
));
1599 CoTaskMemFree(tmpstr
);
1602 hr
= IFileDialogCustomize_AddSeparator(pfdc
, i
);
1603 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1604 hr
= IFileDialogCustomize_AddSeparator(pfdc
, ++i
);
1605 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1607 cdstate
= 0xdeadbeef;
1608 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1609 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1610 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1612 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1613 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1615 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, separatorW
);
1616 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1618 hr
= IFileDialogCustomize_AddText(pfdc
, i
, label
);
1619 ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1620 hr
= IFileDialogCustomize_AddText(pfdc
, ++i
, textW
);
1621 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1623 cdstate
= 0xdeadbeef;
1624 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1625 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1626 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1628 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1629 ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1631 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, text2W
);
1632 ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1634 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, i
, label
);
1635 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1636 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, visualgroup1W
);
1637 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1639 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1640 todo_wine
ok(hr
== E_NOINTERFACE
, "got 0x%08x.\n", hr
);
1642 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, visualgroup2W
);
1643 todo_wine
ok(hr
== S_OK
, "got 0x%08x (control: %d).\n", hr
, i
);
1645 cdstate
= 0xdeadbeef;
1646 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1647 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1648 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1650 hr
= IFileDialogCustomize_StartVisualGroup(pfdc
, ++i
, label
);
1651 todo_wine
ok(hr
== E_UNEXPECTED
, "got 0x%08x.\n", hr
);
1652 hr
= IFileDialogCustomize_EndVisualGroup(pfdc
);
1653 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1655 i
++; /* Nonexisting control */
1656 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, 0, label
);
1657 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1658 hr
= IFileDialogCustomize_SetControlLabel(pfdc
, i
, label2
);
1659 ok(hr
== E_INVALIDARG
, "got 0x%08x (control: %d).\n", hr
, i
);
1660 cdstate
= 0xdeadbeef;
1661 hr
= IFileDialogCustomize_GetControlState(pfdc
, i
, &cdstate
);
1662 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1663 ok(cdstate
== 0xdeadbeef, "got 0x%08x.\n", cdstate
);
1665 pfde
= IFileDialogEvents_Constructor();
1666 pfdeimpl
= impl_from_IFileDialogEvents(pfde
);
1667 pfdeimpl
->cfd_test1
= TRUE
;
1668 hr
= IFileDialog_Advise(pfod
, pfde
, &cookie
);
1669 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1671 hr
= IFileDialog_Show(pfod
, NULL
);
1672 ok(hr
== HRESULT_FROM_WIN32(ERROR_CANCELLED
), "Got 0x%08x\n", hr
);
1674 hr
= IFileDialog_Unadvise(pfod
, cookie
);
1675 ok(hr
== S_OK
, "Got 0x%08x\n", hr
);
1677 IFileDialogEvents_Release(pfde
);
1678 IFileDialogCustomize_Release(pfdc
);
1679 ref
= IFileDialog_Release(pfod
);
1680 ok(!ref
, "Refcount not zero (%d).\n", ref
);
1683 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1684 &IID_IFileDialog
, (void**)&pfod
);
1685 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1687 hr
= IFileDialog_QueryInterface(pfod
, &IID_IFileDialogCustomize
, (void**)&pfdc
);
1688 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1691 hr
= IFileDialogCustomize_AddMenu(pfdc
, ++i
, label
);
1692 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1698 for(j
= 0; j
< 10; j
++)
1700 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1701 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1704 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1705 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1707 cdstate
= 0xdeadbeef;
1708 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1709 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1710 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1711 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1712 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1713 cdstate
= 0xdeadbeef;
1714 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1715 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1716 todo_wine
ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1717 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1718 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1719 cdstate
= 0xdeadbeef;
1720 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1721 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1722 todo_wine
ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1724 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1725 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1727 for(j
= 0; j
< 10; j
++)
1729 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1730 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1733 hr
= IFileDialogCustomize_AddPushButton(pfdc
, ++i
, label
);
1734 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1735 hr
= IFileDialogCustomize_AddComboBox(pfdc
, ++i
);
1736 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1739 DWORD selected
= -1;
1742 for(j
= 0; j
< 10; j
++)
1744 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1745 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1748 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1749 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
1750 ok(selected
== -1, "got %d.\n", selected
);
1753 cdstate
= 0xdeadbeef;
1754 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1755 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1756 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1757 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1758 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1759 cdstate
= 0xdeadbeef;
1760 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1761 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1762 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1763 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1764 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1765 cdstate
= 0xdeadbeef;
1766 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1767 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1768 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1771 for(j
= 0; j
< 10; j
++)
1773 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1774 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1775 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1776 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1777 ok(selected
== j
, "got %d.\n", selected
);
1780 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1781 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1783 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1784 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1786 for(j
= 0; j
< 10; j
++)
1788 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1789 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1793 hr
= IFileDialogCustomize_AddRadioButtonList(pfdc
, ++i
);
1794 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1797 DWORD selected
= -1;
1800 for(j
= 0; j
< 10; j
++)
1802 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1803 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1806 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1807 ok(hr
== E_FAIL
, "got 0x%08x.\n", hr
);
1808 ok(selected
== -1, "got %d.\n", selected
);
1811 cdstate
= 0xdeadbeef;
1812 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1813 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1814 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1815 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1816 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1817 cdstate
= 0xdeadbeef;
1818 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1819 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1820 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1821 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1822 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1823 cdstate
= 0xdeadbeef;
1824 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1825 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1826 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1829 for(j
= 0; j
< 10; j
++)
1831 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1832 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1833 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1834 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1835 ok(selected
== j
, "got %d.\n", selected
);
1838 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, j
);
1839 ok(hr
== E_INVALIDARG
, "got 0x%08x.\n", hr
);
1841 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1842 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1844 for(j
= 0; j
< 10; j
++)
1846 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1847 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1850 hr
= IFileDialogCustomize_EnableOpenDropDown(pfdc
, ++i
);
1851 todo_wine
ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1854 DWORD selected
= -1;
1857 for(j
= 0; j
< 10; j
++)
1859 hr
= IFileDialogCustomize_AddControlItem(pfdc
, i
, j
, label
);
1860 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1863 hr
= IFileDialogCustomize_GetSelectedControlItem(pfdc
, i
, &selected
);
1864 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1865 ok(selected
== 0, "got %d.\n", selected
);
1867 cdstate
= 0xdeadbeef;
1868 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1869 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1870 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1871 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, 0);
1872 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1873 cdstate
= 0xdeadbeef;
1874 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1875 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1876 ok(cdstate
== 0, "got 0x%08x.\n", cdstate
);
1877 hr
= IFileDialogCustomize_SetControlItemState(pfdc
, i
, 0, CDCS_ENABLEDVISIBLE
);
1878 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1879 cdstate
= 0xdeadbeef;
1880 hr
= IFileDialogCustomize_GetControlItemState(pfdc
, i
, 0, &cdstate
);
1881 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1882 ok(cdstate
== CDCS_ENABLEDVISIBLE
, "got 0x%08x.\n", cdstate
);
1883 hr
= IFileDialogCustomize_SetSelectedControlItem(pfdc
, i
, 0);
1884 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1886 hr
= IFileDialogCustomize_RemoveAllControlItems(pfdc
, i
);
1887 ok(hr
== E_NOTIMPL
, "got 0x%08x.\n", hr
);
1889 for(j
= 0; j
< 10; j
++)
1891 hr
= IFileDialogCustomize_RemoveControlItem(pfdc
, i
, j
);
1892 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1896 IFileDialogCustomize_Release(pfdc
);
1897 ref
= IFileDialog_Release(pfod
);
1898 ok(!ref
, "Refcount not zero (%d).\n", ref
);
1901 static void test_persistent_state(void)
1906 hr
= CoCreateInstance(&CLSID_FileOpenDialog
, NULL
, CLSCTX_INPROC_SERVER
,
1907 &IID_IFileDialog
, (void**)&fd
);
1908 ok(hr
== S_OK
, "got 0x%08x.\n", hr
);
1912 /* crashes at least on Win8 */
1913 hr
= IFileDialog_SetClientGuid(fd
, NULL
);
1916 hr
= IFileDialog_SetClientGuid(fd
, &IID_IUnknown
);
1917 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1919 hr
= IFileDialog_SetClientGuid(fd
, &IID_NULL
);
1920 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1922 IFileDialog_Release(fd
);
1927 OleInitialize(NULL
);
1928 init_function_pointers();
1930 if(test_instantiation())
1936 test_persistent_state();
1939 skip("Skipping all Item Dialog tests.\n");