Question : How do I identify monitor device display settings?

Hi experts. How can I detect monitor display setting?
I know basic monitor information from TScreen object.
I want to find monitor index detected by windows os.

See following image:  I have 3 monitors. (1 LCD[primary], 2 USB type)
1st monior index: 1
2nd monitor index: 3
3rd monitor index: 4

How do I find that number 1,3,4 and it's additional information?

Attachments:
 
windows display settings
windows display settings
 

Answer : How do I identify monitor device display settings?

ok, here is it:

procedure TForm1.Button2Click(Sender: TObject);
type
  TDeviceMode2 = packed record
    dmDeviceName: array[0..CCHDEVICENAME - 1] of AnsiChar;
    dmSpecVersion: Word;
    dmDriverVersion: Word;
    dmSize: Word;
    dmDriverExtra: Word;
    dmFields: DWORD;
    dmPosition: TPoint;
    dmDisplayOrientation: DWORD;
    dmDisplayFixedOutput: DWORD;
    dmColor: SHORT;
    dmDuplex: SHORT;
    dmYResolution: SHORT;
    dmTTOption: SHORT;
    dmCollate: SHORT;
    dmFormName: array[0..CCHFORMNAME - 1] of AnsiChar;
    dmLogPixels: Word;
    dmBitsPerPel: DWORD;
    dmPelsWidth: DWORD;
    dmPelsHeight: DWORD;
    dmDisplayFlags: DWORD;
    dmDisplayFrequency: DWORD;
    dmICMMethod: DWORD;
    dmICMIntent: DWORD;
    dmMediaType: DWORD;
    dmDitherType: DWORD;
    dmICCManufacturer: DWORD;
    dmICCModel: DWORD;
    dmPanningWidth: DWORD;
    dmPanningHeight: DWORD;
  end;

const
  EDD_GET_DEVICE_INTERFACE_NAME = 1;
  DISPLAY_DEVICE_ACTIVE = 1;
  ENUM_CURRENT_SETTINGS: DWORD = DWORD(-1);
var
  d: TDisplayDevice;
  i: Integer;
  DevMode: TDevMode;
begin
  for i:= 0 to Screen.MonitorCount do
  begin
    d.cb:= sizeof(d);
    if EnumDisplayDevices( nil, i, d, EDD_GET_DEVICE_INTERFACE_NAME) then
    begin
      Memo1.Lines.Add( 'Monitor ' + IntToStr(i) );
      if (d.StateFlags and DISPLAY_DEVICE_ACTIVE) =0 then
        Memo1.Lines.Add( 'Monitor isn''t active' );
      Memo1.Lines.Add( d.DeviceName );
      Memo1.Lines.Add( d.DeviceString );
      if EnumDisplaySettings( d.DeviceName, ENUM_CURRENT_SETTINGS, DevMode ) then
      begin
        Memo1.Lines.Add( Format( 'Resolution %d x %d', [DevMode.dmPelsWidth, DevMode.dmPelsHeight]) );
        Memo1.Lines.Add( Format( 'Bits per pixels %d', [DevMode.dmBitsPerPel]) );

        Memo1.Lines.Add( Format( 'Rect %d, %d, %d, %d', [TDeviceMode2(DevMode).dmPosition.X, TDeviceMode2(DevMode).dmPosition.Y, TDeviceMode2(DevMode).dmPosition.X+DevMode.dmPelsWidth, TDeviceMode2(DevMode).dmPosition.Y+DevMode.dmPelsHeight ]) );

      end;

      Memo1.Lines.Add('');
    end;
  end;
end;
Random Solutions  
 
programming4us programming4us