From a2a14d064100a73bb4fe02fe1f89272fe72899ba Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Tue, 1 Aug 2023 14:47:22 +0200 Subject: [PATCH] TaskDialog: Win32 WS: don't let TaskDialogIndirect fail if tfUseCommandLinks is set and no custom buttons ar defined. --- lcl/interfaces/win32/win32wsdialogs.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lcl/interfaces/win32/win32wsdialogs.pp b/lcl/interfaces/win32/win32wsdialogs.pp index f59b0d525c..300b37b17c 100644 --- a/lcl/interfaces/win32/win32wsdialogs.pp +++ b/lcl/interfaces/win32/win32wsdialogs.pp @@ -1870,7 +1870,6 @@ var RUCount := 0; AddTaskDiakogButton(ADlg.Buttons,Config.cButtons,TaskDialogFirstButtonIndex); AddTaskDiakogButton(ADlg.RadioButtons,Config.cRadioButtons,TaskDialogFirstRadioButtonIndex); - if (Config.cButtons > 0) then Config.pButtons := @Buttons[0]; if (Config.cRadioButtons > 0) then @@ -1884,6 +1883,10 @@ var Exclude(Flags,tfVerificationFlagChecked); if (Config.cButtons=0) and (CommonButtons=[tcbOk]) then Include(Flags,tfAllowDialogCancellation); // just OK -> Esc/Alt+F4 close + //while the MS docs say that this flag is ignored if Config.cButtons = 0, + //in practice it will make TaskDialogIndirect fail with E_INVALIDARG + if (ADlg.Buttons.Count = 0) then + Exclude(Flags, tfUseCommandLinks); Config.dwFlags := TaskDialogFlagsToInteger(Flags); Config.hMainIcon := TD_ICONS[TF_DIALOGICON(ADlg.MainIcon)];