TTaskDialog: implement CustomMainIcon and CustomFooterIcon, needed for flags tfUseHIconMain and tfUseHIconFooter respectively.

The flags now work on Windows Vista+ native dialog.
Partly resolves issue #40449.
This commit is contained in:
Bart 2023-08-20 13:48:40 +02:00
parent fe4a986145
commit d7801adb2a
3 changed files with 23 additions and 4 deletions

View File

@ -643,6 +643,8 @@ type
FCaption: TTranslateString;
FCollapseButtonCaption: TTranslateString;
FCommonButtons: TTaskDialogCommonButtons;
FCustomFooterIcon: TIcon;
FCustomMainIcon: TIcon;
FDefaultButton: TTaskDialogCommonButton;
FExpandButtonCaption: TTranslateString;
FExpanded: Boolean;
@ -676,6 +678,8 @@ type
FWidth: Integer;
FOnButtonClicked: TTaskDlgClickEvent;
procedure SetButtons(const Value: TTaskDialogButtons);
procedure SetCustomFooterIcon(AValue: TIcon);
procedure SetCustomMainIcon(AValue: TIcon);
procedure SetFlags(AValue: TTaskDialogFlags);
procedure SetQueryChoices(AValue: TStrings);
procedure SetRadioButtons(const Value: TTaskDialogButtons);
@ -707,6 +711,8 @@ type
property Button: TTaskDialogButtonItem read FButton write FButton;
property Buttons: TTaskDialogButtons read FButtons write SetButtons;
property Caption: TTranslateString read FCaption write FCaption;
property CustomFooterIcon: TIcon read FCustomFooterIcon write SetCustomFooterIcon;
property CustomMainIcon: TIcon read FCustomMainIcon write SetCustomMainIcon;
property CommonButtons: TTaskDialogCommonButtons read FCommonButtons write FCommonButtons default [tcbOk, tcbCancel];
property CollapseButtonCaption: TTranslateString read FCollapseButtonCaption write FCollapseButtonCaption;
property DefaultButton: TTaskDialogCommonButton read FDefaultButton write FDefaultButton default tcbOk;

View File

@ -95,6 +95,9 @@ begin
FMainIcon := tdiInformation;
FQueryChoices := TStringList.Create;
FCustomFooterIcon := TIcon.Create;
FCustomMainIcon := TIcon.Create;
end;
function TCustomTaskDialog.ButtonIDToModalResult(const AButtonID: Integer
@ -132,6 +135,8 @@ begin
FButtons.Free;
FRadioButtons.Free;
FQueryChoices.Free;
FCustomFooterIcon.Free;
FCustomMainIcon.Free;
inherited Destroy;
end;
@ -275,6 +280,16 @@ begin
FButtons.Assign(Value);
end;
procedure TCustomTaskDialog.SetCustomFooterIcon(AValue: TIcon);
begin
FCustomFooterIcon.Assign(AValue);
end;
procedure TCustomTaskDialog.SetCustomMainIcon(AValue: TIcon);
begin
FCustomMainIcon.Assign(AValue);
end;
function DbgS(aFlag: TTaskDialogFlag): String; overload;
begin
WriteStr(Result, aFlag);

View File

@ -1918,14 +1918,12 @@ var
if not (tfUseHIconMain in Flags) then
Config.pszMainIcon := TD_ICONS[ADlg.MainIcon]
else
//ToDo: needs implemenation of TTaskDialog.CustomMainIcon
Config.hMainIcon := 0;
Config.hMainIcon := ADlg.CustomMainIcon.Handle;
if not (tfUseHIconFooter in Flags) then
Config.pszFooterIcon := TD_ICONS[ADlg.FooterIcon]
else
//ToDo: needs implemenation of TTaskDialog.CustomFooterIcon
Config.hFooterIcon := 0;
Config.hFooterIcon := ADlg.CustomFooterIcon.Handle;
{
Although the offcial MS docs (https://learn.microsoft.com/en-us/windows/win32/api/commctrl/ns-commctrl-taskdialogconfig)