[PATCH 3/3] Return the correct path length for CDM_GETFOLDERPATH
Paul Vriens
Paul.Vriens.Wine at gmail.com
Tue Sep 15 07:30:52 CDT 2009
---
dlls/comdlg32/filedlg.c | 2 +-
dlls/comdlg32/tests/filedlg.c | 62 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/dlls/comdlg32/filedlg.c b/dlls/comdlg32/filedlg.c
index 4986122..a28c457 100644
--- a/dlls/comdlg32/filedlg.c
+++ b/dlls/comdlg32/filedlg.c
@@ -910,7 +910,7 @@ static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM
WideCharToMultiByte(CP_ACP, 0, lpstrPath, -1,
(LPSTR)lParam, (int)wParam, NULL, NULL);
}
- retval = lstrlenW(lpstrPath);
+ retval = lstrlenW(lpstrPath) + 1;
break;
case CDM_GETFOLDERIDLIST:
diff --git a/dlls/comdlg32/tests/filedlg.c b/dlls/comdlg32/tests/filedlg.c
index be3cf8c..e376c3c 100644
--- a/dlls/comdlg32/tests/filedlg.c
+++ b/dlls/comdlg32/tests/filedlg.c
@@ -868,6 +868,67 @@ static void test_arrange(void)
}
}
+static CHAR WINDIR[MAX_PATH];
+
+static UINT_PTR CALLBACK path_hook_proc( 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);
+ }
+ else if ( nmh->code == CDN_FOLDERCHANGE)
+ {
+ char buf[1024];
+ int ret;
+
+ memset(buf, 0x66, sizeof(buf));
+ ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERPATH, sizeof(buf), (LPARAM)buf);
+ ok(!lstrcmpA(WINDIR, buf), "Expected '%s', got '%s'\n", WINDIR, buf);
+ ok(lstrlenA(WINDIR) + 1 == ret, "Expected %d, got %d\n", lstrlenA(WINDIR) + 1, ret);
+ }
+ }
+
+ return 0;
+}
+
+static void test_getfolderpath(void)
+{
+ OPENFILENAMEA ofn;
+ BOOL result;
+ char szFileName[MAX_PATH] = "";
+ char szInitialDir[MAX_PATH];
+
+ GetWindowsDirectory(szInitialDir, MAX_PATH);
+ lstrcpyA(WINDIR, szInitialDir);
+
+ 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 = path_hook_proc;
+ ofn.lpstrInitialDir = szInitialDir;
+
+ result = GetOpenFileNameA(&ofn);
+ ok(0 == result, "expected 0, got %d\n", result);
+ ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
+ CommDlgExtendedError());
+
+ result = GetSaveFileNameA(&ofn);
+ ok(0 == result, "expected 0, got %d\n", result);
+ ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
+ CommDlgExtendedError());
+}
+
START_TEST(filedlg)
{
test_DialogCancel();
@@ -876,4 +937,5 @@ START_TEST(filedlg)
test_arrange();
test_resize();
test_ok();
+ test_getfolderpath();
}
--
1.6.2.5
--------------050904040206070405090801--
More information about the wine-patches
mailing list