鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 网站制作教程 > ASP.NET > >

Winform窗体效果实例分析

来源:互联网 作者:佚名 时间:2021-09-23 03:05
本文实例分析了Winform窗体效果。分享给大家供大家参考。具体如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Windows

本文实例分析了Winform窗体效果。分享给大家供大家参考。具体如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication4
{
 public partial class Form3 : Form
 {
  bool flag = false;
  public Form3()
  {
   InitializeComponent();
   flag = true;
  }
  #region user32.dll
  //导入user32.dll
  [System.Runtime.InteropServices.DllImport("user32")]
  //声明API函数
  private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);
  #endregion
  #region 常量
  //正面_水平方向
  const int AW_HOR_POSITIVE = 0x0001;
  //负面_水平方向
  const int AW_HOR_NEGATIVE = 0x0002;
  //正面_垂直方向
  const int AW_VER_POSITIVE = 0x0004;
  //负面_垂直方向
  const int AW_VER_NEGATIVE = 0x0008;
  //由中间四周展开或
  const int AW_CENTER = 0x0010;
  //隐藏对象
  const int AW_HIDE = 0x10000;
  //显示对象
  const int AW_ACTIVATE = 0x20000;
  //拉幕滑动效果
  const int AW_SLIDE = 0x40000;
  //淡入淡出渐变效果
  const int AW_BLEND = 0x80000;
  #endregion
  #region 判断方向
  public int IsHorOrVer(int pos)
  {
   int rtn = 0;
   //判断是正方向还是反方向
   if (pos.Equals(0))
   {
    //判断是横向还是纵向
    if (flag)
     rtn = AW_HOR_POSITIVE;
    else rtn = AW_VER_POSITIVE;
   }
   else if (pos.Equals(1))
   {
    //判断是横向还是纵向
    if (flag)
     rtn = AW_HOR_NEGATIVE;
    else rtn = AW_VER_NEGATIVE;
   }
   return rtn;
  }
  #endregion
  private void button1_Click(object sender, EventArgs e)
  {
   //动画——窗体向上拖拉
   AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_HIDE | IsHorOrVer(1));
   //动画——窗体向下拖拉
   AnimateWindow(this.Handle, 1000, AW_SLIDE | AW_ACTIVATE | IsHorOrVer(0));
   //动画——窗体淡出特效
   AnimateWindow(this.Handle, 1000, AW_BLEND | AW_HIDE | IsHorOrVer(1));
   //动画——窗体淡入特效
   AnimateWindow(this.Handle, 1000, AW_BLEND | AW_ACTIVATE | IsHorOrVer(0));
   //动画——窗体由四周向中心缩小直至消失
   AnimateWindow(this.Handle, 1000, AW_CENTER | AW_HIDE | IsHorOrVer(1));
   //动画——窗体由中心向四周扩展
   AnimateWindow(this.Handle, 1000, AW_CENTER | AW_ACTIVATE | IsHorOrVer(0));
  }
 }
}

希望本文所述对大家的C#程序设计有所帮助。

网友评论
<