问题
I am having multiple monitors(virtual+real) and by default I wanted to put it in clone/dual mode from my program. Can some one suggest how do I achieve this? I am very new to this world:) sorry for this basic question.... even any doc or any link will be highly appreciable.
/sarbojit
回答1:
To set clone displays in Win7, this will work if there are 2 paths and 4 modes
UINT32 cPath=0; //path count
UINT32 cMode=0; //mode count
HRESULT hr;
hr = GetDisplayConfigBufferSizes(QDC_ALL_PATH, &cPath, &cMode);
std::vector<DISPLAYCONFIG_PATH_INFO> pathArray(cPath);
std::vector<DISPLAYCONFIG_MODE_INFO> modeArray(cMode);
hr =QueryDisplayConfig(QDC_ALL_PATHS, &cPath, &pathArray[0], &cMode, &modeArray[0], NULL);
if(hr != ERROR_SUCCESS) { problem in paradise }
if(cPath!=2 || cMode != 4) { anything else is too complex or a single display or already cloned }
// to change resolution also
// int ix=pathArray[0].sourceInfo.modeInfoIdx; assuming path[0] is primary, it should be
// modeArray[ix].sourceMode.width = 320; // :(
// modeArray[ix].sourceMode.hieght = 240; // :(
pathArray[1].flags |= DISPLAYCONFIG_PATH_ACTIVE;
pathArray[1].sourceInfo.modeIdx = pathArray[0].sourceInfo.modeIdx; //same source
pathArray[1].sourceInfo.id = pathArray[0].sourceInfo.id; //same source
hr = SetDisplayConfig(cPath, &pathArray[0], cMode, &modeArray[0], SDC_APPLY | SDC_USE_SUPPLIED_DISPLAY_CONFIG | SDC_ALLOW_CHANGE | SDC_SAVE_TO_DATABASE));
if(hr != ERROR_SUCCESS) { so close!!! }
回答2:
- Changing display settings programmatically
- Example of attaching a monitor and its issues in earlier version of Windows
回答3:
//Extend
SetDisplayConfig(0, NULL,0, NULL,(SDC_APPLY | SDC_TOPOLOGY_EXTEND));
//Clone
SetDisplayConfig(0, NULL,0, NULL,(SDC_APPLY | SDC_TOPOLOGY_CLONE));
For more information: http://msdn.microsoft.com/en-us/library/ff569533%28v=VS.85%29.aspx
回答4:
If you happen to be on Windows XP and have an NVIDIA card you can use the following command line command
rundll32.exe NvCpl.dll,dtcfg setview 1 clone
or
rundll32.exe NvCpl.dll,dtcfg setview 1 dualview
and use CreateProcess to create a child process which runs that command. I have been unable to get NvAPI to set up clone or extended mode on Windows XP, but it seems to run fine on Windows 7.
来源:https://stackoverflow.com/questions/3625983/how-to-make-clone-or-extended-mode