Как получить список установленных мониторов и их параметры?
function EnumDisplayMonitors( dc: HDC; rect: PRect; EnumProc: pointer;
lData: LPARAM ): BOOL; stdcall; external user32;
type
TMonInfo = record
h: THandle; // хэндл окна рабочего стола
dc: HDC; // DC рабочего стола r: TRect; // Координаты рабочего стола end;
var
MonList: array of TMonInfo;
implementation
function MonitorEnumProc( hMonitor: THandle;
hdcMonitor: HDC; lprcMonitor: DWORD; dwData: LPARAM ): BOOL; stdcall;
type
PRect = ^TRect;
var
i: integer;
begin
i := High( MonList )+1;
SetLength( MonList, i+1 );
MonList[i].h := hMonitor;
MonList[i].dc := hdcMonitor;
MonList[i].r := PRect( lprcMonitor )^;
Result := true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
i: integer;
begin
s := 'Кол-во мониторов: ' + IntToStr( High( MonList )+1 ) + #13;
for i := 0 to High( MonList ) do
with MonList[i] do
begin
s := s + #13 + 'handle: ' + IntToStr( h ) + #13 +
'dc: ' + IntToStr( dc ) + #13 +
'size: ' + IntToStr( r.Right ) + 'x' + IntToStr( r.Bottom );
end;
ShowMessage( s );
end;
initialization
EnumDisplayMonitors( 0, nil, Addr( MonitorEnumProc ), 0 );
|