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

(转)winform Form 淡入淡出效果

程序员文章站 2022-04-08 23:49:27
原文地址:http://blog.csdn.net/a237428367/article/details/5933565using System.Runtime.InteropServices; public class Win32 { public const Int32 AW_HOR_POSIT... ......
原文地址:http://blog.csdn.net/a237428367/article/details/5933565

using system.runtime.interopservices; public class win32 { 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; public const int32 aw_hide = 0x00010000; // 在窗体卸载时若想使用本函数就得加上此常量 public const int32 aw_activate = 0x00020000; //在窗体通过本函数打开后,默认情况下会失去焦点,除非加上本常量 public const int32 aw_slide = 0x00040000; public const int32 aw_blend = 0x00080000; // 淡入淡出效果 [dllimport("user32.dll", charset = charset.auto)] public static extern bool animatewindow( intptr hwnd, // handle to window int dwtime, // duration of animation int dwflags // animation type ); } /*淡入窗体*/ 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); }