欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Winform窗体效果实例分析

程序员文章站 2022-07-22 13:33:43
本文实例分析了winform窗体效果。分享给大家供大家参考。具体如下: using system; using system.collections.gener...

本文实例分析了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#程序设计有所帮助。