开发者

How to make clone or extended mode

I am having multiple monitors(virtual+real) and by defaul开发者_运维知识库t 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


//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


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!!! }


  • Changing display settings programmatically
  • Example of attaching a monitor and its issues in earlier version of Windows


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜