zoukankan      html  css  js  c++  java
  • WM下代码实现转屏

    在WM下用户可以经常转屏,但是这个也能通过代码实现,下面是一个经过测试的代码。

    int ChangeDisplaySettings( )


        DEVMODE DevMode; 
        int RotationAngles = 0; 
        int CurrentAngle = 0; 
        int NewAngle = 0; 

        //Check for rotation support by getting the rotation angles supported. 
        memset( &DevMode, 0, sizeof( DevMode ) ); 
        DevMode.dmSize = sizeof( DevMode ); 
        DevMode.dmFields = DM_DISPLAYQUERYORIENTATION; 

        if( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx( NULL, &DevMode, NULL, CDS_TEST, NULL ) ) 
        { 
            RotationAngles = DevMode.dmDisplayOrientation; 
        } 
        else 
        { 
            RotationAngles = -1; 
        } 

        //Get the current rotation angle. 
        memset( &DevMode, 0, sizeof( DevMode ) ); 
        DevMode.dmSize = sizeof( DevMode ); 
        DevMode.dmFields = DM_DISPLAYORIENTATION; 

        if( DISP_CHANGE_SUCCESSFUL ==  ChangeDisplaySettingsEx( NULL, &DevMode, NULL, CDS_TEST, NULL ) ) 
        { 
            CurrentAngle = DevMode.dmDisplayOrientation; 
        } 
        else 
        {   
            CurrentAngle = -1; 
        } 

        //Rotate to the "next " angle. 
        if   ( ( CurrentAngle >= 0 ) && ( RotationAngles >= 0 ) ) 
        { 
            NewAngle = CurrentAngle; 
            do 
            { 
                NewAngle <<= 1; 

                if( DMDO_0 == NewAngle ) 
                { 
                    NewAngle = DMDO_270; 
                } 

                if( NewAngle > DMDO_270 ) 
                { 
                    NewAngle = DMDO_0; 
                } 
            }   while ( !( NewAngle & RotationAngles) && ( NewAngle != DMDO_0 ) ); 

            memset( &DevMode, 0, sizeof( DevMode ) ); 
            DevMode.dmSize = sizeof( DevMode ); 
            DevMode.dmFields =  DM_DISPLAYORIENTATION; 
            DevMode.dmDisplayOrientation = NewAngle; 

            if( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx( NULL, &DevMode, NULL, CDS_RESET, NULL ) ) 
            { 
            } 
            else 
            {
            } 
        } 

        return   0; 

    }

  • 相关阅读:
    python 中 print函数的用法详解
    可转债操作一览
    Python基本数据类型
    python的列表
    理财的方法
    92、Multiple commands produce Info.plist 报错
    91、最新cocoaPods安装与使用
    90、引入头文件不提示
    89、instancetype和id的区别
    88、const、static、extern介绍
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2458394.html
Copyright © 2011-2022 走看看