使用C#实现WINFORM窗体的动画效果
2010-08-17 16:56
1926 查看
using System.Runtime.InteropServices;
public class WinAnimate
{
public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左到右打开窗口
public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右到左打开窗口
public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下打开窗口
public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上打开窗口
public const Int32 AW_CENTER = 0x00000010; //若使用了AW_HIDE标志,则使窗口向内重叠;若未使用AW_HIDE标志,则使窗口向外扩展。
public const Int32 AW_HIDE = 0x00010000; //隐藏窗口,缺省则显示窗口。
public const Int32 AW_ACTIVATE = 0x00020000; //激活窗口。在使用了AW_HIDE标志后不要使用这个标志。
public const Int32 AW_SLIDE = 0x00040000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略。
public const Int32 AW_BLEND = 0x00080000; //使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // 动画时间
int dwFlags // 动画类型
);
}
/*淡入窗体*/
private void Form_Load(object sender, EventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_BLEND);
}
/*淡出窗体*/
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_SLIDE | Win32.AW_HIDE | Win32.AW_BLEND);
}
public class WinAnimate
{
public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左到右打开窗口
public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右到左打开窗口
public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下打开窗口
public const Int32 AW_VER_NEGATIVE = 0x00000008; // 从下到上打开窗口
public const Int32 AW_CENTER = 0x00000010; //若使用了AW_HIDE标志,则使窗口向内重叠;若未使用AW_HIDE标志,则使窗口向外扩展。
public const Int32 AW_HIDE = 0x00010000; //隐藏窗口,缺省则显示窗口。
public const Int32 AW_ACTIVATE = 0x00020000; //激活窗口。在使用了AW_HIDE标志后不要使用这个标志。
public const Int32 AW_SLIDE = 0x00040000; //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略。
public const Int32 AW_BLEND = 0x00080000; //使用淡出效果。只有当hWnd为顶层窗口的时候才可以使用此标志。
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool AnimateWindow(
IntPtr hwnd, // handle to window
int dwTime, // 动画时间
int dwFlags // 动画类型
);
}
/*淡入窗体*/
private void Form_Load(object sender, EventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_BLEND);
}
/*淡出窗体*/
private void Form_FormClosing(object sender, FormClosingEventArgs e)
{
Win32.AnimateWindow(this.Handle, 2000, Win32.AW_SLIDE | Win32.AW_HIDE | Win32.AW_BLEND);
}
相关文章推荐
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- 使用C#实现WinForm窗体的动画效果
- C# WinForm 实现窗体渐显效果
- 转:C#_让WinForm窗体拥有动画效果(淡入淡出等…)
- 使用C#实现Form窗体的淡入淡出效果
- 使用 electron 实现类似新版 QQ 的登录界面效果(阴影、背景动画、窗体3D翻转)
- 使用C#实现Form窗体的淡入淡出效果
- C#实现WinForm窗体逐渐显示效果
- 用c#实现winform的动画效果
- C# winform窗体动画实现
- 使用Tesseract (OCR)实现简单的验证码识别(C#)+窗体淡入淡出效果
- 使用 electron 实现类似新版 QQ 的登录界面效果(阴影、背景动画、窗体3D翻转)
- WinForm实现窗体的渐进渐出效果(C#)
- C#中如何使用Winform实现炫酷的透明动画界面
- C#.NET vs2010中使用IrisSkin4.dll轻松实现WinForm窗体换肤功能