基本信息
源码名称:C# 仿酷狗音乐打开关闭效果
源码大小:0.92M
文件格式:.rar
开发语言:C#
更新时间:2015-06-29
   源码介绍

酷狗音乐打开关闭


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;

namespace CartoonForm
{
    public partial class Frm_Main : Form
    {
        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;
        static int x;
        static int y;
        static int WIDTH;
        static int HEIGHT;
        int SH;
        int SW;
        public Frm_Main()
        {
            InitializeComponent();
            AnimateWindow(this.Handle, 0, AW_SLIDE AW_VER_NEGATIVE);//开始窗体动画
            x = this.Location.X;//窗体左上角x坐标
            y = this.Location.Y;//窗体左上角y坐标
            WIDTH = this.Width;//得到当前窗体的宽度
            HEIGHT = this.Height;//得到当前窗体的高度
            //得到屏幕的分辨率
            SH = Screen.PrimaryScreen.Bounds.Height;
            SW = Screen.PrimaryScreen.Bounds.Width;

        }

        //重写API函数,用来执行窗体动画显示操作
        [DllImportAttribute("user32.dll")]
        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            //AnimateWindow(this.Handle, 1000,  AW_CENTER AW_HIDE);//结束窗体动画
            window();
        }
        //结束窗体时特效
        private void window()
        {

            while (this.Width > 124)
            {

                if (this.Height >= 40)
                {
                    this.Location = new System.Drawing.Point(x, y = 15);//设置窗体位置
                    this.Size = new Size(this.Width, this.Height -= 25);//设置窗体大小
                    this.Refresh();//重绘窗体
                }

                else
                {
                    this.Location = new System.Drawing.Point(x = 15, y);

                    if (this.Width > 123)
                    {

                        this.Size = new Size(this.Width -= 25, this.Height);
                        this.Refresh();
                        this.Opacity -= 0.04;//设置窗体透明度递减
                    }

                }


                Thread.Sleep(10);  // 线程休眠10毫秒

            }


        }


        //拖动窗体时动态获得窗体的位置
        private void Frm_Main_Move(object sender, EventArgs e)
        {
            x = this.Location.X;
            y = this.Location.Y;
        }




    }
}