delphi 多个监视器中的Application.MessageBox  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 多个监视器中的Application.MessageBox


image.thumb.png.35601ed3a8d804211c6e51cd37ab576a.png


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