From: Fabian Maurer Subject: [v3 11/12] comctl32: TaskDialog - Set default button and add tests Message-Id: <20170310182204.20127-11-dark.shadow4@web.de> Date: Fri, 10 Mar 2017 19:22:03 +0100 In-Reply-To: <20170310182204.20127-1-dark.shadow4@web.de> References: <20170310182204.20127-1-dark.shadow4@web.de> v3: Rewrite to implement Nikolay Sivov's suggestions Signed-off-by: Fabian Maurer --- dlls/comctl32/taskdialog.c | 19 +++++++-- dlls/comctl32/tests/taskdialog.c | 85 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 4a510eb247..47ade8f2f6 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -366,7 +366,7 @@ static button_info make_button(HDC hdc, UINT dialog_width, int id, const WCHAR * } static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *task_config, struct list *controls, - UINT dialog_width, UINT dialog_height) + UINT dialog_width, UINT dialog_height, int default_button) { static const WCHAR class_button[] = WC_BUTTONW; /* Can't use WC_BUTTONW directy, need to store it into a static variable since it goes out of scope */ static WCHAR text_ok [20] = {0}; @@ -379,6 +379,7 @@ static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *task_config, struct lis UINT alignment = DIALOG_SPACING_BUTTONS_LEFT; /* minimum distance from the left dialog border */ UINT location_x; BOOL first_row = TRUE; + BOOL found_default = FALSE; /* Whether the default button ID is valid or not */ button_info *buttons; int count = 0; int i; @@ -461,11 +462,21 @@ static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *task_config, struct lis buttons[i].x += diff; } + for(i=0; inDefaultButton); header.title = pTaskConfig->pszWindowTitle; if(!header.title) diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index f76624c45d..c29ac89792 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -34,6 +34,12 @@ #define NUM_MSG_SEQUENCES 1 #define TASKDIALOG_SEQ_INDEX 0 +#define TEST_NUM_BUTTONS 20 /* Number of custom buttons to test with */ + +#define ID_START 20 /* Lower IDs might be used by the system */ +#define ID_START_BUTTON (ID_START + 0) +#define ID_START_RADIO (ID_START + 1000) + static HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG *, int *, int *, BOOL *); static struct msg_sequence *sequences[NUM_MSG_SEQUENCES]; @@ -64,7 +70,7 @@ struct message_info static const struct message_info *current_message_info; -static const struct message_info mes_simple_show[] = { +static const struct message_info mes_return_press_ok[] = { { TDN_CREATED, 0, 0, S_OK, { { WM_KEYDOWN, VK_RETURN, 0, TRUE }, { 0 }}}, @@ -84,6 +90,30 @@ static const struct message_info mes_cancel_button_press[] = { { 0 } }; +static const struct message_info mes_return_press_custom1[] = { + { TDN_CREATED, 0, 0, S_OK, { + { WM_KEYDOWN, VK_RETURN, 0, TRUE }, + { 0 }}}, + { TDN_BUTTON_CLICKED, ID_START_BUTTON, 0, S_OK, {{ 0 }}}, + { 0 } +}; + +static const struct message_info mes_return_press_custom4[] = { + { TDN_CREATED, 0, 0, S_OK, { + { WM_KEYDOWN, VK_RETURN, 0, TRUE }, + { 0 }}}, + { TDN_BUTTON_CLICKED, ID_START_BUTTON + 3, 0, S_OK, {{ 0 }}}, + { 0 } +}; + +static const struct message_info mes_return_press_retry[] = { + { TDN_CREATED, 0, 0, S_OK, { + { WM_KEYDOWN, VK_RETURN, 0, TRUE }, + { 0 }}}, + { TDN_BUTTON_CLICKED, IDRETRY, 0, S_OK, {{ 0 }}}, + { 0 } +}; + /* Create a message to test against */ static struct message create_test_message(UINT message, WPARAM wParam, LPARAM lParam) @@ -206,11 +236,34 @@ static HRESULT CALLBACK TaskDialogCallbackProc(HWND hwnd, UINT uNotification, WP return S_OK; } + + +static TASKDIALOG_BUTTON* buttons_make(void) +{ + static const WCHAR str_format[] = {'%','0','2','d',0}; + static TASKDIALOG_BUTTON buttons[TEST_NUM_BUTTONS]; + static WCHAR titles[TEST_NUM_BUTTONS * 3]; /* Each button has two digits as title, plus null-terminator */ + int i; + + for(i=0; i