对话框的隐藏和出现



CRect  rc;
 int    moves = 10;     //动画滚动窗体的步数

 int    xStep, yStep;
 int    xEnd, yEnd;
 int    width;
 int    height;
 
 GetWindowRect(&rc);
 width = rc.right - rc.left;
 height = rc.bottom - rc.top;

 //下边判断窗体该如何移动,由停靠方式决定
 switch (alignType)
 {
  case ALIGN_TOP:
   {
    //向上隐藏
    xStep = 0;
    xEnd  = rc.left;

    if (hide)
    {
     yStep = -rc.bottom / moves;
     yEnd  = -height + NEAR_SIDE ;
    }
    else
    {
     yStep = -rc.top / moves;
     yEnd  = 0;
    }

    break;
   }

  case ALIGN_LEFT:
   {
    //向左隐藏
    yStep = 0;
    yEnd  = rc.top;

    if (hide)
    {
     xStep = -rc.right / moves;
     xEnd  = -width + NEAR_SIDE;
    }
    else
    {
     xStep = -rc.left / moves;
     xEnd  = 0;
    }

    break;
   }

  case ALIGN_RIGHT:
   {
    //向右隐藏
    yStep = 0;
    yEnd  = rc.top;

    if (hide)
    {
     xStep = (ScreenX - rc.left) / moves;
     xEnd  = ScreenX - NEAR_SIDE;
    }
    else
    {
     xStep = (ScreenX - rc.right) / moves;
     xEnd  = ScreenX - width;
    }

    break;
   }

  default:
   {
    return;
   } 
 }

 //动画滚动窗体.
 for (int i = 0; i < moves; i++)
 {
  rc.left += xStep;
  rc.top  += yStep;

  SetWindowPos(NULL, rc.left, rc.top, width, height,SWP_NOSIZE | SWP_NOSENDCHANGING);

  RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
  //UpdateWindow();

  Sleep(2);
 }

 SetWindowPos(&wndTopMost, xEnd, yEnd,width, height, SWP_NOSIZE);

 //如果窗体已被显示,设置定时器,监视鼠标
 if (!hide) 
 {
  SetTimer(WM_TIMER, 50, NULL);
 }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值