Delphi中开发使用多显示器的应用程序

来源:互联网 发布:糖豆软件录制 编辑:程序博客网 时间:2024/05/22 12:46
windows7以上系统支持多显示器,Delphi的全局变量screen可以查询当前有几个显示器可用。如果连接多个显示器,那么其中有一个为主显示器,其left=0,
top=0,其它显示器的left和top是相对于主显示器的,如主显示器的分辨率为1366×768,另外一个显示器为1440×900,那么这个显示器的left=1366,

top ,为负值,这个属性可通过monitor属性获得。所以通过设定mainform的left、top、width、height来让程序在指定显示器上面显示。


procedure TMainForm.ToggleScreen(const index: Integer);var  rect : TRect;begin  if index <= Screen.MonitorCount then  begin    rect := Screen.Monitors[ index ].BoundsRect;    Left := rect.Left;    Top := rect.Top;    Width := rect.Width;    Height := rect.Height;    Screen.Realign;    Screen.ResetFonts;    WriteToScreenCinfig(index);  // 写入ini文件,在程序启动时直接在上次设定的显示器显示    ScreenBox.ItemIndex := index;  end;end;
这个方法通过指定显示器号,让程序在指定的显示器上面运行。
0 0
原创粉丝点击