程序显示在指定显示器上

procedure SetFormMonitor(Form:TCustomForm;MonitorIndex:integer);
begin
  if (MonitorIndex>-1) and (MonitorIndex<Screen.MonitorCount) then{保证屏幕索引在范围内}
  begin
    Form.SetBounds(
      Screen.Monitors[MonitorIndex].Left + ((Screen.Monitors[MonitorIndex].Width - Form.Width) div 2),
      Screen.Monitors[MonitorIndex].Top + ((Screen.Monitors[MonitorIndex].Height - Form.Height) div 2),
      Form.Width,
      Form.Height
      );
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if Screen.MonitorCount>1 then
  setformMonitor(Form1,1);
  {Form1.SetBounds(1700,200,600,300);}
  {left:=1700;}
end;

 

posted @ 2012-04-09 13:18  ftwsnow  阅读(713)  评论(0)    收藏  举报