我需要在桌面的右上角显示我的表单。请给我建议一下方法。
尝试了很多方法都失败了。
最佳答案
这里的主要复杂因素是多个显示器。对于多个显示器,桌面上可能没有顶部和右侧的点。我认为在这种情况下您可能指的是最右侧监视器的顶部。
这样做:
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;
关于delphi - 如何获取屏幕右上角的表单位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7818651/