procedure TForm1.Button1Click(Sender: TObject);
var
lMyMonitor: TMonitor;
//
X1 : integer;
Y1 : integer;
lOffSetWindowWidth : integer;
lOffSetWindowHeight: integer;
begin
lMyMonitor := Screen.MonitorFromWindow(Self.Handle);
//
lOffSetWindowWidth := 100; // needs calculate it before show the window, of course...
lOffSetWindowHeight := 50;
//
X1 := Random(lMyMonitor.Width - lOffSetWindowWidth);
Y1 := Random(lMyMonitor.Height - lOffSetWindowHeight);;
//
try
Memo1.Lines.Add(Format('Monitor = %d', [lMyMonitor.MonitorNum]));
Memo1.Lines.Add(Format('Monitor Height=%d, Width=%d', [lMyMonitor.Height, lMyMonitor.Width]));
Memo1.Lines.Add(Format('Monitor Left=%d, Top=%d, Height=%d, Width=%d', [ { }
lMyMonitor.WorkareaRect.Left, { }
lMyMonitor.WorkareaRect.Top, { }
lMyMonitor.WorkareaRect.Height, { }
lMyMonitor.WorkareaRect.Width { }
]));
//
Memo1.Lines.Add(Format('X1=%d, Y1=%d', [X1, Y1]));
//
Vcl.Dialogs.MessageDlgPos('msg string', mtInformation, [mbOK], 0, X1, Y1);
finally
//
end;
end;
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.036023855209351 seconds