Search results for 'Screen.MonitorCount'. 1 post(s) found.

  1. 2008/12/16 How to get screen resolution in case of using multiple monitors ?
2008/12/16 10:30

How to get screen resolution in case of using multiple monitors ?


You can simply get the total number of monitors by Screen.MonitorCount.
If you have Dual Monitors, the return value of Screen.MonitorCount is 2.

Screen.Monitors[ index ] has the properties related with your Multiple Monitors.

Here's the simple example which measure the full screen resolution for Multiple Monitors.

//
// Programmed 2008 by Kurapa Chunun Kang (kurapa@kurapa.com)
//
// http://kurapa.com
//
function GetScreenResolution: TRect;
var
  i: Integer;
  r, n: TRect;
begin
  // initialize returning value
  r.Left := 0;
  r.Right := 0;
  r.Top := 0;
  r.Bottom := 0;

  for i := 1 to Screen.MonitorCount do
  begin
    n.Left := Screen.Monitors[i-1].WorkareaRect.Left;
    n.Right := Screen.Monitors[i-1].WorkareaRect.Right;
    n.Top := Screen.Monitors[i-1].WorkareaRect.Top;
    n.Bottom := Screen.Monitors[i-1].WorkareaRect.Bottom;
    if r.Left>n.Left then r.Left := n.Left;
    if r.Right<n.Right then r.Right := n.Right;
    if r.Top>n.Top then r.Top := n.Top;
    if r.Bottom<n.Bottom then r.Bottom := n.Bottom;
  end;

  Result := r;
end;


// In case of clicking button, window size is changed to the full resolution.
procedure TForm1.Button1Click(Sender: TObject);
var r: TRect;
begin
  r := GetScreenResolution;
  Left := r.Left;
  Top := r.Top;
  Width := (r.Right-r.Left);
  Height := (r.Bottom-r.Top);
end;

Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.