TaskDialog: Win32 WS: use pszMainIcon and pszFooterIcon fields of TTaskDialogConfig structure to set MainIcon and FooterIcon.

Gets rid of some constant definitions which are magic numbers that I was unable to trace why they work at all.
The new constants are predefined by MS, with the exception of TD_QUESTION_ICON.
Also this way we use the same constants for both MainIcon and FooterIcon.
This commit is contained in:
Bart 2023-08-17 23:41:23 +02:00
parent 0112fc4456
commit 65106f1e28

View File

@ -1807,11 +1807,17 @@ var
const
TD_BTNMOD: array[TTaskDialogCommonButton] of Integer = (
mrOk, mrYes, mrNo, mrCancel, mrRetry, mrAbort);
TD_ICONS: array[TLCLTaskDialogIcon] of integer = (
0 {tiBlank}, 84 {tiWarning}, 99 {tiQuestion}, 98 {tiError}, 81 {tiInformation}, 0 {tiNotUsed}, 78 {tiShield});
//TD_ICONS: array[TLCLTaskDialogIcon] of integer = (
// 0 {tiBlank}, 84 {tiWarning}, 99 {tiQuestion}, 98 {tiError}, 81 {tiInformation}, 0 {tiNotUsed}, 78 {tiShield});
TD_FOOTERICONS: array[TLCLTaskDialogFooterIcon] of integer = (
0 {tfiBlank}, 84 {tfiWarning}, 99 {tfiQuestion}, 98 {tfiError}, 65533 {tfiInformation}, 65532 {tfiShield});
TD_QUESTION_ICON = MAKEINTRESOURCEW(Word(32514)); //source: https://www.vbarchiv.net/tipps/tipp_2224-vista-taskdialogindirect.html
TD_ICONS: array[TTaskDialogIcon] of MAKEINTRESOURCEW = (
nil, TD_WARNING_ICON, TD_ERROR_ICON, TD_INFORMATION_ICON, TD_SHIELD_ICON, TD_QUESTION_ICON
);
procedure AddTaskDiakogButton(Btns: TTaskDialogButtons; var n: longword; firstID: integer);
var
i: Integer;
@ -1920,13 +1926,15 @@ var
Config.dwFlags := TaskDialogFlagsToInteger(Flags);
if not (tfUseHIconMain in Flags) then
Config.hMainIcon := TD_ICONS[TF_DIALOGICON(ADlg.MainIcon)]
//Config.hMainIcon := TD_ICONS[TF_DIALOGICON(ADlg.MainIcon)]
Config.pszMainIcon := TD_ICONS[ADlg.MainIcon]
else
//ToDo: needs implemenation of TTaskDialog.CustomMainIcon
Config.hMainIcon := 0;
if not (tfUseHIconFooter in Flags) then
Config.hFooterIcon := TD_FOOTERICONS[TF_FOOTERICON(ADlg.FooterIcon)]
//Config.hFooterIcon := TD_FOOTERICONS[TF_FOOTERICON(ADlg.FooterIcon)]
Config.pszFooterIcon := TD_ICONS[ADlg.FooterIcon]
else
//ToDo: needs implemenation of TTaskDialog.CustomFooterIcon
Config.hFooterIcon := 0;