2 * Unit test suite for comdlg32 API functions: file dialogs
4 * Copyright 2007 Google (Lei Zhang)
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
23 #include <wine/test.h>
31 static int resizesupported = TRUE;
33 static void toolbarcheck( HWND hDlg)
35 /* test toolbar properties */
42 for( ctrl = GetWindow( hDlg, GW_CHILD);
43 ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
44 GetClassName( ctrl, classname, 10);
46 if( !strcmp( classname, "Toolbar")) break;
48 ok( ctrl != NULL, "could not get the toolbar control\n");
49 ret = SendMessage( ctrl, TB_ADDSTRING, 0, (LPARAM)"winetestwinetest\0\0");
50 ok( ret == 0, "addstring returned %d (expected 0)\n", ret);
51 maxtextrows = SendMessage( ctrl, TB_GETTEXTROWS, 0, 0);
52 ok( maxtextrows == 0 || broken(maxtextrows == 1), /* Win2k and below */
53 "Get(Max)TextRows returned %d (expected 0)\n", maxtextrows);
57 static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
63 nmh = (LPNMHDR) lParam;
64 if( nmh->code == CDN_INITDONE)
66 PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
67 } else if (nmh->code == CDN_FOLDERCHANGE )
72 memset(buf, 0x66, sizeof(buf));
73 ret = SendMessage( GetParent(hDlg), CDM_GETFOLDERIDLIST, 5, (LPARAM)buf);
74 ok(ret > 0, "CMD_GETFOLDERIDLIST not implemented\n");
76 ok(buf[0] == 0x66 && buf[1] == 0x66, "CMD_GETFOLDERIDLIST: The buffer was touched on failure\n");
77 toolbarcheck( GetParent(hDlg));
85 static void test_DialogCancel(void)
89 char szFileName[MAX_PATH] = "";
90 char szInitialDir[MAX_PATH];
92 GetWindowsDirectory(szInitialDir, MAX_PATH);
94 ZeroMemory(&ofn, sizeof(ofn));
96 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
98 ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
99 ofn.lpstrFile = szFileName;
100 ofn.nMaxFile = MAX_PATH;
101 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
102 ofn.lpstrDefExt = "txt";
103 ofn.lpfnHook = OFNHookProc;
104 ofn.lpstrInitialDir = szInitialDir;
107 ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
108 "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
110 result = GetOpenFileNameA(&ofn);
111 ok(0 == result, "expected 0, got %d\n", result);
112 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
113 CommDlgExtendedError());
116 ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
117 "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
119 result = GetSaveFileNameA(&ofn);
120 ok(0 == result, "expected 0, got %d\n", result);
121 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
122 CommDlgExtendedError());
125 ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
126 "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
128 /* Before passing the ofn to Unicode functions, remove the ANSI strings */
129 ofn.lpstrFilter = NULL;
130 ofn.lpstrInitialDir = NULL;
131 ofn.lpstrDefExt = NULL;
134 ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
135 "expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
137 SetLastError(0xdeadbeef);
138 result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
139 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
140 win_skip("GetOpenFileNameW is not implemented\n");
143 ok(0 == result, "expected 0, got %d\n", result);
144 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
147 SetLastError(0xdeadbeef);
148 result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
149 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
150 win_skip("GetSaveFileNameW is not implemented\n");
153 ok(0 == result, "expected 0, got %d\n", result);
154 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
158 static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
160 if (msg == WM_NOTIFY)
162 if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
164 IShellBrowser *shell_browser = (IShellBrowser *)SendMessage(GetParent(dlg), WM_USER + 7 /* WM_GETISHELLBROWSER */, 0, 0);
165 IShellView *shell_view = NULL;
166 IShellView2 *shell_view2 = NULL;
167 SV2CVW2_PARAMS view_params;
168 FOLDERSETTINGS folder_settings;
170 RECT rect = {0, 0, 0, 0};
172 hr = IShellBrowser_QueryActiveShellView(shell_browser, &shell_view);
173 ok(SUCCEEDED(hr), "QueryActiveShellView returned %#x\n", hr);
174 if (FAILED(hr)) goto cleanup;
176 hr = IShellView_QueryInterface(shell_view, &IID_IShellView2, (void **)&shell_view2);
177 if (hr == E_NOINTERFACE)
179 win_skip("IShellView2 not supported\n");
182 ok(SUCCEEDED(hr), "QueryInterface returned %#x\n", hr);
183 if (FAILED(hr)) goto cleanup;
185 hr = IShellView2_DestroyViewWindow(shell_view2);
186 ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
188 folder_settings.ViewMode = FVM_LIST;
189 folder_settings.fFlags = 0;
191 view_params.cbSize = sizeof(view_params);
192 view_params.psvPrev = NULL;
193 view_params.pfs = &folder_settings;
194 view_params.psbOwner = shell_browser;
195 view_params.prcView = ▭
196 view_params.pvid = NULL;
197 view_params.hwndView = NULL;
199 hr = IShellView2_CreateViewWindow2(shell_view2, &view_params);
202 win_skip("CreateViewWindow2 is broken on Vista/W2K8\n");
205 ok(SUCCEEDED(hr), "CreateViewWindow2 returned %#x\n", hr);
206 if (FAILED(hr)) goto cleanup;
208 hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
209 ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
210 ok(folder_settings.ViewMode == FVM_LIST,
211 "view mode is %d, expected FVM_LIST\n",
212 folder_settings.ViewMode);
214 hr = IShellView2_DestroyViewWindow(shell_view2);
215 ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
217 /* XP and W2K3 need this. On W2K the call to DestroyWindow() fails and has
218 * no side effects. NT4 doesn't get here. (FIXME: Vista doesn't get here yet).
220 DestroyWindow(view_params.hwndView);
222 view_params.pvid = &VID_Details;
223 hr = IShellView2_CreateViewWindow2(shell_view2, &view_params);
224 ok(SUCCEEDED(hr), "CreateViewWindow2 returned %#x\n", hr);
225 if (FAILED(hr)) goto cleanup;
227 hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
228 ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
229 ok(folder_settings.ViewMode == FVM_DETAILS || broken(folder_settings.ViewMode == FVM_LIST), /* nt4 */
230 "view mode is %d, expected FVM_DETAILS\n",
231 folder_settings.ViewMode);
234 if (shell_view2) IShellView2_Release(shell_view2);
235 if (shell_view) IShellView_Release(shell_view);
236 PostMessage(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
242 static UINT_PTR WINAPI template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
244 if (msg == WM_INITDIALOG)
249 ok(p!=NULL, "Failed to get parent of template\n");
250 cb = GetDlgItem(p,0x470);
251 ok(cb!=NULL, "Failed to get filter combobox\n");
252 sel = SendMessage(cb, CB_GETCURSEL, 0, 0);
253 ok (sel != -1, "Failed to get selection from filter listbox\n");
255 if (msg == WM_NOTIFY)
257 if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
258 PostMessage(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
263 static void test_create_view_window2(void)
265 OPENFILENAMEA ofn = {0};
266 char filename[1024] = {0};
269 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
270 ofn.lpstrFile = filename;
272 ofn.lpfnHook = create_view_window2_hook;
273 ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
274 ret = GetOpenFileNameA(&ofn);
275 ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
276 ret = CommDlgExtendedError();
277 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
280 static void test_create_view_template(void)
282 OPENFILENAMEA ofn = {0};
283 char filename[1024] = {0};
286 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
287 ofn.lpstrFile = filename;
289 ofn.lpfnHook = template_hook;
290 ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE;
291 ofn.hInstance = GetModuleHandleA(NULL);
292 ofn.lpTemplateName = "template1";
293 ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
294 ret = GetOpenFileNameA(&ofn);
295 ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
296 ret = CommDlgExtendedError();
297 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
300 /* test cases for resizing of the file dialog */
301 static const struct {
303 int resize_folderchange;/* change in CDN_FOLDERCHANGE handler */
304 int resize_timer1; /* change in first WM_TIMER handler */
305 int resize_check; /* expected change (in second WM_TIMER handler) */
306 BOOL todo; /* mark that test todo_wine */
307 BOOL testcontrols; /* test resizing and moving of the controls */
308 } resize_testcases[] = {
309 { 0 , 10, 10, 20,FALSE,FALSE}, /* 0 */
310 { 0 ,-10,-10,-20,FALSE,FALSE},
311 { OFN_ENABLESIZING , 0, 0, 0,FALSE,FALSE},
312 { OFN_ENABLESIZING , 0,-10, 0,FALSE,FALSE},
313 { OFN_ENABLESIZING , 0, 10, 10,FALSE, TRUE},
314 { OFN_ENABLESIZING ,-10, 0, 10,FALSE,FALSE}, /* 5 */
315 { OFN_ENABLESIZING , 10, 0, 10,FALSE,FALSE},
316 { OFN_ENABLESIZING , 0, 10, 20,FALSE,FALSE},
321 static UINT_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
323 static RECT initrc, rc;
324 static int index, count;
325 static int gotSWP_bottom, gotShowWindow;
326 HWND parent = GetParent( dlg);
328 #define MAXNRCTRLS 30
329 static RECT ctrlrcs[MAXNRCTRLS];
330 static int ctrlids[MAXNRCTRLS];
331 static HWND ctrls[MAXNRCTRLS];
340 index = ((OPENFILENAME*)lParam)->lCustData;
342 gotSWP_bottom = gotShowWindow = 0;
344 style = GetWindowLong( parent, GWL_STYLE);
345 if( resize_testcases[index].flags & OFN_ENABLESIZING)
346 if( !(style & WS_SIZEBOX)) {
347 win_skip( "OFN_ENABLESIZING flag not supported.\n");
348 resizesupported = FALSE;
349 PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
351 ok( style & WS_SIZEBOX,
352 "testid %d: dialog should have a WS_SIZEBOX style.\n", index);
354 ok( !(style & WS_SIZEBOX),
355 "testid %d: dialog should not have a WS_SIZEBOX style.\n", index);
360 if(( (LPNMHDR)lParam)->code == CDN_FOLDERCHANGE){
361 GetWindowRect( parent, &initrc);
362 if( (resize = resize_testcases[index].resize_folderchange)){
363 MoveWindow( parent, initrc.left,initrc.top, initrc.right - initrc.left + resize,
364 initrc.bottom - initrc.top + resize, TRUE);
366 SetTimer( dlg, 0, 100, 0);
373 /* store the control rectangles */
374 if( resize_testcases[index].testcontrols) {
377 for( i = 0, ctrl = GetWindow( parent, GW_CHILD);
378 i < MAXNRCTRLS && ctrl;
379 i++, ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
380 ctrlids[i] = GetDlgCtrlID( ctrl);
381 GetWindowRect( ctrl, &ctrlrcs[i]);
382 MapWindowPoints( NULL, parent, (LPPOINT) &ctrlrcs[i], 2);
387 if( (resize = resize_testcases[index].resize_timer1)){
388 GetWindowRect( parent, &rc);
389 MoveWindow( parent, rc.left,rc.top, rc.right - rc.left + resize,
390 rc.bottom - rc.top + resize, TRUE);
392 } else if( count == 1){
393 resize = resize_testcases[index].resize_check;
394 GetWindowRect( parent, &rc);
395 if( resize_testcases[index].todo){
397 ok( resize == rc.right - rc.left - initrc.right + initrc.left,
398 "testid %d size-x change %d expected %d\n", index,
399 rc.right - rc.left - initrc.right + initrc.left, resize);
400 ok( resize == rc.bottom - rc.top - initrc.bottom + initrc.top,
401 "testid %d size-y change %d expected %d\n", index,
402 rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
405 ok( resize == rc.right - rc.left - initrc.right + initrc.left,
406 "testid %d size-x change %d expected %d\n", index,
407 rc.right - rc.left - initrc.right + initrc.left, resize);
408 ok( resize == rc.bottom - rc.top - initrc.bottom + initrc.top,
409 "testid %d size-y change %d expected %d\n", index,
410 rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
412 if( resize_testcases[index].testcontrols) {
415 for( i = 0; i < nrctrls; i++) {
416 GetWindowRect( ctrls[i], &rc);
417 MapWindowPoints( NULL, parent, (LPPOINT) &rc, 2);
420 /* test if RECT R1, moved and sized result in R2 */
421 #define TESTRECTS( R1, R2, Mx, My, Sx, Sy) \
422 ((R1).left + (Mx) ==(R2).left \
423 &&(R1).top + (My) ==(R2).top \
424 &&(R1).right + (Mx) + (Sx) == (R2).right \
425 &&(R1).bottom + (My) + (Sy) ==(R2).bottom)
427 /* sized horizontal and moved vertical */
430 ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0),
431 "control id %03x should have sized horizontally and moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
432 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
433 ctrlrcs[i].right, ctrlrcs[i].bottom,
434 rc.left, rc.top, rc.right, rc.bottom);
436 /* sized horizontal and vertical */
438 ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 10),
439 "control id %03x should have sized horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
440 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
441 ctrlrcs[i].right, ctrlrcs[i].bottom,
442 rc.left, rc.top, rc.right, rc.bottom);
444 /* moved horizontal and vertical */
447 ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0),
448 "control id %03x should have moved horizontally and vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
449 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
450 ctrlrcs[i].right, ctrlrcs[i].bottom,
451 rc.left, rc.top, rc.right, rc.bottom);
453 /* moved vertically */
457 ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0),
458 "control id %03x should have moved vertically, before %d,%d-%d,%d after %d,%d-%d,%d\n",
459 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
460 ctrlrcs[i].right, ctrlrcs[i].bottom,
461 rc.left, rc.top, rc.right, rc.bottom);
463 /* resized horizontal */
464 case cmb2: /* aka IDC_LOOKIN */
465 ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 0)||
466 TESTRECTS( ctrlrcs[i], rc, 0, 0, 0, 0), /* Vista and higher */
467 "control id %03x should have resized horizontally, before %d,%d-%d,%d after %d,%d-%d,%d\n",
468 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
469 ctrlrcs[i].right, ctrlrcs[i].bottom,
470 rc.left, rc.top, rc.right, rc.bottom);
472 /* non moving non sizing controls */
474 ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
475 "control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
476 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
477 ctrlrcs[i].right, ctrlrcs[i].bottom,
478 rc.left, rc.top, rc.right, rc.bottom);
480 /* todo_wine: non moving non sizing controls */
483 ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
484 "control id %03x was moved/resized, before %d,%d-%d,%d after %d,%d-%d,%d\n",
485 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
486 ctrlrcs[i].right, ctrlrcs[i].bottom,
487 rc.left, rc.top, rc.right, rc.bottom);
489 /* don't test: id is not unique */
496 trace("untested control id %03x before %d,%d-%d,%d after %d,%d-%d,%d\n",
497 ctrlids[i], ctrlrcs[i].left, ctrlrcs[i].top,
498 ctrlrcs[i].right, ctrlrcs[i].bottom,
499 rc.left, rc.top, rc.right, rc.bottom);
506 PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
511 case WM_WINDOWPOSCHANGING:
513 WINDOWPOS *pwp = (WINDOWPOS *)lParam;
514 if( !index && pwp->hwndInsertAfter == HWND_BOTTOM){
516 ok( gotShowWindow == 0, "The WM_WINDOWPOSCHANGING message came after a WM_SHOWWINDOW message\n");
524 ok( gotSWP_bottom == 1, "No WM_WINDOWPOSCHANGING message came before a WM_SHOWWINDOW message\n");
532 static void test_resize(void)
534 OPENFILENAME ofn = { OPENFILENAME_SIZE_VERSION_400 };
535 char filename[1024] = {0};
539 ofn.lpstrFile = filename;
541 ofn.lpfnHook = resize_template_hook;
542 ofn.hInstance = GetModuleHandle(NULL);
543 ofn.lpTemplateName = "template_sz";
544 for( i = 0; resize_testcases[i].flags != 0xffffffff; i++) {
546 ofn.Flags = resize_testcases[i].flags |
547 OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE | OFN_SHOWHELP ;
548 ret = GetOpenFileName(&ofn);
549 ok(!ret, "GetOpenFileName returned %#x\n", ret);
550 ret = CommDlgExtendedError();
551 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
555 /* test cases for control message IDOK */
556 /* Show case for bug #19079 */
558 int retval; /* return code of the message handler */
559 BOOL setmsgresult; /* set the result in the DWLP_MSGRESULT */
560 BOOL usemsgokstr; /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */
561 BOOL do_subclass; /* subclass the dialog hook procedure */
562 BOOL expclose; /* is the dialog expected to close ? */
563 BOOL actclose; /* has the dialog actually closed ? */
564 } ok_wndproc_testcase;
566 static ok_wndproc_testcase ok_testcases[] = {
567 { 0, FALSE, FALSE, FALSE, TRUE},
568 { 0, TRUE, FALSE, FALSE, TRUE},
569 { 0, FALSE, FALSE, TRUE, TRUE},
570 { 0, TRUE, FALSE, TRUE, TRUE},
571 { 1, FALSE, FALSE, FALSE, TRUE},
572 { 1, TRUE, FALSE, FALSE, FALSE},
573 { 1, FALSE, FALSE, TRUE, FALSE},
574 { 1, TRUE, FALSE, TRUE, FALSE},
575 /* FILEOKSTRING tests */
576 { 1, TRUE, TRUE, FALSE, FALSE},
577 { 1, FALSE, TRUE, TRUE, FALSE},
582 /* test_ok_wndproc can be used as hook procedure or a subclass
583 * window proc for the file dialog */
584 static UINT_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
586 HWND parent = GetParent( dlg);
587 static ok_wndproc_testcase *testcase = NULL;
588 static UINT msgFILEOKSTRING;
589 if (msg == WM_INITDIALOG)
591 testcase = (ok_wndproc_testcase*)((OPENFILENAME*)lParam)->lCustData;
592 testcase->actclose = TRUE;
593 msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRING);
595 if( msg == WM_NOTIFY) {
596 if(((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
597 SetTimer( dlg, 0, 100, 0);
598 PostMessage( parent, WM_COMMAND, IDOK, 0);
600 } else if(((LPNMHDR)lParam)->code == CDN_FILEOK) {
601 if( testcase->usemsgokstr)
603 if( testcase->setmsgresult)
604 SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
605 return testcase->retval;
608 if( msg == msgFILEOKSTRING) {
609 if( !testcase->usemsgokstr)
611 if( testcase->setmsgresult)
612 SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
613 return testcase->retval;
615 if( msg == WM_TIMER) {
616 /* the dialog did not close automatically */
617 testcase->actclose = FALSE;
619 PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
622 if( testcase && testcase->do_subclass)
623 return DefWindowProc( dlg, msg, wParam, lParam);
627 static UINT_PTR WINAPI ok_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
629 if (msg == WM_SETFONT)
630 SetWindowLongPtrA( dlg, GWLP_WNDPROC, (LONG_PTR) test_ok_wndproc);
634 static void test_ok(void)
636 OPENFILENAME ofn = { OPENFILENAME_SIZE_VERSION_400 };
637 char filename[1024] = {0};
638 char tmpfilename[ MAX_PATH];
639 char curdir[MAX_PATH];
644 cdret = GetCurrentDirectoryA(sizeof(curdir), curdir);
645 ok(cdret, "Failed to get current dir err %d\n", GetLastError());
646 if (!GetTempFileNameA(".", "txt", 0, tmpfilename)) {
647 skip("Failed to create a temporary file name\n");
650 ofn.lpstrFile = filename;
652 ofn.hInstance = GetModuleHandle(NULL);
653 ofn.lpTemplateName = "template1";
654 ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
655 for( i = 0; ok_testcases[i].retval != -1; i++) {
656 strcpy( filename, tmpfilename);
657 ofn.lCustData = (LPARAM)(ok_testcases + i);
658 ofn.lpfnHook = ok_testcases[i].do_subclass ? ok_template_hook : test_ok_wndproc;
659 ret = GetOpenFileNameA(&ofn);
660 ok( ok_testcases[i].expclose == ok_testcases[i].actclose,
661 "testid %d: Open File dialog should %shave closed.\n", i,
662 ok_testcases[i].expclose ? "" : "NOT ");
663 ok(ret == ok_testcases[i].expclose, "testid %d: GetOpenFileName returned %#x\n", i, ret);
664 ret = CommDlgExtendedError();
665 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
666 cdret = SetCurrentDirectoryA(curdir);
667 ok(cdret, "Failed to restore current dir err %d\n", GetLastError());
669 ret = DeleteFileA( tmpfilename);
670 ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError());
673 /* test arranging with a custom template */
675 int x, y; /* left, top coordinates */
676 int cx, cy; /* width and height */
679 int nrcontrols; /* 0: no controls, 1: just the stc32 control 2: with button */
684 } arrange_tests[] = {
685 /* do not change the first two cases: used to get the uncustomized sizes */
686 { 0, {0},{0},{0},0 },
687 { 0, {0},{0},{0}, OFN_SHOWHELP},
688 /* two tests with just a subdialog, no controls */
689 { 0, {0, 0, 316, 76},{0},{0},0 },
690 { 0, {0, 0, 100, 76},{0},{0}, OFN_SHOWHELP},
691 /* now with a control with id stc32 */
692 { 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0},0 }, /* bug #17748*/
693 { 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0}, OFN_SHOWHELP}, /* bug #17748*/
694 /* tests with size of the stc32 control higher or wider then the standard dialog */
695 { 1, {0, 0, 316, 170} ,{0, 0, 204, 170,},{0},0 },
696 { 1, {0, 0, 316, 165} ,{0, 0, 411, 165,},{0}, OFN_SHOWHELP },
697 /* move the stc32 control around */
698 { 1, {0, 0, 300, 100} ,{73, 17, 50, 50,},{0},0 },
700 { 2, {0, 0, 280, 100} ,{0, 0, 50, 50,},{300,20,30,30},0 },
701 /* enable resizing should make the dialog bigger */
702 { 0, {0},{0},{0}, OFN_SHOWHELP|OFN_ENABLESIZING},
707 static UINT_PTR WINAPI template_hook_arrange(HWND dlgChild, UINT msg, WPARAM wParam, LPARAM lParam)
709 static int index, fixhelp;
710 static posz posz0[2];
711 static RECT clrcParent, clrcChild, rcStc32;
712 static HWND hwndStc32;
715 dlgParent = GetParent( dlgChild);
716 if (msg == WM_INITDIALOG) {
717 index = ((OPENFILENAME*)lParam)->lCustData;
718 /* get the positions before rearrangement */
719 GetClientRect( dlgParent, &clrcParent);
720 GetClientRect( dlgChild, &clrcChild);
721 hwndStc32 = GetDlgItem( dlgChild, stc32);
722 if( hwndStc32) GetWindowRect( hwndStc32, &rcStc32);
724 if (msg == WM_NOTIFY && ((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
727 GetWindowRect( dlgParent, &wrcParent);
728 /* the fist two "tests" just save the dialogs position, with and without
731 posz0[0].x = wrcParent.left;
732 posz0[0].y = wrcParent.top;
733 posz0[0].cx = wrcParent.right - wrcParent.left;
734 posz0[0].cy = wrcParent.bottom - wrcParent.top;
735 } else if( index == 1) {
736 posz0[1].x = wrcParent.left;
737 posz0[1].y = wrcParent.top;
738 posz0[1].cx = wrcParent.right - wrcParent.left;
739 posz0[1].cy = wrcParent.bottom - wrcParent.top;
740 fixhelp = posz0[1].cy - posz0[0].cy;
744 int expectx, expecty;
747 withhelp = (arrange_tests[index].ofnflags & OFN_SHOWHELP) != 0;
748 GetWindowRect( dlgParent, &wrcParent);
750 /* case with no custom subitem with stc32:
751 * default to all custom controls below the standard */
752 expecty = posz0[withhelp].cy + clrcChild.bottom;
753 expectx = posz0[withhelp].cx;
755 /* special case: there is a control with id stc32 */
756 /* expected height */
757 expecty = posz0[withhelp].cy;
758 if( rcStc32.bottom - rcStc32.top + (withhelp ? 0 : fixhelp) > clrcParent.bottom) {
759 expecty += clrcChild.bottom - clrcParent.bottom;
760 if( !withhelp) expecty += fixhelp;
763 expecty += clrcChild.bottom - ( rcStc32.bottom - rcStc32.top) ;
765 expectx = posz0[withhelp].cx;
766 if( rcStc32.right - rcStc32.left > clrcParent.right) {
767 expectx += clrcChild.right - clrcParent.right;
770 expectx += clrcChild.right - ( rcStc32.right - rcStc32.left) ;
772 style = GetWindowLong( dlgParent, GWL_STYLE);
773 if( !(style & WS_SIZEBOX)) {
774 /* without the OFN_ENABLESIZING flag */
775 ok( wrcParent.bottom - wrcParent.top == expecty,
776 "Wrong height of dialog %d, expected %d\n",
777 wrcParent.bottom - wrcParent.top, expecty);
778 ok( wrcParent.right - wrcParent.left == expectx,
779 "Wrong width of dialog %d, expected %d\n",
780 wrcParent.right - wrcParent.left, expectx);
782 /* with the OFN_ENABLESIZING flag */
783 ok( wrcParent.bottom - wrcParent.top > expecty,
784 "Wrong height of dialog %d, expected more than %d\n",
785 wrcParent.bottom - wrcParent.top, expecty);
786 ok( wrcParent.right - wrcParent.left > expectx,
787 "Wrong width of dialog %d, expected more than %d\n",
788 wrcParent.right - wrcParent.left, expectx);
792 PostMessage( dlgParent, WM_COMMAND, IDCANCEL, 0);
797 static void test_arrange(void)
799 OPENFILENAMEA ofn = {0};
800 char filename[1024] = {0};
805 DLGTEMPLATE *template;
806 DLGITEMTEMPLATE *itemtemplateStc32, *itemtemplateBtn;
809 /* load subdialog template into memory */
810 hRes = FindResource( GetModuleHandle(NULL), "template_stc32", (LPSTR)RT_DIALOG);
811 hDlgTmpl = LoadResource( GetModuleHandle(NULL), hRes );
812 /* get pointers to the structures for the dialog and the controls */
813 pv = LockResource( hDlgTmpl );
814 template = (DLGTEMPLATE*)pv;
815 if( template->x != 11111) {
816 win_skip("could not find the dialog template\n");
819 /* skip dialog template, menu, class and title */
820 pv += sizeof(DLGTEMPLATE);
821 pv += 3 * sizeof(WORD);
826 /* align on 32 bit boundaries */
827 pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
828 itemtemplateStc32 = (DLGITEMTEMPLATE*)pv;
829 if( itemtemplateStc32->x != 22222) {
830 win_skip("could not find the first item template\n");
833 /* skip itemtemplate, class, title and creation data */
834 pv += sizeof(DLGITEMTEMPLATE);
835 pv += 4 * sizeof(WORD);
836 /* align on 32 bit boundaries */
837 pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
838 itemtemplateBtn = (DLGITEMTEMPLATE*)pv;
839 if( itemtemplateBtn->x != 12345) {
840 win_skip("could not find the second item template\n");
844 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
845 ofn.lpstrFile = filename;
847 ofn.lpfnHook = template_hook_arrange;
848 ofn.hInstance = hDlgTmpl;
849 ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
850 for( i = 0; arrange_tests[i].nrcontrols != -1; i++) {
852 ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATEHANDLE | OFN_HIDEREADONLY |
853 arrange_tests[i].ofnflags;
854 template->cdit = arrange_tests[i].nrcontrols;
855 template->x = arrange_tests[i].poszDlg.x;
856 template->y = arrange_tests[i].poszDlg.y;
857 template->cx = arrange_tests[i].poszDlg.cx;
858 template->cy = arrange_tests[i].poszDlg.cy;
859 itemtemplateStc32->x = arrange_tests[i].poszStc32.x;
860 itemtemplateStc32->y = arrange_tests[i].poszStc32.y;
861 itemtemplateStc32->cx = arrange_tests[i].poszStc32.cx;
862 itemtemplateStc32->cy = arrange_tests[i].poszStc32.cy;
863 itemtemplateBtn->x = arrange_tests[i].poszBtn.x;
864 itemtemplateBtn->y = arrange_tests[i].poszBtn.y;
865 itemtemplateBtn->cx = arrange_tests[i].poszBtn.cx;
866 itemtemplateBtn->cy = arrange_tests[i].poszBtn.cy;
867 ret = GetOpenFileNameA(&ofn);
868 ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
869 ret = CommDlgExtendedError();
870 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
874 static CHAR SYSDIR[MAX_PATH];
876 static UINT_PTR CALLBACK path_hook_proc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
880 if( msg == WM_NOTIFY)
882 nmh = (LPNMHDR) lParam;
883 if( nmh->code == CDN_INITDONE)
885 PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
887 else if ( nmh->code == CDN_FOLDERCHANGE)
892 memset(buf, 0x66, sizeof(buf));
893 ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERPATH, sizeof(buf), (LPARAM)buf);
894 ok(!lstrcmpiA(SYSDIR, buf), "Expected '%s', got '%s'\n", SYSDIR, buf);
895 ok(lstrlenA(SYSDIR) + 1 == ret, "Expected %d, got %d\n", lstrlenA(SYSDIR) + 1, ret);
902 static void test_getfolderpath(void)
906 char szFileName[MAX_PATH] = "";
907 char szInitialDir[MAX_PATH];
909 /* We need to pick a different directory as the other tests because of new
910 * Windows 7 behavior.
912 GetSystemDirectory(szInitialDir, MAX_PATH);
913 lstrcpyA(SYSDIR, szInitialDir);
915 ZeroMemory(&ofn, sizeof(ofn));
917 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
918 ofn.hwndOwner = NULL;
919 ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
920 ofn.lpstrFile = szFileName;
921 ofn.nMaxFile = MAX_PATH;
922 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
923 ofn.lpstrDefExt = "txt";
924 ofn.lpfnHook = path_hook_proc;
925 ofn.lpstrInitialDir = szInitialDir;
927 result = GetOpenFileNameA(&ofn);
928 ok(0 == result, "expected 0, got %d\n", result);
929 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
930 CommDlgExtendedError());
932 result = GetSaveFileNameA(&ofn);
933 ok(0 == result, "expected 0, got %d\n", result);
934 ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
935 CommDlgExtendedError());
938 static void test_resizable2(void)
940 OPENFILENAMEA ofn = {0};
941 char filename[1024] = "pls press Enter if sizable, Esc otherwise";
944 /* interactive because there is no hook function */
945 if( !winetest_interactive) {
946 skip( "some interactive resizable dialog tests (set WINETEST_INTERACTIVE=1)\n");
949 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
950 ofn.lpstrFile = filename;
953 ofn.hInstance = GetModuleHandleA(NULL);
954 ofn.lpTemplateName = "template1";
955 ofn.Flags = OFN_EXPLORER;
957 ret = GetOpenFileNameA(&ofn);
958 ok( ret == ISSIZABLE, "File Dialog should have been sizable\n");
959 ret = CommDlgExtendedError();
960 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
961 ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATE;
962 ret = GetOpenFileNameA(&ofn);
963 ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
964 ret = CommDlgExtendedError();
965 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
966 ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATEHANDLE;
967 ofn.hInstance = LoadResource( GetModuleHandle(NULL), FindResource( GetModuleHandle(NULL), "template1", (LPSTR)RT_DIALOG));
968 ofn.lpTemplateName = NULL;
969 ret = GetOpenFileNameA(&ofn);
970 ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
971 ret = CommDlgExtendedError();
972 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
973 ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
974 ret = GetOpenFileNameA(&ofn);
975 ok( ret != ISSIZABLE, "File Dialog should NOT have been sizable\n");
976 ret = CommDlgExtendedError();
977 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
981 static void test_mru(void)
983 ok_wndproc_testcase testcase = {0};
984 OPENFILENAME ofn = { OPENFILENAME_SIZE_VERSION_400 };
985 const char *test_dir_name = "C:\\mru_test";
986 const char *test_file_name = "test.txt";
987 const char *test_full_path = "C:\\mru_test\\test.txt";
988 char filename_buf[MAX_PATH];
991 ofn.lpstrFile = filename_buf;
992 ofn.nMaxFile = sizeof(filename_buf);
993 ofn.lpTemplateName = "template1";
994 ofn.hInstance = GetModuleHandle(NULL);
995 ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_NOCHANGEDIR;
996 ofn.lCustData = (LPARAM)&testcase;
997 ofn.lpfnHook = test_ok_wndproc;
999 SetLastError(0xdeadbeef);
1000 ret = CreateDirectoryA(test_dir_name, NULL);
1001 ok(ret == TRUE, "CreateDirectoryA should have succeeded: %d\n", GetLastError());
1003 /* "teach" comdlg32 about this directory */
1004 strcpy(filename_buf, test_full_path);
1005 SetLastError(0xdeadbeef);
1006 ret = GetOpenFileNameA(&ofn);
1007 ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
1008 ret = CommDlgExtendedError();
1009 ok(!ret, "CommDlgExtendedError returned %x\n", ret);
1010 ok(testcase.actclose, "Open File dialog should have closed.\n");
1011 ok(!strcmp(ofn.lpstrFile, test_full_path), "Expected to get %s, got %s\n", test_full_path, ofn.lpstrFile);
1013 /* get a filename without a full path. it should return the file in
1014 * test_dir_name, not in the CWD */
1015 strcpy(filename_buf, test_file_name);
1016 SetLastError(0xdeadbeef);
1017 ret = GetOpenFileNameA(&ofn);
1018 ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
1019 ret = CommDlgExtendedError();
1020 ok(!ret, "CommDlgExtendedError returned %x\n", ret);
1021 ok(testcase.actclose, "Open File dialog should have closed.\n");
1022 if(strcmp(ofn.lpstrFile, test_full_path) != 0)
1023 win_skip("Platform doesn't save MRU data\n");
1025 SetLastError(0xdeadbeef);
1026 ret = RemoveDirectoryA(test_dir_name);
1027 ok(ret == TRUE, "RemoveDirectoryA should have succeeded: %d\n", GetLastError());
1030 static UINT_PTR WINAPI test_extension_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
1032 HWND parent = GetParent( dlg);
1033 if( msg == WM_NOTIFY) {
1034 SetTimer( dlg, 0, 1000, 0);
1035 PostMessage( parent, WM_COMMAND, IDOK, 0);
1037 if( msg == WM_TIMER) {
1038 /* the dialog did not close automatically */
1040 PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
1045 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
1047 static void test_extension_helper(OPENFILENAME* ofn, const char *filter,
1048 const char *expected_filename)
1054 strcpy(ofn->lpstrFile, "deadbeef");
1055 ofn->lpstrFilter = filter;
1057 boolret = GetSaveFileNameA(ofn);
1058 ok(boolret, "%s: expected TRUE\n", filter);
1060 ret = CommDlgExtendedError();
1061 ok(!ret, "%s: CommDlgExtendedError returned %#x\n", filter, ret);
1063 filename_ptr = ofn->lpstrFile + ofn->nFileOffset;
1064 ok(strcmp(filename_ptr, expected_filename) == 0,
1065 "%s: Filename is %s, expected %s\n", filter, filename_ptr, expected_filename);
1068 static void test_extension(void)
1070 OPENFILENAME ofn = { OPENFILENAME_SIZE_VERSION_400 };
1071 char filename[1024] = {0};
1072 char curdir[MAX_PATH];
1076 const char *defext_concrete_filters[] = {
1077 "TestFilter (*.abc)\0*.abc\0",
1078 "TestFilter (*.abc;)\0*.abc;\0",
1079 "TestFilter (*.abc;*.def)\0*.abc;*.def\0",
1082 const char *defext_wildcard_filters[] = {
1083 "TestFilter (*.pt*)\0*.pt*\0",
1084 "TestFilter (*.pt*;*.abc)\0*.pt*;*.abc\0",
1085 "TestFilter (*.ab?)\0*.ab?\0",
1086 "TestFilter (*.*)\0*.*\0",
1087 "TestFilter (*sav)\0*sav\0",
1088 NULL /* is a test, not an endmark! */
1091 boolret = GetCurrentDirectoryA(sizeof(curdir), curdir);
1092 ok(boolret, "Failed to get current dir err %d\n", GetLastError());
1094 ofn.hwndOwner = NULL;
1095 ofn.lpstrFile = filename;
1096 ofn.nMaxFile = MAX_PATH;
1097 ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
1098 ofn.lpstrInitialDir = curdir;
1099 ofn.lpfnHook = test_extension_wndproc;
1100 ofn.nFileExtension = 0;
1102 ofn.lpstrDefExt = NULL;
1104 /* Without lpstrDefExt, append no extension */
1105 test_extension_helper(&ofn, "TestFilter (*.abc) lpstrDefExt=NULL\0*.abc\0", "deadbeef");
1106 test_extension_helper(&ofn, "TestFilter (*.ab?) lpstrDefExt=NULL\0*.ab?\0", "deadbeef");
1108 ofn.lpstrDefExt = "";
1110 /* If lpstrDefExt="" and the filter has a concrete extension, append it */
1111 test_extension_helper(&ofn, "TestFilter (*.abc) lpstrDefExt=\"\"\0*.abc\0", "deadbeef.abc");
1113 /* If lpstrDefExt="" and the filter has a wildcard extension, do nothing */
1114 test_extension_helper(&ofn, "TestFilter (*.ab?) lpstrDefExt=\"\"\0*.ab?\0", "deadbeef");
1116 ofn.lpstrDefExt = "xyz";
1118 /* Append concrete extensions from filters */
1119 for (i = 0; i < ARRAY_SIZE(defext_concrete_filters); i++) {
1120 test_extension_helper(&ofn, defext_concrete_filters[i], "deadbeef.abc");
1123 /* Append nothing from this filter */
1124 test_extension_helper(&ofn, "TestFilter (*.)\0*.\0", "deadbeef");
1126 /* Ignore wildcard extensions in filters */
1127 for (i = 0; i < ARRAY_SIZE(defext_wildcard_filters); i++) {
1128 test_extension_helper(&ofn, defext_wildcard_filters[i], "deadbeef.xyz");
1135 static BOOL WINAPI test_null_enum(HWND hwnd, LPARAM lParam)
1137 /* Find the textbox and send a filename so IDOK will work.
1138 If the file textbox is empty IDOK will be ignored */
1140 if(GetClassNameA(hwnd, className, sizeof(className)) > 0 && !strcmp("Edit",className))
1142 SetWindowText(hwnd, "testfile");
1143 return FALSE; /* break window enumeration */
1148 static UINT_PTR WINAPI test_null_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
1150 HWND parent = GetParent( dlg);
1151 if( msg == WM_NOTIFY) {
1152 SetTimer( dlg, 0, 100, 0);
1153 SetTimer( dlg, 1, 1000, 0);
1154 EnumChildWindows( parent, test_null_enum, 0);
1156 if( msg == WM_TIMER) {
1158 PostMessage( parent, WM_COMMAND, IDOK, 0);
1160 /* the dialog did not close automatically */
1162 PostMessage( parent, WM_COMMAND, IDCANCEL, 0);
1168 static void test_null_filename(void)
1170 OPENFILENAMEA ofnA = {0};
1171 OPENFILENAMEW ofnW = {0};
1172 WCHAR filterW[] = {'t','e','x','t','\0','*','.','t','x','t','\0',
1173 'A','l','l','\0','*','\0','\0'};
1176 ofnA.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
1177 ofnA.lpstrFile = NULL;
1179 ofnA.nFileOffset = 0xdead;
1180 ofnA.nFileExtension = 0xbeef;
1181 ofnA.lpfnHook = test_null_wndproc;
1182 ofnA.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
1183 ofnA.hInstance = GetModuleHandleA(NULL);
1184 ofnA.lpstrFilter = "text\0*.txt\0All\0*\0\0";
1185 ofnA.lpstrDefExt = NULL;
1186 ret = GetOpenFileNameA(&ofnA);
1187 todo_wine ok(ret, "GetOpenFileNameA returned %#x\n", ret);
1188 ret = CommDlgExtendedError();
1189 todo_wine ok(!ret, "CommDlgExtendedError returned %#x, should be 0\n", ret);
1191 todo_wine ok(ofnA.nFileOffset != 0xdead, "ofnA.nFileOffset is 0xdead\n");
1192 todo_wine ok(ofnA.nFileExtension != 0xbeef, "ofnA.nFileExtension is 0xbeef\n");
1194 ofnA.lpstrFile = NULL;
1195 ofnA.nMaxFile = 1024; /* bogus input - lpstrFile = NULL but fake 1024 bytes available */
1196 ofnA.nFileOffset = 0xdead;
1197 ofnA.nFileExtension = 0xbeef;
1198 ret = GetOpenFileNameA(&ofnA);
1199 ok(ret, "GetOpenFileNameA returned %#x\n", ret);
1200 ret = CommDlgExtendedError();
1201 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
1203 ok(ofnA.nFileOffset != 0xdead, "ofnA.nFileOffset is 0xdead\n");
1204 ok(ofnA.nFileExtension == 0, "ofnA.nFileExtension is 0x%x, should be 0\n", ofnA.nFileExtension);
1207 ofnW.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
1208 ofnW.lpstrFile = NULL;
1210 ofnW.nFileOffset = 0xdead;
1211 ofnW.nFileExtension = 0xbeef;
1212 ofnW.lpfnHook = test_null_wndproc;
1213 ofnW.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
1214 ofnW.hInstance = GetModuleHandleW(NULL);
1215 ofnW.lpstrFilter = filterW;
1216 ofnW.lpstrDefExt = NULL;
1217 ret = GetOpenFileNameW(&ofnW);
1218 todo_wine ok(ret, "GetOpenFileNameW returned %#x\n", ret);
1219 ret = CommDlgExtendedError();
1220 todo_wine ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
1222 todo_wine ok(ofnW.nFileOffset != 0xdead, "ofnW.nFileOffset is 0xdead\n");
1223 todo_wine ok(ofnW.nFileExtension != 0xbeef, "ofnW.nFileExtension is 0xbeef\n");
1225 ofnW.lpstrFile = NULL;
1226 ofnW.nMaxFile = 1024; /* bogus input - lpstrFile = NULL but fake 1024 bytes available */
1227 ofnW.nFileOffset = 0xdead;
1228 ofnW.nFileExtension = 0xbeef;
1229 ret = GetOpenFileNameW(&ofnW);
1230 ok(ret, "GetOpenFileNameA returned %#x\n", ret);
1231 ret = CommDlgExtendedError();
1232 ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
1234 ok(ofnW.nFileOffset != 0xdead, "ofnW.nFileOffset is 0xdead\n");
1235 ok(ofnW.nFileExtension == 0, "ofnW.nFileExtension is 0x%x, should be 0\n", ofnW.nFileExtension);
1240 test_DialogCancel();
1241 test_create_view_window2();
1242 test_create_view_template();
1246 test_getfolderpath();
1248 if( resizesupported) test_resizable2();
1250 test_null_filename();