From: Fabian Maurer Subject: [15/18] comctl32: TaskDialog - Set default button and add tests Message-Id: <20170224200412.12968-15-dark.shadow4@web.de> Date: Fri, 24 Feb 2017 21:04:09 +0100 In-Reply-To: <20170224200412.12968-1-dark.shadow4@web.de> References: <20170224200412.12968-1-dark.shadow4@web.de> Signed-off-by: Fabian Maurer # Conflicts: # dlls/comctl32/tests/taskdialog.c --- dlls/comctl32/taskdialog.c | 17 ++++++-- dlls/comctl32/tests/taskdialog.c | 92 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) diff --git a/dlls/comctl32/taskdialog.c b/dlls/comctl32/taskdialog.c index 864b616fb7..fcfc1fb243 100644 --- a/dlls/comctl32/taskdialog.c +++ b/dlls/comctl32/taskdialog.c @@ -414,7 +414,7 @@ static button_info make_button(HDC hdc, UINT dialog_width, int id, const WCHAR * } static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *pTaskConfig, struct list *controls, - UINT dialog_width, UINT dialog_height) + UINT dialog_width, UINT dialog_height, int default_button) { static const WCHAR class_button[] = {'B','u','t','t','o','n',0}; static const WCHAR text_ok[] = {'O','K',0}; @@ -426,6 +426,7 @@ static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *pTaskConfig, struct lis UINT alignment = 40; /* 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; @@ -497,10 +498,20 @@ static UINT add_buttons(HDC hdc, const TASKDIALOGCONFIG *pTaskConfig, 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 f975a53de5..725bcd1b9a 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -33,6 +33,10 @@ static HRESULT (WINAPI *pTaskDialogIndirect)(const TASKDIALOGCONFIG *, int *, in /* For message checking we use a simplified version from the code used for user32 messages */ #define TDN_NO_MORE_MESSAGES 0xffffffff +#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) /* How the message is sent to the dialog */ typedef enum @@ -84,6 +88,38 @@ static const message_data mes_cancel_button_press[] = { { TDN_NO_MORE_MESSAGES } }; +static const message_data mes_button_clicked_ok[] = { + { TDN_DIALOG_CONSTRUCTED, 0, 0 }, + { TDN_CREATED, 0, 0 }, + { TDN_BUTTON_CLICKED, IDOK, 0 }, + { TDN_DESTROYED, 0, 0 }, + { TDN_NO_MORE_MESSAGES } +}; + +static const message_data mes_button_clicked_custom1[] = { + { TDN_DIALOG_CONSTRUCTED, 0, 0 }, + { TDN_CREATED, 0, 0 }, + { TDN_BUTTON_CLICKED, ID_START_BUTTON, 0 }, + { TDN_DESTROYED, 0, 0 }, + { TDN_NO_MORE_MESSAGES } +}; + +static const message_data mes_button_clicked_retry[] = { + { TDN_DIALOG_CONSTRUCTED, 0, 0 }, + { TDN_CREATED, 0, 0 }, + { TDN_BUTTON_CLICKED, IDRETRY, 0 }, + { TDN_DESTROYED, 0, 0 }, + { TDN_NO_MORE_MESSAGES } +}; + +static const message_data mes_button_clicked_custom4[] = { + { TDN_DIALOG_CONSTRUCTED, 0, 0 }, + { TDN_CREATED, 0, 0 }, + { TDN_BUTTON_CLICKED, ID_START_BUTTON + 4, 0 }, + { TDN_DESTROYED, 0, 0 }, + { TDN_NO_MORE_MESSAGES } +}; + /* Message lists to send */ static const message_send_data mes_send_return[] = { @@ -328,6 +364,31 @@ static void run_test_(TASKDIALOGCONFIG *info, int expect_button, int expect_radi CloseHandle(event); } +static const TASKDIALOG_BUTTON* buttons_make(int count) +{ + int i; + static const WCHAR str_format[] = {'%','d',0}; + TASKDIALOG_BUTTON *ret = HeapAlloc(GetProcessHeap(), 0, count*sizeof(TASKDIALOG_BUTTON)); + + for(i=0; i