TTaskDialog: implement flags tfUseHIconMain and tfUseHIconFooter for emulated dialog as well.

Resolves issue #40449.
This commit is contained in:
Bart 2023-08-20 14:29:25 +02:00
parent d7801adb2a
commit e975ddddf5

View File

@ -114,7 +114,7 @@ type
procedure InitCaptions; procedure InitCaptions;
procedure InitGlobalDimensionsAndStyle(ACustomButtonsTextLength: Integer; out aWidth, aFontHeight: Integer); procedure InitGlobalDimensionsAndStyle(ACustomButtonsTextLength: Integer; out aWidth, aFontHeight: Integer);
function GetGlobalLeftMargin: Integer; function GetGlobalLeftMargin: Integer;
procedure AddIcon(out ALeft,ATop: Integer; AGlobalLeftMargin: Integer; AParent: TWinControl); procedure AddMainIcon(out ALeft,ATop: Integer; AGlobalLeftMargin: Integer; AParent: TWinControl);
procedure AddPanels; procedure AddPanels;
procedure AddRadios(const ARadioOffSet, AWidth, ARadioDef, AFontHeight, ALeft: Integer; var ATop: Integer; AParent: TWinControl); procedure AddRadios(const ARadioOffSet, AWidth, ARadioDef, AFontHeight, ALeft: Integer; var ATop: Integer; AParent: TWinControl);
procedure AddCommandLinkButtons(const ALeft: Integer; var ATop: Integer; AWidth, AButtonDef, AFontHeight: Integer; AParent: TWinControl); procedure AddCommandLinkButtons(const ALeft: Integer; var ATop: Integer; AWidth, AButtonDef, AFontHeight: Integer; AParent: TWinControl);
@ -421,17 +421,33 @@ begin
Result := 16; Result := 16;
end; end;
procedure TLCLTaskDialog.AddIcon(out ALeft,ATop: Integer; AGlobalLeftMargin: Integer; AParent: TWinControl); procedure TLCLTaskDialog.AddMainIcon(out ALeft,ATop: Integer; AGlobalLeftMargin: Integer; AParent: TWinControl);
var var
aDialogIcon: TTaskDialogIcon; aDialogIcon: TTaskDialogIcon;
begin begin
MainImage := nil;
if not (tfUseHIconMain in FDlg.Flags) then
begin
aDialogIcon := FDlg.MainIcon; aDialogIcon := FDlg.MainIcon;
if (LCL_IMAGES[FDlg.MainIcon]<>0) then if (LCL_IMAGES[aDialogIcon]<>0) then
begin begin
MainImage := TImage.Create(Self); MainImage := TImage.Create(Self);
MainImage.Parent := AParent; MainImage.Parent := AParent;
MainImage.Images := DialogGlyphs; MainImage.Images := DialogGlyphs;
MainImage.ImageIndex := DialogGlyphs.DialogIcon[LCL_IMAGES[aDialogIcon]]; MainImage.ImageIndex := DialogGlyphs.DialogIcon[LCL_IMAGES[aDialogIcon]];
end;
end
else
begin
if Assigned(FDlg.CustomMainIcon) and not (FDlg.CustomMainIcon.Empty) then
begin
MainImage := TImage.Create(Self);
MainImage.Parent := AParent;
MainImage.Picture.Assign(FDlg.CustomMainIcon);
end;
end;
if Assigned(MainImage) then
begin
MainImage.SetBounds(AGlobalLeftMargin, AGlobalLeftMargin, LargeImageSize, LargeImageSize); MainImage.SetBounds(AGlobalLeftMargin, AGlobalLeftMargin, LargeImageSize, LargeImageSize);
MainImage.Stretch := True; MainImage.Stretch := True;
MainImage.StretchOutEnabled := False; MainImage.StretchOutEnabled := False;
@ -444,7 +460,6 @@ begin
end end
else else
begin begin
MainImage := nil;
ALeft := AGlobalLeftMargin; ALeft := AGlobalLeftMargin;
ATop := AGlobalLeftMargin; ATop := AGlobalLeftMargin;
end; end;
@ -715,14 +730,31 @@ begin
//debugln(['AddFooterText: XB=',XB]); //debugln(['AddFooterText: XB=',XB]);
AddBevel(ATop, aWidth, AParent); AddBevel(ATop, aWidth, AParent);
inc(ATop,LabelVSPacing div 2); inc(ATop,LabelVSPacing div 2);
FooterImage := nil;
if not (tfUseHIconFooter in FDlg.Flags) then
begin
aFooterIcon := FDlg.FooterIcon; aFooterIcon := FDlg.FooterIcon;
if (LCL_IMAGES[aFooterIcon]<>0) then if (LCL_IMAGES[aFooterIcon]<>0) then
begin begin
FooterImage := TImage.Create(Self); FooterImage := TImage.Create(Self);
FooterImage.Parent := AParent; FooterImage.Parent := AParent;
FooterImage.Images := DialogGlyphs; FooterImage.Images := DialogGlyphs;
FooterImage.ImageWidth := 16; FooterImage.ImageWidth := SmallImageSize;
FooterImage.ImageIndex := DialogGlyphs.DialogIcon[LCL_IMAGES[aFooterIcon]]; FooterImage.ImageIndex := DialogGlyphs.DialogIcon[LCL_IMAGES[aFooterIcon]];
end;
end
else
begin
if Assigned(FDlg.CustomFooterIcon) and not (FDlg.CustomFooterIcon.Empty) then
begin
FooterImage := TImage.Create(Self);
FooterImage.Parent := AParent;
FooterImage.ImageWidth := SmallImageSize;
FooterImage.Picture.Assign(FDlg.CustomFooterIcon);
end;
end;
if Assigned(FooterImage) then
begin
FooterImage.Stretch := True; FooterImage.Stretch := True;
FooterImage.StretchOutEnabled := False; FooterImage.StretchOutEnabled := False;
FooterImage.Proportional := True; FooterImage.Proportional := True;
@ -1014,7 +1046,7 @@ begin
// handle main dialog icon // handle main dialog icon
GlobalLeftMargin := GetGlobalLeftMargin; GlobalLeftMargin := GetGlobalLeftMargin;
AddIcon(ALeft, ATop, GlobalLeftMargin, CurrParent); AddMainIcon(ALeft, ATop, GlobalLeftMargin, CurrParent);
//debugln('SetupControls'); //debugln('SetupControls');
//debugln([' GlobalLeftMargin=',GlobalLeftMargin]); //debugln([' GlobalLeftMargin=',GlobalLeftMargin]);
//debugln([' ALeft=',ALeft]); //debugln([' ALeft=',ALeft]);