From: Fabian Maurer Subject: [01/18] comctl32: Move TaskDialogIndirect and tests into own source files Message-Id: <20170224200412.12968-1-dark.shadow4@web.de> Date: Fri, 24 Feb 2017 21:03:55 +0100 Signed-off-by: Fabian Maurer --- dlls/comctl32/Makefile.in | 1 + dlls/comctl32/commctrl.c | 39 ---------------------- dlls/comctl32/taskdialog.c | 72 ++++++++++++++++++++++++++++++++++++++++ dlls/comctl32/tests/Makefile.in | 1 + dlls/comctl32/tests/misc.c | 19 ----------- dlls/comctl32/tests/taskdialog.c | 52 +++++++++++++++++++++++++++++ 6 files changed, 126 insertions(+), 58 deletions(-) create mode 100644 dlls/comctl32/taskdialog.c create mode 100644 dlls/comctl32/tests/taskdialog.c diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in index 27f9741d68..e1a681237e 100644 --- a/dlls/comctl32/Makefile.in +++ b/dlls/comctl32/Makefile.in @@ -30,6 +30,7 @@ C_SRCS = \ string.c \ syslink.c \ tab.c \ + taskdialog.c \ theme_button.c \ theme_combo.c \ theme_dialog.c \ diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 2a4cd42657..d3ba314c47 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -1622,45 +1622,6 @@ int WINAPI DrawShadowText(HDC hdc, LPCWSTR text, UINT length, RECT *rect, DWORD } /*********************************************************************** - * TaskDialogIndirect [COMCTL32.@] - */ -HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, - int *pnRadioButton, BOOL *pfVerificationFlagChecked) -{ - UINT uType = 0; - INT ret; - FIXME("%p, %p, %p, %p\n", pTaskConfig, pnButton, pnRadioButton, pfVerificationFlagChecked); - - if (pTaskConfig->dwCommonButtons & TDCBF_YES_BUTTON && - pTaskConfig->dwCommonButtons & TDCBF_NO_BUTTON && - pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) - uType |= MB_YESNOCANCEL; - else - if (pTaskConfig->dwCommonButtons & TDCBF_YES_BUTTON && - pTaskConfig->dwCommonButtons & TDCBF_NO_BUTTON) - uType |= MB_YESNO; - else - if (pTaskConfig->dwCommonButtons & TDCBF_RETRY_BUTTON && - pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) - uType |= MB_RETRYCANCEL; - else - if (pTaskConfig->dwCommonButtons & TDCBF_OK_BUTTON && - pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) - uType |= MB_OKCANCEL; - else - if (pTaskConfig->dwCommonButtons & TDCBF_OK_BUTTON) - uType |= MB_OK; - ret = MessageBoxW(pTaskConfig->hwndParent, pTaskConfig->pszMainInstruction, - pTaskConfig->pszWindowTitle, uType); - FIXME("dwCommonButtons=%x uType=%x ret=%x\n", pTaskConfig->dwCommonButtons, uType, ret); - - if (pnButton) *pnButton = ret; - if (pnRadioButton) *pnRadioButton = pTaskConfig->nDefaultButton; - if (pfVerificationFlagChecked) *pfVerificationFlagChecked = TRUE; - return S_OK; -} - -/*********************************************************************** * LoadIconWithScaleDown [COMCTL32.@] */ HRESULT WINAPI LoadIconWithScaleDown(HINSTANCE hinst, const WCHAR *name, int cx, int cy, HICON *icon) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c new file mode 100644 index 0000000000..c26d53bac9 --- /dev/null +++ b/dlls/comctl32/taskdialog.c @@ -0,0 +1,72 @@ +/* + * Task dialog control + * + * Copyright 2017 Fabian Maurer for the Wine project + * + * 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 +#include + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "commctrl.h" +#include "winerror.h" +#include "comctl32.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(commctrl); + +/*********************************************************************** + * TaskDialogIndirect [COMCTL32.@] + */ +HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, + int *pnRadioButton, BOOL *pfVerificationFlagChecked) +{ + UINT uType = 0; + INT ret; + TRACE("%p, %p, %p, %p\n", pTaskConfig, pnButton, pnRadioButton, pfVerificationFlagChecked); + + if (pTaskConfig->dwCommonButtons & TDCBF_YES_BUTTON && + pTaskConfig->dwCommonButtons & TDCBF_NO_BUTTON && + pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) + uType |= MB_YESNOCANCEL; + else + if (pTaskConfig->dwCommonButtons & TDCBF_YES_BUTTON && + pTaskConfig->dwCommonButtons & TDCBF_NO_BUTTON) + uType |= MB_YESNO; + else + if (pTaskConfig->dwCommonButtons & TDCBF_RETRY_BUTTON && + pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) + uType |= MB_RETRYCANCEL; + else + if (pTaskConfig->dwCommonButtons & TDCBF_OK_BUTTON && + pTaskConfig->dwCommonButtons & TDCBF_CANCEL_BUTTON) + uType |= MB_OKCANCEL; + else + if (pTaskConfig->dwCommonButtons & TDCBF_OK_BUTTON) + uType |= MB_OK; + ret = MessageBoxW(pTaskConfig->hwndParent, pTaskConfig->pszMainInstruction, + pTaskConfig->pszWindowTitle, uType); + FIXME("dwCommonButtons=%x uType=%x ret=%x\n", pTaskConfig->dwCommonButtons, uType, ret); + + if (pnButton) *pnButton = ret; + if (pnRadioButton) *pnRadioButton = pTaskConfig->nDefaultButton; + if (pfVerificationFlagChecked) *pfVerificationFlagChecked = TRUE; + return S_OK; +} diff --git a/dlls/comctl32/tests/Makefile.in b/dlls/comctl32/tests/Makefile.in index cb2fdf32c2..5faf1f88ba 100644 --- a/dlls/comctl32/tests/Makefile.in +++ b/dlls/comctl32/tests/Makefile.in @@ -22,6 +22,7 @@ C_SRCS = \ subclass.c \ syslink.c \ tab.c \ + taskdialog.c \ toolbar.c \ tooltips.c \ trackbar.c \ diff --git a/dlls/comctl32/tests/misc.c b/dlls/comctl32/tests/misc.c index 5cc6c29225..a6939bdb71 100644 --- a/dlls/comctl32/tests/misc.c +++ b/dlls/comctl32/tests/misc.c @@ -200,24 +200,6 @@ static void test_Alloc(void) ok(res == TRUE, "Expected TRUE, got %d\n", res); } -static void test_TaskDialogIndirect(void) -{ - HINSTANCE hinst; - void *ptr, *ptr2; - - hinst = LoadLibraryA("comctl32.dll"); - - ptr = GetProcAddress(hinst, "TaskDialogIndirect"); - if (!ptr) - { - win_skip("TaskDialogIndirect not exported by name\n"); - return; - } - - ptr2 = GetProcAddress(hinst, (const CHAR*)345); - ok(ptr == ptr2, "got wrong pointer for ordinal 345, %p expected %p\n", ptr2, ptr); -} - static void test_LoadIconWithScaleDown(void) { static const WCHAR nonexisting_fileW[] = {'n','o','n','e','x','i','s','t','i','n','g','.','i','c','o',0}; @@ -402,7 +384,6 @@ START_TEST(misc) return; test_builtin_classes(); - test_TaskDialogIndirect(); test_LoadIconWithScaleDown(); unload_v6_module(ctx_cookie, hCtx); diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c new file mode 100644 index 0000000000..332fa23db0 --- /dev/null +++ b/dlls/comctl32/tests/taskdialog.c @@ -0,0 +1,52 @@ +/* Unit tests for the task dialog control. + * + * Copyright 2017 Fabian Maurer for the Wine project + * + * 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 + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "commctrl.h" + +#include "wine/test.h" +#include "v6util.h" + +static HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG *, int *, int *, BOOL *); + +START_TEST(taskdialog) +{ + ULONG_PTR ctx_cookie; + HANDLE hCtx; + HINSTANCE hinst; + void *ptr_ordinal; + + if (!load_v6_module(&ctx_cookie, &hCtx)) + return; + + /* Check if task dialogs are available */ + hinst = LoadLibraryA("comctl32.dll"); + + pTaskDialogIndirect = (void *)GetProcAddress(hinst, "TaskDialogIndirect"); + ok(pTaskDialogIndirect != NULL, "TaskDialogIndirect not exported by name.\n"); + + ptr_ordinal = GetProcAddress(hinst, (const CHAR*)345); + ok(pTaskDialogIndirect == ptr_ordinal, "got wrong pointer for ordinal 345, %p expected %p\n", ptr_ordinal, pTaskDialogIndirect); + + unload_v6_module(ctx_cookie, hCtx); +} -- 2.11.1