Skip to content

Commit

Permalink
Use correct owner on task dialogs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrussell authored Dec 18, 2024
1 parent 0a0d827 commit f9d5475
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Projects/Src/Shared.TaskDialogFunc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,8 @@ function DoTaskDialog(const hWnd: HWND; const Instruction, Text, Caption, Icon:
Config.cbSize := SizeOf(Config);
if RightToLeft then
Config.dwFlags := Config.dwFlags or TDF_RTL_LAYOUT;
{ If the application window isn't currently visible, show the task dialog
with no owner window so it'll get a taskbar button }
Config.hInstance := HInstance;
if IsIconic(Application.Handle) or
(GetWindowLong(Application.Handle, GWL_STYLE) and WS_VISIBLE = 0) or
(GetWindowLong(Application.Handle, GWL_EXSTYLE) and WS_EX_TOOLWINDOW <> 0) then
Config.hWndParent := 0
else
Config.hwndParent := hWnd;
Config.hwndParent := hWnd;
Config.dwCommonButtons := CommonButtons;
Config.pszWindowTitle := Caption;
Config.pszMainIcon := Icon;
Expand Down Expand Up @@ -85,7 +78,7 @@ function DoTaskDialog(const hWnd: HWND; const Instruction, Text, Caption, Icon:
end;
TriggerMessageBoxCallbackFunc(TriggerMessageBoxCallbackFuncFlags, False);
ActiveWindow := GetActiveWindow;
WindowList := DisableTaskWindows(0);
WindowList := DisableTaskWindows(Config.hwndParent);
try
Result := TaskDialogIndirectFunc(Config, @ModalResult, nil, pfVerificationFlagChecked) = S_OK;
finally
Expand Down Expand Up @@ -178,7 +171,7 @@ function TaskDialogMsgBox(const Icon, Instruction, Text, Caption: String; const
end;
if Length(ButtonIDs) <> NButtonLabelsAvailable then
DoInternalError('TaskDialogMsgBox: Invalid ButtonLabels');
if not DoTaskDialog(Application.Handle, PChar(Instruction), PChar(Text),
if not DoTaskDialog(GetOwnerWndForMessageBox, PChar(Instruction), PChar(Text),
GetMessageBoxCaption(PChar(Caption), Typ), IconP, TDCommonButtons, ButtonLabels, ButtonIDs, ShieldButton,
GetMessageBoxRightToLeft, IfThen(Typ in [mbError, mbCriticalError], MB_ICONSTOP, 0), Result, PChar(VerificationText), pfVerificationFlagChecked) then //note that MB_ICONEXCLAMATION (used by mbError) includes MB_ICONSTOP (used by mbCriticalError)
Result := 0;
Expand Down

0 comments on commit f9d5475

Please sign in to comment.