From bff41e1f5d0e346933fb1f639586cad9302ab061 Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 29 Jul 2023 23:29:53 +0200 Subject: [PATCH] TTaskDialog: In Execute, use the Handle of the current active form for the ParentWnd parameter. Based upon the documentation of Delphi: https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Dialogs.TCustomTaskDialog.Execute It makes Execute honour the tfRelativeToWindow flag. --- lcl/include/taskdialog.inc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lcl/include/taskdialog.inc b/lcl/include/taskdialog.inc index a63b6c20da..5b749e088c 100644 --- a/lcl/include/taskdialog.inc +++ b/lcl/include/taskdialog.inc @@ -181,8 +181,18 @@ begin end; function TCustomTaskDialog.Execute: Boolean; +var + AParentWnd: HWND; begin - Result := Execute(0); + //See: https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Dialogs.TCustomTaskDialog.Execute + //If no handle is supplied, then the handle of the active form should be used. + //For that Delphi uses Application.ActiveFormHandle (the docs say so). + //Currently TApplication does not have a ActiveFormHandle property, so we use our own code for that. + if Assigned(Screen.ActiveCustomForm) then + AParentWnd := Screen.ActiveCustomForm.Handle + else + AParentWnd := 0; + Result := Execute(AParentWnd); end; procedure TCustomTaskDialog.SetButtons(const Value: TTaskDialogButtons);