2007-04-23 23:20:37 +02:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2008-10-14 09:45:41 +02:00
|
|
|
#include "shlguid.h"
|
|
|
|
#define COBJMACROS
|
|
|
|
#include "shobjidl.h"
|
2013-10-15 14:07:35 +02:00
|
|
|
#include "commdlg.h"
|
|
|
|
#include "cderr.h"
|
|
|
|
#include "dlgs.h"
|
2007-04-23 23:20:37 +02:00
|
|
|
|
|
|
|
/* ##### */
|
|
|
|
|
2013-10-04 23:32:11 +02:00
|
|
|
static BOOL resizesupported = TRUE;
|
2009-10-07 11:17:05 +02:00
|
|
|
|
2009-07-28 12:19:20 +02:00
|
|
|
static void toolbarcheck( HWND hDlg)
|
|
|
|
{
|
|
|
|
/* test toolbar properties */
|
|
|
|
/* bug #10532 */
|
|
|
|
int maxtextrows;
|
|
|
|
HWND ctrl;
|
|
|
|
DWORD ret;
|
|
|
|
char classname[20];
|
|
|
|
|
|
|
|
for( ctrl = GetWindow( hDlg, GW_CHILD);
|
|
|
|
ctrl ; ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
|
2013-10-15 14:07:35 +02:00
|
|
|
GetClassNameA( ctrl, classname, 10);
|
2009-07-28 12:19:20 +02:00
|
|
|
classname[7] = '\0';
|
|
|
|
if( !strcmp( classname, "Toolbar")) break;
|
|
|
|
}
|
|
|
|
ok( ctrl != NULL, "could not get the toolbar control\n");
|
2013-10-15 14:07:35 +02:00
|
|
|
ret = SendMessageA( ctrl, TB_ADDSTRINGA, 0, (LPARAM)"winetestwinetest\0\0");
|
2009-07-28 12:19:20 +02:00
|
|
|
ok( ret == 0, "addstring returned %d (expected 0)\n", ret);
|
2013-10-15 14:07:35 +02:00
|
|
|
maxtextrows = SendMessageA( ctrl, TB_GETTEXTROWS, 0, 0);
|
2009-08-03 20:48:22 +02:00
|
|
|
ok( maxtextrows == 0 || broken(maxtextrows == 1), /* Win2k and below */
|
|
|
|
"Get(Max)TextRows returned %d (expected 0)\n", maxtextrows);
|
2009-07-28 12:19:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-08 13:20:47 +01:00
|
|
|
static UINT_PTR CALLBACK OFNHookProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2007-04-23 23:20:37 +02:00
|
|
|
{
|
|
|
|
LPNMHDR nmh;
|
|
|
|
|
|
|
|
if( msg == WM_NOTIFY)
|
|
|
|
{
|
|
|
|
nmh = (LPNMHDR) lParam;
|
|
|
|
if( nmh->code == CDN_INITDONE)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
|
2008-06-19 15:31:35 +02:00
|
|
|
} else if (nmh->code == CDN_FOLDERCHANGE )
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(buf, 0x66, sizeof(buf));
|
2013-10-15 14:07:35 +02:00
|
|
|
ret = SendMessageA( GetParent(hDlg), CDM_GETFOLDERIDLIST, 5, (LPARAM)buf);
|
2008-06-19 15:31:35 +02:00
|
|
|
ok(ret > 0, "CMD_GETFOLDERIDLIST not implemented\n");
|
|
|
|
if (ret > 5)
|
|
|
|
ok(buf[0] == 0x66 && buf[1] == 0x66, "CMD_GETFOLDERIDLIST: The buffer was touched on failure\n");
|
2009-07-28 12:19:20 +02:00
|
|
|
toolbarcheck( GetParent(hDlg));
|
2007-04-23 23:20:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bug 6829 */
|
|
|
|
static void test_DialogCancel(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn;
|
|
|
|
BOOL result;
|
|
|
|
char szFileName[MAX_PATH] = "";
|
2008-06-19 15:31:35 +02:00
|
|
|
char szInitialDir[MAX_PATH];
|
|
|
|
|
2013-10-15 14:07:35 +02:00
|
|
|
GetWindowsDirectoryA(szInitialDir, MAX_PATH);
|
2007-04-23 23:20:37 +02:00
|
|
|
|
|
|
|
ZeroMemory(&ofn, sizeof(ofn));
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2007-04-23 23:20:37 +02:00
|
|
|
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";
|
2009-01-13 23:30:08 +01:00
|
|
|
ofn.lpfnHook = OFNHookProc;
|
2008-06-19 15:31:35 +02:00
|
|
|
ofn.lpstrInitialDir = szInitialDir;
|
2007-04-23 23:20:37 +02:00
|
|
|
|
|
|
|
PrintDlgA(NULL);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
|
|
|
|
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
|
2007-04-23 23:20:37 +02:00
|
|
|
|
|
|
|
result = GetOpenFileNameA(&ofn);
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
|
2007-04-23 23:20:37 +02:00
|
|
|
CommDlgExtendedError());
|
|
|
|
|
2008-06-20 23:03:20 +02:00
|
|
|
PrintDlgA(NULL);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
|
|
|
|
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
|
2008-06-20 23:03:20 +02:00
|
|
|
|
|
|
|
result = GetSaveFileNameA(&ofn);
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
|
2008-06-20 23:03:20 +02:00
|
|
|
CommDlgExtendedError());
|
|
|
|
|
|
|
|
PrintDlgA(NULL);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
|
|
|
|
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
|
2008-06-20 23:03:20 +02:00
|
|
|
|
|
|
|
/* Before passing the ofn to Unicode functions, remove the ANSI strings */
|
|
|
|
ofn.lpstrFilter = NULL;
|
|
|
|
ofn.lpstrInitialDir = NULL;
|
|
|
|
ofn.lpstrDefExt = NULL;
|
|
|
|
|
2007-04-23 23:20:37 +02:00
|
|
|
PrintDlgA(NULL);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(CDERR_INITIALIZATION == CommDlgExtendedError(),
|
|
|
|
"expected CDERR_INITIALIZATION, got %d\n", CommDlgExtendedError());
|
2007-04-23 23:20:37 +02:00
|
|
|
|
2007-06-07 11:47:58 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2007-04-23 23:20:37 +02:00
|
|
|
result = GetOpenFileNameW((LPOPENFILENAMEW) &ofn);
|
2007-06-07 11:47:58 +02:00
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
2009-02-26 09:45:25 +01:00
|
|
|
win_skip("GetOpenFileNameW is not implemented\n");
|
2007-06-07 11:47:58 +02:00
|
|
|
else
|
|
|
|
{
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2011-02-25 23:29:32 +01:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
|
2007-06-07 11:47:58 +02:00
|
|
|
}
|
2007-04-23 23:20:37 +02:00
|
|
|
|
2007-06-07 11:47:58 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2007-04-23 23:20:37 +02:00
|
|
|
result = GetSaveFileNameW((LPOPENFILENAMEW) &ofn);
|
2007-06-07 11:47:58 +02:00
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
2009-02-26 09:45:25 +01:00
|
|
|
win_skip("GetSaveFileNameW is not implemented\n");
|
2007-06-07 11:47:58 +02:00
|
|
|
else
|
|
|
|
{
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2011-02-25 23:29:32 +01:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n", CommDlgExtendedError());
|
2007-06-07 11:47:58 +02:00
|
|
|
}
|
2007-04-23 23:20:37 +02:00
|
|
|
}
|
|
|
|
|
2009-02-08 13:20:47 +01:00
|
|
|
static UINT_PTR CALLBACK create_view_window2_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2008-10-14 09:45:41 +02:00
|
|
|
{
|
|
|
|
if (msg == WM_NOTIFY)
|
|
|
|
{
|
|
|
|
if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
IShellBrowser *shell_browser = (IShellBrowser *)SendMessageA(GetParent(dlg), WM_USER + 7 /* WM_GETISHELLBROWSER */, 0, 0);
|
2008-10-14 09:45:41 +02:00
|
|
|
IShellView *shell_view = NULL;
|
|
|
|
IShellView2 *shell_view2 = NULL;
|
|
|
|
SV2CVW2_PARAMS view_params;
|
|
|
|
FOLDERSETTINGS folder_settings;
|
|
|
|
HRESULT hr;
|
|
|
|
RECT rect = {0, 0, 0, 0};
|
|
|
|
|
|
|
|
hr = IShellBrowser_QueryActiveShellView(shell_browser, &shell_view);
|
|
|
|
ok(SUCCEEDED(hr), "QueryActiveShellView returned %#x\n", hr);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IShellView_QueryInterface(shell_view, &IID_IShellView2, (void **)&shell_view2);
|
|
|
|
if (hr == E_NOINTERFACE)
|
|
|
|
{
|
2009-02-26 09:45:25 +01:00
|
|
|
win_skip("IShellView2 not supported\n");
|
2008-10-14 09:45:41 +02:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
ok(SUCCEEDED(hr), "QueryInterface returned %#x\n", hr);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IShellView2_DestroyViewWindow(shell_view2);
|
|
|
|
ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
|
|
|
|
|
|
|
|
folder_settings.ViewMode = FVM_LIST;
|
|
|
|
folder_settings.fFlags = 0;
|
|
|
|
|
|
|
|
view_params.cbSize = sizeof(view_params);
|
|
|
|
view_params.psvPrev = NULL;
|
|
|
|
view_params.pfs = &folder_settings;
|
|
|
|
view_params.psbOwner = shell_browser;
|
|
|
|
view_params.prcView = ▭
|
|
|
|
view_params.pvid = NULL;
|
|
|
|
view_params.hwndView = NULL;
|
|
|
|
|
|
|
|
hr = IShellView2_CreateViewWindow2(shell_view2, &view_params);
|
2009-09-16 14:27:43 +02:00
|
|
|
if (hr == E_FAIL)
|
|
|
|
{
|
|
|
|
win_skip("CreateViewWindow2 is broken on Vista/W2K8\n");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-10-14 09:45:41 +02:00
|
|
|
ok(SUCCEEDED(hr), "CreateViewWindow2 returned %#x\n", hr);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
|
|
|
|
ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
|
2009-08-03 20:29:48 +02:00
|
|
|
ok(folder_settings.ViewMode == FVM_LIST,
|
|
|
|
"view mode is %d, expected FVM_LIST\n",
|
|
|
|
folder_settings.ViewMode);
|
2008-10-14 09:45:41 +02:00
|
|
|
|
|
|
|
hr = IShellView2_DestroyViewWindow(shell_view2);
|
|
|
|
ok(SUCCEEDED(hr), "DestroyViewWindow returned %#x\n", hr);
|
|
|
|
|
2011-02-25 23:29:32 +01:00
|
|
|
/* XP and W2K3 need this. On W2K the call to DestroyWindow() fails and has
|
2008-11-20 20:48:12 +01:00
|
|
|
* no side effects. NT4 doesn't get here. (FIXME: Vista doesn't get here yet).
|
|
|
|
*/
|
|
|
|
DestroyWindow(view_params.hwndView);
|
|
|
|
|
2008-10-14 09:45:41 +02:00
|
|
|
view_params.pvid = &VID_Details;
|
|
|
|
hr = IShellView2_CreateViewWindow2(shell_view2, &view_params);
|
|
|
|
ok(SUCCEEDED(hr), "CreateViewWindow2 returned %#x\n", hr);
|
|
|
|
if (FAILED(hr)) goto cleanup;
|
|
|
|
|
|
|
|
hr = IShellView2_GetCurrentInfo(shell_view2, &folder_settings);
|
|
|
|
ok(SUCCEEDED(hr), "GetCurrentInfo returned %#x\n", hr);
|
2011-08-04 08:51:48 +02:00
|
|
|
ok(folder_settings.ViewMode == FVM_DETAILS || broken(folder_settings.ViewMode == FVM_LIST), /* nt4 */
|
|
|
|
"view mode is %d, expected FVM_DETAILS\n",
|
2009-08-03 20:29:48 +02:00
|
|
|
folder_settings.ViewMode);
|
2008-10-14 09:45:41 +02:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (shell_view2) IShellView2_Release(shell_view2);
|
|
|
|
if (shell_view) IShellView_Release(shell_view);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
|
2008-10-14 09:45:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-20 13:35:05 +01:00
|
|
|
static UINT_PTR WINAPI template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2008-10-21 20:10:59 +02:00
|
|
|
{
|
2008-10-21 20:11:23 +02:00
|
|
|
if (msg == WM_INITDIALOG)
|
|
|
|
{
|
|
|
|
HWND p,cb;
|
|
|
|
INT sel;
|
|
|
|
p = GetParent(dlg);
|
2008-10-24 11:24:38 +02:00
|
|
|
ok(p!=NULL, "Failed to get parent of template\n");
|
2008-10-21 20:11:23 +02:00
|
|
|
cb = GetDlgItem(p,0x470);
|
2008-10-24 11:24:38 +02:00
|
|
|
ok(cb!=NULL, "Failed to get filter combobox\n");
|
2013-10-15 14:07:35 +02:00
|
|
|
sel = SendMessageA(cb, CB_GETCURSEL, 0, 0);
|
2008-10-21 20:11:23 +02:00
|
|
|
ok (sel != -1, "Failed to get selection from filter listbox\n");
|
|
|
|
}
|
2008-10-21 20:10:59 +02:00
|
|
|
if (msg == WM_NOTIFY)
|
|
|
|
{
|
|
|
|
if (((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE)
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
|
2008-10-21 20:10:59 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-10-14 09:45:41 +02:00
|
|
|
static void test_create_view_window2(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn = {0};
|
|
|
|
char filename[1024] = {0};
|
|
|
|
DWORD ret;
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2008-10-14 09:45:41 +02:00
|
|
|
ofn.lpstrFile = filename;
|
2009-06-17 13:27:16 +02:00
|
|
|
ofn.nMaxFile = 1024;
|
2008-10-14 09:45:41 +02:00
|
|
|
ofn.lpfnHook = create_view_window2_hook;
|
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
}
|
2007-04-23 23:20:37 +02:00
|
|
|
|
2008-10-21 20:10:59 +02:00
|
|
|
static void test_create_view_template(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn = {0};
|
|
|
|
char filename[1024] = {0};
|
|
|
|
DWORD ret;
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2008-10-21 20:10:59 +02:00
|
|
|
ofn.lpstrFile = filename;
|
2009-06-17 13:27:16 +02:00
|
|
|
ofn.nMaxFile = 1024;
|
2012-11-20 13:35:05 +01:00
|
|
|
ofn.lpfnHook = template_hook;
|
2008-10-21 20:10:59 +02:00
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE;
|
2008-10-28 09:49:45 +01:00
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
2008-10-21 20:10:59 +02:00
|
|
|
ofn.lpTemplateName = "template1";
|
2008-10-21 20:11:23 +02:00
|
|
|
ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
|
2008-10-21 20:10:59 +02:00
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
}
|
|
|
|
|
2009-06-16 08:17:09 +02:00
|
|
|
/* test cases for resizing of the file dialog */
|
2010-10-01 13:41:42 +02:00
|
|
|
static const struct {
|
2009-06-16 08:17:09 +02:00
|
|
|
DWORD flags;
|
2009-07-12 14:36:10 +02:00
|
|
|
int resize_folderchange;/* change in CDN_FOLDERCHANGE handler */
|
|
|
|
int resize_timer1; /* change in first WM_TIMER handler */
|
|
|
|
int resize_check; /* expected change (in second WM_TIMER handler) */
|
|
|
|
BOOL todo; /* mark that test todo_wine */
|
|
|
|
BOOL testcontrols; /* test resizing and moving of the controls */
|
2009-06-16 08:17:09 +02:00
|
|
|
} resize_testcases[] = {
|
2009-07-12 14:36:10 +02:00
|
|
|
{ 0 , 10, 10, 20,FALSE,FALSE}, /* 0 */
|
|
|
|
{ 0 ,-10,-10,-20,FALSE,FALSE},
|
|
|
|
{ OFN_ENABLESIZING , 0, 0, 0,FALSE,FALSE},
|
|
|
|
{ OFN_ENABLESIZING , 0,-10, 0,FALSE,FALSE},
|
|
|
|
{ OFN_ENABLESIZING , 0, 10, 10,FALSE, TRUE},
|
|
|
|
{ OFN_ENABLESIZING ,-10, 0, 10,FALSE,FALSE}, /* 5 */
|
|
|
|
{ OFN_ENABLESIZING , 10, 0, 10,FALSE,FALSE},
|
|
|
|
{ OFN_ENABLESIZING , 0, 10, 20,FALSE,FALSE},
|
2009-06-16 08:17:09 +02:00
|
|
|
/* mark the end */
|
|
|
|
{ 0xffffffff }
|
|
|
|
};
|
|
|
|
|
2012-11-20 13:35:05 +01:00
|
|
|
static UINT_PTR WINAPI resize_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-06-16 08:17:09 +02:00
|
|
|
{
|
|
|
|
static RECT initrc, rc;
|
|
|
|
static int index, count;
|
2014-02-25 00:05:34 +01:00
|
|
|
static BOOL gotSWP_bottom, gotShowWindow;
|
2009-06-16 08:17:09 +02:00
|
|
|
HWND parent = GetParent( dlg);
|
|
|
|
int resize;
|
2009-07-07 08:11:55 +02:00
|
|
|
#define MAXNRCTRLS 30
|
|
|
|
static RECT ctrlrcs[MAXNRCTRLS];
|
|
|
|
static int ctrlids[MAXNRCTRLS];
|
|
|
|
static HWND ctrls[MAXNRCTRLS];
|
|
|
|
static int nrctrls;
|
|
|
|
|
2009-06-16 08:17:09 +02:00
|
|
|
switch( msg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
{
|
|
|
|
DWORD style;
|
|
|
|
|
2013-10-15 14:07:35 +02:00
|
|
|
index = ((OPENFILENAMEA*)lParam)->lCustData;
|
2009-06-16 08:17:09 +02:00
|
|
|
count = 0;
|
2014-02-25 00:05:34 +01:00
|
|
|
gotSWP_bottom = gotShowWindow = FALSE;
|
2009-06-16 08:17:09 +02:00
|
|
|
/* test style */
|
2013-10-15 14:07:35 +02:00
|
|
|
style = GetWindowLongA( parent, GWL_STYLE);
|
2009-06-16 08:17:09 +02:00
|
|
|
if( resize_testcases[index].flags & OFN_ENABLESIZING)
|
2009-06-17 08:18:04 +02:00
|
|
|
if( !(style & WS_SIZEBOX)) {
|
|
|
|
win_skip( "OFN_ENABLESIZING flag not supported.\n");
|
2009-10-07 11:17:05 +02:00
|
|
|
resizesupported = FALSE;
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDCANCEL, 0);
|
2009-06-17 08:18:04 +02:00
|
|
|
} else
|
|
|
|
ok( style & WS_SIZEBOX,
|
|
|
|
"testid %d: dialog should have a WS_SIZEBOX style.\n", index);
|
2009-06-16 08:17:09 +02:00
|
|
|
else
|
|
|
|
ok( !(style & WS_SIZEBOX),
|
|
|
|
"testid %d: dialog should not have a WS_SIZEBOX style.\n", index);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
2009-07-10 10:07:48 +02:00
|
|
|
if(( (LPNMHDR)lParam)->code == CDN_FOLDERCHANGE){
|
2009-06-16 08:17:09 +02:00
|
|
|
GetWindowRect( parent, &initrc);
|
2009-07-10 10:07:48 +02:00
|
|
|
if( (resize = resize_testcases[index].resize_folderchange)){
|
2009-06-16 08:17:09 +02:00
|
|
|
MoveWindow( parent, initrc.left,initrc.top, initrc.right - initrc.left + resize,
|
|
|
|
initrc.bottom - initrc.top + resize, TRUE);
|
|
|
|
}
|
|
|
|
SetTimer( dlg, 0, 100, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_TIMER:
|
|
|
|
{
|
|
|
|
if( count == 0){
|
2009-07-07 08:11:55 +02:00
|
|
|
/* store the control rectangles */
|
|
|
|
if( resize_testcases[index].testcontrols) {
|
|
|
|
HWND ctrl;
|
|
|
|
int i;
|
|
|
|
for( i = 0, ctrl = GetWindow( parent, GW_CHILD);
|
|
|
|
i < MAXNRCTRLS && ctrl;
|
|
|
|
i++, ctrl = GetWindow( ctrl, GW_HWNDNEXT)) {
|
|
|
|
ctrlids[i] = GetDlgCtrlID( ctrl);
|
|
|
|
GetWindowRect( ctrl, &ctrlrcs[i]);
|
|
|
|
MapWindowPoints( NULL, parent, (LPPOINT) &ctrlrcs[i], 2);
|
|
|
|
ctrls[i] = ctrl;
|
|
|
|
}
|
|
|
|
nrctrls = i;
|
|
|
|
}
|
2009-06-16 08:17:09 +02:00
|
|
|
if( (resize = resize_testcases[index].resize_timer1)){
|
|
|
|
GetWindowRect( parent, &rc);
|
|
|
|
MoveWindow( parent, rc.left,rc.top, rc.right - rc.left + resize,
|
|
|
|
rc.bottom - rc.top + resize, TRUE);
|
|
|
|
}
|
|
|
|
} else if( count == 1){
|
|
|
|
resize = resize_testcases[index].resize_check;
|
|
|
|
GetWindowRect( parent, &rc);
|
2016-02-11 19:32:42 +01:00
|
|
|
todo_wine_if( resize_testcases[index].todo){
|
2009-06-16 08:17:09 +02:00
|
|
|
ok( resize == rc.right - rc.left - initrc.right + initrc.left,
|
|
|
|
"testid %d size-x change %d expected %d\n", index,
|
|
|
|
rc.right - rc.left - initrc.right + initrc.left, resize);
|
|
|
|
ok( resize == rc.bottom - rc.top - initrc.bottom + initrc.top,
|
|
|
|
"testid %d size-y change %d expected %d\n", index,
|
|
|
|
rc.bottom - rc.top - initrc.bottom + initrc.top, resize);
|
|
|
|
}
|
2009-07-07 08:11:55 +02:00
|
|
|
if( resize_testcases[index].testcontrols) {
|
|
|
|
int i;
|
|
|
|
RECT rc;
|
|
|
|
for( i = 0; i < nrctrls; i++) {
|
|
|
|
GetWindowRect( ctrls[i], &rc);
|
|
|
|
MapWindowPoints( NULL, parent, (LPPOINT) &rc, 2);
|
|
|
|
switch( ctrlids[i]){
|
|
|
|
|
|
|
|
/* test if RECT R1, moved and sized result in R2 */
|
|
|
|
#define TESTRECTS( R1, R2, Mx, My, Sx, Sy) \
|
|
|
|
((R1).left + (Mx) ==(R2).left \
|
|
|
|
&&(R1).top + (My) ==(R2).top \
|
|
|
|
&&(R1).right + (Mx) + (Sx) == (R2).right \
|
|
|
|
&&(R1).bottom + (My) + (Sy) ==(R2).bottom)
|
|
|
|
|
|
|
|
/* sized horizontal and moved vertical */
|
|
|
|
case cmb1:
|
|
|
|
case edt1:
|
2011-02-25 23:29:32 +01:00
|
|
|
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 10, 0),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x should have sized horizontally and moved vertically, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* sized horizontal and vertical */
|
|
|
|
case lst2:
|
|
|
|
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 10),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x should have sized horizontally and vertically, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* moved horizontal and vertical */
|
|
|
|
case IDCANCEL:
|
|
|
|
case pshHelp:
|
2011-02-25 23:29:32 +01:00
|
|
|
ok( TESTRECTS( ctrlrcs[i], rc, 10, 10, 0, 0),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x should have moved horizontally and vertically, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* moved vertically */
|
|
|
|
case chx1:
|
|
|
|
case stc2:
|
|
|
|
case stc3:
|
|
|
|
ok( TESTRECTS( ctrlrcs[i], rc, 0, 10, 0, 0),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x should have moved vertically, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* resized horizontal */
|
|
|
|
case cmb2: /* aka IDC_LOOKIN */
|
|
|
|
ok( TESTRECTS( ctrlrcs[i], rc, 0, 0, 10, 0)||
|
|
|
|
TESTRECTS( ctrlrcs[i], rc, 0, 0, 0, 0), /* Vista and higher */
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x should have resized horizontally, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* non moving non sizing controls */
|
|
|
|
case stc4:
|
|
|
|
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x was moved/resized, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* todo_wine: non moving non sizing controls */
|
|
|
|
case lst1:
|
|
|
|
todo_wine
|
|
|
|
ok( TESTRECTS( rc, ctrlrcs[i], 0, 0, 0, 0),
|
2016-06-10 09:39:39 +02:00
|
|
|
"control id %03x was moved/resized, before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
break;
|
|
|
|
/* don't test: id is not unique */
|
|
|
|
case IDOK:
|
|
|
|
case stc1:
|
|
|
|
case 0:
|
|
|
|
case -1:
|
|
|
|
break;
|
|
|
|
default:
|
2016-06-10 09:39:39 +02:00
|
|
|
trace("untested control id %03x before %s after %s\n",
|
|
|
|
ctrlids[i], wine_dbgstr_rect( &ctrlrcs[i] ),
|
|
|
|
wine_dbgstr_rect( &rc ));
|
2009-07-07 08:11:55 +02:00
|
|
|
#undef TESTRECTS
|
|
|
|
#undef MAXNRCTRLS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-16 08:17:09 +02:00
|
|
|
KillTimer( dlg, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDCANCEL, 0);
|
2009-06-16 08:17:09 +02:00
|
|
|
}
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
break;
|
2009-07-02 13:32:28 +02:00
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
{
|
|
|
|
WINDOWPOS *pwp = (WINDOWPOS *)lParam;
|
|
|
|
if( !index && pwp->hwndInsertAfter == HWND_BOTTOM){
|
2014-02-25 00:05:34 +01:00
|
|
|
gotSWP_bottom = TRUE;
|
|
|
|
ok(!gotShowWindow, "The WM_WINDOWPOSCHANGING message came after a WM_SHOWWINDOW message\n");
|
2009-07-02 13:32:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_SHOWWINDOW:
|
|
|
|
{
|
|
|
|
if( !index){
|
2014-02-25 00:05:34 +01:00
|
|
|
gotShowWindow = TRUE;
|
|
|
|
ok(gotSWP_bottom, "No WM_WINDOWPOSCHANGING message came before a WM_SHOWWINDOW message\n");
|
2009-07-02 13:32:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2009-06-16 08:17:09 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_resize(void)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
OPENFILENAMEA ofn = { OPENFILENAME_SIZE_VERSION_400A };
|
2009-06-16 08:17:09 +02:00
|
|
|
char filename[1024] = {0};
|
|
|
|
DWORD ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
ofn.lpstrFile = filename;
|
2009-06-17 13:27:16 +02:00
|
|
|
ofn.nMaxFile = 1024;
|
2012-11-20 13:35:05 +01:00
|
|
|
ofn.lpfnHook = resize_template_hook;
|
2013-10-15 14:07:35 +02:00
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
2009-06-17 08:18:04 +02:00
|
|
|
ofn.lpTemplateName = "template_sz";
|
2009-06-16 08:17:09 +02:00
|
|
|
for( i = 0; resize_testcases[i].flags != 0xffffffff; i++) {
|
|
|
|
ofn.lCustData = i;
|
|
|
|
ofn.Flags = resize_testcases[i].flags |
|
2009-07-07 08:11:55 +02:00
|
|
|
OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE | OFN_SHOWHELP ;
|
2013-10-15 14:07:35 +02:00
|
|
|
ret = GetOpenFileNameA(&ofn);
|
2009-06-16 08:17:09 +02:00
|
|
|
ok(!ret, "GetOpenFileName returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-30 08:41:10 +02:00
|
|
|
/* test cases for control message IDOK */
|
|
|
|
/* Show case for bug #19079 */
|
2010-07-22 21:18:37 +02:00
|
|
|
typedef struct {
|
2009-06-30 08:41:10 +02:00
|
|
|
int retval; /* return code of the message handler */
|
|
|
|
BOOL setmsgresult; /* set the result in the DWLP_MSGRESULT */
|
|
|
|
BOOL usemsgokstr; /* use the FILEOKSTRING message instead of WM_NOTIFY:CDN_FILEOK */
|
|
|
|
BOOL do_subclass; /* subclass the dialog hook procedure */
|
|
|
|
BOOL expclose; /* is the dialog expected to close ? */
|
|
|
|
BOOL actclose; /* has the dialog actually closed ? */
|
2010-07-22 21:18:37 +02:00
|
|
|
} ok_wndproc_testcase;
|
|
|
|
|
|
|
|
static ok_wndproc_testcase ok_testcases[] = {
|
2009-06-30 08:41:10 +02:00
|
|
|
{ 0, FALSE, FALSE, FALSE, TRUE},
|
|
|
|
{ 0, TRUE, FALSE, FALSE, TRUE},
|
|
|
|
{ 0, FALSE, FALSE, TRUE, TRUE},
|
|
|
|
{ 0, TRUE, FALSE, TRUE, TRUE},
|
|
|
|
{ 1, FALSE, FALSE, FALSE, TRUE},
|
|
|
|
{ 1, TRUE, FALSE, FALSE, FALSE},
|
|
|
|
{ 1, FALSE, FALSE, TRUE, FALSE},
|
|
|
|
{ 1, TRUE, FALSE, TRUE, FALSE},
|
|
|
|
/* FILEOKSTRING tests */
|
|
|
|
{ 1, TRUE, TRUE, FALSE, FALSE},
|
|
|
|
{ 1, FALSE, TRUE, TRUE, FALSE},
|
|
|
|
/* mark the end */
|
|
|
|
{ -1 }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* test_ok_wndproc can be used as hook procedure or a subclass
|
|
|
|
* window proc for the file dialog */
|
2012-11-20 13:35:05 +01:00
|
|
|
static UINT_PTR WINAPI test_ok_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-06-30 08:41:10 +02:00
|
|
|
{
|
|
|
|
HWND parent = GetParent( dlg);
|
2010-07-22 21:18:37 +02:00
|
|
|
static ok_wndproc_testcase *testcase = NULL;
|
2009-06-30 08:41:10 +02:00
|
|
|
static UINT msgFILEOKSTRING;
|
|
|
|
if (msg == WM_INITDIALOG)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
testcase = (ok_wndproc_testcase*)((OPENFILENAMEA*)lParam)->lCustData;
|
2010-07-22 21:18:37 +02:00
|
|
|
testcase->actclose = TRUE;
|
2013-10-15 14:07:35 +02:00
|
|
|
msgFILEOKSTRING = RegisterWindowMessageA( FILEOKSTRINGA);
|
2009-06-30 08:41:10 +02:00
|
|
|
}
|
|
|
|
if( msg == WM_NOTIFY) {
|
2009-07-03 11:46:23 +02:00
|
|
|
if(((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
|
2009-06-30 08:41:10 +02:00
|
|
|
SetTimer( dlg, 0, 100, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDOK, 0);
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
|
|
|
} else if(((LPNMHDR)lParam)->code == CDN_FILEOK) {
|
2010-07-22 21:18:37 +02:00
|
|
|
if( testcase->usemsgokstr)
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
2010-07-22 21:18:37 +02:00
|
|
|
if( testcase->setmsgresult)
|
|
|
|
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
|
|
|
|
return testcase->retval;
|
2009-06-30 08:41:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if( msg == msgFILEOKSTRING) {
|
2010-07-22 21:18:37 +02:00
|
|
|
if( !testcase->usemsgokstr)
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
2010-07-22 21:18:37 +02:00
|
|
|
if( testcase->setmsgresult)
|
|
|
|
SetWindowLongPtrA( dlg, DWLP_MSGRESULT, testcase->retval);
|
|
|
|
return testcase->retval;
|
2009-06-30 08:41:10 +02:00
|
|
|
}
|
|
|
|
if( msg == WM_TIMER) {
|
|
|
|
/* the dialog did not close automatically */
|
2010-07-22 21:18:37 +02:00
|
|
|
testcase->actclose = FALSE;
|
2009-06-30 08:41:10 +02:00
|
|
|
KillTimer( dlg, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDCANCEL, 0);
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-07-22 21:18:37 +02:00
|
|
|
if( testcase && testcase->do_subclass)
|
2013-10-15 14:07:35 +02:00
|
|
|
return DefWindowProcA( dlg, msg, wParam, lParam);
|
2009-06-30 08:41:10 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-20 13:35:05 +01:00
|
|
|
static UINT_PTR WINAPI ok_template_hook(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-06-30 08:41:10 +02:00
|
|
|
{
|
|
|
|
if (msg == WM_SETFONT)
|
|
|
|
SetWindowLongPtrA( dlg, GWLP_WNDPROC, (LONG_PTR) test_ok_wndproc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_ok(void)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
OPENFILENAMEA ofn = { OPENFILENAME_SIZE_VERSION_400A };
|
2009-06-30 08:41:10 +02:00
|
|
|
char filename[1024] = {0};
|
|
|
|
char tmpfilename[ MAX_PATH];
|
2009-08-31 09:15:35 +02:00
|
|
|
char curdir[MAX_PATH];
|
2009-06-30 08:41:10 +02:00
|
|
|
int i;
|
|
|
|
DWORD ret;
|
2010-12-29 19:41:39 +01:00
|
|
|
BOOL cdret;
|
2009-06-30 08:41:10 +02:00
|
|
|
|
2010-12-29 19:41:39 +01:00
|
|
|
cdret = GetCurrentDirectoryA(sizeof(curdir), curdir);
|
|
|
|
ok(cdret, "Failed to get current dir err %d\n", GetLastError());
|
2009-07-10 10:07:48 +02:00
|
|
|
if (!GetTempFileNameA(".", "txt", 0, tmpfilename)) {
|
2009-06-30 08:41:10 +02:00
|
|
|
skip("Failed to create a temporary file name\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = 1024;
|
2013-10-15 14:07:35 +02:00
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
2009-06-30 08:41:10 +02:00
|
|
|
ofn.lpTemplateName = "template1";
|
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATE ;
|
|
|
|
for( i = 0; ok_testcases[i].retval != -1; i++) {
|
|
|
|
strcpy( filename, tmpfilename);
|
2010-07-22 21:18:37 +02:00
|
|
|
ofn.lCustData = (LPARAM)(ok_testcases + i);
|
2012-11-20 13:35:05 +01:00
|
|
|
ofn.lpfnHook = ok_testcases[i].do_subclass ? ok_template_hook : test_ok_wndproc;
|
2009-06-30 08:41:10 +02:00
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok( ok_testcases[i].expclose == ok_testcases[i].actclose,
|
2009-07-03 11:46:23 +02:00
|
|
|
"testid %d: Open File dialog should %shave closed.\n", i,
|
2009-06-30 08:41:10 +02:00
|
|
|
ok_testcases[i].expclose ? "" : "NOT ");
|
2009-07-03 11:46:23 +02:00
|
|
|
ok(ret == ok_testcases[i].expclose, "testid %d: GetOpenFileName returned %#x\n", i, ret);
|
2009-06-30 08:41:10 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
2010-12-29 19:41:39 +01:00
|
|
|
cdret = SetCurrentDirectoryA(curdir);
|
|
|
|
ok(cdret, "Failed to restore current dir err %d\n", GetLastError());
|
2009-06-30 08:41:10 +02:00
|
|
|
}
|
2009-07-07 08:11:55 +02:00
|
|
|
ret = DeleteFileA( tmpfilename);
|
|
|
|
ok( ret, "Failed to delete temporary file %s err %d\n", tmpfilename, GetLastError());
|
2009-06-30 08:41:10 +02:00
|
|
|
}
|
|
|
|
|
2009-08-06 07:32:08 +02:00
|
|
|
/* test arranging with a custom template */
|
|
|
|
typedef struct {
|
|
|
|
int x, y; /* left, top coordinates */
|
|
|
|
int cx, cy; /* width and height */
|
|
|
|
} posz;
|
|
|
|
static struct {
|
|
|
|
int nrcontrols; /* 0: no controls, 1: just the stc32 control 2: with button */
|
|
|
|
posz poszDlg;
|
|
|
|
posz poszStc32;
|
|
|
|
posz poszBtn;
|
|
|
|
DWORD ofnflags;
|
|
|
|
} arrange_tests[] = {
|
|
|
|
/* do not change the first two cases: used to get the uncustomized sizes */
|
|
|
|
{ 0, {0},{0},{0},0 },
|
|
|
|
{ 0, {0},{0},{0}, OFN_SHOWHELP},
|
|
|
|
/* two tests with just a subdialog, no controls */
|
|
|
|
{ 0, {0, 0, 316, 76},{0},{0},0 },
|
|
|
|
{ 0, {0, 0, 100, 76},{0},{0}, OFN_SHOWHELP},
|
|
|
|
/* now with a control with id stc32 */
|
|
|
|
{ 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0},0 }, /* bug #17748*/
|
|
|
|
{ 1, {0, 0, 316, 76} ,{0, 0, 204, 76,},{0}, OFN_SHOWHELP}, /* bug #17748*/
|
|
|
|
/* tests with size of the stc32 control higher or wider then the standard dialog */
|
|
|
|
{ 1, {0, 0, 316, 170} ,{0, 0, 204, 170,},{0},0 },
|
|
|
|
{ 1, {0, 0, 316, 165} ,{0, 0, 411, 165,},{0}, OFN_SHOWHELP },
|
|
|
|
/* move the stc32 control around */
|
|
|
|
{ 1, {0, 0, 300, 100} ,{73, 17, 50, 50,},{0},0 },
|
|
|
|
/* add control */
|
|
|
|
{ 2, {0, 0, 280, 100} ,{0, 0, 50, 50,},{300,20,30,30},0 },
|
|
|
|
/* enable resizing should make the dialog bigger */
|
|
|
|
{ 0, {0},{0},{0}, OFN_SHOWHELP|OFN_ENABLESIZING},
|
|
|
|
/* mark the end */
|
|
|
|
{ -1 }
|
|
|
|
};
|
|
|
|
|
2012-11-20 13:35:05 +01:00
|
|
|
static UINT_PTR WINAPI template_hook_arrange(HWND dlgChild, UINT msg, WPARAM wParam, LPARAM lParam)
|
2009-08-06 07:32:08 +02:00
|
|
|
{
|
|
|
|
static int index, fixhelp;
|
|
|
|
static posz posz0[2];
|
|
|
|
static RECT clrcParent, clrcChild, rcStc32;
|
|
|
|
static HWND hwndStc32;
|
|
|
|
HWND dlgParent;
|
|
|
|
|
|
|
|
dlgParent = GetParent( dlgChild);
|
|
|
|
if (msg == WM_INITDIALOG) {
|
2013-10-15 14:07:35 +02:00
|
|
|
index = ((OPENFILENAMEA*)lParam)->lCustData;
|
2009-08-06 07:32:08 +02:00
|
|
|
/* get the positions before rearrangement */
|
|
|
|
GetClientRect( dlgParent, &clrcParent);
|
|
|
|
GetClientRect( dlgChild, &clrcChild);
|
|
|
|
hwndStc32 = GetDlgItem( dlgChild, stc32);
|
|
|
|
if( hwndStc32) GetWindowRect( hwndStc32, &rcStc32);
|
|
|
|
}
|
|
|
|
if (msg == WM_NOTIFY && ((LPNMHDR)lParam)->code == CDN_FOLDERCHANGE) {
|
|
|
|
RECT wrcParent;
|
|
|
|
|
|
|
|
GetWindowRect( dlgParent, &wrcParent);
|
|
|
|
/* the fist two "tests" just save the dialogs position, with and without
|
|
|
|
* help button */
|
|
|
|
if( index == 0) {
|
|
|
|
posz0[0].x = wrcParent.left;
|
|
|
|
posz0[0].y = wrcParent.top;
|
|
|
|
posz0[0].cx = wrcParent.right - wrcParent.left;
|
|
|
|
posz0[0].cy = wrcParent.bottom - wrcParent.top;
|
|
|
|
} else if( index == 1) {
|
|
|
|
posz0[1].x = wrcParent.left;
|
|
|
|
posz0[1].y = wrcParent.top;
|
|
|
|
posz0[1].cx = wrcParent.right - wrcParent.left;
|
|
|
|
posz0[1].cy = wrcParent.bottom - wrcParent.top;
|
|
|
|
fixhelp = posz0[1].cy - posz0[0].cy;
|
|
|
|
} else {
|
|
|
|
/* the real tests */
|
|
|
|
int withhelp;
|
|
|
|
int expectx, expecty;
|
2009-08-10 11:11:23 +02:00
|
|
|
DWORD style;
|
2009-08-06 07:32:08 +02:00
|
|
|
|
|
|
|
withhelp = (arrange_tests[index].ofnflags & OFN_SHOWHELP) != 0;
|
|
|
|
GetWindowRect( dlgParent, &wrcParent);
|
|
|
|
if( !hwndStc32) {
|
|
|
|
/* case with no custom subitem with stc32:
|
|
|
|
* default to all custom controls below the standard */
|
|
|
|
expecty = posz0[withhelp].cy + clrcChild.bottom;
|
|
|
|
expectx = posz0[withhelp].cx;
|
|
|
|
} else {
|
|
|
|
/* special case: there is a control with id stc32 */
|
|
|
|
/* expected height */
|
|
|
|
expecty = posz0[withhelp].cy;
|
2011-01-16 19:44:12 +01:00
|
|
|
if( rcStc32.bottom - rcStc32.top + (withhelp ? 0 : fixhelp) > clrcParent.bottom) {
|
2009-08-06 07:32:08 +02:00
|
|
|
expecty += clrcChild.bottom - clrcParent.bottom;
|
|
|
|
if( !withhelp) expecty += fixhelp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
expecty += clrcChild.bottom - ( rcStc32.bottom - rcStc32.top) ;
|
|
|
|
/* expected width */
|
|
|
|
expectx = posz0[withhelp].cx;
|
|
|
|
if( rcStc32.right - rcStc32.left > clrcParent.right) {
|
|
|
|
expectx += clrcChild.right - clrcParent.right;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
expectx += clrcChild.right - ( rcStc32.right - rcStc32.left) ;
|
|
|
|
}
|
2013-10-15 14:07:35 +02:00
|
|
|
style = GetWindowLongA( dlgParent, GWL_STYLE);
|
2009-08-10 11:11:23 +02:00
|
|
|
if( !(style & WS_SIZEBOX)) {
|
|
|
|
/* without the OFN_ENABLESIZING flag */
|
2009-08-06 07:32:08 +02:00
|
|
|
ok( wrcParent.bottom - wrcParent.top == expecty,
|
|
|
|
"Wrong height of dialog %d, expected %d\n",
|
|
|
|
wrcParent.bottom - wrcParent.top, expecty);
|
|
|
|
ok( wrcParent.right - wrcParent.left == expectx,
|
|
|
|
"Wrong width of dialog %d, expected %d\n",
|
|
|
|
wrcParent.right - wrcParent.left, expectx);
|
2015-12-07 13:20:39 +01:00
|
|
|
} else {
|
2009-08-10 11:11:23 +02:00
|
|
|
/* with the OFN_ENABLESIZING flag */
|
2009-08-06 07:32:08 +02:00
|
|
|
ok( wrcParent.bottom - wrcParent.top > expecty,
|
|
|
|
"Wrong height of dialog %d, expected more than %d\n",
|
|
|
|
wrcParent.bottom - wrcParent.top, expecty);
|
|
|
|
ok( wrcParent.right - wrcParent.left > expectx,
|
|
|
|
"Wrong width of dialog %d, expected more than %d\n",
|
|
|
|
wrcParent.right - wrcParent.left, expectx);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( dlgParent, WM_COMMAND, IDCANCEL, 0);
|
2009-08-06 07:32:08 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_arrange(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn = {0};
|
|
|
|
char filename[1024] = {0};
|
|
|
|
DWORD ret;
|
|
|
|
HRSRC hRes;
|
|
|
|
HANDLE hDlgTmpl;
|
|
|
|
LPBYTE pv;
|
|
|
|
DLGTEMPLATE *template;
|
|
|
|
DLGITEMTEMPLATE *itemtemplateStc32, *itemtemplateBtn;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* load subdialog template into memory */
|
2013-10-15 14:07:35 +02:00
|
|
|
hRes = FindResourceA( GetModuleHandleA(NULL), "template_stc32", (LPSTR)RT_DIALOG);
|
|
|
|
hDlgTmpl = LoadResource( GetModuleHandleA(NULL), hRes );
|
2009-08-06 07:32:08 +02:00
|
|
|
/* get pointers to the structures for the dialog and the controls */
|
|
|
|
pv = LockResource( hDlgTmpl );
|
|
|
|
template = (DLGTEMPLATE*)pv;
|
|
|
|
if( template->x != 11111) {
|
|
|
|
win_skip("could not find the dialog template\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* skip dialog template, menu, class and title */
|
|
|
|
pv += sizeof(DLGTEMPLATE);
|
|
|
|
pv += 3 * sizeof(WORD);
|
|
|
|
/* skip font info */
|
|
|
|
while( *(WORD*)pv)
|
|
|
|
pv += sizeof(WORD);
|
|
|
|
pv += sizeof(WORD);
|
|
|
|
/* align on 32 bit boundaries */
|
|
|
|
pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
|
|
|
|
itemtemplateStc32 = (DLGITEMTEMPLATE*)pv;
|
|
|
|
if( itemtemplateStc32->x != 22222) {
|
|
|
|
win_skip("could not find the first item template\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* skip itemtemplate, class, title and creation data */
|
|
|
|
pv += sizeof(DLGITEMTEMPLATE);
|
|
|
|
pv += 4 * sizeof(WORD);
|
|
|
|
/* align on 32 bit boundaries */
|
|
|
|
pv = (LPBYTE)(((UINT_PTR)pv + 3 ) & ~3);
|
|
|
|
itemtemplateBtn = (DLGITEMTEMPLATE*)pv;
|
|
|
|
if( itemtemplateBtn->x != 12345) {
|
|
|
|
win_skip("could not find the second item template\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2009-08-06 07:32:08 +02:00
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = 1024;
|
2012-11-20 13:35:05 +01:00
|
|
|
ofn.lpfnHook = template_hook_arrange;
|
2009-08-06 07:32:08 +02:00
|
|
|
ofn.hInstance = hDlgTmpl;
|
|
|
|
ofn.lpstrFilter="text\0*.txt\0All\0*\0\0";
|
|
|
|
for( i = 0; arrange_tests[i].nrcontrols != -1; i++) {
|
|
|
|
ofn.lCustData = i;
|
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER| OFN_ENABLETEMPLATEHANDLE | OFN_HIDEREADONLY |
|
|
|
|
arrange_tests[i].ofnflags;
|
|
|
|
template->cdit = arrange_tests[i].nrcontrols;
|
|
|
|
template->x = arrange_tests[i].poszDlg.x;
|
|
|
|
template->y = arrange_tests[i].poszDlg.y;
|
|
|
|
template->cx = arrange_tests[i].poszDlg.cx;
|
|
|
|
template->cy = arrange_tests[i].poszDlg.cy;
|
|
|
|
itemtemplateStc32->x = arrange_tests[i].poszStc32.x;
|
|
|
|
itemtemplateStc32->y = arrange_tests[i].poszStc32.y;
|
|
|
|
itemtemplateStc32->cx = arrange_tests[i].poszStc32.cx;
|
|
|
|
itemtemplateStc32->cy = arrange_tests[i].poszStc32.cy;
|
|
|
|
itemtemplateBtn->x = arrange_tests[i].poszBtn.x;
|
|
|
|
itemtemplateBtn->y = arrange_tests[i].poszBtn.y;
|
|
|
|
itemtemplateBtn->cx = arrange_tests[i].poszBtn.cx;
|
|
|
|
itemtemplateBtn->cy = arrange_tests[i].poszBtn.cy;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-20 14:20:40 +01:00
|
|
|
static CHAR SYSDIR[MAX_PATH];
|
2009-09-16 11:52:04 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( GetParent(hDlg), WM_COMMAND, IDCANCEL, FALSE);
|
2009-09-16 11:52:04 +02:00
|
|
|
}
|
|
|
|
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);
|
2009-11-20 14:20:40 +01:00
|
|
|
ok(!lstrcmpiA(SYSDIR, buf), "Expected '%s', got '%s'\n", SYSDIR, buf);
|
|
|
|
ok(lstrlenA(SYSDIR) + 1 == ret, "Expected %d, got %d\n", lstrlenA(SYSDIR) + 1, ret);
|
2009-09-16 11:52:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_getfolderpath(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn;
|
|
|
|
BOOL result;
|
|
|
|
char szFileName[MAX_PATH] = "";
|
|
|
|
char szInitialDir[MAX_PATH];
|
|
|
|
|
2009-11-20 14:20:40 +01:00
|
|
|
/* We need to pick a different directory as the other tests because of new
|
|
|
|
* Windows 7 behavior.
|
|
|
|
*/
|
2013-10-15 14:07:35 +02:00
|
|
|
GetSystemDirectoryA(szInitialDir, MAX_PATH);
|
2009-11-20 14:20:40 +01:00
|
|
|
lstrcpyA(SYSDIR, szInitialDir);
|
2009-09-16 11:52:04 +02:00
|
|
|
|
|
|
|
ZeroMemory(&ofn, sizeof(ofn));
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2009-09-16 11:52:04 +02:00
|
|
|
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);
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2009-09-16 11:52:04 +02:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
|
|
|
|
CommDlgExtendedError());
|
|
|
|
|
|
|
|
result = GetSaveFileNameA(&ofn);
|
2013-10-22 22:21:52 +02:00
|
|
|
ok(FALSE == result, "expected FALSE, got %d\n", result);
|
2009-09-16 11:52:04 +02:00
|
|
|
ok(0 == CommDlgExtendedError(), "expected 0, got %d\n",
|
|
|
|
CommDlgExtendedError());
|
|
|
|
}
|
|
|
|
|
2009-10-07 11:17:05 +02:00
|
|
|
static void test_resizable2(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofn = {0};
|
|
|
|
char filename[1024] = "pls press Enter if sizable, Esc otherwise";
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
/* interactive because there is no hook function */
|
|
|
|
if( !winetest_interactive) {
|
|
|
|
skip( "some interactive resizable dialog tests (set WINETEST_INTERACTIVE=1)\n");
|
|
|
|
return;
|
|
|
|
}
|
2012-09-21 14:22:47 +02:00
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2009-10-07 11:17:05 +02:00
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = 1024;
|
|
|
|
ofn.lpfnHook = NULL;
|
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
|
|
|
ofn.lpTemplateName = "template1";
|
|
|
|
ofn.Flags = OFN_EXPLORER;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
2018-03-16 13:54:52 +01:00
|
|
|
ok( ret == TRUE, "File Dialog should have been sizable\n");
|
2009-10-07 11:17:05 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATE;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
2018-03-16 13:54:52 +01:00
|
|
|
ok( !ret, "File Dialog should NOT have been sizable\n");
|
2009-10-07 11:17:05 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLETEMPLATEHANDLE;
|
2013-10-15 14:07:35 +02:00
|
|
|
ofn.hInstance = LoadResource( GetModuleHandleA(NULL), FindResourceA( GetModuleHandleA(NULL), "template1", (LPSTR)RT_DIALOG));
|
2009-10-07 11:17:05 +02:00
|
|
|
ofn.lpTemplateName = NULL;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
2018-03-16 13:54:52 +01:00
|
|
|
ok( !ret, "File Dialog should NOT have been sizable\n");
|
2009-10-07 11:17:05 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
2018-03-16 13:54:52 +01:00
|
|
|
ok( !ret, "File Dialog should NOT have been sizable\n");
|
2009-10-07 11:17:05 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
}
|
|
|
|
|
2010-07-23 20:13:04 +02:00
|
|
|
static void test_mru(void)
|
|
|
|
{
|
|
|
|
ok_wndproc_testcase testcase = {0};
|
2013-10-15 14:07:35 +02:00
|
|
|
OPENFILENAMEA ofn = { OPENFILENAME_SIZE_VERSION_400A };
|
2010-07-28 16:23:00 +02:00
|
|
|
const char *test_dir_name = "C:\\mru_test";
|
|
|
|
const char *test_file_name = "test.txt";
|
|
|
|
const char *test_full_path = "C:\\mru_test\\test.txt";
|
|
|
|
char filename_buf[MAX_PATH];
|
2010-07-23 20:13:04 +02:00
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
ofn.lpstrFile = filename_buf;
|
|
|
|
ofn.nMaxFile = sizeof(filename_buf);
|
2010-07-28 16:23:00 +02:00
|
|
|
ofn.lpTemplateName = "template1";
|
2013-10-15 14:07:35 +02:00
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
2010-07-23 20:13:04 +02:00
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_NOCHANGEDIR;
|
|
|
|
ofn.lCustData = (LPARAM)&testcase;
|
2012-11-20 13:35:05 +01:00
|
|
|
ofn.lpfnHook = test_ok_wndproc;
|
2010-07-23 20:13:04 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2010-07-28 16:23:00 +02:00
|
|
|
ret = CreateDirectoryA(test_dir_name, NULL);
|
2010-07-23 20:13:04 +02:00
|
|
|
ok(ret == TRUE, "CreateDirectoryA should have succeeded: %d\n", GetLastError());
|
|
|
|
|
|
|
|
/* "teach" comdlg32 about this directory */
|
2010-07-28 16:23:00 +02:00
|
|
|
strcpy(filename_buf, test_full_path);
|
2010-07-23 20:13:04 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2010-07-28 16:23:00 +02:00
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
|
2010-07-23 20:13:04 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %x\n", ret);
|
2010-07-28 16:23:00 +02:00
|
|
|
ok(testcase.actclose, "Open File dialog should have closed.\n");
|
|
|
|
ok(!strcmp(ofn.lpstrFile, test_full_path), "Expected to get %s, got %s\n", test_full_path, ofn.lpstrFile);
|
2010-07-23 20:13:04 +02:00
|
|
|
|
|
|
|
/* get a filename without a full path. it should return the file in
|
|
|
|
* test_dir_name, not in the CWD */
|
2010-07-28 16:23:00 +02:00
|
|
|
strcpy(filename_buf, test_file_name);
|
2010-07-23 20:13:04 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2010-07-28 16:23:00 +02:00
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(ret, "GetOpenFileNameA should have succeeded: %d\n", GetLastError());
|
2010-07-23 20:13:04 +02:00
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %x\n", ret);
|
2010-07-28 16:23:00 +02:00
|
|
|
ok(testcase.actclose, "Open File dialog should have closed.\n");
|
|
|
|
if(strcmp(ofn.lpstrFile, test_full_path) != 0)
|
2010-07-23 20:13:04 +02:00
|
|
|
win_skip("Platform doesn't save MRU data\n");
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2010-07-28 16:23:00 +02:00
|
|
|
ret = RemoveDirectoryA(test_dir_name);
|
2010-07-23 20:13:04 +02:00
|
|
|
ok(ret == TRUE, "RemoveDirectoryA should have succeeded: %d\n", GetLastError());
|
|
|
|
}
|
|
|
|
|
2010-11-01 16:57:07 +01:00
|
|
|
static UINT_PTR WINAPI test_extension_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HWND parent = GetParent( dlg);
|
|
|
|
if( msg == WM_NOTIFY) {
|
2011-08-04 08:51:48 +02:00
|
|
|
SetTimer( dlg, 0, 1000, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDOK, 0);
|
2010-11-01 16:57:07 +01:00
|
|
|
}
|
|
|
|
if( msg == WM_TIMER) {
|
|
|
|
/* the dialog did not close automatically */
|
|
|
|
KillTimer( dlg, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDCANCEL, 0);
|
2010-11-01 16:57:07 +01:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-10-15 14:07:35 +02:00
|
|
|
static void test_extension_helper(OPENFILENAMEA* ofn, const char *filter,
|
2012-01-20 22:52:18 +01:00
|
|
|
const char *expected_filename)
|
|
|
|
{
|
|
|
|
char *filename_ptr;
|
|
|
|
DWORD ret;
|
|
|
|
BOOL boolret;
|
|
|
|
|
|
|
|
strcpy(ofn->lpstrFile, "deadbeef");
|
|
|
|
ofn->lpstrFilter = filter;
|
|
|
|
|
|
|
|
boolret = GetSaveFileNameA(ofn);
|
|
|
|
ok(boolret, "%s: expected TRUE\n", filter);
|
|
|
|
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "%s: CommDlgExtendedError returned %#x\n", filter, ret);
|
|
|
|
|
|
|
|
filename_ptr = ofn->lpstrFile + ofn->nFileOffset;
|
|
|
|
ok(strcmp(filename_ptr, expected_filename) == 0,
|
|
|
|
"%s: Filename is %s, expected %s\n", filter, filename_ptr, expected_filename);
|
|
|
|
}
|
|
|
|
|
2010-11-01 16:57:07 +01:00
|
|
|
static void test_extension(void)
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
OPENFILENAMEA ofn = { OPENFILENAME_SIZE_VERSION_400A };
|
2010-11-01 16:57:07 +01:00
|
|
|
char filename[1024] = {0};
|
|
|
|
char curdir[MAX_PATH];
|
2011-07-21 11:11:20 +02:00
|
|
|
unsigned int i;
|
2011-01-29 09:15:34 +01:00
|
|
|
BOOL boolret;
|
2010-11-01 16:57:07 +01:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
const char *defext_concrete_filters[] = {
|
|
|
|
"TestFilter (*.abc)\0*.abc\0",
|
|
|
|
"TestFilter (*.abc;)\0*.abc;\0",
|
|
|
|
"TestFilter (*.abc;*.def)\0*.abc;*.def\0",
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *defext_wildcard_filters[] = {
|
|
|
|
"TestFilter (*.pt*)\0*.pt*\0",
|
|
|
|
"TestFilter (*.pt*;*.abc)\0*.pt*;*.abc\0",
|
|
|
|
"TestFilter (*.ab?)\0*.ab?\0",
|
|
|
|
"TestFilter (*.*)\0*.*\0",
|
2012-01-24 22:34:43 +01:00
|
|
|
"TestFilter (*sav)\0*sav\0",
|
2012-01-20 22:52:18 +01:00
|
|
|
NULL /* is a test, not an endmark! */
|
|
|
|
};
|
|
|
|
|
2011-01-29 09:15:34 +01:00
|
|
|
boolret = GetCurrentDirectoryA(sizeof(curdir), curdir);
|
|
|
|
ok(boolret, "Failed to get current dir err %d\n", GetLastError());
|
2010-11-01 16:57:07 +01:00
|
|
|
|
|
|
|
ofn.hwndOwner = NULL;
|
|
|
|
ofn.lpstrFile = filename;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLEHOOK;
|
|
|
|
ofn.lpstrInitialDir = curdir;
|
|
|
|
ofn.lpfnHook = test_extension_wndproc;
|
|
|
|
ofn.nFileExtension = 0;
|
2011-01-29 09:15:34 +01:00
|
|
|
|
2012-01-20 22:52:18 +01:00
|
|
|
ofn.lpstrDefExt = NULL;
|
|
|
|
|
|
|
|
/* Without lpstrDefExt, append no extension */
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.abc) lpstrDefExt=NULL\0*.abc\0", "deadbeef");
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.ab?) lpstrDefExt=NULL\0*.ab?\0", "deadbeef");
|
|
|
|
|
|
|
|
ofn.lpstrDefExt = "";
|
|
|
|
|
|
|
|
/* If lpstrDefExt="" and the filter has a concrete extension, append it */
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.abc) lpstrDefExt=\"\"\0*.abc\0", "deadbeef.abc");
|
|
|
|
|
|
|
|
/* If lpstrDefExt="" and the filter has a wildcard extension, do nothing */
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.ab?) lpstrDefExt=\"\"\0*.ab?\0", "deadbeef");
|
|
|
|
|
|
|
|
ofn.lpstrDefExt = "xyz";
|
|
|
|
|
|
|
|
/* Append concrete extensions from filters */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(defext_concrete_filters); i++) {
|
|
|
|
test_extension_helper(&ofn, defext_concrete_filters[i], "deadbeef.abc");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append nothing from this filter */
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.)\0*.\0", "deadbeef");
|
|
|
|
|
|
|
|
/* Ignore wildcard extensions in filters */
|
|
|
|
for (i = 0; i < ARRAY_SIZE(defext_wildcard_filters); i++) {
|
|
|
|
test_extension_helper(&ofn, defext_wildcard_filters[i], "deadbeef.xyz");
|
2011-01-29 09:15:34 +01:00
|
|
|
}
|
2015-06-03 00:14:08 +02:00
|
|
|
|
|
|
|
/* Append valid extensions consisting of multiple parts */
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.abc.def)\0*.abc.def\0", "deadbeef.abc.def");
|
|
|
|
test_extension_helper(&ofn, "TestFilter (.abc.def)\0.abc.def\0", "deadbeef.abc.def");
|
|
|
|
test_extension_helper(&ofn, "TestFilter (*.*.def)\0*.*.def\0", "deadbeef.xyz");
|
2010-11-01 16:57:07 +01:00
|
|
|
}
|
|
|
|
|
2012-06-15 05:51:34 +02:00
|
|
|
static BOOL WINAPI test_null_enum(HWND hwnd, LPARAM lParam)
|
|
|
|
{
|
|
|
|
/* Find the textbox and send a filename so IDOK will work.
|
|
|
|
If the file textbox is empty IDOK will be ignored */
|
|
|
|
CHAR className[20];
|
|
|
|
if(GetClassNameA(hwnd, className, sizeof(className)) > 0 && !strcmp("Edit",className))
|
|
|
|
{
|
2013-10-15 14:07:35 +02:00
|
|
|
SetWindowTextA(hwnd, "testfile");
|
2012-06-15 05:51:34 +02:00
|
|
|
return FALSE; /* break window enumeration */
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT_PTR WINAPI test_null_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HWND parent = GetParent( dlg);
|
|
|
|
if( msg == WM_NOTIFY) {
|
|
|
|
SetTimer( dlg, 0, 100, 0);
|
|
|
|
SetTimer( dlg, 1, 1000, 0);
|
|
|
|
EnumChildWindows( parent, test_null_enum, 0);
|
|
|
|
}
|
|
|
|
if( msg == WM_TIMER) {
|
|
|
|
if(!wParam)
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDOK, 0);
|
2012-06-15 05:51:34 +02:00
|
|
|
else {
|
|
|
|
/* the dialog did not close automatically */
|
|
|
|
KillTimer( dlg, 0);
|
2013-10-15 14:07:35 +02:00
|
|
|
PostMessageA( parent, WM_COMMAND, IDCANCEL, 0);
|
2012-06-15 05:51:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_null_filename(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofnA = {0};
|
|
|
|
OPENFILENAMEW ofnW = {0};
|
|
|
|
WCHAR filterW[] = {'t','e','x','t','\0','*','.','t','x','t','\0',
|
|
|
|
'A','l','l','\0','*','\0','\0'};
|
|
|
|
DWORD ret;
|
|
|
|
|
2012-09-21 14:22:47 +02:00
|
|
|
ofnA.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
2012-06-15 05:51:34 +02:00
|
|
|
ofnA.lpstrFile = NULL;
|
|
|
|
ofnA.nMaxFile = 0;
|
|
|
|
ofnA.nFileOffset = 0xdead;
|
|
|
|
ofnA.nFileExtension = 0xbeef;
|
|
|
|
ofnA.lpfnHook = test_null_wndproc;
|
|
|
|
ofnA.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ofnA.hInstance = GetModuleHandleA(NULL);
|
|
|
|
ofnA.lpstrFilter = "text\0*.txt\0All\0*\0\0";
|
|
|
|
ofnA.lpstrDefExt = NULL;
|
|
|
|
ret = GetOpenFileNameA(&ofnA);
|
|
|
|
todo_wine ok(ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
todo_wine ok(!ret, "CommDlgExtendedError returned %#x, should be 0\n", ret);
|
|
|
|
|
|
|
|
todo_wine ok(ofnA.nFileOffset != 0xdead, "ofnA.nFileOffset is 0xdead\n");
|
|
|
|
todo_wine ok(ofnA.nFileExtension != 0xbeef, "ofnA.nFileExtension is 0xbeef\n");
|
|
|
|
|
|
|
|
ofnA.lpstrFile = NULL;
|
|
|
|
ofnA.nMaxFile = 1024; /* bogus input - lpstrFile = NULL but fake 1024 bytes available */
|
|
|
|
ofnA.nFileOffset = 0xdead;
|
|
|
|
ofnA.nFileExtension = 0xbeef;
|
|
|
|
ret = GetOpenFileNameA(&ofnA);
|
|
|
|
ok(ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
|
|
|
|
ok(ofnA.nFileOffset != 0xdead, "ofnA.nFileOffset is 0xdead\n");
|
|
|
|
ok(ofnA.nFileExtension == 0, "ofnA.nFileExtension is 0x%x, should be 0\n", ofnA.nFileExtension);
|
|
|
|
|
|
|
|
/* unicode tests */
|
2012-09-21 14:22:47 +02:00
|
|
|
ofnW.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
|
2012-06-15 05:51:34 +02:00
|
|
|
ofnW.lpstrFile = NULL;
|
|
|
|
ofnW.nMaxFile = 0;
|
|
|
|
ofnW.nFileOffset = 0xdead;
|
|
|
|
ofnW.nFileExtension = 0xbeef;
|
|
|
|
ofnW.lpfnHook = test_null_wndproc;
|
|
|
|
ofnW.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ofnW.hInstance = GetModuleHandleW(NULL);
|
|
|
|
ofnW.lpstrFilter = filterW;
|
|
|
|
ofnW.lpstrDefExt = NULL;
|
|
|
|
ret = GetOpenFileNameW(&ofnW);
|
|
|
|
todo_wine ok(ret, "GetOpenFileNameW returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
todo_wine ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
|
|
|
|
todo_wine ok(ofnW.nFileOffset != 0xdead, "ofnW.nFileOffset is 0xdead\n");
|
|
|
|
todo_wine ok(ofnW.nFileExtension != 0xbeef, "ofnW.nFileExtension is 0xbeef\n");
|
|
|
|
|
|
|
|
ofnW.lpstrFile = NULL;
|
|
|
|
ofnW.nMaxFile = 1024; /* bogus input - lpstrFile = NULL but fake 1024 bytes available */
|
|
|
|
ofnW.nFileOffset = 0xdead;
|
|
|
|
ofnW.nFileExtension = 0xbeef;
|
|
|
|
ret = GetOpenFileNameW(&ofnW);
|
|
|
|
ok(ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
ret = CommDlgExtendedError();
|
|
|
|
ok(!ret, "CommDlgExtendedError returned %#x\n", ret);
|
|
|
|
|
|
|
|
ok(ofnW.nFileOffset != 0xdead, "ofnW.nFileOffset is 0xdead\n");
|
|
|
|
ok(ofnW.nFileExtension == 0, "ofnW.nFileExtension is 0x%x, should be 0\n", ofnW.nFileExtension);
|
|
|
|
}
|
|
|
|
|
2016-10-27 08:53:39 +02:00
|
|
|
static void test_directory_filename(void)
|
|
|
|
{
|
|
|
|
OPENFILENAMEA ofnA = {0};
|
|
|
|
OPENFILENAMEW ofnW = {0};
|
|
|
|
WCHAR filterW[] = {'t','e','x','t','\0','*','.','t','x','t','\0',
|
|
|
|
'A','l','l','\0','*','\0','\0'};
|
|
|
|
char szInitialDir[MAX_PATH] = {0};
|
|
|
|
WCHAR szInitialDirW[MAX_PATH] = {0};
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
GetWindowsDirectoryA(szInitialDir, MAX_PATH);
|
|
|
|
GetWindowsDirectoryW(szInitialDirW, MAX_PATH);
|
|
|
|
|
|
|
|
szInitialDir[strlen(szInitialDir)] = '\\';
|
|
|
|
szInitialDirW[lstrlenW(szInitialDirW)] = '\\';
|
|
|
|
|
|
|
|
ofnA.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
|
|
|
ofnA.lpstrFile = szInitialDir;
|
|
|
|
ofnA.nMaxFile = MAX_PATH;
|
|
|
|
ofnA.lpfnHook = test_null_wndproc;
|
|
|
|
ofnA.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ofnA.hInstance = GetModuleHandleA(NULL);
|
|
|
|
ofnA.lpstrFilter = "text\0*.txt\0All\0*\0\0";
|
|
|
|
ofnA.lpstrDefExt = NULL;
|
|
|
|
ret = GetOpenFileNameA(&ofnA);
|
|
|
|
todo_wine ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
|
|
|
|
/* unicode tests */
|
|
|
|
ofnW.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
|
|
|
|
ofnW.lpstrFile = szInitialDirW;
|
|
|
|
ofnW.nMaxFile = MAX_PATH;
|
|
|
|
ofnW.lpfnHook = test_null_wndproc;
|
|
|
|
ofnW.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ofnW.hInstance = GetModuleHandleW(NULL);
|
|
|
|
ofnW.lpstrFilter = filterW;
|
|
|
|
ofnW.lpstrDefExt = NULL;
|
|
|
|
ret = GetOpenFileNameW(&ofnW);
|
|
|
|
todo_wine ok(!ret, "GetOpenFileNameW returned %#x\n", ret);
|
|
|
|
}
|
|
|
|
|
2017-02-02 16:10:05 +01:00
|
|
|
static UINT_PTR WINAPI test_ole_init_wndproc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = OleInitialize(NULL);
|
|
|
|
ok(hr == S_FALSE, "OleInitialize() returned %#x\n", hr);
|
|
|
|
OleUninitialize();
|
|
|
|
|
|
|
|
if (msg == WM_NOTIFY)
|
|
|
|
PostMessageA(GetParent(dlg), WM_COMMAND, IDCANCEL, 0);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT CALLBACK hook_proc(int code, WPARAM wp, LPARAM lp)
|
|
|
|
{
|
|
|
|
static BOOL first_dlg = TRUE;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (code == HCBT_CREATEWND)
|
|
|
|
{
|
|
|
|
CBT_CREATEWNDW *c = (CBT_CREATEWNDW *)lp;
|
|
|
|
|
|
|
|
if (c->lpcs->lpszClass == (LPWSTR)WC_DIALOG)
|
|
|
|
{
|
|
|
|
/* OleInitialize() creates a window for the main apartment. Since
|
|
|
|
* Vista OleInitialize() is called before the file dialog is
|
|
|
|
* created. SimCity 2000 expects that the first window created
|
|
|
|
* after GetOpenFileA() is a file dialog window. Mark Vista+
|
|
|
|
* behavior as broken. */
|
|
|
|
hr = OleInitialize(NULL);
|
|
|
|
ok((first_dlg ? hr == S_OK : hr == S_FALSE)
|
|
|
|
|| broken(first_dlg && hr == S_FALSE),
|
|
|
|
"OleInitialize() returned %#x (first dialog %#x)\n", hr, first_dlg);
|
|
|
|
OleUninitialize();
|
|
|
|
first_dlg = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallNextHookEx(NULL, code, wp, lp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_ole_initialization(void)
|
|
|
|
{
|
|
|
|
char file[MAX_PATH] = {0};
|
|
|
|
OPENFILENAMEA ofn = {0};
|
|
|
|
HRESULT hr;
|
|
|
|
HHOOK hook;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
hook = SetWindowsHookExW(WH_CBT, hook_proc, NULL, GetCurrentThreadId());
|
|
|
|
|
|
|
|
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400A;
|
|
|
|
ofn.lpstrFile = file;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.lpfnHook = test_ole_init_wndproc;
|
|
|
|
ofn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
|
|
|
|
ofn.hInstance = GetModuleHandleA(NULL);
|
|
|
|
ret = GetOpenFileNameA(&ofn);
|
|
|
|
ok(!ret, "GetOpenFileNameA returned %#x\n", ret);
|
|
|
|
|
|
|
|
hr = OleInitialize(NULL);
|
|
|
|
ok(hr == S_OK, "OleInitialize() returned %#x\n", hr);
|
|
|
|
OleUninitialize();
|
|
|
|
|
|
|
|
UnhookWindowsHookEx(hook);
|
|
|
|
}
|
|
|
|
|
2007-04-23 23:20:37 +02:00
|
|
|
START_TEST(filedlg)
|
|
|
|
{
|
|
|
|
test_DialogCancel();
|
2008-10-14 09:45:41 +02:00
|
|
|
test_create_view_window2();
|
2008-10-21 20:10:59 +02:00
|
|
|
test_create_view_template();
|
2009-08-06 07:32:08 +02:00
|
|
|
test_arrange();
|
2009-06-16 08:17:09 +02:00
|
|
|
test_resize();
|
2009-06-30 08:41:10 +02:00
|
|
|
test_ok();
|
2009-09-16 11:52:04 +02:00
|
|
|
test_getfolderpath();
|
2010-07-23 20:13:04 +02:00
|
|
|
test_mru();
|
2009-10-07 11:17:05 +02:00
|
|
|
if( resizesupported) test_resizable2();
|
2010-11-01 16:57:07 +01:00
|
|
|
test_extension();
|
2012-06-15 05:51:34 +02:00
|
|
|
test_null_filename();
|
2016-10-27 08:53:39 +02:00
|
|
|
test_directory_filename();
|
2017-02-02 16:10:05 +01:00
|
|
|
test_ole_initialization();
|
2007-04-23 23:20:37 +02:00
|
|
|
}
|