C#.NET 使用windowsAPI 制作出窗口淡入淡出特殊效果
2007-08-29 09:02
507 查看
好久没有写blog了,因为最近很忙,这几天在网上search时发现了有人问了一个问题,通过windows API来制作淡入淡出特殊效果,在网上baidu了一下,还不少好东西,把它整理了一下贴出来大家看看。
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections.Generic;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Windows.Forms;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Runtime.InteropServices;// 添加using
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WindowsApplication1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public partial class Form1 : Form
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
[DllImport("user32")]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//dwflag的取值如下
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HOR_POSITIVE = 0x00000001;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从左到右显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HOR_NEGATIVE = 0x00000002;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从右到左显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_VER_POSITIVE = 0x00000004;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从上到下显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_VER_NEGATIVE = 0x00000008;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从下到上显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_CENTER = 0x00000010;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HIDE = 0x00010000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//隐藏窗口,缺省则显示窗口
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_ACTIVATE = 0x00020000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//激活窗口。在使用了AW_HIDE标志后不能使用这个标志
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_SLIDE = 0x00040000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_BLEND = 0x00080000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//透明度从高到低
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Form1()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//在Form_Load中添加代码实现窗体的淡入
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AnimateWindow(this.Handle, 500, AW_CENTER);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//多个dwflag之间用 | 隔开
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//在Form_FormClosing中添加代码实现窗体的淡出
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AnimateWindow(this.Handle,500,AW_CENTER|AW_HIDE);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//必须有AW_HIDE才能看到窗体的淡出
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Collections.Generic;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.ComponentModel;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Drawing;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Text;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Windows.Forms;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Runtime.InteropServices;// 添加using
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
namespace WindowsApplication1
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public partial class Form1 : Form
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
[DllImport("user32")]
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//dwflag的取值如下
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HOR_POSITIVE = 0x00000001;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从左到右显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HOR_NEGATIVE = 0x00000002;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从右到左显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_VER_POSITIVE = 0x00000004;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从上到下显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_VER_NEGATIVE = 0x00000008;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//从下到上显示
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_CENTER = 0x00000010;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_HIDE = 0x00010000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//隐藏窗口,缺省则显示窗口
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_ACTIVATE = 0x00020000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//激活窗口。在使用了AW_HIDE标志后不能使用这个标志
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_SLIDE = 0x00040000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public const Int32 AW_BLEND = 0x00080000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//透明度从高到低
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
public Form1()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeComponent();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//在Form_Load中添加代码实现窗体的淡入
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AnimateWindow(this.Handle, 500, AW_CENTER);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//多个dwflag之间用 | 隔开
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//在Form_FormClosing中添加代码实现窗体的淡出
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
AnimateWindow(this.Handle,500,AW_CENTER|AW_HIDE);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//必须有AW_HIDE才能看到窗体的淡出
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
相关文章推荐
- 【转】C#.NET使用AnimateWindow制作淡入淡出特殊效果的窗体
- C#.NET使用Window API 制作淡入淡出特殊效果
- C#.NET使用AnimateWindow制作淡入淡出特殊效果的窗体
- c# form窗体渐隐效果 制作vist窗口淡入淡出效果
- 利用CSS3制作淡入淡出动画效果
- 利用CSS3制作淡入淡出动画效果
- Asp.net(C#)读取数据库并生成JS文件制作首页图片切换效果(附demo源码下载)
- [C#.NET][WinForm] Windows 窗口讯息接收 - WndProc 的使用
- 利用CSS3制作淡入淡出动画效果
- C#登录窗口(访问数据库)的制作,类文件的制作及使用
- C#中使用WeiFenLuo.WinFormsUI.Docking.dll实现窗口停靠效果
- ASP.NET 登陆界面中过滤特殊字符(使用c#)
- [C#]使用 C# 代码实现拓扑排序 dotNet Core WEB程序使用 Nginx反向代理 C#里面获得应用程序的当前路径 关于Nginx设置端口号,在Asp.net 获取不到的,解决办法 .Net程序员 初学Ubuntu ,配置Nignix 夜深了,写了个JQuery的省市区三级级联效果
- C#中使用WeiFenLuo.WinFormsUI.Docking.dll实现窗口停靠效果
- 使用Quartz.net、Topshelf、wcf命名管道制作的一个c#定时任务管理程序(热插拔)
- C#实现窗体的淡入和淡出效果
- c#操作EXCEL\ 使用ActiveReport for .net \使用ZedGraph制作动态更新的统计图
- 利用ASP.NET(C#)来制作页面进度条效果
- ASP.NET实例:用C#制作超酷的图像效果
- C#.net制作验证码(英文与数字组成的4位随机数),以及MD5值的使用