Multi-monitor support started with Delphi 4. The "Desktop" extends over all monitors,
from left to right. You position forms like this:
Form1.Left := Screen.Monitors[0].Left+10;
Form1.Left := Screen.Monitors[1].Left+10;
Where does "Screen" come from? It's a global variable that is created automatically when
your application starts. "Screen" provides information about the monitors, such as screen
resolution, available fonts, and so on. Important properties of Screen:
- Screen.MonitorCount: number of monitors;
- Screen.Monitors: zero-based array of TMonitor objects. The following code example
shows how to access the Left and Width properties of each monitor:
procedure TForm1.Button1Click(Sender: TObject);
var
i, NrOfMon: integer;
Mon: TMonitor;
begin
NrOfMon := Screen.MonitorCount;
with Memo1.Lines do begin
Clear;
Add('Number of monitors: ' + IntToStr(NrOfMon));
for i := 0 to NrOfMon - 1 do begin
Mon := Screen.Monitors[i];
Add('Monitor ' + IntToStr(i) + ' : ' +
' left = ' + IntToStr(Mon.Left));
Add('Monitor ' + IntToStr(i) + ' : ' +
' width = ' + IntToStr(Mon.Width));
end;
end;
end;
Each form also has a property Monitor (also of type TMonitor, just like the elements
of Screen.Monitors), of which you can access the properties. For example:
W := Form1.Monitor.Width;
Additional notes:
Win95 does not support multiple monitors, and neither does NT 4.0: in these cases,
you need a special driver for the videocard(s). Also, each monitor must run the same
resolution, color depth, and refresh rate. But still, some windows may have their left
half appearing on one monitor and the right half appearing on the other.
Microsoft started multiple monitor support only with Win98 and Win2000. Now, the GetSystemMetrics
API function returns the dimensions of the "primary monitor" instead of the dimensions
of the whole virtual desktop covering all the monitors. For example, with two monitors
each at 1280×1024, now you get 1280×1024 instead of 2560×1024.
Windows also maximize within the monitor they're on, not over all monitors. You can even
run each monitor at its own resolution, color depth, and refresh rate.