如何将表格位置设为屏幕的右上角?

Rak*_*tti 3 delphi

我需要在桌面的右上角显示我的表单.请指教我的方式.

我尝试了很多方法,但失败了.

Dav*_*nan 9

这里主要的复杂因素是多个监视器.使用多台显示器,桌面上可能没有任何一点是顶部和右侧.在这种情况下,我认为你可能意味着最右边的监视器的顶部.

像这样做:

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)