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>
28 static UINT CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
34 nmh = (LPNMHDR) lParam;
35 if( nmh->code == CDN_INITDONE)
37 PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
45 static void test_DialogCancel(void)
49 char szFileName[MAX_PATH] = "";
51 ZeroMemory(&ofn, sizeof(ofn));
53 ofn.lStructSize = sizeof(ofn);
55 ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
56 ofn.lpstrFile = szFileName;
57 ofn.nMaxFile = MAX_PATH;
58 ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
59 ofn.lpstrDefExt = "txt";
60 ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
63 ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
64 CDERR_INITIALIZATION, CommDlgExtendedError());
66 result = GetOpenFileNameA(&ofn);
67 ok(0 == result, "expected %d, got %d\n", 0, result);
68 ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
69 CommDlgExtendedError());
72 ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
73 CDERR_INITIALIZATION, CommDlgExtendedError());
75 SetLastError(0xdeadbeef);
76 result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
77 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
78 skip("GetOpenFileNameW is not implemented\n");
81 ok(0 == result, "expected %d, got %d\n", 0, result);
82 ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
83 CommDlgExtendedError());
87 ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
88 CDERR_INITIALIZATION, CommDlgExtendedError());
90 result = GetSaveFileNameA(&ofn);
91 ok(0 == result, "expected %d, got %d\n", 0, result);
92 ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
93 CommDlgExtendedError());
96 ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
97 CDERR_INITIALIZATION, CommDlgExtendedError());
99 SetLastError(0xdeadbeef);
100 result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
101 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
102 skip("GetSaveFileNameW is not implemented\n");
105 ok(0 == result, "expected %d, got %d\n", 0, result);
106 ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
107 CommDlgExtendedError());