[PATCH 11/18] comctl32: TaskDialog - Add button return value and tests
Fabian Maurer
dark.shadow4 at web.de
Sat Feb 25 10:01:39 CST 2017
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
# Conflicts:
# dlls/comctl32/tests/taskdialog.c
---
dlls/comctl32/taskdialog.c | 21 +++++++++++++++++++--
dlls/comctl32/tests/taskdialog.c | 24 ++++++++++++++++++++++++
2 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index a52fbb927e..f2a419a5ac 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -379,7 +379,7 @@ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
WORD command_id = LOWORD(wParam);
ret_callback = callback(dialog, TDN_BUTTON_CLICKED, command_id, 0);
- if(ret_callback == S_OK) /* FIXME */
+ if(ret_callback == S_OK)
{
EndDialog(hwndDlg, command_id);
@@ -388,6 +388,12 @@ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
return TRUE;
}
break;
+
+ /* Custom messages*/
+
+ case TDM_CLICK_BUTTON:
+ SendMessageA(hwndDlg, WM_COMMAND, MAKEWORD(wParam, BN_CLICKED), 0);
+ break;
}
return FALSE;
}
@@ -520,6 +526,7 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnBu
dialog_header header = {0};
struct list *controls;
HDC dc_dummy;
+ int ret;
TRACE("%p, %p, %p, %p\n", pTaskConfig, pnButton, pnRadioButton, pfVerificationFlagChecked);
@@ -589,7 +596,17 @@ HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, int *pnBu
/* Turn template information into a dialog template to display it */
template_data = dialog_template_create(header, controls);
- DialogBoxIndirectParamW(pTaskConfig->hInstance, template_data, pTaskConfig->hwndParent, DialogProc, (LPARAM)dialog);
+ ret = DialogBoxIndirectParamW(pTaskConfig->hInstance, template_data,
+ pTaskConfig->hwndParent, DialogProc, (LPARAM)dialog);
+
+ if(pnButton)
+ *pnButton = ret;
+
+ if(pnRadioButton)
+ *pnRadioButton = 0;
+
+ if(pfVerificationFlagChecked)
+ *pfVerificationFlagChecked = FALSE;
/* Cleanup */
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 99501ab56d..b8feeffc69 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -64,6 +64,16 @@ static const message_data mes_simple_show[] = {
{ TDN_NO_MORE_MESSAGES }
};
+static const message_data mes_cancel_button_press[] = {
+ { TDN_DIALOG_CONSTRUCTED, 0, 0 },
+ { TDN_CREATED, 0, 0 },
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_FALSE },
+ { TDN_BUTTON_CLICKED, IDOK, 0, 0xFF }, /* Random return value tested here */
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK },
+ { TDN_DESTROYED, 0, 0 },
+ { TDN_NO_MORE_MESSAGES }
+};
+
/* Message lists to send */
static const message_send_data mes_send_return[] = {
@@ -71,6 +81,13 @@ static const message_send_data mes_send_return[] = {
{ 0 }
};
+static const message_send_data mes_send_3_click_button_ok[] = {
+ { TDM_CLICK_BUTTON, IDOK, 0 },
+ { TDM_CLICK_BUTTON, IDOK, 0 },
+ { TDM_CLICK_BUTTON, IDOK, 0 },
+ { 0 }
+};
+
/* Our only way to get a button handle, since GetDlgItem and FindWindowEx don't work for the official taskdialog */
static HWND taskdialog_child;
@@ -209,6 +226,7 @@ static void test_TaskDialogIndirect(void)
{
TASKDIALOGCONFIG info = {0};
HRESULT ret;
+ INT ret_button = 0;
ret = pTaskDialogIndirect(NULL, NULL, NULL, NULL);
ok(ret == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", ret);
@@ -226,6 +244,12 @@ static void test_TaskDialogIndirect(void)
ok(ret == S_OK, "Expected S_OK, got %x\n", ret);
ok_sequence(message_list);
+ message_list = mes_cancel_button_press;
+ message_send_list = mes_send_3_click_button_ok;
+ ret = pTaskDialogIndirect(&info, &ret_button, NULL, NULL);
+ ok(ret == S_OK, "Expected S_OK, got %x\n", ret);
+ ok(ret_button == IDOK, "Expected IDOK, got %d\n", ret_button);
+ ok_sequence(message_list);
}
START_TEST(taskdialog)
--
2.12.0
More information about the wine-patches
mailing list