Lei Zhang : comdlg32: Initialize CommDlgExtendedError() return value for file dialogs.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Apr 24 07:23:57 CDT 2007


Module: wine
Branch: master
Commit: 7aa1b2e419976a14495227bfd45b37cdae219207
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7aa1b2e419976a14495227bfd45b37cdae219207

Author: Lei Zhang <thestig at google.com>
Date:   Mon Apr 23 14:20:37 2007 -0700

comdlg32: Initialize CommDlgExtendedError() return value for file dialogs.

---

 dlls/comdlg32/filedlg.c         |    6 ++
 dlls/comdlg32/tests/Makefile.in |    3 +-
 dlls/comdlg32/tests/filedlg.c   |  104 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+), 1 deletions(-)

diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index e267e45..0b940ea 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -323,6 +323,9 @@ BOOL  WINAPI GetFileDialog95A(LPOPENFILENAMEA ofn,UINT iDlgType)
   LPWSTR filter = NULL;
   LPWSTR customfilter = NULL;
 
+  /* Initialize CommDlgExtendedError() */
+  COMDLG32_SetCommDlgExtendedError(0);
+
   /* Initialize FileOpenDlgInfos structure */
   ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
 
@@ -453,6 +456,9 @@ BOOL  WINAPI GetFileDialog95W(LPOPENFILENAMEW ofn,UINT iDlgType)
   FileOpenDlgInfos fodInfos;
   LPWSTR lpstrSavDir = NULL;
 
+  /* Initialize CommDlgExtendedError() */
+  COMDLG32_SetCommDlgExtendedError(0);
+
   /* Initialize FileOpenDlgInfos structure */
   ZeroMemory(&fodInfos, sizeof(FileOpenDlgInfos));
 
diff --git a/dlls/comdlg32/tests/Makefile.in b/dlls/comdlg32/tests/Makefile.in
index aa1ec87..c3bf0cb 100644
--- a/dlls/comdlg32/tests/Makefile.in
+++ b/dlls/comdlg32/tests/Makefile.in
@@ -3,9 +3,10 @@ TOPOBJDIR = ../../..
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 TESTDLL   = comdlg32.dll
-IMPORTS   = comdlg32 kernel32
+IMPORTS   = comdlg32 user32 kernel32
 
 CTESTS = \
+	filedlg.c \
 	printdlg.c
 
 @MAKE_TEST_RULES@
diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c
new file mode 100644
index 0000000..9ae0c40
--- /dev/null
+++ b/dlls/comdlg32/tests/filedlg.c
@@ -0,0 +1,104 @@
+/*
+ * Unit test suite for comdlg32 API functions: file dialogs
+ *
+ * Copyright 2007 Google (Lei Zhang)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#include <windows.h>
+#include <wine/test.h>
+
+
+/* ##### */
+
+static UINT CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    LPNMHDR nmh;
+
+    if( msg == WM_NOTIFY)
+    {
+        nmh = (LPNMHDR) lParam;
+        if( nmh->code == CDN_INITDONE)
+        {
+            PostMessage( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
+        }
+    }
+
+    return 0;
+}
+
+/* bug 6829 */
+static void test_DialogCancel(void)
+{
+    OPENFILENAMEA ofn;
+    BOOL result;
+    char szFileName[MAX_PATH] = "";
+
+    ZeroMemory(&ofn, sizeof(ofn));
+
+    ofn.lStructSize = sizeof(ofn);
+    ofn.hwndOwner = NULL;
+    ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0";
+    ofn.lpstrFile = szFileName;
+    ofn.nMaxFile = MAX_PATH;
+    ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ENABLEHOOK;
+    ofn.lpstrDefExt = "txt";
+    ofn.lpfnHook = (LPOFNHOOKPROC) OFNHookProc;
+
+    PrintDlgA(NULL);
+    ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
+       CDERR_INITIALIZATION, CommDlgExtendedError());
+
+    result = GetOpenFileNameA(&ofn);
+    ok(0 == result, "expected %d, got %d\n", 0, result);
+    ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
+       CommDlgExtendedError());
+
+    PrintDlgA(NULL);
+    ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
+              CDERR_INITIALIZATION, CommDlgExtendedError());
+
+    result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
+    ok(0 == result, "expected %d, got %d\n", 0, result);
+    ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
+       CommDlgExtendedError());
+
+    PrintDlgA(NULL);
+    ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
+              CDERR_INITIALIZATION, CommDlgExtendedError());
+
+    result = GetSaveFileNameA(&ofn);
+    ok(0 == result, "expected %d, got %d\n", 0, result);
+    ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
+       CommDlgExtendedError());
+
+    PrintDlgA(NULL);
+    ok(CDERR_INITIALIZATION == CommDlgExtendedError(), "expected %d, got %d\n",
+              CDERR_INITIALIZATION, CommDlgExtendedError());
+
+    result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
+    ok(0 == result, "expected %d, got %d\n", 0, result);
+    ok(0 == CommDlgExtendedError(), "expected %d, got %d\n", 0,
+       CommDlgExtendedError());
+}
+
+
+START_TEST(filedlg)
+{
+    test_DialogCancel();
+
+}




More information about the wine-cvs mailing list