Question

I've searched all over Google but found no answer, so If someone knows It would be very thankful!

I want to use command line or some WinApi to check the state of the multiple display. For example : If I set : "extended screen" or "duplicate screen" I want to be able to verify it. Just have no idea where to start.

thanks a lot

Was it helpful?

Solution

I would start with the WinAPI EnumDisplayMonitors function: http://msdn.microsoft.com/en-us/library/dd162610%28VS.85%29.aspx

BOOL EnumDisplayMonitors(
  _In_  HDC hdc,
  _In_  LPCRECT lprcClip,
  _In_  MONITORENUMPROC lpfnEnum,
  _In_  LPARAM dwData
);

You need to call this function setting the first 2 parameters to NULL like this:

EnumDisplayMonitors(NULL, NULL, MyPaintEnumProc, 0);

//Enumerates all display monitors.
//The callback function receives a NULL HDC.

Now you have your MonitorEnumProc callback function: http://msdn.microsoft.com/en-us/library/dd145061%28v=vs.85%29.aspx

BOOL CALLBACK MonitorEnumProc(
  _In_  HMONITOR hMonitor,
  _In_  HDC hdcMonitor,
  _In_  LPRECT lprcMonitor,
  _In_  LPARAM dwData
);

You wiil get filled lprcMonitor back:

A pointer to a RECT structure. If hdcMonitor is non-NULL, this rectangle is the intersection of the clipping area of the device context identified by hdcMonitor and the display monitor rectangle. The rectangle coordinates are device-context coordinates.

If hdcMonitor is NULL, this rectangle is the display monitor rectangle. The rectangle coordinates are virtual-screen coordinates.

Based on this values for ALL monitors you can decide whether you have an extended mode (the rects are different) or the duplicate (they are equal).

HTH - good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top