这里主要的复杂因素是多个监视器.使用多台显示器,桌面上可能没有任何一点是顶部和右侧.在这种情况下,我认为你可能意味着最右边的监视器的顶部.
像这样做:
procedure MoveFormToTopOfRightmostMonitor(Form: TForm);
var
i: Integer;
Monitor, RightMostMonitor: TMonitor;
begin
RightMostMonitor := Screen.Monitors[0];
for i := 1 to Screen.MonitorCount-1 do
begin
Monitor := Screen.Monitors[i];
if Monitor.Left+Monitor.Width > RightMostMonitor.Left+RightMostMonitor.Width then
Monitor := RightMostMonitor;
end;
Form.Left := Monitor.Left+Monitor.Width-Form.Left;
Form.Top := Monitor.Top;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5538 次 |
| 最近记录: |