0 Replies Latest reply on Nov 18, 2010 1:59 PM by ahepa

    Rotate screen through code?

    ahepa
      How to rotate screen using c++?

      Where I work we need to rotate the screen using c++. I know the driver supports rotation as I can rotate the screen from the Catalyst control panel. What I need is to do the same thing from c++ code.

       

      There is a WIN32 API call to just do that, which you can change resolution, colour bit depth and rotation in one go. It seams that this call is not supported though from the Catalyst drivers.

      The code below returns success (DISP_CHANGE_SUCCESSFUL) on Intel's driver but returns DISP_CHANGE_BADPARAM on any ATI graphics cards we've tested.

       

      int _tmain(int argc, _TCHAR* argv[])

      {

            DEVMODE dmode;

            bool foundMode = false;

            memset(&dmode, 0, sizeof(DEVMODE));

            dmode.dmSize = sizeof(DEVMODE);

       

            dmode.dmPelsWidth = 1024;

            dmode.dmPelsHeight = 1280;

            dmode.dmDisplayOrientation = DMDO_90;

            dmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT |       DM_DISPLAYORIENTATION;

       

          LONG ret = ChangeDisplaySettingsEx(NULL, &dmode, NULL, 0, NULL);

       

          return 0;

      }



      DEVMODE dmode; bool foundMode = false; memset(&dmode, 0, sizeof(DEVMODE)); dmode.dmSize = sizeof(DEVMODE); dmode.dmPelsWidth = 1024; dmode.dmPelsHeight = 1280; dmode.dmDisplayOrientation = DMDO_90; dmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYORIENTATION; LONG ret = ChangeDisplaySettingsEx(NULL, &dmode, NULL, 0, NULL);