[v3 10/12] comctl32: TaskDialog - Add button return value and tests
Fabian Maurer
dark.shadow4 at web.de
Fri Mar 10 12:22:02 CST 2017
v3: Rewrite to implement Nikolay Sivov's suggestions
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/comctl32/taskdialog.c | 25 ++++++++++++++++++-------
dlls/comctl32/tests/taskdialog.c | 13 +++++++++++++
2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c
index 65787c5c54..4a510eb247 100644
--- a/dlls/comctl32/taskdialog.c
+++ b/dlls/comctl32/taskdialog.c
@@ -256,10 +256,20 @@ static HRESULT callback(taskdialog_info *dialog_info, UINT uNotification, WPARAM
return S_OK;
}
+ static void click_button(taskdialog_info *dialog_info, WORD command_id)
+ {
+ HRESULT ret_callback;
+
+ ret_callback = callback(dialog_info, TDN_BUTTON_CLICKED, command_id, 0);
+ if(ret_callback == S_OK)
+ {
+ EndDialog(dialog_info->hwnd, command_id);
+ }
+ }
+
static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static const WCHAR taskdialog_info_propnameW[] = {'T','a','s','k','D','i','a','l','o','g','I','n','f','o',0};
- HRESULT ret_callback;
taskdialog_info *dialog_info;
if(uMsg != WM_INITDIALOG && uMsg != WM_NCDESTROY)
@@ -296,12 +306,7 @@ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
if(HIWORD(wParam) == BN_CLICKED)
{
WORD command_id = LOWORD(wParam);
-
- ret_callback = callback(dialog_info, TDN_BUTTON_CLICKED, command_id, 0);
- if(ret_callback == S_OK) /* FIXME */
- {
- EndDialog(hwndDlg, command_id);
- }
+ click_button(dialog_info, command_id);
return TRUE;
}
break;
@@ -309,6 +314,12 @@ static INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
callback(dialog_info, TDN_DESTROYED, 0, 0);
RemovePropW(hwndDlg, taskdialog_info_propnameW);
break;
+
+ /* Custom messages*/
+
+ case TDM_CLICK_BUTTON:
+ click_button(dialog_info, wParam);
+ break;
}
return FALSE;
}
diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c
index 51a6451721..f76624c45d 100644
--- a/dlls/comctl32/tests/taskdialog.c
+++ b/dlls/comctl32/tests/taskdialog.c
@@ -72,6 +72,18 @@ static const struct message_info mes_simple_show[] = {
{ 0 }
};
+static const struct message_info mes_cancel_button_press[] = {
+ { TDN_CREATED, 0, 0, S_OK, {
+ { TDM_CLICK_BUTTON, IDOK, 0, TRUE },
+ { TDM_CLICK_BUTTON, IDOK, 0, TRUE },
+ { TDM_CLICK_BUTTON, IDOK, 0, TRUE },
+ { 0 }}},
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_FALSE, {{ 0 }}},
+ { TDN_BUTTON_CLICKED, IDOK, 0, 0xFF, {{ 0 }}}, /* Random return value tested here */
+ { TDN_BUTTON_CLICKED, IDOK, 0, S_OK, {{ 0 }}},
+ { 0 }
+};
+
/* Create a message to test against */
static struct message create_test_message(UINT message, WPARAM wParam, LPARAM lParam)
@@ -210,6 +222,7 @@ static void test_TaskDialogIndirect(void)
info.lpCallbackData = backup_ref_data = 0x12345678; /* Set data for callback tests */
run_test(&info, IDOK, 0, FALSE, mes_simple_show, "Simple test with parameters null");
+ run_test(&info, IDOK, 0, FALSE, mes_cancel_button_press, "Simple test for cancelling button press");
}
START_TEST(taskdialog)
--
2.12.0
More information about the wine-patches
mailing list