mcicda: Exclude unused headers.
[wine] / dlls / comdlg32 / tests / filedlg.c
1 /*
2  * Unit test suite for comdlg32 API functions: file dialogs
3  *
4  * Copyright 2007 Google (Lei Zhang)
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #include <windows.h>
23 #include <wine/test.h>
24
25
26 /* ##### */
27
28 static UINT CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
29 {
30     LPNMHDR nmh;
31
32     if( msg == WM_NOTIFY)
33     {
34         nmh = (LPNMHDR) lParam;
35         if( nmh->code == CDN_INITDONE)
36         {
37             PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
38         }
39     }
40
41     return 0;
42 }
43
44 /* bug 6829 */
45 static void test_DialogCancel(void)
46 {
47     OPENFILENAMEA ofn;
48     BOOL result;
49     char szFileName[MAX_PATH] = "";
50
51     ZeroMemory(&ofn, sizeof(ofn));
52
53     ofn.lStructSize = sizeof(ofn);
54     ofn.hwndOwner = NULL;
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;
61
62     PrintDlgA(NULL);
63     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
64        CDERR_INITIALIZATION, CommDlgExtendedError());
65
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());
70
71     PrintDlgA(NULL);
72     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
73               CDERR_INITIALIZATION, CommDlgExtendedError());
74
75     result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
76     ok(0 == result, "expected %d, got %d\n", 0, result);
77     ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
78        CommDlgExtendedError());
79
80     PrintDlgA(NULL);
81     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
82               CDERR_INITIALIZATION, CommDlgExtendedError());
83
84     result = GetSaveFileNameA(&ofn);
85     ok(0 == result, "expected %d, got %d\n", 0, result);
86     ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
87        CommDlgExtendedError());
88
89     PrintDlgA(NULL);
90     ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
91               CDERR_INITIALIZATION, CommDlgExtendedError());
92
93     result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
94     ok(0 == result, "expected %d, got %d\n", 0, result);
95     ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
96        CommDlgExtendedError());
97 }
98
99
100 START_TEST(filedlg)
101 {
102     test_DialogCancel();
103
104 }