2

How to change screen orientation of each screen individually from C++ or C#? Having dual screen display configuration in mirror mode. Intel Graphics card is installed on the machine. I tried EnumDisplaySettings function and DeviceMode structure. However, it only works in extended mode. If I try to change orientation by this function in mirror mode both screens are set to the same orientation. Maybe there is a way to change this settings through Intel driver SDK or any other native windows 7 functionality?

UPDATE 1:

Here is the code I tried with CCD API. It still rotates both displays =(

UINT32 PathArraySize = 0;
UINT32 ModeArraySize = 0;
DISPLAYCONFIG_PATH_INFO* PathArray;
DISPLAYCONFIG_MODE_INFO* ModeArray;
DISPLAYCONFIG_TOPOLOGY_ID CurrentTopology;  

SetDisplayConfig(0,NULL,0,NULL,SDC_TOPOLOGY_CLONE|SDC_APPLY); //set to clone mode
GetDisplayConfigBufferSizes(QDC_ALL_PATHS, &PathArraySize, &ModeArraySize);

PathArray =   (DISPLAYCONFIG_PATH_INFO*)malloc(PathArraySize * sizeof(DISPLAYCONFIG_PATH_INFO));
memset(PathArray, 0, PathArraySize * sizeof(DISPLAYCONFIG_PATH_INFO));
ModeArray =   (DISPLAYCONFIG_MODE_INFO*)malloc(ModeArraySize * sizeof(DISPLAYCONFIG_MODE_INFO));
memset(ModeArray, 0, ModeArraySize * sizeof(DISPLAYCONFIG_MODE_INFO));
LONG ret = QueryDisplayConfig(QDC_DATABASE_CURRENT,&PathArraySize, PathArray, &ModeArraySize, ModeArray, &CurrentTopology);

PathArray++;
PathArray->targetInfo.rotation =  DISPLAYCONFIG_ROTATION_ROTATE180; //set Second display rotated 180
PathArray--;

SetDisplayConfig(PathArraySize,PathArray,ModeArraySize,ModeArray, SDC_APPLY | SDC_SAVE_TO_DATABASE | SDC_ALLOW_CHANGES | SDC_USE_SUPPLIED_DISPLAY_CONFIG); //apply rotation

free(PathArray);
free(ModeArray);
Yaroslav
  • 340
  • 3
  • 11
  • The point of mirror mode is to make one screen show exactly what's on the other. Why would you want them in different orientations in that mode? – RobH Mar 01 '13 at 17:27
  • There is a device where screen was installed rotated 180 degrees to improve viewing angle from certain position. In case additional monitor is connected to it, one of the screens is always flipped in mirrored mode. In extended mode it is possible to rotate them individually. – Yaroslav Mar 01 '13 at 22:08
  • Right! I forgot about that use case. – RobH Mar 04 '13 at 17:13

1 Answers1

1

You can try using the CCD APIs. These functions allows you to manipulate the VidPN topology for your current session. They aren't the easiest functions to call though.


Edit:

I don't see anything wrong with your code, apart from maybe the SDC_ALLOW_CHANGES flag. I tried your code on my system which has a Nvidia card. It does one of two things depends on which target I rotate. If I rotate the 2nd of the two targets, it ignores the change. In the Nvidia control panel, I can see the 2nd monitor is rotated, but its settings are greyed out. This suggests to me that the Nvidia driver doesn't support what you want to do. If I rotate the first target, it causes both targets to rotate. I've also tried changing the target scaling to DISPLAYCONFIG_SCALING_STRETCHED. That also made no difference. SetDisplayConfig returns 0. Windows at least seems to be happy with the change.

Have you tried to do what you want with the Intel display utility? If you can't do it with the Intel tool, then maybe the Intel driver doesn't support it. You probably want to ask someone from Intel on whether it is supported.

Camford
  • 770
  • 3
  • 5
  • this seems to be what I really need. Strange that I could not find this API before. Thanks, I will try it. – Yaroslav Mar 01 '13 at 22:27
  • Check my code in the first post. It still flips both screens. Any ideas? – Yaroslav Mar 04 '13 at 01:50
  • Comment in the Edit section. – Camford Mar 04 '13 at 12:26
  • During the weekend I could not test it with Intel card. At my place I have only Nvidia card. I am observing the same behavior as you. – Yaroslav Mar 04 '13 at 16:55
  • The funny thing is that sometime ago on the unit with rotated display windows XP was used. Under Windows XP Intel driver also did not allow to change this in its control panel, however if you supply special Scheme configuration file for mirror mode it did the trick. After moving to Windows 7 profile storing method has changed and does not include this options anymore. I hope it would still accept the settings from windows. – Yaroslav Mar 04 '13 at 17:03
  • XP uses a completely different display driver model. Whatever worked for XP, is very unlikely work the same way on Vista and later. – Camford Mar 05 '13 at 09:21
  • It did not work with Intel neither. Funny thing is that picture has same orientation on both screens while mouse pointer is rotated O_o. – Yaroslav Mar 15 '13 at 08:41
  • Well, I guess that means the driver doesn't support it. If it did, the CCD apis would be the way to manipulate your displays. I think your best bet would to ask Intel directly and see what they have to say about the situation. – Camford Mar 18 '13 at 11:30
  • http://stackoverflow.com/questions/11087613/how-do-i-set-the-monitor-orientation-in-windows-7/16106369#16106369 You can check that thread. I posted solution that works. If that doesn't work for you, then your card doesn't support it. If you are able to do it from the nvidia/ati panel, then it's probably custom hackery. – Erti-Chris Eelmaa Apr 19 '13 at 13:59