Search results for 'Dual Monitors'. 1 post(s) found.
2008/12/16 10:30
How to get screen resolution in case of using multiple monitors ?
2008/12/16 10:30 in Delphi

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;
// 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;
Another posts included in "Delphi"
| Save TBitmap image to Jpeg format image in Delphi (0) | 2009/06/26 |
| How to get parameter string ? (0) | 2009/06/30 |
| How to return exit code such as exit() function in C/C++ ? (0) | 2009/07/02 |
| How to turn off monitor ? (0) | 2008/12/10 |
| Find File at certain directory in Delphi (0) | 2008/10/10 |
| Sending email messages in .Net (0) | 2007/10/04 |
| Implementing C#'s foreach loop in Delphi 8 (0) | 2007/10/04 |
| Delphi for .Net Code Folding keyboard shortcuts (0) | 2007/10/04 |
Prev

Rss Feed