C# 动画窗体(AnimateWindow)的小例子

代码如下:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WinFormTitle
{
    public partial class FormTitle : Form
    {
        [DllImport("user32.dll", EntryPoint = "AnimateWindow")]
        private static extern bool AnimateWindow(IntPtr handle, int ms, int flags);

public FormTitle()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            AnimateWindow(this.Handle, 1000, 0x20010);   // 居中逐渐显示。
            //AnimateWindow(this.Handle, 1000, 0xA0000); // 淡入淡出效果。
            //AnimateWindow(this.Handle, 1000, 0x60004); // 自上向下。
            //AnimateWindow(this.Handle, 1000, 0x20004); // 自上向下。
        }

protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
            AnimateWindow(this.Handle, 1000, 0x10010);    // 居中逐渐隐藏。
            //AnimateWindow(this.Handle, 1000, 0x90000); // 淡入淡出效果。
            //AnimateWindow(this.Handle, 1000, 0x50008); // 自下而上。
            //AnimateWindow(this.Handle, 1000, 0x10008); // 自下而上。
        }
    }
}

(0)

相关推荐

  • C# Winform实现捕获窗体最小化、最大化、关闭按钮事件的方法

    本文实例讲述了C# Winform实现捕获窗体最小化.最大化.关闭按钮事件的方法,主要是通过重写WndProc来实现的.分享给大家供大家参考.具体方法如下: 主要功能代码如下: const int WM_SYSCOMMAND = 0x112; const int SC_CLOSE = 0xF060; const int SC_MINIMIZE = 0xF020; const int SC_MAXIMIZE = 0xF030; protected override void WndProc(ref

  • C# SkinEngine控件 给窗体添加皮肤的方法

    自己写的一个日历记事本效果图 具体步骤: 1.添加控件SkinEngine.  1.右键"工具箱"."添加选项卡",取名"皮肤".   2.右键"皮肤","选择项"弹出对话框.  3.点击"浏览",找到IrisSkin2.dll,这时你会发现 SkinEngine 的控件已经被打上勾 - 确定.2.将 SkinEngine 控件添加到窗体上.3.把皮肤文件(以ssk为后缀名)放在&quo

  • C# WINFORM 强制让窗体获得焦点的方法代码

    复制代码 代码如下: //调用API [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, ExactSpelling = true)] public static extern IntPtr GetForegroundWindow(); //获得本窗体的句柄 [System.Runtime.InteropService

  • C#编程实现带有Aero效果的窗体示例

    本文实例讲述了C#编程实现带有Aero效果的窗体.分享给大家供大家参考,具体如下: using System.Runtime.InteropServices;//引用,放在哪不用说了吧.... [DllImport("dwmapi.dll")] public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarinset); [StructLayout(LayoutKind.Sequen

  • C#实现窗体淡入淡出效果的方法总结

    1. 复制代码 代码如下: private   void   Form1_Load(object   sender,   System.EventArgs   e)     for(double   d=0.01;   d<   1;   d+=0.02)     {     System.Threading.Thread.Sleep(1);     Application.DoEvents();     this.Opacity=d;     this.Refresh();     } 2.

  • C# 无边框窗体边框阴影效果的简单实现

    通过下面代码在构造函数中调用方法 SetShadow(); 即可实现无边框窗体的阴影效果了 需要添加命名空间 using System.Runtime.InteropServices; 复制代码 代码如下: private const int CS_DropSHADOW = 0x20000;        private const int GCL_STYLE = (-26); [DllImport("user32.dll", CharSet = CharSet.Auto)]     

  • 用 C# Winform做出全透明的磨砂玻璃窗体效果代码

    首先, 调用系统 API, 这里如果要引用神马的, 就不一一列出了, 大家自己引用一下. 复制代码 代码如下: [StructLayout(LayoutKind.Sequential)] public struct MARGINS { public int Left; public int Right; public int Top; public int Bottom; } [DllImport("dwmapi.dll", PreserveSig = false)] public s

  • C# 开发圆角控件(窗体)的具体实现

    最近在做卡片视图的程序,要求将控件做成带有圆角的效果,下面是我在网上查找的资料,经过测试,确定可以实现功能.其中方法三既适应于控件,也适应于窗体. 先上传效果图: 方法一: 增加命名空间:using System.Drawing.Drawing2D;  添加方法如下:当然各角的点可根据需要确定. 复制代码 代码如下: private void Type(Control sender, int p_1, double p_2)        {            GraphicsPath oP

  • C# WinForm实现Win7 Aero透明效果代码

    在Vista系统之后,微软为窗体程序提供了Aero磨砂的效果,如下图.那么用C#如何来实现这种磨砂效果呢? 背景为我的桌面 那先上代码吧: [StructLayout(LayoutKind.Sequential)] public struct MARGINS { public int Left; public int Right; public int Top; public int Bottom; } [DllImport("dwmapi.dll", PreserveSig = fa

  • C# 透明窗体制作实现方法比较分析

    制作透明窗体办法有好几种,各有优缺点. 我们先来看看C#本身提供的办法 1:通过设置窗体的 TransparencyKey实现 例:窗体中的白色会变成透明 复制代码 代码如下: this.BackColor =Color.White; this.TransparencyKey = Color.White; 2:通过设置窗体的 Opacity 实现 例:窗体的透明度为50% 复制代码 代码如下: this.Opacity = 0.5; 为了更好说明问题,我们先看一个实例. (1)新建一个winfo

随机推荐