I am trying to stretch a desktop to two monitors using the ChangeDisplaySettingsEx function. I want the desktop resolution to be 3840×1080 instead of 1920×1080 resolution. I tried the following:
POINTL posPrimary={0};
posPrimary.x=0
posPrimary.y=0;
DEVMODE mode_primary = {0};
mode_primary.dmSize = sizeof(mode_primary);
mode_primary.dmFields = DM_POSITION;
mode_primary.dmPosition = posPrimary;
mode_primary.dmPelsWidth = 3840;
mode_primary.dmPelsHeight = 1080;
LONG status = ChangeDisplaySettingsEx(
nameofMonitor,
&mode_primary,
nullptr, // reserved
CDS_SET_PRIMARY | CDS_UPDATEREGISTRY,
nullptr // no video parameter
);
if (DISP_CHANGE_SUCCESSFUL != status) {
printf("ChangeDisplaySettingsEx returned %d", status);
return -__LINE__;
}
I also tried the SetDisplayConfig function:
SetDisplayConfig(0,NULL,0,NULL,SDC_TOPOLOGY_CLONE|SDC_APPLY);
SDC_TOPOLOGY_CLONE just clones the monitors while SDC_TOPOLOGY_EXTEND extends the desktop to the second display.
Any suggestions would be appreciated.
Windows 7 does not support “stretching” the desktop across multiple monitors. You can extend the desktop across multiple monitors, but you always have to pick which monitor will be the primary monitor. The task bar appears on the primary monitor and there is no way to have it stretch across to other monitors.
Windows 8 has much better multi-monitor support, and allows a task bar on each monitor. You can configure the same task bar to be on all screens, or individual task bars with the icons for the windows on that screen. AFAIK, you still can’t have a single task bar stretched across all monitors.
Update
I was thinking a little more about this, and it occurred to me that it may be possible for a video card driver to present multiple monitors to Windows as a single device with the combined resolution. This configuration would be proprietary to the video card vendor, and you’d have to use their APIs to access the capability, if indeed it exists.