现在的位置: 首页 > 综合 > 正文

window smobile上C#旋转屏幕(横屏/竖屏切换)

2013年10月21日 ⁄ 综合 ⁄ 共 721字 ⁄ 字号 评论关闭

前提是要添加引用

Microsoft.WindowsCE.Forms

实现横竖屏的切换目前我知道的有二种方式:

一是利用API ChangeDisplaySettingsEx来实现;

二是利用在Microsoft.WindowsCE.Forms中的SystemSettings.ScreenOrientation实现,

相对来说第一种是调用API, 代码很多,不容易看懂. 第二种就比较简单.

代码如下:

Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation= Microsoft.WindowsCE.Forms.ScreenOrientation.Angle0;  //竖屏

Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation= Microsoft.WindowsCE.Forms.ScreenOrientation.Angle90;  //转过90度

Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation= Microsoft.WindowsCE.Forms.ScreenOrientation.Angle180;  //转过180度 呵呵

Microsoft.WindowsCE.Forms.SystemSettings.ScreenOrientation= Microsoft.WindowsCE.Forms.ScreenOrientation.Angle270; //270

 

下面是个wm的一键横屏/一键竖屏切换

只要在 开始->设置->按键 设置一个键指向程序就能实现一键 切换 横屏竖屏.

抱歉!评论已关闭.