5

I'm working on a legacy vb6 application that operates on Windows XP (embedded) that uses ChangeDisplaySettingsEx to control the resolution of the connected monitors.

I have been tasked with finding a way to get ChangeDisplaySettingsEx to change between Clone and Extended mode when more than one monitor is installed.

When a second monitor is connected it automatically works in Clone mode.

When I enumerate the available display devices using EnumDisplayDevices, the DISPLAY_DEVICE.DeviceString appear as follows:

\\.\DISPLAY1\Monitor0
\\.\DISPLAY1\Monitor1

When the Monitors are in Extended mode, they appear as follows:

\\.\DISPLAY1\Monitor0
\\.\DISPLAY2\Monitor0

I've read MSDN repeatedly and there doesn't appear to be a solid answer tas to how you invoke the APIs to change the mode from Clone to Extended.

My guess was to detach the second monitor and then try and figure out a way to reattach, so I started trying to detach as per http://msdn.microsoft.com/en-us/library/dd162617(v=vs.85).aspx but I can't get any of this to work.

Whenever I try parsing \.\DISPLAY1\Monitor1 to ChangeDisplaySettingsEx I get DISP_CHANGE_BADPARAM - e.g.

ChangeDisplaySettingsEx(\\.\DISPLAY1\Monitor1, DevM, 0, CDS_GLOBAL Or CDS_UPDATEREGISTRY, 0)

I'm really pulling my hair out with this.

Does anyone know how to disable Clone Mode and enable as Extended Mode using the APIs?

Deanna
  • 23,876
  • 7
  • 71
  • 156
Ben
  • 1,000
  • 2
  • 15
  • 36
  • Are you sure that the OS / Hardware actually supports an extended desktop? XPe is quite restricted in some of the things it can do – Matt Wilko Jan 30 '12 at 16:36
  • I think your question was answered here: http://stackoverflow.com/a/2836411 – lacriz Aug 10 '12 at 12:10
  • @KevinBrown do you think vb6 and c# are similar enough to make that the correct dup? – rene Mar 10 '15 at 20:30
  • Have you tried [`SetDisplayConfig`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setdisplayconfig)? **Extend**: `SetDisplayConfig(0, NULL, 0, NULL, (SDC_APPLY | SDC_TOPOLOGY_EXTEND));` **Clone**: `SetDisplayConfig(0, NULL, 0, NULL, (SDC_APPLY | SDC_TOPOLOGY_CLONE));` – Drake Wu Jan 21 '20 at 03:24

0 Answers0