Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/comctl32/taskdialog.c | 25 ++++++++++++++++++++++- dlls/comctl32/tests/taskdialog.c | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index ba19ed51a6..f458e32002 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -48,10 +48,13 @@ static const UINT DIALOG_MIN_WIDTH = 240; static const UINT DIALOG_SPACING = 5; static const UINT DIALOG_BUTTON_WIDTH = 50; static const UINT DIALOG_BUTTON_HEIGHT = 14; +static const UINT DIALOG_TIMER_MS = 200;
static const UINT ID_MAIN_INSTRUCTION = 0xf000; static const UINT ID_CONTENT = 0xf001;
+static const UINT ID_TIMER = 1; + struct taskdialog_control { struct list entry; @@ -85,6 +88,7 @@ struct taskdialog_info { HWND hwnd; const TASKDIALOGCONFIG *taskconfig; + DWORD last_timer_tick; };
static void pixels_to_dialogunits(const struct taskdialog_template_desc *desc, LONG *width, LONG *height) @@ -533,6 +537,19 @@ static void taskdialog_on_button_click(struct taskdialog_info *dialog_info, WORD EndDialog(dialog_info->hwnd, command_id); }
+static void taskdialog_init(struct taskdialog_info *dialog_info, HWND hwnd) +{ + const TASKDIALOGCONFIG *taskconfig = dialog_info->taskconfig; + + dialog_info->hwnd = hwnd; + + if (taskconfig->dwFlags & TDF_CALLBACK_TIMER) + { + SetTimer(hwnd, ID_TIMER, DIALOG_TIMER_MS, NULL); + dialog_info->last_timer_tick = GetTickCount(); + } +} + static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, 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}; @@ -550,8 +567,8 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR break; case WM_INITDIALOG: dialog_info = (struct taskdialog_info *)lParam; - dialog_info->hwnd = hwnd; SetPropW(hwnd, taskdialog_info_propnameW, dialog_info); + taskdialog_init(dialog_info, hwnd);
taskdialog_notify(dialog_info, TDN_DIALOG_CONSTRUCTED, 0, 0); break; @@ -568,9 +585,15 @@ static INT_PTR CALLBACK taskdialog_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR case WM_HELP: taskdialog_notify(dialog_info, TDN_HELP, 0, 0); break; + case WM_TIMER: + if (ID_TIMER == wParam + && taskdialog_notify(dialog_info, TDN_TIMER, GetTickCount() - dialog_info->last_timer_tick, 0) == S_FALSE) + dialog_info->last_timer_tick = GetTickCount(); + break; case WM_DESTROY: taskdialog_notify(dialog_info, TDN_DESTROYED, 0, 0); RemovePropW(hwnd, taskdialog_info_propnameW); + if (dialog_info->taskconfig->dwFlags & TDF_CALLBACK_TIMER) KillTimer(dialog_info->hwnd, ID_TIMER); break; default: return FALSE; diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index ad455554b2..94fb25abb3 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -323,6 +323,39 @@ static void test_help(void) run_test(&info, IDOK, msg_got_tdn_help, "send f1"); }
+static HRESULT CALLBACK taskdialog_callback_proc_timer(HWND hwnd, UINT notification, WPARAM wParam, LPARAM lParam, + LONG_PTR ref_data) +{ + int elapsed_ms; + int delta; + static int last_elapsed_ms = 0; + static int fired_count = 0; + if (notification == TDN_TIMER) + { + fired_count++; + elapsed_ms = (int)wParam; + delta = elapsed_ms - last_elapsed_ms; + ok(delta > 0, "Expect timer delta positive\n"); + last_elapsed_ms = elapsed_ms; + } + + if (fired_count == 2) SendMessageW(hwnd, TDM_CLICK_BUTTON, IDOK, 0); + + return S_OK; +} + +static void test_timer(void) +{ + TASKDIALOGCONFIG info = {0}; + + info.cbSize = sizeof(TASKDIALOGCONFIG); + info.pfCallback = taskdialog_callback_proc_timer; + info.dwFlags = TDF_CALLBACK_TIMER; + info.dwCommonButtons = TDCBF_OK_BUTTON; + + pTaskDialogIndirect(&info, NULL, NULL, NULL); +} + START_TEST(taskdialog) { ULONG_PTR ctx_cookie; @@ -360,6 +393,7 @@ START_TEST(taskdialog) test_callback(); test_buttons(); test_help(); + test_timer();
unload_v6_module(ctx_cookie, hCtx); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=38494
Your paranoid android.
=== wvistau64 (32 bit taskdialog) === 08b4:taskdialog: unhandled exception c00000fd at 761F7A5E
=== wvistau64_zh_CN (32 bit taskdialog) === 0bbc:taskdialog: unhandled exception c00000fd at 765D7A5E
=== wvistau64_fr (32 bit taskdialog) === 072c:taskdialog: unhandled exception c00000fd at 755F7A5E
=== wvistau64_he (32 bit taskdialog) === 0bd8:taskdialog: unhandled exception c00000fd at 757C7A5E
=== w2008s64 (32 bit taskdialog) === 084c:taskdialog: unhandled exception c00000fd at 76027A5E
=== w7u (32 bit taskdialog) === 01b8:taskdialog: unhandled exception c00000fd at 75CAC44A
=== w7pro64 (32 bit taskdialog) === 0700:taskdialog: unhandled exception c00000fd at 768E6E6F
=== w8 (32 bit taskdialog) === comctl32:taskdialog crashed (c0000005)
=== w864 (32 bit taskdialog) === comctl32:taskdialog crashed (c0000005)
=== w1064 (32 bit taskdialog) === comctl32:taskdialog crashed (c0000005)
=== wvistau64 (64 bit taskdialog) === 0890:taskdialog: unhandled exception c00000fd at 0000000076C9D449
=== w2008s64 (64 bit taskdialog) === 0870:taskdialog: unhandled exception c00000fd at 000000007701F696
=== w7pro64 (64 bit taskdialog) === 0a88:taskdialog: unhandled exception c00000fd at 00000000770E69AC The previous 1 run(s) terminated abnormally
=== w864 (64 bit taskdialog) === 07b4:taskdialog: unhandled exception c00000fd at 00007FFB23308750
=== w1064 (64 bit taskdialog) === 0cec:taskdialog: unhandled exception c00000fd at 00007FFC3C07FF0C