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; 

    }

  • 相关阅读:
    Java读取resource文件/路径的几种方式
    log4j:WARN Please initialize the log4j system properly解决办法
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    log4j.properties配置详解与实例-全部测试通过[转]
    testNG中dataprovider使用的两种方式
    远程仓库获取最新代码合并到本地分支
    git 冲突解决办法
    【转】JsonPath教程
    selenium及webdriver的原理【转】
    [转]Redis 数据结构简介
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2458394.html
Copyright © 2011-2022 走看看