Delphi 打开时的 TTaskDialog 位置
Delphi TTaskDialog position on open
通过 Delphi 10.2.3:TTaskDialog 始终在屏幕中心打开,并且由于它没有位置 属性,因此似乎没有直接的覆盖方法那种行为。我希望我所有的 TTaskDialogs 都位于 poMainFormCenter。没有编写 TTaskDialog 的替代品,有没有办法强制这种行为?
您可能不知道 Flags
属性 和 tfPositionRelativeToWindow
标志:
If set, [the] Task Dialog is centered with respect to [its] parent window.
with TTaskDialog.Create(Self) do
try
Caption := Self.Caption;
MainIcon := tdiNone;
Title := 'Do you want to create a new batch of frogs?';
CommonButtons := [tcbYes, tcbNo];
Flags := [tfPositionRelativeToWindow];
Execute;
finally
Free
end;
严格来说,这使任务对话框相对于父窗体而不是主窗体定位,但我怀疑这正是您真正想要的。
tfPositionRelativeToWindow
标志映射到 TDF_POSITION_RELATIVE_TO_WINDOW
flag of the underlying API call to TaskDialogIndirect
:
Indicates that the task dialog is positioned (centered) relative to the window specified by hwndParent. If the flag is not supplied (or no hwndParent member is specified), the task dialog is positioned (centered) relative to the monitor.
通过 Delphi 10.2.3:TTaskDialog 始终在屏幕中心打开,并且由于它没有位置 属性,因此似乎没有直接的覆盖方法那种行为。我希望我所有的 TTaskDialogs 都位于 poMainFormCenter。没有编写 TTaskDialog 的替代品,有没有办法强制这种行为?
您可能不知道 Flags
属性 和 tfPositionRelativeToWindow
标志:
If set, [the] Task Dialog is centered with respect to [its] parent window.
with TTaskDialog.Create(Self) do
try
Caption := Self.Caption;
MainIcon := tdiNone;
Title := 'Do you want to create a new batch of frogs?';
CommonButtons := [tcbYes, tcbNo];
Flags := [tfPositionRelativeToWindow];
Execute;
finally
Free
end;
严格来说,这使任务对话框相对于父窗体而不是主窗体定位,但我怀疑这正是您真正想要的。
tfPositionRelativeToWindow
标志映射到 TDF_POSITION_RELATIVE_TO_WINDOW
flag of the underlying API call to TaskDialogIndirect
:
Indicates that the task dialog is positioned (centered) relative to the window specified by hwndParent. If the flag is not supplied (or no hwndParent member is specified), the task dialog is positioned (centered) relative to the monitor.