WinCE旋转屏幕函数

以下函数,每执行一次旋转90度

 
void RotationScreenFun(void)
{
 DEVMODE DevMode;
 int RotationAngles;
 int CurrentAngle;
 int NewAngle;
 //
 // Check for rotation support by getting the rotation angles supported.
 //(原创内容,转载请注册出处,原帖地址:[url=http://www.veabol.com/thread-67-1-1.html]http://www.veabol.com/thread-67-1-1.html[/url])
 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;
  RETAILMSG(1, (L"ChangeDisplaySettingsEx supports these rotation angles %d", RotationAngles));
 }
 else
 {
  RETAILMSG(1, (L"ChangeDisplaySettingsEx failed to get the supported rotation angles."));
  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;
  RETAILMSG(1, (L"ChangeDisplaySettingsEx reports the current rotation as %d", CurrentAngle));
 }
 else
 { 
  RETAILMSG(1, (L"ChangeDisplaySettingsEx failed to get the current rotation angle."));
  CurrentAngle = -1;
 }
 //
 // Rotate to the "next" angle.
 //
 if (CurrentAngle >= 0 && RotationAngles >= 0)
 {
  NewAngle = CurrentAngle;
  do
  {
   NewAngle <<= 1;
   if (NewAngle == DMDO_0)
   {
    NewAngle = DMDO_90;
   }
   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))
  {
   RETAILMSG(1, (L"ChangeDisplaySettingsEx changed rotation angle to %d", NewAngle));
  }
  else
  {
   RETAILMSG(1, (L"ChangeDisplaySettingsEx failed to change the rotation angle to %d", NewAngle));
  }
 }
}
---------------------------
本站内容如未注明“转载”分类则为站内用户原创,未经作者允许商业网站不得转载,普通网站及用户转载时需保留文章原版内容且注明出处!
文章来源:  普嵌嵌入式  | 原文地址:  http://www.pro-embedded.com/thread-67-1-1.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值